Esempio n. 1
0
 def get_last_x_radio_message_data(noOfMessages):
     db = DB(DatabaseHelper.database_name, DataMapping())
     row_list = db.get_table_objects_by_SQL(
         RadioMessageData,
         "SELECT * FROM RadioMessageData ORDER BY id desc LIMIT " +
         str(noOfMessages))
     return row_list
Esempio n. 2
0
 def get_punches_to_send_to_meos():
     db = DB(DatabaseHelper.database_name, DataMapping())
     row_list = db.get_table_objects_by_SQL(
         PunchData,
         "SELECT * FROM PunchData " + "WHERE sentToMeos = 0 AND " +
         "stationNumberNotFound = 0 ORDER BY id asc")
     return row_list
Esempio n. 3
0
 def get_radio_message(id):
     db = DB(DatabaseHelper.database_name, DataMapping())
     row_list = db.get_table_objects_by_SQL(RadioMessageData, "SELECT * FROM RadioMessageData WHERE id = " + str(id) + " ORDER BY id")
     if row_list[0].messageType == PUNCH or row_list[0].messageType == COMBINED_PUNCH:
         dataRecords = db.get_table_objects_by_SQL(PunchData, "SELECT * FROM PunchData WHERE radioMessageId = " + str(id))
         row_list[0].dataRecordArray = dataRecords
     return row_list[0]
Esempio n. 4
0
 def get_control_number_by_node_number(node_number):
     db = DB(DatabaseHelper.database_name, DataMapping())
     rows = db.get_table_objects_by_SQL(NodeToControlNumberData, "SELECT * FROM NodeToControlNumberData " +
                                                          "WHERE NodeNumber = " + str(node_number))
     if len(rows) >= 1:
         return rows[0].ControlNumber
     return None
Esempio n. 5
0
 def get_last_x_radio_message_data_not_acked(radioNumber, noOfMessages=1):
     db = DB(DatabaseHelper.database_name, DataMapping())
     row_list = db.get_table_objects_by_SQL(RadioMessageData, "SELECT * FROM RadioMessageData " +
                                                              "WHERE ackSent = 0 "
                                                              "and radioNumber = " + str(radioNumber) +
                                                              " ORDER BY id desc LIMIT " +
                                            str(noOfMessages))
     return row_list
Esempio n. 6
0
 def get_control_number_by_node_number(node_number):
     db = DB(DatabaseHelper.database_name, DataMapping())
     rows = db.get_table_objects_by_SQL(
         NodeToControlNumberData, "SELECT * FROM NodeToControlNumberData " +
         "WHERE NodeNumber = " + str(node_number))
     if len(rows) >= 1:
         return rows[0].ControlNumber
     return None
Esempio n. 7
0
 def get_last_x_radio_message_data_not_acked(radioNumber, noOfMessages=1):
     db = DB(DatabaseHelper.database_name, DataMapping())
     row_list = db.get_table_objects_by_SQL(
         RadioMessageData,
         "SELECT * FROM RadioMessageData " + "WHERE ackSent = 0 "
         "and radioNumber = " + str(radioNumber) +
         " ORDER BY id desc LIMIT " + str(noOfMessages))
     return row_list
Esempio n. 8
0
 def get_channel(channel_id):
     if channel_id is None:
         return None
     db = DB(DatabaseHelper.database_name, DataMapping())
     sql = "SELECT * FROM ChannelData WHERE Id = " + str(channel_id)
     rows = db.get_table_objects_by_SQL(RadioSettingsData, sql)
     if len(rows) >= 1:
         return rows[0].FrequencyName + rows[0].SpeedName
     return None
Esempio n. 9
0
 def get_channel(channel_id):
     if channel_id is None:
         return None
     db = DB(DatabaseHelper.database_name, DataMapping())
     sql = "SELECT * FROM ChannelData WHERE Id = " + str(channel_id)
     rows = db.get_table_objects_by_SQL(RadioSettingsData, sql)
     if len(rows) >= 1:
         return rows[0].FrequencyName + rows[0].SpeedName
     return None
Esempio n. 10
0
    def get_main_settings_data():
        db = DB(DatabaseHelper.database_name, DataMapping())
        row_list = db.get_table_objects_by_SQL(MainSettingsData, "SELECT * FROM MainSettingsData ORDER BY id desc LIMIT 1")
        if len(row_list) == 0:
            return None
        main_settings = row_list[0]

        node_to_control_number_list = db.get_table_objects_by_SQL(NodeToControlNumberData, "SELECT * FROM NodeToControlNumberData ORDER BY id asc")
        main_settings.NodeToControlNumberMapping = node_to_control_number_list
        return main_settings
