def handler_pchv3_set_temp_limit(log, parsing_data, param_data) -> [bytes]: len_packet, code, bytes_recv = parsing_data request_data, response_data, control_gui = param_data code_req, code_resp = request_data if code == code_req: t_low = value_from_qt_bytes('quint8', bytes_recv[4:5]) t_high = value_from_qt_bytes('quint8', bytes_recv[5:6]) t_crit = value_from_qt_bytes('quint8', bytes_recv[6:7]) log.info( '+++ Команда: Установить Лимиты температуры": t_low = {}, t_high = {}, t_crit = {}' .format(t_low, t_high, t_crit)) return [ __qt_create_packet({ 'value': code_resp, 'type': 'quint16' }, [{ 'value': t_low + 1, 'type': 'quint8' }, { 'value': t_high + 1, 'type': 'quint8' }, { 'value': t_crit - 1, 'type': 'quint8' }]) ]
def gui_handler_pchv3_state_aru(log, parsing_data, param_data) -> [bytes]: len_packet, code, bytes_recv = parsing_data request_data, response_data, control_gui = param_data names_channels = globals().get('config_vars').get('names_channels') # names_vch_tructs = globals().get('config_vars').get('names_vch_tructs') code_ps = request_data if code == code_ps: if len_packet == 6: id_channel = value_from_qt_bytes('quint8', bytes_recv[4:5]) state_aru = value_from_qt_bytes('quint8', bytes_recv[-1:]) log.info( '+++ Команда: "Установить состояние АРУ тракта":, АРУ = {}, канал = \"{}\"' .format('выкл' if state_aru == 0 else 'вкл', names_channels.get(id_channel))) return [ __qt_create_packet({ 'value': code_ps, 'type': 'quint16' }, [{ 'value': id_channel, 'type': 'quint8' }, { 'value': state_aru, 'type': 'quint8' }]) ] # return [bytes_recv] log.error( '+++ ERROR: Команда: "Установить состояние АРУ тракта": Длина пакета неверная (!= 6)' ) return []
def handler_pchv3_set_cap(log, parsing_data, param_data) -> [bytes]: len_packet, code, bytes_recv = parsing_data request_data, response_data, control_gui = param_data names_channels = globals().get('config_vars').get('names_channels') code_ps = request_data if code == code_ps: if len_packet == 7: id_channel = value_from_qt_bytes('quint8', bytes_recv[4:5]) code_cap = value_from_qt_bytes('qint16', bytes_recv[5:7]) log.info( '+++ Команда: "Установить код ЦАП":, код = {}, канал = \"{}\"'. format(code_cap, names_channels.get(id_channel))) if code_cap == 1: code_cap = -1 return [ __qt_create_packet({ 'value': code_ps, 'type': 'quint16' }, [{ 'value': id_channel, 'type': 'quint8' }, { 'value': code_cap, 'type': 'qint16' }]) ] return []
def handler_pchv3_fapch_codes(log, parsing_data, param_data) -> [bytes]: len_packet, code, bytes_recv = parsing_data # v= response_data.get_ui_value('Состояние питания', 'Источники питания', 'Мощность', 'spinbox') # response_data.set_ui_value('Состояние питания', 'Источники питания', 'Мощность', 'spinbox', 13) request_data, response_data, control_gui = param_data code_req, code_resp = request_data if code == code_req: names_channels = globals().get('config_vars').get('names_channels') id_channel = value_from_qt_bytes('quint8', bytes_recv[4:5]) amount_codes = value_from_qt_bytes('quint8', bytes_recv[5:6]) len_list = len(bytes_recv[6:]) if amount_codes * 5 != len_list: log.error('+++ ERROR: list\'s length is invalid: {} vs {}'.format( amount_codes, len_list)) list_codes_fapch = [] for i in range(0, amount_codes, 2): reg = value_from_qt_bytes('quint8', bytes_recv[i + 6:i + 7]) bits = value_from_qt_bytes('quint8', bytes_recv[i + 7:i + 8]) list_codes_fapch.append( ('{0:X}h'.format(reg), '{0:b}'.format(bits))) log.info( '+++ Команда: "Установить таблицу кодов ФАПЧ": канал = \"{}\" ФАПЧ = "{}"' .format(names_channels.get(id_channel), list_codes_fapch)) return [bytes.fromhex(response_data)] # return [__qt_create_packet({'value': code_resp, 'type': 'quint16'}, # [{'value': id_channel, 'type': 'quint8'}, # {'value': True, 'type': 'quint8'}])] return []
def handler_pchv3_vch_truct(log, parsing_data, param_data) -> [bytes]: len_packet, code, bytes_recv = parsing_data code_ps = param_data[0] if code == code_ps: if len_packet == 6: names_channels = globals().get('config_vars').get('names_channels') names_vch_tructs = globals().get('config_vars').get( 'names_vch_tructs') id_channel = value_from_qt_bytes('quint8', bytes_recv[4:5]) vch_truct = value_from_qt_bytes('quint8', bytes_recv[-1:]) log.info( '+++ Команда: "Установить аттенюаторы":, ВЧ тракт = {}, канал = \"{}\"' .format(names_vch_tructs.get(vch_truct), names_channels.get(id_channel))) return [ __qt_create_packet({ 'value': code_ps, 'type': 'quint16' }, [{ 'value': id_channel, 'type': 'quint8' }, { 'value': vch_truct, 'type': 'quint8' }]) ] log.error( '+++ ERROR: Команда: "Установить аттенюаторы": Длина пакета неверная (!= 14)' ) return []
def handler_pchv3_attenuators(log, parsing_data, param_data) -> [bytes]: len_packet, code, bytes_recv = parsing_data code_ps = param_data[0] if code == code_ps: if len_packet == 10: names_channels = globals().get('config_vars').get('names_channels') id_channel = value_from_qt_bytes('quint8', bytes_recv[4:5]) at1 = value_from_qt_bytes('float', bytes_recv[5:-1]) at2 = value_from_qt_bytes('quint8', bytes_recv[-1:]) log.info( '+++ Команда: "Установить аттенюаторы":, АТ1 = {}, АТ2 = {}, канал = \"{}\"' .format(at1, at2, names_channels.get(id_channel))) return [ __qt_create_packet({ 'value': code_ps, 'type': 'quint16' }, [{ 'value': id_channel, 'type': 'quint8' }, { 'value': at1, 'type': 'float' }, { 'value': at2, 'type': 'quint8' }]) ] # return [bytes_recv] log.error( '+++ ERROR: Команда: "Установить аттенюаторы": Длина пакета неверная (!= 14)' ) return []
def handler_pchv3_set_control_cap(log, parsing_data, param_data) -> [bytes]: len_packet, code, bytes_recv = parsing_data request_data, response_data, control_gui = param_data code_req, code_resp = request_data if code == code_req: command = value_from_qt_bytes('quint8', bytes_recv[4:5]) address = value_from_qt_bytes('quint8', bytes_recv[5:6]) data = value_from_qt_bytes('quint16', bytes_recv[6:8]) log.info( '+++ Команда: "Установить управление ЦАП": Команда = {}, Адрес = {}, Данные = {}' .format(command, address, data)) return [bytes.fromhex(response_data)] return []
def handler_pchv3_set_control_adt7310(log, parsing_data, param_data) -> [bytes]: len_packet, code, bytes_recv = parsing_data request_data, response_data, control_gui = param_data code_req, code_resp = request_data if code == code_req: if control_gui: result = control_gui.get_ui_value('Состояние питания', 'Источники питания2', 'ADTResult', 'checkbox') else: result = True data = value_from_qt_bytes('quint16', bytes_recv[4:6]) log.info( '+++ Команда: "Установить управление adt7310": Данные = {}'.format( data)) return [ __qt_create_packet({ 'value': code_resp, 'type': 'quint16' }, { 'value': bool(result), 'type': 'bool' }) ]
def handler_pchv3_all_power_changer(log, parsing_data, param_data) -> [bytes]: len_packet, code, bytes_recv = parsing_data code_ps_all, code_ps, control_gui = param_data if code_ps_all == code: pchv3_power_source = globals().get('config_vars').get( 'pchv3_power_source') value = value_from_qt_bytes('quint8', bytes_recv[4:5]) turn_on = bool(value) log.info('+++ Команда: "{}" turn_on = {}'.format( 'Питание на всех ИП', turn_on)) for id_power in pchv3_power_source: pchv3_power_source[id_power] = turn_on return __get_power_state_packet(log, code_ps_all, code_ps) return []