Exemplo n.º 1
0
def is_in_connections_db(args,station_name,check_if_active=False):
    db = mc.connect_to_mc_db(args)
    with db.sessionmaker() as session:
        connected_station = session.query(part_connect.Connections).filter(part_connect.Connections.up == station_name)
        if connected_station.count() > 0:
            station_connected = True
        else:
            station_connected = False
        if station_connected and check_if_active:
            current = cm_utils._get_datetime(args.date,args.time)
            for connection in connected_station.all():
                stop_date = cm_utils._get_stopdate(connection.stop_date)
                if current>connection.start_date and current<stop_date:
                    station_connected = int(connection.down.strip('A'))
                else:
                    station_connected = False
    return station_connected
Exemplo n.º 2
0
def find_station_name(args,station_number):
    station = 'A'+str(station_number)
    db = mc.connect_to_mc_db(args)
    with db.sessionmaker() as session:
        connected_station = session.query(part_connect.Connections).filter(part_connect.Connections.down == station)
        if connected_station.count() > 0:
            station_connected = True
        else:
            station_connected = False
        if station_connected:
            current = cm_utils._get_datetime(args.date,args.time)
            for connection in connected_station.all():
                stop_date = cm_utils._get_stopdate(connection.stop_date)
                if current>connection.start_date and current<stop_date:
                    station_connected = connection.up
                else:
                    station_connected = False
    return station_connected
Exemplo n.º 3
0
 def __go_downstream(self, args, hpn, rev, port):
     """
     Find the next connection down the signal chain
     """
     down_port = self.__get_next_port(args,hpn,rev,port,direction='down',check_part=False)
     if down_port == self.no_connection_designator or down_port is None:
         return
     connection_dict = self.get_connection(args, hpn_query=hpn, rev_query=rev, port_query=down_port, 
                                           exact_match=True, show_connection=False)
     for i,hpn_down in enumerate(connection_dict[hpn]['down_parts']):
         port = connection_dict[hpn]['a_on_down'][i]
         if hpn_down not in self.downstream:
             stopdown = cm_utils._get_stopdate(connection_dict[hpn]['stop_on_down'][i])
             if (self.current>connection_dict[hpn]['start_on_down'][i]) and (self.current<stopdown):
                 hpn_down_pr = hpn_down
             else:
                 hpn_down_pr = '**'+hpn_down
             self.downstream.append([hpn_down_pr,port])
         self.__go_downstream(args, hpn_down, rev, port)
Exemplo n.º 4
0
 def __go_upstream(self, args, hpn, rev, port):
     """
     Find the next connection up the signal chain.
     """
     up_port = self.__get_next_port(args,hpn,rev,port,direction='up',check_part=False)
     if up_port == self.no_connection_designator or up_port is None:
         return
     connection_dict = self.get_connection(args, hpn_query=hpn, rev_query=rev, port_query=up_port, 
                                           exact_match=True, show_connection=False)
     for i,hpn_up in enumerate(connection_dict[hpn]['up_parts']):
         port = connection_dict[hpn]['b_on_up'][i]
         if hpn_up not in self.upstream:
             stopup = cm_utils._get_stopdate(connection_dict[hpn]['stop_on_up'][i])
             if (self.current>connection_dict[hpn]['start_on_up'][i]) and (self.current<stopup):
                 hpn_up_pr = hpn_up
             else:
                 hpn_up_pr = '**'+hpn_up
             self.upstream.append([hpn_up_pr,port])
         self.__go_upstream(args, hpn_up, rev, port)