Exemple #1
0
 def evt_set(self, DT):
     self.res_b.setText('')
     bit_string_text = ''
     for byte_index in range(11):
         for bit_index in range(8):
             evt_no = byte_index * 8 + bit_index + 1
             bit_val = 0
             if evt_no <= 85:
                 if eval('self.valid_c_' + str(evt_no) +
                         '.isChecked()') is True:
                     bit_val = 1
             bit_string_text += str(bit_val)
     bit_string_text = hex(int(bit_string_text,
                               2)).split('x')[1].rjust(22, '0')
     valid_text = '0455' + bit_string_text
     bit_string_text = ''
     for byte_index in range(11):
         for bit_index in range(8):
             evt_no = byte_index * 8 + bit_index + 1
             bit_val = 0
             if evt_no <= 85:
                 if eval('self.rpt_c_' + str(evt_no) +
                         '.isChecked()') is True:
                     bit_val = 1
             bit_string_text += str(bit_val)
     bit_string_text = hex(int(bit_string_text,
                               2)).split('x')[1].rjust(22, '0')
     rpt_text = '0455' + bit_string_text
     apdu_text = '060101 3FFF0200 0202' + valid_text + rpt_text + '00'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.read_res)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #2
0
 def send_trans(self):
     input_text = self.send_input_box.toPlainText()
     try:
         data_in = link_layer.data_format(input_text, auto_add_0=False)
         print('data_in', data_in)
         ret_dict = link_layer.all_translate(data_in)
         if ret_dict['res'] == 'ok':
             self.quick_fix_button.setText(
                 '修正地址' if self.is_good_linklayer() is False else
                 '修正校验码' if config.good_HCS is not None or config.
                 good_FCS is not None else '修正格式')
             if ret_dict['input_type'] == 'full' and config.auto_fix is True:
                 if self.is_good_linklayer() is False:
                     self.fix_addr()
                     input_text = self.send_input_box.toPlainText()
                     data_in = link_layer.data_format(input_text)
                     link_layer.all_translate(data_in)
             elif ret_dict['input_type'] == 'apdu':
                 input_text = link_layer.add_link_layer(input_text)
                 self.send_input_box.setText(input_text)
                 data_in = link_layer.data_format(input_text)
                 link_layer.all_translate(data_in)
         else:
             self.quick_fix_button.setText(
                 '修正长度域' if config.good_L is not None else '修正格式')
     except Exception:
         traceback.print_exc()
         output('\n\n报文解析过程出现问题,请检查报文。若报文无问题请反馈665593,谢谢!')
     self.send_output_box.setText(config.output_text)
     config.output_text = ''
Exemple #3
0
 def evt_read(self):
     self.res_b.setText('')
     self.clr_all_cb()
     apdu_text = '0501003FFF020000'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.re_evt)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #4
0
 def communication_set(self, DT):
     self.res_b.setText('')
     work_mode_text = '16' + '%02X' % self.C_work_mode_l.currentIndex()
     online_mode_text = '16' + '%02X' % self.C_online_mode_l.currentIndex()
     connect_mode_text = '16' + '%02X' % self.C_connect_mode_l.currentIndex(
     )
     connect_app_mode_text = '16' + '%02X' % self.C_connect_app_mode_l.currentIndex(
     )
     listen_port_text = '0100'  # 暂时不可设置
     APN_text = param.format_visible_string(self.C_APN_box.text())
     usr_text = param.format_visible_string(self.C_usr_box.text())
     pw_text = param.format_visible_string(self.C_pw_box.text())
     proxy_addr_text = param.format_octet(self.C_proxy_addr_box.text())
     proxy_port_text = param.format_long_unsigned(
         self.C_proxy_prot_box.text())
     overtm_retry_num_text = '11' + '%02X' % (
         (int(self.C_retry_box.text()) << 6)
         | int(self.C_over_tm_box.text()))
     heart_tm_text = param.format_long_unsigned(self.C_heart_tm_box.text())
     apdu_text = '06010D45000200 020C' + work_mode_text + online_mode_text + \
                 connect_mode_text + connect_app_mode_text + listen_port_text + APN_text + \
                 usr_text + pw_text + proxy_addr_text + proxy_port_text +\
                 overtm_retry_num_text + heart_tm_text + '00'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.read_res)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #5
0
 def rpt_read(self):
     self.clear_res()
     apdu_text = '0502 0104 43000700 43000800 43000900 43000A00 00'
     self.rpt_follow_cb.setCurrentIndex(-1)
     self.rpt_cb.setCurrentIndex(-1)
     self.conn_sever_cb.setCurrentIndex(-1)
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.re_rpt)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #6
0
 def esam_certi_read(self):
     self.res_b.setText('')
     if self.esam_certi_l.currentIndex() == 0:
         apdu_text = '0502 0102 F1000900 F1000A00 00'
     else:
         apdu_text = '0502 0102 F1000B00 F1000C00 00'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.re_esam_certi)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #7