Esempio n. 11
0
 def save_radio_message(radioMessageData):
     db = DB(DatabaseHelper.database_name, DataMapping())
     rm = db.save_table_object(radioMessageData)
     print(radioMessageData.dataRecordArray)
     if radioMessageData.dataRecordArray is not None:
         for rec in radioMessageData.dataRecordArray:
             rec.radioMessageId = rm.id
             if rm.messageType == PUNCH:
                 rec.origFromNode = rm.fromNode
             db.save_table_object(rec)
     return DatabaseHelper.get_radio_message(rm.id)
Esempio n. 12
0
 def save_radio_message(radioMessageData):
     db = DB(DatabaseHelper.database_name, DataMapping())
     rm = db.save_table_object(radioMessageData)
     print(radioMessageData.dataRecordArray)
     if radioMessageData.dataRecordArray is not None:
         for rec in radioMessageData.dataRecordArray:
             rec.radioMessageId = rm.id
             if rm.messageType == PUNCH:
                 rec.origFromNode = rm.fromNode
             db.save_table_object(rec)
     return DatabaseHelper.get_radio_message(rm.id)
Esempio n. 13
0
 def get_radio_message(id):
     db = DB(DatabaseHelper.database_name, DataMapping())
     row_list = db.get_table_objects_by_SQL(
         RadioMessageData, "SELECT * FROM RadioMessageData WHERE id = " +
         str(id) + " ORDER BY id")
     if row_list[0].messageType == PUNCH or row_list[
             0].messageType == COMBINED_PUNCH:
         dataRecords = db.get_table_objects_by_SQL(
             PunchData,
             "SELECT * FROM PunchData WHERE radioMessageId = " + str(id))
         row_list[0].dataRecordArray = dataRecords
     return row_list[0]
Esempio n. 14
0
    def get_main_settings_data():
        db = DB(DatabaseHelper.database_name, DataMapping())
        row_list = db.get_table_objects_by_SQL(
            MainSettingsData,
            "SELECT * FROM MainSettingsData ORDER BY id desc LIMIT 1")
        if len(row_list) == 0:
            return None
        main_settings = row_list[0]

        node_to_control_number_list = db.get_table_objects_by_SQL(
            NodeToControlNumberData,
            "SELECT * FROM NodeToControlNumberData ORDER BY id asc")
        main_settings.NodeToControlNumberMapping = node_to_control_number_list
        return main_settings
Esempio n. 15
0
    def get_radio_settings_data(radioSettingsId=None):
        db = DB(DatabaseHelper.database_name, DataMapping())
        sql = ""
        if radioSettingsId is None:
            sql = "SELECT * FROM RadioSettingsData ORDER BY id"
        elif radioSettingsId is int:
            sql = "SELECT * FROM RadioSettingsData WHERE id = " + str(radioSettingsId)

        row_list = db.get_table_objects_by_SQL(RadioSettingsData, sql)
        for radioSetting in row_list:
            nodes = db.get_table_objects_by_SQL(InboundRadioNodeData, "SELECT * FROM InboundRadioNodeData WHERE RadioSettingsId = " + str(radioSetting.id))
            radioSetting.InboundRadioNodes = nodes

        return row_list
Esempio n. 16
0
 def save_main_settings(main_settings_data):
     db = DB(DatabaseHelper.database_name, DataMapping())
     old_main_settings_data = DatabaseHelper.get_main_settings_data()
     if old_main_settings_data is not None:
         main_settings_data.id = old_main_settings_data.id
     db.save_table_object(main_settings_data)
     db.execute_SQL("DELETE FROM NodeToControlNumberData")
     for nodeToControl in main_settings_data.NodeToControlNumberMapping:
         db.save_table_object(nodeToControl)
     return DatabaseHelper.get_main_settings_data()
Esempio n. 17
0
    def get_radio_settings_data(radioSettingsId=None):
        db = DB(DatabaseHelper.database_name, DataMapping())
        sql = ""
        if radioSettingsId is None:
            sql = "SELECT * FROM RadioSettingsData ORDER BY id"
        elif radioSettingsId is int:
            sql = "SELECT * FROM RadioSettingsData WHERE id = " + str(
                radioSettingsId)

        row_list = db.get_table_objects_by_SQL(RadioSettingsData, sql)
        for radioSetting in row_list:
            nodes = db.get_table_objects_by_SQL(
                InboundRadioNodeData,
                "SELECT * FROM InboundRadioNodeData WHERE RadioSettingsId = " +
                str(radioSetting.id))
            radioSetting.InboundRadioNodes = nodes

        return row_list
