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]
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
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]
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
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
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
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
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
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
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
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
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
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
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
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
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