0
 def set_DT(self, DT):
     # self.DT_box.setDateTime(DT)
     DT_list = DT.toString('yyyy.MM.dd.hh.mm.ss').split('.')
     DT_text = '1C%04X' % int(DT_list[0])
     for DT in DT_list[1:]:
         DT_text += '%02X' % int(DT)
     print(DT_text)
     apdu_text = '06010D40000200' + DT_text + '00'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.read_res)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #8
0
 def SA_set(self, DT):
     self.res_b.setText('')
     SA_text = self.SA_box.text().replace(' ', '')
     if len(SA_text) % 2 == 1:
         SA_text += 'F'
     self.SA_box.setText(SA_text)
     print('SA_text', SA_text)
     SA_len = len(SA_text) // 2
     apdu_text = '06010D4001020009' + '%02X' % (SA_len) + SA_text + '00'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.read_res_SA)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #9
0
 def local_net_set(self, DT):
     self.res_b.setText('')
     ip_mode = '%02X' % self.local_ip_mode_l.currentIndex()
     ip_text = param.format_ip(self.local_ip_box.text())
     ip_mask = param.format_ip(self.local_mask_box.text())
     gate = param.format_ip(self.local_gate_addr_box.text())
     ppp_usr = param.format_octet(self.ppp_usr_box.text())
     ppp_pw = param.format_octet(self.ppp_pw_box.text())
     apdu_text = '06010D45100400 0206 16' + ip_mode + '0904' + ip_text + '0904' + ip_mask + '0904'\
                 + gate + ppp_usr + ppp_pw + '00'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.read_res)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #10
0
    def ip_set(self, DT):
        self.res_b.setText('')
        ip_text = param.format_ip(self.S_ip_box.text())
        port_text = '%04X' % int(self.S_port_box.text().replace(' ', ''))

        if self.S_ip_box_2.text() and self.S_port_box_2.text():
            apdu_text = '06010D45000300010202020904' + ip_text + '12' + port_text
            ip_text = param.format_ip(self.S_ip_box_2.text())
            port_text = '%04X' % int(self.S_port_box_2.text().replace(' ', ''))
            apdu_text += '02020904' + ip_text + '12' + port_text + '00'
        else:
            apdu_text = '06010D45000300010102020904' + ip_text + '12' + port_text + '00'

        config.serial_window._receive_signal.disconnect()
        config.serial_window._receive_signal.connect(self.read_res)
        communication.send(link_layer.add_link_layer(apdu_text))
Exemple #11
0
 def rpt_set(self, DT):
     self.res_b.setText('')
     rpt_follow_text = '03' + '%02X' % self.rpt_follow_cb.currentIndex()
     rpt_text = '03' + '%02X' % self.rpt_cb.currentIndex()
     conn_sever_text = '03' + '%02X' % self.conn_sever_cb.currentIndex()
     rpt_channel_text = self.rpt_channel_box.text()
     rpt_channel_text = list(filter(str.isdigit, rpt_channel_text))
     rpt_channel_text = ''.join(rpt_channel_text)
     print('Kay', rpt_channel_text)
     array_sum = len(rpt_channel_text) // 8
     rpt_channel_array_text = '01' + '%02X' % array_sum
     offset = 0
     for _ in range(array_sum):
         rpt_channel_array_text += '51' + rpt_channel_text[offset:offset +
                                                           8]
         offset += 8
     apdu_text = '060200 04 43000700' + rpt_follow_text + '43000800' + rpt_text +\
                 '43000900' + conn_sever_text + '43000A00' + rpt_channel_array_text + '00'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.read_res)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #12
0
 def DT_param_set(self, DT):
     self.res_b.setText('')
     mode_text = '16' + {
         0: '00',
         1: '01',
         2: '02',
         3: '03',
         4: 'FF'
     }[self.DT_mode_l.currentIndex()]
     tot_num_text = '11' + '%02X' % int(self.DT_tot_num_box.text().replace(
         ' ', ''))
     biggest_num_text = '11' + '%02X' % int(
         self.DT_biggest_num_box.text().replace(' ', ''))
     smallest_num_text = '11' + '%02X' % int(
         self.DT_smallest_num_box.text().replace(' ', ''))
     dly_max_text = '11' + '%02X' % int(self.DT_dly_max_box.text().replace(
         ' ', ''))
     valid_num_min_text = '11' + '%02X' % int(
         self.DT_valid_num_min_box.text().replace(' ', ''))
     apdu_text = '060200 02 40000300' + mode_text + '40000400 0205' + tot_num_text + biggest_num_text + smallest_num_text + dly_max_text + valid_num_min_text + '00'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.read_res)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #13
0
 def DT_read(self):
     self.res_b.setText('')
     apdu_text = '0501014000020000'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.re_DT)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #14
0
 def esam_info_read(self):
     self.res_b.setText('')
     apdu_text = '0502 0107 F1000200 F1000300 F1000400 F1000500 F1000600 F1000700 F1000800 00'
     config.serial_window._receive_signal.disconnect()
     config.serial_window._receive_signal.connect(self.re_esam_info)
     communication.send(link_layer.add_link_layer(apdu_text))
Exemple #15
0
 def fix_addr(self):
     apdu_text = link_layer.get_apdu_text(self.send_input_box.toPlainText())
     self.send_input_box.setText(link_layer.add_link_layer(apdu_text))