Esempio n. 18
0
 def save_main_settings(main_settings_data):
     db = DB(DatabaseHelper.database_name, DataMapping())
     old_main_settings_data = DatabaseHelper.get_main_settings_data()
     if old_main_settings_data is not None:
         main_settings_data.id = old_main_settings_data.id
     db.save_table_object(main_settings_data)
     db.execute_SQL("DELETE FROM NodeToControlNumberData")
     for nodeToControl in main_settings_data.NodeToControlNumberMapping:
         db.save_table_object(nodeToControl)
     return DatabaseHelper.get_main_settings_data()
Esempio n. 19
0
 def save_radio_settings(radio_settings_data):
     db = DB(DatabaseHelper.database_name, DataMapping())
     print("save radio settings")
     saved_radio_settings_data = db.save_table_object(radio_settings_data)
     print("save radio settings 2")
     db.execute_SQL(
         "DELETE FROM InboundRadioNodeData WHERE RadioSettingsId = " +
         str(saved_radio_settings_data.id))
     for node in radio_settings_data.InboundRadioNodes:
         node.id = None
         node.RadioSettingsId = saved_radio_settings_data.id
         db.save_table_object(node)
     return DatabaseHelper.get_radio_settings_data(
         saved_radio_settings_data.id)
Esempio n. 20
0
 def save_radio_settings(radio_settings_data):
     db = DB(DatabaseHelper.database_name, DataMapping())
     print("save radio settings")
     saved_radio_settings_data = db.save_table_object(radio_settings_data)
     print("save radio settings 2")
     db.execute_SQL("DELETE FROM InboundRadioNodeData WHERE RadioSettingsId = " + str(saved_radio_settings_data.id))
     for node in radio_settings_data.InboundRadioNodes:
         node.id = None
         node.RadioSettingsId = saved_radio_settings_data.id
         db.save_table_object(node)
     return DatabaseHelper.get_radio_settings_data(saved_radio_settings_data.id)
Esempio n. 21
0
 def drop_all_tables():
     db = DB(DatabaseHelper.database_name, DataMapping())
     radioMessageData = RadioMessageData()
     db.drop_table(radioMessageData)
     punchData = PunchData()
     db.drop_table(punchData)
     nodeSettingsData = NodeSettingsData()
     db.drop_table(nodeSettingsData)
     inboundRadioNodeData = InboundRadioNodeData()
     db.drop_table(inboundRadioNodeData)
     mainSettingsData = MainSettingsData()
     db.drop_table(mainSettingsData)
     radioSettingsData = RadioSettingsData()
     db.drop_table(radioSettingsData)
     channelData = ChannelData()
     db.drop_table(channelData)
Esempio n. 22
0
 def save_channel(channel):
     db = DB(DatabaseHelper.database_name, DataMapping())
     db.save_table_object(channel)
Esempio n. 23
0
 def get_channels():
     db = DB(DatabaseHelper.database_name, DataMapping())
     sql = "SELECT * FROM ChannelData ORDER BY id"
     row_list = db.get_table_objects_by_SQL(RadioSettingsData, sql)
     return row_list
Esempio n. 24
0
 def ensure_tables_created():
     db = DB(DatabaseHelper.database_name, DataMapping())
     radioMessageData = RadioMessageData()
     db.ensure_table_created(radioMessageData)
     punchData = PunchData()
     db.ensure_table_created(punchData)
     nodeSettingsData = NodeSettingsData()
     db.ensure_table_created(nodeSettingsData)
     inboundRadioNodeData = InboundRadioNodeData()
     db.ensure_table_created(inboundRadioNodeData)
     mainSettingsData = MainSettingsData()
     db.ensure_table_created(mainSettingsData)
     radioSettingsData = RadioSettingsData()
     db.ensure_table_created(radioSettingsData)
     channelData = ChannelData()
     db.ensure_table_created(channelData)
     nodeToControlNumberData = NodeToControlNumberData()
     db.ensure_table_created(nodeToControlNumberData)
Esempio n. 25
0
 def drop_all_tables():
     db = DB(DatabaseHelper.database_name, DataMapping())
     radioMessageData = RadioMessageData()
     db.drop_table(radioMessageData)
     punchData = PunchData()
     db.drop_table(punchData)
     nodeSettingsData = NodeSettingsData()
     db.drop_table(nodeSettingsData)
     inboundRadioNodeData = InboundRadioNodeData()
     db.drop_table(inboundRadioNodeData)
     mainSettingsData = MainSettingsData()
     db.drop_table(mainSettingsData)
     radioSettingsData = RadioSettingsData()
     db.drop_table(radioSettingsData)
     channelData = ChannelData()
     db.drop_table(channelData)
Esempio n. 26
0
 def set_no_station_number_found(punchDataId):
     db = DB(DatabaseHelper.database_name, DataMapping())
     db.execute_SQL(
         "UPDATE PunchData SET stationNumberNotFound = 1 WHERE id=" +
         str(punchDataId))
Esempio n. 27
0
 def remove_all_punches():
     db = DB(DatabaseHelper.database_name, DataMapping())
     db.execute_SQL("DELETE FROM PunchData")
     db.execute_SQL("DELETE FROM RadioMessageData")
Esempio n. 28
0
 def drop_tables():
     db = DB(DatabaseHelper.database_name, DataMapping())
Esempio n. 29
0
 def get_channels():
     db = DB(DatabaseHelper.database_name, DataMapping())
     sql = "SELECT * FROM ChannelData ORDER BY id"
     row_list = db.get_table_objects_by_SQL(RadioSettingsData, sql)
     return row_list
Esempio n. 30
0
 def save_channel(channel):
     db = DB(DatabaseHelper.database_name, DataMapping())
     db.save_table_object(channel)
Esempio n. 31
0
 def get_last_x_radio_message_data(noOfMessages):
     db = DB(DatabaseHelper.database_name, DataMapping())
     row_list = db.get_table_objects_by_SQL(RadioMessageData, "SELECT * FROM RadioMessageData ORDER BY id desc LIMIT " + str(noOfMessages))
     return row_list
Esempio n. 32
0
 def remove_all_punches():
     db = DB(DatabaseHelper.database_name, DataMapping())
     db.execute_SQL("DELETE FROM PunchData")
     db.execute_SQL("DELETE FROM RadioMessageData")
Esempio n. 33
0
 def ensure_tables_created():
     db = DB(DatabaseHelper.database_name, DataMapping())
     radioMessageData = RadioMessageData()
     db.ensure_table_created(radioMessageData)
     punchData = PunchData()
     db.ensure_table_created(punchData)
     nodeSettingsData = NodeSettingsData()
     db.ensure_table_created(nodeSettingsData)
     inboundRadioNodeData = InboundRadioNodeData()
     db.ensure_table_created(inboundRadioNodeData)
     mainSettingsData = MainSettingsData()
     db.ensure_table_created(mainSettingsData)
     radioSettingsData = RadioSettingsData()
     db.ensure_table_created(radioSettingsData)
     channelData = ChannelData()
     db.ensure_table_created(channelData)
     nodeToControlNumberData = NodeToControlNumberData()
     db.ensure_table_created(nodeToControlNumberData)
Esempio n. 34
0
 def set_punch_sent_to_meos(punchDataId):
     db = DB(DatabaseHelper.database_name, DataMapping())
     db.execute_SQL("UPDATE PunchData SET sentToMeos = 1 WHERE id=" + str(punchDataId))
Esempio n. 35
0
 def get_punches_to_send_to_meos():
     db = DB(DatabaseHelper.database_name, DataMapping())
     row_list = db.get_table_objects_by_SQL(PunchData, "SELECT * FROM PunchData " +
                                                              "WHERE sentToMeos = 0 AND " +
                                                              "stationNumberNotFound = 0 ORDER BY id asc")
     return row_list
Esempio n. 36
0
 def set_punch_sent_to_meos(punchDataId):
     db = DB(DatabaseHelper.database_name, DataMapping())
     db.execute_SQL("UPDATE PunchData SET sentToMeos = 1 WHERE id=" +
                    str(punchDataId))
Esempio n. 37
0
 def set_no_station_number_found(punchDataId):
     db = DB(DatabaseHelper.database_name, DataMapping())
     db.execute_SQL("UPDATE PunchData SET stationNumberNotFound = 1 WHERE id=" + str(punchDataId))