mirror of
https://gitee.com/qpy-solutions/dtu.git
synced 2025-05-19 19:18:24 +08:00
2025 lines
103 KiB
Python
2025 lines
103 KiB
Python
#!/usr/bin/env python
|
||
# -*- coding: UTF-8 -*-
|
||
# generated by wxGlade 0.9.6 on Fri Jan 29 17:03:21 2021
|
||
# import time
|
||
import zlib
|
||
|
||
# from transfer import TransferS
|
||
# import _thread
|
||
import threading, time, wx, re
|
||
# serial (pyserial)
|
||
# import serial
|
||
import json
|
||
import serial.tools.list_ports
|
||
# from threading import Thread
|
||
# message (pypubsub)
|
||
from pubsub import pub
|
||
import os, base64
|
||
|
||
ser = serial.Serial() # 创建串口对象
|
||
serPort = serial.tools.list_ports # 串口列表
|
||
serialStatus = False
|
||
add_time = False # 是否加时间戳
|
||
convet_to_hex = False # 是否转为hex
|
||
serialList = [] # 串口列表
|
||
no_password_funcode = [0, 1, 2, 3, 5] # 不需要密码的指令
|
||
need_password_funcode = [4, 65, 66, 67, 68, 69, 70, 71, 81, 82, 83, 84, 85, 88, 89, 96, 97, 255] # 需要密码的指令
|
||
funcode_list = need_password_funcode + no_password_funcode
|
||
file_password = None # 配置文件的密码
|
||
uart_0_list = [] # 串口0的标签
|
||
uart_1_list = [] # 串口1的标签
|
||
uart_2_list = [] # 串口2的标签
|
||
uart_3_list = [] # 串口3的标签
|
||
label_1_list = [] # 通道1的标签
|
||
label_2_list = [] # 通道2的标签
|
||
label_3_list = [] # 通道3的标签
|
||
label_4_list = [] # 通道4的标签
|
||
label_5_list = [] # 通道5的标签
|
||
label_6_list = [] # 通道6的标签
|
||
label_7_list = [] # 通道7的标签
|
||
open_password = False # 密码勾选框的开关
|
||
import_error = False
|
||
# some software vars
|
||
PROJECT_ABSOLUTE_PATH = os.path.dirname(os.path.abspath(__file__))
|
||
|
||
SERIAL_BUFFER = ""
|
||
|
||
|
||
class _847017531_MyFrame(wx.Frame):
|
||
def __init__(self, *args, **kwds):
|
||
# begin wxGlade: _847017531_MyFrame.__init__
|
||
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
|
||
wx.Frame.__init__(self, *args, **kwds)
|
||
self.SetSize((1100, 710))
|
||
# Menu Bar
|
||
self.frame_menubar = wx.MenuBar()
|
||
self.SetMenuBar(self.frame_menubar)
|
||
# Menu Bar end
|
||
self.combo_box_6 = wx.ComboBox(self, wx.ID_ANY, choices=[""], style=wx.CB_DROPDOWN)
|
||
self.combo_box_7 = wx.ComboBox(self, wx.ID_ANY,
|
||
choices=["1200", "2400", "4800", "9600", "14400", "19200", "28800", "38400",
|
||
"57600", "115200", "230400", "460800", "921600"], style=wx.CB_READONLY)
|
||
self.combo_box_8 = wx.ComboBox(self, wx.ID_ANY, choices=["7", "8"], style=wx.CB_READONLY)
|
||
self.combo_box_9 = wx.ComboBox(self, wx.ID_ANY, choices=["NONE", "ODD", "EVENT"], style=wx.CB_READONLY)
|
||
self.combo_box_10 = wx.ComboBox(self, wx.ID_ANY, choices=["1", "2"], style=wx.CB_READONLY)
|
||
self.button_2 = wx.Button(self, wx.ID_ANY, u"打开串口")
|
||
self.checkbox_1 = wx.CheckBox(self, wx.ID_ANY, "")
|
||
self.text_ctrl_12 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_PASSWORD)
|
||
self.notebook_10 = wx.Notebook(self, wx.ID_ANY)
|
||
self.notebook_10_ = wx.Panel(self.notebook_10, wx.ID_ANY)
|
||
self.combo_box_63 = wx.ComboBox(self.notebook_10_, wx.ID_ANY, choices=[u"不添加", u"添加"], style=wx.CB_READONLY)
|
||
self.combo_box_84 = wx.ComboBox(self.notebook_10_, wx.ID_ANY, choices=[u"不发送", u"发送"], style=wx.CB_READONLY)
|
||
self.text_ctrl_6 = wx.TextCtrl(self.notebook_10_, wx.ID_ANY, "")
|
||
self.combo_box_86 = wx.ComboBox(self.notebook_10_, wx.ID_ANY, choices=[u"关闭", u"开启"], style=wx.CB_READONLY)
|
||
self.text_ctrl_10 = wx.TextCtrl(self.notebook_10_, wx.ID_ANY, "")
|
||
self.text_ctrl_11 = wx.TextCtrl(self.notebook_10_, wx.ID_ANY, "")
|
||
self.text_ctrl_13 = wx.TextCtrl(self.notebook_10_, wx.ID_ANY, "")
|
||
###########################################################################################################
|
||
# 串口0
|
||
self.serial_param = wx.Notebook(self.notebook_10, wx.ID_ANY)
|
||
self.serial_panel_0 = wx.Panel(self.serial_param, wx.ID_ANY)
|
||
self.panel_18 = wx.Panel(self.serial_panel_0, wx.ID_ANY)
|
||
self.radio_btn_49 = wx.RadioButton(self.panel_18, 705, u"启用")
|
||
self.radio_btn_50 = wx.RadioButton(self.panel_18, 706, u"不启用")
|
||
self.panel_17 = wx.Panel(self.serial_panel_0, wx.ID_ANY)
|
||
###########################################################################################################
|
||
# 串口1
|
||
self.serial_panel_1 = wx.Panel(self.serial_param, wx.ID_ANY)
|
||
self.panel_24 = wx.Panel(self.serial_panel_1, wx.ID_ANY)
|
||
self.radio_btn_57 = wx.RadioButton(self.panel_24, 704, u"启用")
|
||
self.radio_btn_58 = wx.RadioButton(self.panel_24, 705, u"不启用")
|
||
self.panel_25 = wx.Panel(self.serial_panel_1, wx.ID_ANY)
|
||
###########################################################################################################
|
||
# 串口2
|
||
self.serial_panel_2 = wx.Panel(self.serial_param, wx.ID_ANY)
|
||
self.panel_21 = wx.Panel(self.serial_panel_2, wx.ID_ANY)
|
||
self.radio_btn_55 = wx.RadioButton(self.panel_21, 702, u"启用")
|
||
self.radio_btn_56 = wx.RadioButton(self.panel_21, 703, u"不启用")
|
||
self.panel_22 = wx.Panel(self.serial_panel_2, wx.ID_ANY)
|
||
###########################################################################################################
|
||
# 串口3
|
||
self.serial_panel_3 = wx.Panel(self.serial_param, wx.ID_ANY)
|
||
self.panel_19 = wx.Panel(self.serial_panel_3, wx.ID_ANY)
|
||
self.radio_btn_53 = wx.RadioButton(self.panel_19, 700, u"启用")
|
||
self.radio_btn_54 = wx.RadioButton(self.panel_19, 701, u"不启用")
|
||
self.panel_20 = wx.Panel(self.serial_panel_3, wx.ID_ANY)
|
||
######################################################################################################
|
||
# channel 1
|
||
self.notebook_10_3 = wx.Panel(self.notebook_10, wx.ID_ANY)
|
||
self.channel = wx.Notebook(self.notebook_10_3, wx.ID_ANY)
|
||
self.channel_1 = wx.Panel(self.channel, wx.ID_ANY)
|
||
self.panel_34 = wx.Panel(self.channel_1, wx.ID_ANY)
|
||
self.radio_btn_59 = wx.RadioButton(self.panel_34, 800, u"启用")
|
||
self.radio_btn_60 = wx.RadioButton(self.panel_34, 801, u"不启用")
|
||
self.panel_12 = wx.Panel(self.channel_1, wx.ID_ANY)
|
||
self.label_272 = wx.StaticText(self.panel_12, 802, u"通道类型", pos=(20, 5))
|
||
self.combo_box_95 = wx.ComboBox(self.panel_12, 802, pos=(170, 5),
|
||
choices=["HTTP", "SOCKET TCP", "SOCKET UDP", "MQTT", u"阿里云", u"腾讯云", u"移远云"],
|
||
style=wx.CB_READONLY)
|
||
self.label_273 = wx.StaticText(self.panel_12, wx.ID_ANY, u"提示:选择透传的类型", pos=(290, 5))
|
||
###########################################################################################################
|
||
# channel 2
|
||
self.channel_2 = wx.Panel(self.channel, wx.ID_ANY)
|
||
self.panel_35 = wx.Panel(self.channel_2, wx.ID_ANY)
|
||
self.radio_btn_47 = wx.RadioButton(self.panel_35, 807, u"启用")
|
||
self.radio_btn_48 = wx.RadioButton(self.panel_35, 808, u"不启用")
|
||
self.panel_14 = wx.Panel(self.channel_2, wx.ID_ANY)
|
||
self.label_309 = wx.StaticText(self.panel_14, wx.ID_ANY, u"通道类型", pos=(20, 5))
|
||
self.combo_box_100 = wx.ComboBox(self.panel_14, 809, pos=(170, 5),
|
||
choices=["HTTP", "SOCKET TCP", "SOCKET UDP", "MQTT", u"阿里云", u"腾讯云", u"移远云"],
|
||
style=wx.CB_READONLY)
|
||
self.label_310 = wx.StaticText(self.panel_14, 810, u"提示:选择透传的类型", pos=(290, 5))
|
||
###########################################################################################################
|
||
# channel 3
|
||
self.channel_3 = wx.Panel(self.channel, wx.ID_ANY)
|
||
self.panel_70 = wx.Panel(self.channel_3, wx.ID_ANY)
|
||
self.radio_btn_29 = wx.RadioButton(self.panel_70, 816, u"启用")
|
||
self.radio_btn_30 = wx.RadioButton(self.panel_70, 817, u"不启用")
|
||
self.panel_15 = wx.Panel(self.channel_3, wx.ID_ANY)
|
||
self.label_266 = wx.StaticText(self.panel_15, wx.ID_ANY, u"通道类型", pos=(20, 5))
|
||
self.combo_box_75 = wx.ComboBox(self.panel_15, 828, pos=(170, 5),
|
||
choices=["HTTP", "SOCKET TCP", "SOCKET UDP", "MQTT", u"阿里云", u"腾讯云", u"移远云"],
|
||
style=wx.CB_READONLY)
|
||
self.label_267 = wx.StaticText(self.panel_15, wx.ID_ANY, u"提示:选择透传的类型", pos=(290, 5))
|
||
###########################################################################################################
|
||
# channel 4
|
||
self.channel_4 = wx.Panel(self.channel, wx.ID_ANY)
|
||
self.panel_68 = wx.Panel(self.channel_4, wx.ID_ANY)
|
||
self.radio_btn_31 = wx.RadioButton(self.panel_68, 818, u"启用")
|
||
self.radio_btn_32 = wx.RadioButton(self.panel_68, 819, u"不启用")
|
||
self.panel_16 = wx.Panel(self.channel_4, wx.ID_ANY)
|
||
|
||
self.label_330 = wx.StaticText(self.panel_16, wx.ID_ANY, u"通道类型", pos=(20, 5))
|
||
self.combo_box_79 = wx.ComboBox(self.panel_16, 829, pos=(170, 5),
|
||
choices=["HTTP", "SOCKET TCP", "SOCKET UDP", "MQTT", u"阿里云", u"腾讯云", u"移远云"],
|
||
style=wx.CB_READONLY)
|
||
self.label_331 = wx.StaticText(self.panel_16, wx.ID_ANY, u"提示:选择透传的类型", pos=(290, 5))
|
||
###########################################################################################################
|
||
# channel 5
|
||
self.channel_5 = wx.Panel(self.channel, wx.ID_ANY)
|
||
self.panel_28 = wx.Panel(self.channel_5, wx.ID_ANY)
|
||
self.radio_btn_43 = wx.RadioButton(self.panel_28, 820, u"启用")
|
||
self.radio_btn_44 = wx.RadioButton(self.panel_28, 821, u"不启用")
|
||
self.panel_29 = wx.Panel(self.channel_5, wx.ID_ANY)
|
||
|
||
self.label_485 = wx.StaticText(self.panel_29, wx.ID_ANY, u"通道类型", pos=(20, 5))
|
||
self.combo_box_120 = wx.ComboBox(self.panel_29, 830, pos=(170, 5),
|
||
choices=["HTTP", "SOCKET TCP", "SOCKET UDP", "MQTT", u"阿里云", u"腾讯云", u"移远云"],
|
||
style=wx.CB_READONLY)
|
||
self.label_486 = wx.StaticText(self.panel_29, wx.ID_ANY, u"提示:选择透传的类型", pos=(290, 5))
|
||
###########################################################################################################
|
||
# channel 6
|
||
self.channel_6 = wx.Panel(self.channel, wx.ID_ANY)
|
||
self.panel_30 = wx.Panel(self.channel_6, wx.ID_ANY)
|
||
self.radio_btn_45 = wx.RadioButton(self.panel_30, 822, u"启用")
|
||
self.radio_btn_46 = wx.RadioButton(self.panel_30, 823, u"不启用")
|
||
self.panel_31 = wx.Panel(self.channel_6, wx.ID_ANY)
|
||
self.label_511 = wx.StaticText(self.panel_31, wx.ID_ANY, u"通道类型", pos=(20, 5))
|
||
self.combo_box_125 = wx.ComboBox(self.panel_31, 831, pos=(170, 5),
|
||
choices=["HTTP", "SOCKET TCP", "SOCKET UDP", "MQTT", u"阿里云", u"腾讯云", u"移远云"],
|
||
style=wx.CB_READONLY)
|
||
self.label_512 = wx.StaticText(self.panel_31, wx.ID_ANY, u"提示:选择透传的类型", pos=(290, 5))
|
||
###########################################################################################################
|
||
# channel 7
|
||
self.channel_7 = wx.Panel(self.channel, wx.ID_ANY)
|
||
self.panel_32 = wx.Panel(self.channel_7, wx.ID_ANY)
|
||
self.radio_btn_51 = wx.RadioButton(self.panel_32, 824, u"启用")
|
||
self.radio_btn_52 = wx.RadioButton(self.panel_32, 825, u"不启用")
|
||
self.panel_33 = wx.Panel(self.channel_7, wx.ID_ANY)
|
||
|
||
self.label_537 = wx.StaticText(self.panel_33, wx.ID_ANY, u"通道类型", pos=(20, 5))
|
||
self.combo_box_130 = wx.ComboBox(self.panel_33, 832, pos=(170, 5),
|
||
choices=["HTTP", "SOCKET TCP", "SOCKET UDP", "MQTT", u"阿里云", u"腾讯云", u"移远云"],
|
||
style=wx.CB_READONLY)
|
||
self.label_538 = wx.StaticText(self.panel_33, wx.ID_ANY, u"提示:选择透传的类型", pos=(290, 5))
|
||
###########################################################################################################
|
||
# APN 设置
|
||
self.panel_11 = wx.Panel(self.notebook_10, wx.ID_ANY)
|
||
self.panel_1 = wx.Panel(self.panel_11, wx.ID_ANY)
|
||
self.radio_btn_65 = wx.RadioButton(self.panel_1, 850, u"启用")
|
||
self.radio_btn_66 = wx.RadioButton(self.panel_1, 851, u"不启用")
|
||
self.panel_10 = wx.Panel(self.panel_11, wx.ID_ANY)
|
||
self.text_ctrl_8 = wx.TextCtrl(self.panel_10, wx.ID_ANY, "")
|
||
self.text_ctrl_81 = wx.TextCtrl(self.panel_10, wx.ID_ANY, "")
|
||
self.text_ctrl_9 = wx.TextCtrl(self.panel_10, wx.ID_ANY, "")
|
||
###########################################################################################################
|
||
# GPIO 引脚
|
||
self.notebook_10_test = wx.Panel(self.notebook_10, wx.ID_ANY)
|
||
self.panel_36 = wx.Panel(self.notebook_10_test, wx.ID_ANY)
|
||
self.radio_btn_61 = wx.RadioButton(self.panel_36, 826, u"启用")
|
||
self.radio_btn_62 = wx.RadioButton(self.panel_36, 827, u"不启用")
|
||
self.panel_37 = wx.Panel(self.notebook_10_test, wx.ID_ANY)
|
||
self.text_ctrl_66 = wx.TextCtrl(self.panel_37, wx.ID_ANY, "")
|
||
self.text_ctrl_96 = wx.TextCtrl(self.panel_37, wx.ID_ANY, "")
|
||
self.text_ctrl_22 = wx.TextCtrl(self.panel_37, wx.ID_ANY, "")
|
||
###########################################################################################################
|
||
# 设置
|
||
self.notebook_12 = wx.Panel(self.notebook_10, wx.ID_ANY)
|
||
self.panel_38 = wx.Panel(self.notebook_12, wx.ID_ANY)
|
||
|
||
# 右侧工具栏
|
||
self.button_8 = wx.Button(self, wx.ID_ANY, u"工具箱")
|
||
self.button_9 = wx.Button(self, wx.ID_ANY, u"查询当前配置参数")
|
||
self.button_10 = wx.Button(self, wx.ID_ANY, u"导入配置参数")
|
||
self.button_14 = wx.Button(self, wx.ID_ANY, u"修改密码")
|
||
self.text_ctrl_3 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE)
|
||
self.checkbox_5 = wx.CheckBox(self, wx.ID_ANY, "HEX")
|
||
self.checkbox_6 = wx.CheckBox(self, wx.ID_ANY, u"时间戳")
|
||
self.button_11 = wx.Button(self, 1000, u"清空接收")
|
||
self.text_ctrl_14 = wx.TextCtrl(self, wx.ID_ANY, "")
|
||
self.button_12 = wx.Button(self, 1001, u"清空发送")
|
||
self.button_13 = wx.Button(self, wx.ID_ANY, u"发送")
|
||
###########################################################################################################
|
||
self.__set_properties()
|
||
self.__do_layout()
|
||
self.Bind(wx.EVT_COMBOBOX, self.ota_0ff, self.combo_box_86)
|
||
# 打开串口按钮 button_2
|
||
self.Bind(wx.EVT_BUTTON, self.open_serial, self.button_2)
|
||
# 工具箱
|
||
self.Bind(wx.EVT_BUTTON, self.tool_lists, self.button_8)
|
||
# 串口开启/关闭按钮
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.serial_config, self.radio_btn_49)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.serial_config, self.radio_btn_50)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.serial_config, self.radio_btn_53)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.serial_config, self.radio_btn_54)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.serial_config, self.radio_btn_55)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.serial_config, self.radio_btn_56)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.serial_config, self.radio_btn_57)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.serial_config, self.radio_btn_58)
|
||
# 通道开启/关闭按钮
|
||
# channel 1
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_29)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_30)
|
||
# channel 2
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_31)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_32)
|
||
# channel 3
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_43)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_44)
|
||
# channel 4
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_45)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_46)
|
||
# channel 5
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_47)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_48)
|
||
# channel 6
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_51)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_52)
|
||
# channel 7
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_59)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.channel_config, self.radio_btn_60)
|
||
# APN 开启/关闭按钮
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.apn_config, self.radio_btn_65)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.apn_config, self.radio_btn_66)
|
||
# GPIO 开启/关闭按钮
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.gpio_config, self.radio_btn_61)
|
||
self.Bind(wx.EVT_RADIOBUTTON, self.gpio_config, self.radio_btn_62)
|
||
# msg for update ui form
|
||
pub.subscribe(self.updateDisplay, "uiUpdate")
|
||
# 发送数据
|
||
self.Bind(wx.EVT_BUTTON, self.send_data, self.button_13)
|
||
# 清空输入框 text_ctrl_3
|
||
self.Bind(wx.EVT_BUTTON, self.clear_data, self.button_11)
|
||
self.Bind(wx.EVT_BUTTON, self.clear_data, self.button_12)
|
||
# 导入配置参数
|
||
self.Bind(wx.EVT_BUTTON, self.import_config_param, self.button_10)
|
||
# 修改密码
|
||
self.Bind(wx.EVT_BUTTON, self.change_password, self.button_14)
|
||
# 通道类型下拉框
|
||
self.Bind(wx.EVT_COMBOBOX, self.channel_stachange, self.combo_box_95)
|
||
self.Bind(wx.EVT_COMBOBOX, self.channel_stachange, self.combo_box_100)
|
||
self.Bind(wx.EVT_COMBOBOX, self.channel_stachange, self.combo_box_75)
|
||
self.Bind(wx.EVT_COMBOBOX, self.channel_stachange, self.combo_box_79)
|
||
self.Bind(wx.EVT_COMBOBOX, self.channel_stachange, self.combo_box_120)
|
||
self.Bind(wx.EVT_COMBOBOX, self.channel_stachange, self.combo_box_125)
|
||
self.Bind(wx.EVT_COMBOBOX, self.channel_stachange, self.combo_box_130)
|
||
# serial rcv data timer
|
||
self.serRcvTimer = wx.Timer(self)
|
||
self.Bind(wx.EVT_TIMER, self.serRcvHandler, self.serRcvTimer)
|
||
# 查询当前配置参数
|
||
self.Bind(wx.EVT_BUTTON, self.query_config, self.button_9)
|
||
# 密码勾选框 checkbox_1
|
||
self.Bind(wx.EVT_CHECKBOX, self.input_password, self.checkbox_1)
|
||
# 时间戳
|
||
self.Bind(wx.EVT_CHECKBOX, self.add_timestamp, self.checkbox_6)
|
||
# 是否转为HEX显示
|
||
self.Bind(wx.EVT_CHECKBOX, self.convert_hex, self.checkbox_5)
|
||
|
||
def __set_properties(self):
|
||
self.SetTitle("DTU Tools")
|
||
self.combo_box_6.SetToolTip("Uart List")
|
||
self.SetBackgroundColour(wx.NullColour)
|
||
self.combo_box_6.SetMinSize((176, 20))
|
||
self.combo_box_7.SetMinSize((70, 20))
|
||
self.combo_box_7.SetSelection(9)
|
||
self.combo_box_8.SetMinSize((40, 20))
|
||
self.combo_box_8.SetSelection(1)
|
||
self.combo_box_9.SetMinSize((65, 20))
|
||
self.combo_box_9.SetSelection(0)
|
||
self.combo_box_10.SetMinSize((40, 20))
|
||
self.combo_box_10.SetSelection(0)
|
||
self.button_2.SetMinSize((86, 25))
|
||
self.text_ctrl_12.SetMinSize((114, 20))
|
||
self.combo_box_63.SetMinSize((109, 25))
|
||
self.combo_box_63.SetSelection(0)
|
||
self.combo_box_84.SetMinSize((109, 25))
|
||
self.combo_box_84.SetSelection(0)
|
||
self.text_ctrl_6.SetMinSize((109, 25))
|
||
|
||
self.text_ctrl_10.SetMinSize((109, 25))
|
||
self.text_ctrl_11.SetMinSize((109, 25))
|
||
self.text_ctrl_13.SetMinSize((109, 25))
|
||
|
||
self.combo_box_86.SetMinSize((109, 25))
|
||
self.combo_box_86.SetSelection(0)
|
||
self.radio_btn_50.SetMinSize((68, 30))
|
||
self.radio_btn_50.SetValue(1)
|
||
self.radio_btn_58.SetMinSize((68, 30))
|
||
self.radio_btn_58.SetValue(1)
|
||
self.panel_24.SetMinSize((646, 30))
|
||
self.panel_18.SetMinSize((646, 30))
|
||
self.radio_btn_56.SetMinSize((68, 30))
|
||
self.radio_btn_56.SetValue(1)
|
||
self.radio_btn_54.SetMinSize((68, 30))
|
||
self.radio_btn_54.SetValue(1)
|
||
self.panel_19.SetMinSize((646, 30))
|
||
self.radio_btn_59.SetMinSize((40, 30))
|
||
self.radio_btn_60.SetMinSize((60, 30))
|
||
self.radio_btn_60.SetValue(1)
|
||
self.panel_34.SetMinSize((646, 30))
|
||
self.combo_box_95.SetMinSize((150, 20))
|
||
self.radio_btn_47.SetMinSize((40, 30))
|
||
self.radio_btn_48.SetMinSize((60, 30))
|
||
self.radio_btn_48.SetValue(1)
|
||
self.panel_35.SetMinSize((646, 30))
|
||
self.combo_box_100.SetMinSize((150, 20))
|
||
self.radio_btn_29.SetMinSize((40, 30))
|
||
self.radio_btn_30.SetMinSize((60, 30))
|
||
self.radio_btn_30.SetValue(1)
|
||
self.panel_70.SetMinSize((612, 30))
|
||
self.combo_box_75.SetMinSize((170, 20))
|
||
self.radio_btn_31.SetMinSize((40, 30))
|
||
self.radio_btn_32.SetMinSize((60, 30))
|
||
self.radio_btn_32.SetValue(1)
|
||
self.panel_68.SetMinSize((612, 30))
|
||
self.combo_box_79.SetMinSize((170, 20))
|
||
self.radio_btn_43.SetMinSize((40, 30))
|
||
self.radio_btn_44.SetMinSize((60, 30))
|
||
self.radio_btn_44.SetValue(1)
|
||
self.panel_28.SetMinSize((646, 30))
|
||
self.combo_box_120.SetMinSize((160, 20))
|
||
self.radio_btn_45.SetMinSize((40, 30))
|
||
self.radio_btn_46.SetMinSize((60, 30))
|
||
self.radio_btn_46.SetValue(1)
|
||
self.panel_30.SetMinSize((646, 30))
|
||
self.combo_box_125.SetMinSize((160, 20))
|
||
self.radio_btn_51.SetMinSize((40, 30))
|
||
self.radio_btn_52.SetMinSize((60, 30))
|
||
self.radio_btn_52.SetValue(1)
|
||
self.panel_32.SetMinSize((646, 30))
|
||
self.combo_box_130.SetMinSize((160, 20))
|
||
self.text_ctrl_8.SetMinSize((109, 20))
|
||
self.text_ctrl_81.SetMinSize((109, 20))
|
||
self.text_ctrl_9.SetMinSize((109, 20))
|
||
# apn
|
||
self.radio_btn_65.SetMinSize((40, 30))
|
||
self.radio_btn_66.SetMinSize((60, 30))
|
||
self.radio_btn_66.SetValue(1)
|
||
# gpio
|
||
self.radio_btn_61.SetMinSize((40, 30))
|
||
self.radio_btn_62.SetMinSize((60, 30))
|
||
self.radio_btn_62.SetValue(1)
|
||
self.text_ctrl_66.SetMinSize((109, 20))
|
||
self.text_ctrl_96.SetMinSize((109, 20))
|
||
self.text_ctrl_22.SetMinSize((109, 20))
|
||
self.button_8.SetMinSize((100, 53))
|
||
self.button_9.SetMinSize((113, 53))
|
||
self.button_10.SetMinSize((98, 53))
|
||
self.button_14.SetMinSize((98, 53))
|
||
self.text_ctrl_3.SetMinSize((406, 360))
|
||
self.button_11.SetMinSize((81, 25))
|
||
self.text_ctrl_14.SetMinSize((406, 160))
|
||
self.button_13.SetMinSize((80, 25))
|
||
# end wxGlade
|
||
|
||
def __do_layout(self):
|
||
sizer_23 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_28 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_29 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_13 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_20 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_19 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_14 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_12 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_145 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_86 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_85 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_84 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_119 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_120 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_147 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_148 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_91 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_90 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_89 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_88 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_39 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_11 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_317 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_330 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_318 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_116 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_10 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_303 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_316 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_304 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_115 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_9 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_289 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_302 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_290 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_114 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_108 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_192 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_214 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_193 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_109 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_98 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_153 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_188 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_95 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_1 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_195 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_202 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_196 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_118 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_15 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_162 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_163 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_117 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_5 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_262 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_261 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_6 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_8 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_268 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_269 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_267 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_300 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_301 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_7 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_274 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_275 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_273 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_140 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_141 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_76 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_75 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_74 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_73 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_24 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_31 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_32 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_281 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_2 = wx.BoxSizer(wx.VERTICAL)
|
||
sizer_22 = wx.BoxSizer(wx.VERTICAL)
|
||
|
||
sizer_143 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_146 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_144 = wx.BoxSizer(wx.HORIZONTAL)
|
||
|
||
sizer_31.Add((20, 5), 0, 0, 0)
|
||
label_6 = wx.StaticText(self, wx.ID_ANY, u"【PC端口参数】")
|
||
sizer_32.Add(label_6, 0, 0, 0)
|
||
sizer_32.Add((20, 20), 0, 0, 0)
|
||
label_7 = wx.StaticText(self, wx.ID_ANY, u" 串口")
|
||
label_7.SetMinSize((41, 15))
|
||
sizer_32.Add(label_7, 0, 0, 0)
|
||
sizer_32.Add(self.combo_box_6, 0, 0, 0)
|
||
sizer_32.Add((20, 20), 0, 0, 0)
|
||
label_8 = wx.StaticText(self, wx.ID_ANY, u"波特率")
|
||
sizer_32.Add(label_8, 0, 0, 0)
|
||
sizer_32.Add((20, 20), 0, 0, 0)
|
||
sizer_32.Add(self.combo_box_7, 0, 0, 0)
|
||
sizer_32.Add((20, 20), 0, 0, 0)
|
||
label_9 = wx.StaticText(self, wx.ID_ANY, u"数据位/校验位/停止位")
|
||
sizer_32.Add(label_9, 0, 0, 0)
|
||
sizer_32.Add((20, 20), 0, 0, 0)
|
||
sizer_32.Add(self.combo_box_8, 0, 0, 0)
|
||
sizer_32.Add(self.combo_box_9, 0, 0, 0)
|
||
sizer_32.Add(self.combo_box_10, 0, 0, 0)
|
||
sizer_32.Add((20, 20), 0, 0, 0)
|
||
sizer_32.Add(self.button_2, 0, 0, 0)
|
||
sizer_32.Add((20, 20), 0, 0, 0)
|
||
sizer_32.Add(self.checkbox_1, 0, 0, 0)
|
||
label_10 = wx.StaticText(self, wx.ID_ANY, u"密码")
|
||
sizer_32.Add(label_10, 0, 0, 0)
|
||
sizer_32.Add((20, 20), 0, 0, 0)
|
||
sizer_32.Add(self.text_ctrl_12, 0, 0, 0)
|
||
sizer_31.Add(sizer_32, 1, wx.EXPAND, 0)
|
||
sizer_31.Add((20, 5), 0, 0, 0)
|
||
sizer_24.Add(sizer_31, 1, wx.EXPAND, 0)
|
||
sizer_23.Add(sizer_24, 0, wx.EXPAND, 0)
|
||
sizer_140.Add((25, 20), 0, 0, 0)
|
||
sizer_73.Add((20, 20), 0, 0, 0)
|
||
label_126 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"是否加设备识别码IMEI")
|
||
label_126.SetMinSize((156, 18))
|
||
sizer_73.Add(label_126, 0, 0, 0)
|
||
sizer_73.Add((20, 20), 0, 0, 0)
|
||
sizer_73.Add(self.combo_box_63, 0, 0, 0)
|
||
sizer_73.Add((20, 20), 0, 0, 0)
|
||
label_237 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"提示:输出的前缀加设备IMEI")
|
||
label_237.SetMinSize((195, 25))
|
||
sizer_73.Add(label_237, 0, 0, 0)
|
||
sizer_140.Add(sizer_73, 0, 0, 0)
|
||
sizer_140.Add((20, 5), 0, 0, 0)
|
||
sizer_74.Add((20, 20), 0, 0, 0)
|
||
label_127 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"首次登录服务器发送注册信息")
|
||
sizer_74.Add(label_127, 0, 0, 0)
|
||
sizer_74.Add((20, 20), 0, 0, 0)
|
||
sizer_74.Add(self.combo_box_84, 0, 0, 0)
|
||
sizer_74.Add((20, 20), 0, 0, 0)
|
||
label_238 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"提示:首次登陆发送注册消息")
|
||
label_238.SetMinSize((192, 25))
|
||
sizer_74.Add(label_238, 0, 0, 0)
|
||
sizer_140.Add(sizer_74, 0, 0, 0)
|
||
sizer_140.Add((20, 5), 0, 0, 0)
|
||
sizer_75.Add((20, 20), 0, 0, 0)
|
||
label_128 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"参数版本号")
|
||
label_128.SetMinSize((156, 18))
|
||
sizer_75.Add(label_128, 0, 0, 0)
|
||
sizer_75.Add((20, 20), 0, 0, 0)
|
||
sizer_75.Add(self.text_ctrl_6, 0, 0, 0)
|
||
sizer_75.Add((20, 20), 0, 0, 0)
|
||
label_239 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"提示:范围 1~n")
|
||
label_239.SetMinSize((87, 25))
|
||
sizer_75.Add(label_239, 0, 0, 0)
|
||
sizer_140.Add(sizer_75, 0, 0, 0)
|
||
sizer_140.Add((20, 5), 0, 0, 0)
|
||
sizer_76.Add((20, 20), 0, 0, 0)
|
||
label_129 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"是否开启自动更新")
|
||
label_129.SetMinSize((156, 18))
|
||
sizer_76.Add(label_129, 0, 0, 0)
|
||
sizer_76.Add((20, 20), 0, 0, 0)
|
||
sizer_76.Add(self.combo_box_86, 0, 0, 0)
|
||
sizer_76.Add((20, 20), 0, 0, 0)
|
||
label_240 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"提示:是否开启OTA升级")
|
||
label_240.SetMinSize((139, 25))
|
||
sizer_76.Add(label_240, 0, 0, 0)
|
||
sizer_140.Add(sizer_76, 0, 0, 0)
|
||
sizer_140.Add((20, 5), 0, 0, 0)
|
||
sizer_141.Add((20, 20), 0, 0, 0)
|
||
sizer_141.Add((20, 20), 0, 0, 0)
|
||
sizer_143.Add((20, 20), 0, 0, 0)
|
||
label_132 = wx.StaticText(self.notebook_10_, wx.ID_ANY, "uid")
|
||
label_132.SetMinSize((156, 18))
|
||
sizer_143.Add(label_132, 0, 0, 0)
|
||
sizer_143.Add((20, 20), 0, 0, 0)
|
||
sizer_143.Add(self.text_ctrl_11, 0, 0, 0)
|
||
sizer_143.Add((20, 20), 0, 0, 0)
|
||
label_243 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"提示:用户uid")
|
||
label_243.SetMinSize((120, 25))
|
||
sizer_143.Add(label_243, 0, 0, 0)
|
||
sizer_140.Add(sizer_143, 0, 0, 0)
|
||
sizer_140.Add((20, 5), 0, 0, 0)
|
||
sizer_146.Add((20, 20), 0, 0, 0)
|
||
label_134 = wx.StaticText(self.notebook_10_, wx.ID_ANY, "module_type")
|
||
label_134.SetMinSize((156, 18))
|
||
sizer_146.Add(label_134, 0, 0, 0)
|
||
sizer_146.Add((20, 20), 0, 0, 0)
|
||
sizer_146.Add(self.text_ctrl_10, 0, 0, 0)
|
||
sizer_146.Add((20, 20), 0, 0, 0)
|
||
label_245 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"提示:设备类型")
|
||
label_245.SetMinSize((120, 25))
|
||
sizer_146.Add(label_245, 0, 0, 0)
|
||
sizer_140.Add(sizer_146, 0, 0, 0)
|
||
sizer_140.Add((20, 5), 0, 0, 0)
|
||
sizer_144.Add((20, 20), 0, 0, 0)
|
||
label_133 = wx.StaticText(self.notebook_10_, wx.ID_ANY, "pk")
|
||
label_133.SetMinSize((156, 18))
|
||
sizer_144.Add(label_133, 0, 0, 0)
|
||
sizer_144.Add((20, 20), 0, 0, 0)
|
||
sizer_144.Add(self.text_ctrl_13, 0, 0, 0)
|
||
sizer_144.Add((20, 20), 0, 0, 0)
|
||
label_244 = wx.StaticText(self.notebook_10_, wx.ID_ANY, u"提示:设备密钥")
|
||
label_244.SetMinSize((120, 25))
|
||
sizer_144.Add(label_244, 0, 0, 0)
|
||
sizer_140.Add(sizer_144, 0, 0, 0)
|
||
self.notebook_10_.SetSizer(sizer_140)
|
||
|
||
sizer_140.Add(sizer_141, 0, 0, 0)
|
||
self.notebook_10_.SetSizer(sizer_140)
|
||
# 串口0
|
||
sizer_300.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_300.Add(self.radio_btn_49, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_300.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_300.Add(self.radio_btn_50, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_18.SetSizer(sizer_300)
|
||
sizer_8.Add(self.panel_18, 0, wx.EXPAND, 0)
|
||
sizer_301.Add((20, 20), 0, 0, 0)
|
||
self.panel_17.SetSizer(sizer_301)
|
||
sizer_8.Add(self.panel_17, 1, wx.EXPAND, 0)
|
||
self.serial_panel_0.SetSizer(sizer_8)
|
||
# 串口1
|
||
sizer_273.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_273.Add(self.radio_btn_57, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_273.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_273.Add(self.radio_btn_58, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_24.SetSizer(sizer_273)
|
||
sizer_7.Add(self.panel_24, 0, wx.EXPAND, 0)
|
||
sizer_275.Add((20, 20), 0, 0, 0)
|
||
sizer_2.Add(sizer_275, 0, 0, 0)
|
||
sizer_281.Add((20, 20), 0, 0, 0)
|
||
sizer_274.Add((20, 5), 0, 0, 0)
|
||
self.panel_25.SetSizer(sizer_274)
|
||
sizer_7.Add(self.panel_25, 1, wx.EXPAND, 0)
|
||
self.serial_panel_1.SetSizer(sizer_7)
|
||
# 串口2
|
||
sizer_267.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_267.Add(self.radio_btn_55, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_267.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_267.Add(self.radio_btn_56, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_21.SetSizer(sizer_267)
|
||
sizer_6.Add(self.panel_21, 0, wx.EXPAND, 0)
|
||
sizer_269.Add((20, 20), 0, 0, 0)
|
||
sizer_268.Add((20, 5), 0, 0, 0)
|
||
self.panel_22.SetSizer(sizer_268)
|
||
sizer_6.Add(self.panel_22, 1, wx.EXPAND, 0)
|
||
self.serial_panel_2.SetSizer(sizer_6)
|
||
# 串口3
|
||
sizer_261.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_261.Add(self.radio_btn_53, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_261.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_261.Add(self.radio_btn_54, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_19.SetSizer(sizer_261)
|
||
sizer_5.Add(self.panel_19, 0, wx.EXPAND, 0)
|
||
sizer_262.Add((20, 5), 0, 0, 0)
|
||
self.panel_20.SetSizer(sizer_262)
|
||
sizer_5.Add(self.panel_20, 1, wx.EXPAND, 0)
|
||
self.serial_panel_3.SetSizer(sizer_5)
|
||
self.serial_param.AddPage(self.serial_panel_0, u"串口0")
|
||
self.serial_param.AddPage(self.serial_panel_1, u"串口1")
|
||
self.serial_param.AddPage(self.serial_panel_2, u"串口2")
|
||
self.serial_param.AddPage(self.serial_panel_3, u"串口3")
|
||
sizer_117.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_117.Add(self.radio_btn_59, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_117.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_117.Add(self.radio_btn_60, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_34.SetSizer(sizer_117)
|
||
sizer_15.Add(self.panel_34, 0, wx.EXPAND, 0)
|
||
sizer_163.Add((20, 20), 0, 0, 0)
|
||
self.panel_12.SetSizer(sizer_162)
|
||
sizer_15.Add(self.panel_12, 1, wx.EXPAND, 0)
|
||
self.channel_1.SetSizer(sizer_15)
|
||
sizer_118.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_118.Add(self.radio_btn_47, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_118.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_118.Add(self.radio_btn_48, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_35.SetSizer(sizer_118)
|
||
sizer_1.Add(self.panel_35, 0, wx.EXPAND, 0)
|
||
sizer_196.Add((20, 20), 0, 0, 0)
|
||
label_2270 = wx.StaticText(self.panel_14, wx.ID_ANY, "")
|
||
sizer_202.Add(label_2270, 0, 0, 0)
|
||
sizer_195.Add(sizer_202, 0, 0, 0)
|
||
self.panel_14.SetSizer(sizer_195)
|
||
sizer_1.Add(self.panel_14, 1, wx.EXPAND, 0)
|
||
self.channel_2.SetSizer(sizer_1)
|
||
sizer_95.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_95.Add(self.radio_btn_29, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_95.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_95.Add(self.radio_btn_30, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_70.SetSizer(sizer_95)
|
||
sizer_98.Add(self.panel_70, 0, wx.EXPAND, 0)
|
||
sizer_153.Add(sizer_188, 0, 0, 0)
|
||
self.panel_15.SetSizer(sizer_153)
|
||
sizer_98.Add(self.panel_15, 1, wx.EXPAND, 0)
|
||
self.channel_3.SetSizer(sizer_98)
|
||
sizer_109.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_109.Add(self.radio_btn_31, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_109.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_109.Add(self.radio_btn_32, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_68.SetSizer(sizer_109)
|
||
sizer_108.Add(self.panel_68, 0, wx.EXPAND, 0)
|
||
sizer_193.Add((20, 20), 0, 0, 0)
|
||
sizer_192.Add(sizer_214, 0, 0, 0)
|
||
self.panel_16.SetSizer(sizer_192)
|
||
sizer_108.Add(self.panel_16, 1, wx.EXPAND, 0)
|
||
self.channel_4.SetSizer(sizer_108)
|
||
sizer_114.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_114.Add(self.radio_btn_43, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_114.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_114.Add(self.radio_btn_44, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_28.SetSizer(sizer_114)
|
||
sizer_9.Add(self.panel_28, 0, wx.EXPAND, 0)
|
||
sizer_290.Add((20, 20), 0, 0, 0)
|
||
sizer_289.Add(sizer_302, 0, 0, 0)
|
||
self.panel_29.SetSizer(sizer_289)
|
||
sizer_9.Add(self.panel_29, 1, wx.EXPAND, 0)
|
||
self.channel_5.SetSizer(sizer_9)
|
||
sizer_115.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_115.Add(self.radio_btn_45, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_115.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_115.Add(self.radio_btn_46, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_30.SetSizer(sizer_115)
|
||
sizer_10.Add(self.panel_30, 0, wx.EXPAND, 0)
|
||
sizer_304.Add((20, 20), 0, 0, 0)
|
||
sizer_303.Add(sizer_316, 0, 0, 0)
|
||
self.panel_31.SetSizer(sizer_303)
|
||
sizer_10.Add(self.panel_31, 1, wx.EXPAND, 0)
|
||
self.channel_6.SetSizer(sizer_10)
|
||
sizer_116.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_116.Add(self.radio_btn_51, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_116.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_116.Add(self.radio_btn_52, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_32.SetSizer(sizer_116)
|
||
sizer_11.Add(self.panel_32, 0, wx.EXPAND, 0)
|
||
sizer_318.Add((20, 20), 0, 0, 0)
|
||
sizer_317.Add(sizer_330, 0, 0, 0)
|
||
self.panel_33.SetSizer(sizer_317)
|
||
sizer_11.Add(self.panel_33, 1, wx.EXPAND, 0)
|
||
self.channel_7.SetSizer(sizer_11)
|
||
self.channel.AddPage(self.channel_1, u"通道 1")
|
||
self.channel.AddPage(self.channel_2, u"通道 2")
|
||
self.channel.AddPage(self.channel_3, u"通道 3")
|
||
self.channel.AddPage(self.channel_4, u"通道 4")
|
||
self.channel.AddPage(self.channel_5, u"通道 5")
|
||
self.channel.AddPage(self.channel_6, u"通道 6")
|
||
self.channel.AddPage(self.channel_7, u"通道 7")
|
||
sizer_39.Add(self.channel, 1, wx.EXPAND, 0)
|
||
self.notebook_10_3.SetSizer(sizer_39)
|
||
sizer_120.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_120.Add(self.radio_btn_65, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_120.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_120.Add(self.radio_btn_66, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_120.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_120.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_1.SetSizer(sizer_120)
|
||
sizer_22.Add(self.panel_1, 0, wx.EXPAND, 0)
|
||
sizer_89.Add((20, 20), 0, 0, 0)
|
||
label_145 = wx.StaticText(self.panel_10, wx.ID_ANY, u"名称")
|
||
label_145.SetMinSize((80, 18))
|
||
sizer_89.Add(label_145, 0, 0, 0)
|
||
sizer_89.Add((20, 20), 0, 0, 0)
|
||
sizer_89.Add(self.text_ctrl_8, 0, 0, 0)
|
||
sizer_89.Add((20, 20), 0, 0, 0)
|
||
sizer_147.Add(sizer_89, 0, 0, 0)
|
||
sizer_147.Add((20, 5), 0, 0, 0)
|
||
sizer_90.Add((20, 20), 0, 0, 0)
|
||
label_146 = wx.StaticText(self.panel_10, wx.ID_ANY, u"用户名")
|
||
label_146.SetMinSize((80, 18))
|
||
sizer_90.Add(label_146, 0, 0, 0)
|
||
sizer_90.Add((20, 20), 0, 0, 0)
|
||
sizer_90.Add(self.text_ctrl_81, 0, 0, 0)
|
||
sizer_90.Add((20, 20), 0, 0, 0)
|
||
sizer_147.Add(sizer_90, 0, 0, 0)
|
||
sizer_147.Add((20, 5), 0, 0, 0)
|
||
sizer_91.Add((20, 20), 0, 0, 0)
|
||
label_147 = wx.StaticText(self.panel_10, wx.ID_ANY, u"密码")
|
||
label_147.SetMinSize((80, 18))
|
||
sizer_91.Add(label_147, 0, 0, 0)
|
||
sizer_91.Add((20, 20), 0, 0, 0)
|
||
sizer_91.Add(self.text_ctrl_9, 0, 0, 0)
|
||
sizer_91.Add((20, 20), 0, 0, 0)
|
||
sizer_147.Add(sizer_91, 0, 0, 0)
|
||
sizer_147.Add((20, 5), 0, 0, 0)
|
||
sizer_148.Add((20, 20), 0, 0, 0)
|
||
sizer_148.Add((20, 20), 0, 0, 0)
|
||
sizer_148.Add((20, 20), 0, 0, 0)
|
||
sizer_147.Add(sizer_148, 0, 0, 0)
|
||
self.panel_10.SetSizer(sizer_147)
|
||
sizer_22.Add(self.panel_10, 1, wx.EXPAND, 0)
|
||
sizer_4.Add(sizer_22, 1, wx.EXPAND, 0)
|
||
self.panel_11.SetSizer(sizer_4)
|
||
sizer_119.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_119.Add(self.radio_btn_61, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_119.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_119.Add(self.radio_btn_62, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_119.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
self.panel_36.SetSizer(sizer_119)
|
||
sizer_12.Add(self.panel_36, 0, wx.EXPAND, 0)
|
||
sizer_84.Add((20, 20), 0, 0, 0)
|
||
label_139 = wx.StaticText(self.panel_37, wx.ID_ANY, "NETLED")
|
||
label_139.SetMinSize((80, 18))
|
||
sizer_84.Add(label_139, 0, 0, 0)
|
||
sizer_84.Add((20, 20), 0, 0, 0)
|
||
sizer_84.Add(self.text_ctrl_66, 0, 0, 0)
|
||
sizer_84.Add((20, 20), 0, 0, 0)
|
||
label_256 = wx.StaticText(self.panel_37, wx.ID_ANY, u"提示:网络指示灯(pio1~pio19)")
|
||
label_256.SetMinSize((195, 25))
|
||
sizer_84.Add(label_256, 0, 0, 0)
|
||
sizer_145.Add(sizer_84, 0, 0, 0)
|
||
sizer_145.Add((20, 5), 0, 0, 0)
|
||
sizer_85.Add((20, 20), 0, 0, 0)
|
||
label_140 = wx.StaticText(self.panel_37, wx.ID_ANY, "NETRDY")
|
||
label_140.SetMinSize((80, 18))
|
||
sizer_85.Add(label_140, 0, 0, 0)
|
||
sizer_85.Add((20, 20), 0, 0, 0)
|
||
sizer_85.Add(self.text_ctrl_96, 0, 0, 0)
|
||
sizer_85.Add((20, 20), 0, 0, 0)
|
||
label_257 = wx.StaticText(self.panel_37, wx.ID_ANY, u"提示:网络准备通知(pio1~pio19)")
|
||
label_257.SetMinSize((192, 25))
|
||
sizer_85.Add(label_257, 0, 0, 0)
|
||
sizer_145.Add(sizer_85, 0, 0, 0)
|
||
sizer_145.Add((20, 5), 0, 0, 0)
|
||
sizer_86.Add((20, 20), 0, 0, 0)
|
||
label_141 = wx.StaticText(self.panel_37, wx.ID_ANY, "RSTCNF")
|
||
label_141.SetMinSize((80, 18))
|
||
sizer_86.Add(label_141, 0, 0, 0)
|
||
sizer_86.Add((20, 20), 0, 0, 0)
|
||
sizer_86.Add(self.text_ctrl_22, 0, 0, 0)
|
||
sizer_86.Add((20, 20), 0, 0, 0)
|
||
label_258 = wx.StaticText(self.panel_37, wx.ID_ANY, u"提示:重置DTU(pio1~pio19)")
|
||
label_258.SetMinSize((192, 25))
|
||
sizer_86.Add(label_258, 0, 0, 0)
|
||
sizer_145.Add(sizer_86, 0, 0, 0)
|
||
self.panel_37.SetSizer(sizer_145)
|
||
sizer_12.Add(self.panel_37, 1, wx.EXPAND, 0)
|
||
self.notebook_10_test.SetSizer(sizer_12)
|
||
self.notebook_10.AddPage(self.notebook_10_, u"基本参数")
|
||
self.notebook_10.AddPage(self.serial_param, u"串口参数")
|
||
self.notebook_10.AddPage(self.notebook_10_3, u"网络通道参数")
|
||
self.notebook_10.AddPage(self.panel_11, u"APN设置")
|
||
self.notebook_10.AddPage(self.notebook_10_test, u"GPIO引脚设置")
|
||
|
||
self.notebook_10.AddPage(self.notebook_12, u"设置选项")
|
||
|
||
sizer_28.Add(self.notebook_10, 1, wx.EXPAND, 0)
|
||
sizer_14.Add((6, 20), 0, 0, 0)
|
||
sizer_14.Add(self.button_8, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_14.Add(self.button_9, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_14.Add(self.button_10, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_14.Add(self.button_14, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_13.Add(sizer_14, 1, wx.EXPAND, 0)
|
||
sizer_13.Add(self.text_ctrl_3, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
|
||
sizer_19.Add((185, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_19.Add(self.checkbox_5, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_19.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_19.Add(self.checkbox_6, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_19.Add((21, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_19.Add(self.button_11, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_13.Add(sizer_19, 1, wx.EXPAND, 0)
|
||
sizer_13.Add(self.text_ctrl_14, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
|
||
sizer_20.Add((219, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_20.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_20.Add(self.button_12, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_20.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_20.Add(self.button_13, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
sizer_13.Add(sizer_20, 1, wx.EXPAND, 0)
|
||
sizer_29.Add(sizer_13, 1, wx.EXPAND, 0)
|
||
sizer_28.Add(sizer_29, 1, wx.EXPAND, 0)
|
||
sizer_23.Add(sizer_28, 1, wx.EXPAND, 0)
|
||
self.SetSizer(sizer_23)
|
||
self.Layout()
|
||
#################################Hide/Disable panel #################################
|
||
# ota 升级设备参数
|
||
self.text_ctrl_10.Disable()
|
||
self.text_ctrl_11.Disable()
|
||
self.text_ctrl_13.Disable()
|
||
# serial panel
|
||
self.panel_17.Hide()
|
||
self.panel_20.Hide()
|
||
self.panel_22.Hide()
|
||
self.panel_25.Hide()
|
||
# channel panel
|
||
self.panel_12.Hide()
|
||
self.panel_14.Hide()
|
||
self.panel_15.Hide()
|
||
self.panel_16.Hide()
|
||
self.panel_29.Hide()
|
||
self.panel_31.Hide()
|
||
self.panel_33.Hide()
|
||
# apn panel
|
||
self.panel_10.Hide()
|
||
# GPIO panel
|
||
self.panel_37.Hide()
|
||
self.text_ctrl_12.Disable()
|
||
|
||
sizer_121 = wx.BoxSizer(wx.HORIZONTAL)
|
||
sizer_121.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
# sizer_121.Add(self.radio_btn_61, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
# sizer_121.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
# sizer_121.Add(self.radio_btn_62, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
# sizer_121.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
||
|
||
|
||
################################# function ##############################################
|
||
def ota_0ff(self, event):
|
||
if self.combo_box_86.GetValue() == "关闭":
|
||
self.text_ctrl_10.Disable()
|
||
self.text_ctrl_11.Disable()
|
||
self.text_ctrl_13.Disable()
|
||
if self.combo_box_86.GetValue() == "开启":
|
||
self.text_ctrl_10.Enable()
|
||
self.text_ctrl_11.Enable()
|
||
self.text_ctrl_13.Enable()
|
||
|
||
def open_serial(self, event):
|
||
global ser
|
||
if ser.isOpen():
|
||
try:
|
||
self.serRcvTimer.Stop()
|
||
ser.close()
|
||
pub.sendMessage('uiUpdate', arg1="serialStaChange", arg2=serialList)
|
||
except:
|
||
pass
|
||
else:
|
||
comStr = self.combo_box_6.GetString(self.combo_box_6.GetCurrentSelection()).split(' ')
|
||
if len(comStr) <= 2:
|
||
wx.MessageBox(u'未检测到串口', u'错误', wx.YES_DEFAULT | wx.ICON_ERROR)
|
||
else:
|
||
ser.port = comStr[1]
|
||
ser.baudrate = int(self.combo_box_7.GetString(self.combo_box_7.GetCurrentSelection()))
|
||
ser.bytesize = int(self.combo_box_8.GetString(self.combo_box_8.GetCurrentSelection()))
|
||
ser.parity = self.combo_box_9.GetString(self.combo_box_9.GetCurrentSelection())[0:1]
|
||
ser.stopbits = int(self.combo_box_10.GetString(self.combo_box_10.GetCurrentSelection()))
|
||
print(ser.port, ser.baudrate, ser.bytesize, ser.parity, ser.stopbits)
|
||
try:
|
||
# open serial port
|
||
ser.open()
|
||
self.serRcvTimer.Start(50)
|
||
pub.sendMessage('uiUpdate', arg1="serialStaChange", arg2=serialList)
|
||
# fresh mod file list
|
||
except Exception as e:
|
||
wx.MessageBox(u'串口打开失败' + '\n' + str(e), u'错误', wx.YES_DEFAULT | wx.ICON_ERROR)
|
||
return None
|
||
|
||
def updateDisplay(self, arg1, arg2):
|
||
global time_now
|
||
time_now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||
# refresh serial list in main frame section
|
||
global is_open
|
||
is_open = False # 判断串口是否打开
|
||
if arg1 == "serListUpd":
|
||
tmpSerialList = []
|
||
for port, desc, hwid in sorted(serialList):
|
||
# if "Serial Port" in desc:
|
||
tmpSerialList.append(" " + port + " - " + desc.split(" (")[0])
|
||
self.combo_box_6.SetItems(tmpSerialList)
|
||
if not len(tmpSerialList):
|
||
self.text_ctrl_3.write(">>> 未检测到MAIN口\n")
|
||
if self.combo_box_6.GetSelection() != 0:
|
||
self.combo_box_6.SetSelection(0)
|
||
elif arg1 == "serialStaChange":
|
||
global ser
|
||
if ser.isOpen():
|
||
is_open = True
|
||
self.text_ctrl_3.Clear()
|
||
self.text_ctrl_3.AppendText("欢迎使用 DTU Tools {}\n".format(time_now))
|
||
self.button_2.SetLabel(u"关闭串口")
|
||
self.combo_box_6.Disable()
|
||
self.combo_box_7.Disable()
|
||
self.combo_box_8.Disable()
|
||
self.combo_box_9.Disable()
|
||
self.combo_box_10.Disable()
|
||
else:
|
||
is_open = False
|
||
self.button_2.SetLabel(u"打开串口")
|
||
self.combo_box_6.Enable()
|
||
self.combo_box_7.Enable()
|
||
self.combo_box_8.Enable()
|
||
self.combo_box_9.Enable()
|
||
self.combo_box_10.Enable()
|
||
|
||
# 接收串口数据
|
||
def serRcvHandler(self, event):
|
||
global ser, time_now, deviceList, SERIAL_BUFFER
|
||
time_now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||
if ser.port not in deviceList:
|
||
pub.sendMessage('uiUpdate', arg1="serialStaChange", arg2=serialList)
|
||
return None
|
||
try:
|
||
num = ser.inWaiting()
|
||
except:
|
||
self.open_serial(event)
|
||
pub.sendMessage('uiUpdate', arg1="serialStaChange", arg2=serialList)
|
||
return None
|
||
if num > 0:
|
||
data = ser.read(num)
|
||
# 移除原有校验
|
||
if data != b'':
|
||
data_string = data.decode()
|
||
if SERIAL_BUFFER:
|
||
data_string = SERIAL_BUFFER + data_string
|
||
SERIAL_BUFFER = ""
|
||
data_list = data_string.split(",", 2)
|
||
if len(data_list) != 3:
|
||
return
|
||
data_length = data_list[0]
|
||
crc_val = data_list[1]
|
||
data_values = data_list[2]
|
||
print(data_values)
|
||
try:
|
||
data_length_int = int(data_length)
|
||
except:
|
||
return
|
||
if len(data_values) < data_length_int:
|
||
SERIAL_BUFFER = data_string
|
||
return
|
||
if len(data_values) > data_length_int:
|
||
SERIAL_BUFFER = ""
|
||
return
|
||
if crc_val != str(zlib.crc32(data_values.encode('utf-8'))):
|
||
return
|
||
data_dict = json.loads(data_values)
|
||
status_code = data_dict.get("status")
|
||
if status_code == 1:
|
||
self.handler_data(data_dict.get("data"))
|
||
else:
|
||
self.handler_data(data_dict.get("error"))
|
||
|
||
def handler_data(self, new_str):
|
||
print("new_str:", new_str)
|
||
show_data = "【" + time_now + "】" + " " + str(new_str)
|
||
self.text_ctrl_3.write(">>> {}\n".format(show_data))
|
||
|
||
def success_tips(self, success_code):
|
||
print("success_code", success_code)
|
||
if success_code == "20001":
|
||
self.text_ctrl_3.write(">>> http连接成功\n")
|
||
if success_code == "20002":
|
||
self.text_ctrl_3.write(">>> mqtt连接成功\n")
|
||
if success_code == "20003":
|
||
self.text_ctrl_3.write(">>> tcp连接成功\n")
|
||
if success_code == "20004":
|
||
self.text_ctrl_3.write(">>> udp连接成功\n")
|
||
if success_code == "20005":
|
||
self.text_ctrl_3.write(">>> aliyun连接成功\n")
|
||
if success_code == "20006":
|
||
self.text_ctrl_3.write(">>> txyun连接成功\n")
|
||
|
||
def error_tips(self, error_code):
|
||
global import_error
|
||
if error_code == "3001":
|
||
self.text_ctrl_3.write(">>> 读取sim卡错误\n")
|
||
if error_code == "3002":
|
||
self.text_ctrl_3.write(">>> 拨号错误\n")
|
||
if error_code == "4001":
|
||
self.text_ctrl_3.write(">>> http请求失败\n")
|
||
if error_code == "4002":
|
||
self.text_ctrl_3.write(">>> http请求状态500\n")
|
||
if error_code == "4003":
|
||
self.text_ctrl_3.write(">>> tcp连接失败\n")
|
||
if error_code == "4004":
|
||
self.text_ctrl_3.write(">>> udp连接失败\n")
|
||
if error_code == "4005":
|
||
self.text_ctrl_3.write(">>> mqtt连接失败\n")
|
||
if error_code == "4006":
|
||
self.text_ctrl_3.write(">>> aliyun连接失败\n")
|
||
if error_code == "4007":
|
||
self.text_ctrl_3.write(">>> txyun连接失败\n")
|
||
if error_code == "4008":
|
||
self.text_ctrl_3.write(">>> 协议解析错误\n")
|
||
if error_code == "5001":
|
||
self.text_ctrl_3.write(">>> 密码未携带\n")
|
||
if error_code == "5002":
|
||
self.text_ctrl_3.write(">>> 密码错误\n")
|
||
import_error = True
|
||
if error_code == "5003":
|
||
self.text_ctrl_3.write(">>> http参数错误\n")
|
||
if error_code == "5004":
|
||
self.text_ctrl_3.write(">>> 通道透传错误\n")
|
||
if error_code == "5005":
|
||
self.text_ctrl_3.write(">>> 数据类型错误\n")
|
||
if error_code == "5006":
|
||
self.text_ctrl_3.write(">>> 请求方法错误\n")
|
||
if error_code == "5007":
|
||
self.text_ctrl_3.write(">>> 数据透传失败\n")
|
||
if error_code == "5008":
|
||
self.text_ctrl_3.write(">>> mqtt类型不匹配\n")
|
||
if error_code == "5009":
|
||
self.text_ctrl_3.write(">>> 参数数量不符合\n")
|
||
if error_code == "6001":
|
||
self.text_ctrl_3.write(">>> json加载失败\n")
|
||
if error_code == "6002":
|
||
self.text_ctrl_3.write(">>> json解析失败\n")
|
||
if error_code == "6003":
|
||
self.text_ctrl_3.write(">>> 序列化解析失败\n")
|
||
if error_code == "6004":
|
||
self.text_ctrl_3.write(">>> 数据解析错误\n")
|
||
if error_code == "6005":
|
||
self.text_ctrl_3.write(">>> 指令错误\n")
|
||
if error_code == "6006":
|
||
self.text_ctrl_3.write(">>> 读取配置文件失败\n")
|
||
if error_code == "6007":
|
||
self.text_ctrl_3.write(">>> 读取文件不存在\n")
|
||
|
||
def tool_lists(self, event): # 工具箱
|
||
print("工具箱")
|
||
self.Bind(wx.EVT_MENU, self.toolPopupMenu, id=6001, id2=6000 + 9)
|
||
tool_list = ["查询IMEI号", "查询本机号码", "查询版本号", "查询信号强度", "诊断查询", "查询ICCID",
|
||
"查询ADC电压", "查询GPIO信息", "查询电池电压", "查询温湿度", "查询网络连接状态", "查询基站状态", "基站定位"]
|
||
menu = wx.Menu()
|
||
for i in range(len(tool_list)):
|
||
cmd = tool_list[i]
|
||
item = wx.MenuItem(menu, 6001 + int(i), cmd)
|
||
item.Enable(enable=True)
|
||
menu.Append(item)
|
||
self.PopupMenu(menu)
|
||
menu.Destroy()
|
||
|
||
def toolPopupMenu(self, event):
|
||
global ser
|
||
if not ser.isOpen():
|
||
wx.MessageBox(u'请先打开USB Serial Port 串口', u'提示', wx.YES_DEFAULT | wx.ICON_INFORMATION)
|
||
return None
|
||
# TODO 工具箱拓展
|
||
|
||
cmd_list = ["0,None,查询IMEI号", "1,None,查询本机号码", "2,None,查询版本号", "3,None,查询信号强度", "5,None,诊断查询", "6,None,查询ICCID",
|
||
"7,None,查询ADC电压", "8,None,查询GPIO信息", "9,None,查询电池电压", "10,None,查询温湿度",
|
||
"11,None,查询网络连接状态", "12,None,查询基站状态", "13,None,基站定位"]
|
||
for i in range(len(cmd_list)):
|
||
if event.GetId() == 6001 + int(i):
|
||
func_code, data, cmd_name = cmd_list[i].split(",")
|
||
if func_code == '7':
|
||
data = {"cmd_code": func_code, 'data': {"adcn": ""}}
|
||
self.text_ctrl_14.Clear()
|
||
self.text_ctrl_14.write(json.dumps(data))
|
||
elif func_code == "8":
|
||
data = {"cmd_code": func_code, 'data': {"pins": ""}}
|
||
self.text_ctrl_14.Clear()
|
||
self.text_ctrl_14.write(json.dumps(data))
|
||
data = {"cmd_code": func_code, 'data': {}}
|
||
send_datas = self.package_data(data)
|
||
ser.write(send_datas)
|
||
return
|
||
|
||
def serial_config(self, event):
|
||
print(event.GetId())
|
||
# 串口0
|
||
if event.GetId() == 705:
|
||
self.panel_17.Show()
|
||
uart_label_list = self.uart_interface("self.panel_17")
|
||
self.generate_uart_label(uart_label_list, 0)
|
||
if event.GetId() == 706:
|
||
self.panel_17.Hide()
|
||
# 串口1
|
||
if event.GetId() == 704:
|
||
self.panel_25.Show()
|
||
uart_label_list = self.uart_interface("self.panel_25")
|
||
self.generate_uart_label(uart_label_list, 1)
|
||
if event.GetId() == 705:
|
||
self.panel_25.Hide()
|
||
# 串口2
|
||
if event.GetId() == 702:
|
||
self.panel_22.Show()
|
||
uart_label_list = self.uart_interface("self.panel_22")
|
||
self.generate_uart_label(uart_label_list, 2)
|
||
if event.GetId() == 703:
|
||
self.panel_22.Hide()
|
||
# 串口3
|
||
if event.GetId() == 700:
|
||
self.panel_20.Show()
|
||
uart_label_list = self.uart_interface("self.panel_20")
|
||
self.generate_uart_label(uart_label_list, 3)
|
||
if event.GetId() == 701:
|
||
self.panel_20.Hide()
|
||
|
||
# 通道配置参数
|
||
def channel_config(self, event):
|
||
# channel 1
|
||
if event.GetId() == 800:
|
||
self.panel_12.Show()
|
||
if event.GetId() == 801:
|
||
self.panel_12.Hide()
|
||
# channel 2
|
||
if event.GetId() == 807:
|
||
self.panel_14.Show()
|
||
if event.GetId() == 808:
|
||
self.panel_14.Hide()
|
||
# channel 3
|
||
if event.GetId() == 816:
|
||
self.panel_15.Show()
|
||
if event.GetId() == 817:
|
||
self.panel_15.Hide()
|
||
# channel 4
|
||
if event.GetId() == 818:
|
||
self.panel_16.Show()
|
||
if event.GetId() == 819:
|
||
self.panel_16.Hide()
|
||
# channel 5
|
||
if event.GetId() == 820:
|
||
self.panel_29.Show()
|
||
if event.GetId() == 821:
|
||
self.panel_29.Hide()
|
||
# channel 6
|
||
if event.GetId() == 822:
|
||
self.panel_31.Show()
|
||
if event.GetId() == 823:
|
||
self.panel_31.Hide()
|
||
# channel 7
|
||
if event.GetId() == 824:
|
||
self.panel_33.Show()
|
||
if event.GetId() == 825:
|
||
self.panel_33.Hide()
|
||
|
||
def apn_config(self, event):
|
||
print("APN设置")
|
||
if event.GetId() == 850:
|
||
self.panel_10.Show()
|
||
if event.GetId() == 851:
|
||
self.panel_10.Hide()
|
||
|
||
def gpio_config(self, event):
|
||
print("GPIO引脚设置")
|
||
if event.GetId() == 826:
|
||
self.panel_37.Show()
|
||
if event.GetId() == 827:
|
||
self.panel_37.Hide()
|
||
|
||
def send_data(self, event):
|
||
# 先判断串口是否打开
|
||
if not ser.isOpen():
|
||
wx.MessageBox(u'请先打开USB Serial Port 串口', u'提示', wx.YES_DEFAULT | wx.ICON_INFORMATION)
|
||
return None
|
||
if len(self.text_ctrl_14.GetValue().replace(' ', '')) == 0:
|
||
self.text_ctrl_3.write(">>> 请输入指令!\n")
|
||
return
|
||
input_vals = self.text_ctrl_14.GetValue()
|
||
# if ":" in self.text_ctrl_14.GetValue():
|
||
# data = self.text_ctrl_14.GetValue().replace(' ', '').split(":", 1)
|
||
# func_code = data[0]
|
||
# json_data = data[1]
|
||
# if len(func_code) == 0:
|
||
# self.text_ctrl_3.write(">>> ':' 前缺少功能码\n")
|
||
# return
|
||
# if not func_code.isdigit():
|
||
# self.text_ctrl_3.write(">>> 不合法的数据格式 !\n")
|
||
# return
|
||
# if int(func_code) not in funcode_list:
|
||
# self.text_ctrl_3.write(">>> 功能码错误!\n")
|
||
# return
|
||
# try:
|
||
# print(func_code, json_data)
|
||
# ts = TransferS(int(func_code), json.dumps(eval(json_data)))
|
||
# dt = ts.send()
|
||
# ser.write(dt)
|
||
# self.text_ctrl_3.write(">>> 发送成功\n")
|
||
# except Exception as e:
|
||
# print(e)
|
||
# else: # 只有功能码的指令
|
||
# func_code = self.text_ctrl_14.GetValue()
|
||
# if int(func_code) not in funcode_list:
|
||
# self.text_ctrl_3.write(">>> 功能码错误!\n")
|
||
# return
|
||
# if int(func_code) in no_password_funcode:
|
||
# json_data = {"cmd_code": func_code}
|
||
# if int(func_code) in need_password_funcode:
|
||
# password = self.text_ctrl_12.GetValue()
|
||
# print("open_password:", open_password)
|
||
# if not open_password:
|
||
# self.text_ctrl_3.write(">>> 请打开密码输入框 !\n")
|
||
# return
|
||
# if not password:
|
||
# self.text_ctrl_3.write(">>> 请输入密码 !\n")
|
||
# return
|
||
# json_data = {"password": password, "data": {}, "cmd_code": func_code}
|
||
# # 向main口发送数据
|
||
# print(func_code, json_data)
|
||
# ts = TransferS(int(func_code), json.dumps(json_data))
|
||
# dt = ts.send()
|
||
# str_datas = json.dumps(json_data)
|
||
# crc32_vals = str(zlib.crc32(str_datas))
|
||
# data_format = "{},{},{}".format(str(len(str_datas)), crc32_vals, str_datas)
|
||
send_datas = self.package_data(input_vals)
|
||
ser.write(send_datas)
|
||
self.text_ctrl_3.write(">>> 发送成功\n")
|
||
|
||
# 清空输入框
|
||
def clear_data(self, event):
|
||
if event.GetId() == 1000:
|
||
self.text_ctrl_3.Clear()
|
||
if event.GetId() == 1001:
|
||
self.text_ctrl_14.Clear()
|
||
|
||
def get_channel_params(self, flag, channel):
|
||
def get_topic_format(topic_str):
|
||
topic_str = topic_str.replace(",", ",")
|
||
topic_list = topic_str.split(",")
|
||
idx = 0
|
||
topic_map = dict()
|
||
for topic in topic_list:
|
||
topic_map[str(idx)] = topic.replace(" ", "")
|
||
return topic_map
|
||
|
||
label_list_get = eval("label_{}_list".format(channel))
|
||
|
||
if flag == "HTTP":
|
||
conf = {
|
||
"protocol": flag,
|
||
"method": label_list_get[1].GetValue(),
|
||
"url": label_list_get[4].GetValue(),
|
||
"reg_data": label_list_get[7].GetValue(),
|
||
"timeout": label_list_get[10].GetValue(),
|
||
"serialID": label_list_get[13].GetValue()
|
||
}
|
||
return conf
|
||
elif flag in ["TCP", "UDP"]:
|
||
conf = {
|
||
"protocol": flag,
|
||
"ping": label_list_get[1].GetValue(),
|
||
"heartbeat": label_list_get[4].GetValue(),
|
||
"url": label_list_get[7].GetValue(),
|
||
"port": label_list_get[10].GetValue(),
|
||
"keepAlive": label_list_get[13].GetValue(),
|
||
"serialID": label_list_get[16].GetValue()
|
||
}
|
||
return conf
|
||
elif flag == "MQTT":
|
||
conf = {
|
||
"protocol": flag,
|
||
"clientID": label_list_get[1].GetValue(),
|
||
"keepAlive": label_list_get[4].GetValue(),
|
||
"url": label_list_get[7].GetValue(),
|
||
"port": label_list_get[10].GetValue(),
|
||
"cleanSession": label_list_get[13].GetValue(),
|
||
"subscribe": get_topic_format(label_list_get[16].GetValue()),
|
||
"publish": get_topic_format(label_list_get[19].GetValue()),
|
||
"qos": label_list_get[22].GetValue(),
|
||
"retain": label_list_get[25].GetValue(),
|
||
"serialID": label_list_get[22].GetValue()
|
||
}
|
||
return conf
|
||
elif flag in ["阿里云", "腾讯云"]:
|
||
if flag == "阿里云":
|
||
protocol = "aliyun"
|
||
else:
|
||
protocol = "txyun"
|
||
conf = {
|
||
"protocol": protocol,
|
||
"type": label_list_get[1].GetValue(),
|
||
"keepAlive": label_list_get[4].GetValue(),
|
||
"clientID": label_list_get[7].GetValue(),
|
||
"Devicename": label_list_get[10].GetValue(),
|
||
"ProductKey": label_list_get[13].GetValue(),
|
||
"DeviceSecret": label_list_get[16].GetValue(),
|
||
"ProductSecret": label_list_get[19].GetValue(),
|
||
"cleanSession": True if label_list_get[22].GetValue() == '1' else False,
|
||
"qos": label_list_get[25].GetValue(),
|
||
"subscribe": get_topic_format(label_list_get[28].GetValue()),
|
||
"publish": get_topic_format(label_list_get[31].GetValue()),
|
||
"serialID": label_list_get[34].GetValue()
|
||
}
|
||
return conf
|
||
elif flag == "移远云":
|
||
conf = {
|
||
"protocol": "quecthing",
|
||
"keepAlive": label_list_get[1].GetValue(),
|
||
"ProductKey": label_list_get[4].GetValue(),
|
||
"ProductSecret": label_list_get[7].GetValue(),
|
||
"qos": label_list_get[10].GetValue(),
|
||
"SessionFlag": False if label_list_get[13].GetValue() == "关闭" else True,
|
||
"sendMode": "phy" if label_list_get[16].GetValue() == "物模型" else "pass",
|
||
"serialID": label_list_get[19].GetValue(),
|
||
}
|
||
return conf
|
||
else:
|
||
return False
|
||
|
||
def import_config_param(self, event):
|
||
print("导入配置参数")
|
||
ota_list = {}
|
||
ota_list["ota"] = []
|
||
if self.combo_box_86.GetValue() == "开启": # 开启ota升级
|
||
print(self.text_ctrl_11.GetValue()) # uid
|
||
print(self.text_ctrl_10.GetValue()) # module_type
|
||
print(self.text_ctrl_13.GetValue()) # pk
|
||
ota_list["ota"] = [self.text_ctrl_11.GetValue(), self.text_ctrl_10.GetValue(), self.text_ctrl_13.GetValue()]
|
||
else:
|
||
ota_list = {"ota": ["", "", ""]}
|
||
print("ota_list: ", ota_list)
|
||
if not ser.isOpen():
|
||
wx.MessageBox(u'请先打开USB Serial Port 串口', u'提示', wx.YES_DEFAULT | wx.ICON_INFORMATION)
|
||
return None
|
||
dlg = wx.MessageDialog(None, u"是否确认导入配置参数", u"提示", wx.YES_NO | wx.ICON_QUESTION)
|
||
if dlg.ShowModal() == wx.ID_YES:
|
||
global config_password
|
||
config_password = self.text_ctrl_12.GetValue()
|
||
if not config_password:
|
||
wx.MessageBox(u' 请在上方输入框输入密码', u'提示', wx.YES_DEFAULT | wx.ICON_INFORMATION)
|
||
return
|
||
# 基本参数
|
||
plate = [self.combo_box_63.GetCurrentSelection(), 82]
|
||
reg = [self.combo_box_84.GetCurrentSelection(), 83]
|
||
version = [self.text_ctrl_6.GetValue(), 84]
|
||
fota = [self.combo_box_86.GetCurrentSelection(), 85]
|
||
|
||
ser_info = dict()
|
||
# 串口0
|
||
uart_0_value = dict()
|
||
if self.radio_btn_49.GetValue() == True:
|
||
# 串口0打开
|
||
uart_0_value = {
|
||
"baudrate": uart_0_list[1].GetValue(),
|
||
"databits": uart_0_list[3].GetValue(),
|
||
"parity": uart_0_list[5].GetValue(),
|
||
"stopbits": uart_0_list[7].GetValue(),
|
||
"flowctl": "0"}
|
||
ser_info["0"] = uart_0_value
|
||
# 串口1
|
||
uart_1_value = dict()
|
||
if self.radio_btn_57.GetValue() == True: # 串口1打开
|
||
uart_1_value = {
|
||
"baudrate": uart_1_list[1].GetValue(),
|
||
"databits": uart_1_list[3].GetValue(),
|
||
"parity": uart_1_list[5].GetValue(),
|
||
"stopbits": uart_1_list[7].GetValue(),
|
||
"flowctl": "0"}
|
||
ser_info["1"] = uart_1_value
|
||
# 串口2
|
||
uart_2_value = dict()
|
||
if self.radio_btn_55.GetValue() == True: # 串口2打开
|
||
uart_2_value = {
|
||
"baudrate": uart_2_list[1].GetValue(),
|
||
"databits": uart_2_list[3].GetValue(),
|
||
"parity": uart_2_list[5].GetValue(),
|
||
"stopbits": uart_2_list[7].GetValue(),
|
||
"flowctl": "0"}
|
||
ser_info["2"] = uart_2_value
|
||
# 串口3
|
||
uart_3_value = dict()
|
||
if self.radio_btn_53.GetValue() == True: # 串口3打开
|
||
uart_3_value = {
|
||
"baudrate": uart_3_list[1].GetValue(),
|
||
"databits": uart_3_list[3].GetValue(),
|
||
"parity": uart_3_list[5].GetValue(),
|
||
"stopbits": uart_3_list[7].GetValue(),
|
||
"flowctl": "0"}
|
||
ser_info["3"] = uart_3_value
|
||
|
||
# ser_info["uconf"] = [uart_0_value, uart_1_value, uart_2_value, uart_3_value]
|
||
print("ser_info", ser_info)
|
||
|
||
conf_info = dict()
|
||
# 通道1
|
||
if self.radio_btn_59.GetValue() == True:
|
||
flag = self.combo_box_95.GetStringSelection() # 标志位
|
||
conf_info["1"] = self.get_channel_params(flag, "1")
|
||
# 通道2
|
||
channel_2_value = []
|
||
if self.radio_btn_47.GetValue() == True:
|
||
flag = self.combo_box_100.GetStringSelection() # 标志位
|
||
conf_info["2"] = self.get_channel_params(flag, "2")
|
||
# 通道3
|
||
channel_3_value = []
|
||
if self.radio_btn_29.GetValue() == True:
|
||
flag = self.combo_box_75.GetStringSelection() # 标志位
|
||
conf_info["3"] = self.get_channel_params(flag, "3")
|
||
# 通道4
|
||
channel_4_value = []
|
||
if self.radio_btn_31.GetValue() == True:
|
||
flag = self.combo_box_79.GetStringSelection() # 标志位
|
||
conf_info["4"] = self.get_channel_params(flag, "4")
|
||
# 通道5
|
||
channel_5_value = []
|
||
if self.radio_btn_43.GetValue() == True:
|
||
flag = self.combo_box_120.GetStringSelection() # 标志位
|
||
conf_info["5"] = self.get_channel_params(flag, "5")
|
||
# 通道6
|
||
channel_6_value = []
|
||
if self.radio_btn_45.GetValue() == True:
|
||
flag = self.combo_box_125.GetStringSelection() # 标志位
|
||
conf_info["6"] = self.get_channel_params(flag, "6")
|
||
# 通道7
|
||
channel_7_value = []
|
||
if self.radio_btn_51.GetValue() == True:
|
||
flag = self.combo_box_130.GetStringSelection() # 标志位
|
||
conf_info["7"] = self.get_channel_params(flag, "7")
|
||
|
||
print("conf_info: ", conf_info)
|
||
# apn参数
|
||
apn_info = dict()
|
||
apn_info["apn"] = ["", "", ""]
|
||
if self.radio_btn_65.GetValue():
|
||
name = self.text_ctrl_8.GetValue()
|
||
username = self.text_ctrl_81.GetValue()
|
||
apn_password = self.text_ctrl_9.GetValue()
|
||
apn_info["apn"] = [name, username, apn_password]
|
||
print(apn_info)
|
||
# GPIO引脚设置
|
||
pin_info = dict()
|
||
pin_info["pins"] = ["", "", ""]
|
||
if self.radio_btn_61.GetValue():
|
||
NETLED = self.text_ctrl_66.GetValue()
|
||
NETRDY = self.text_ctrl_96.GetValue()
|
||
RSTCNF = self.text_ctrl_22.GetValue()
|
||
if "pio" not in NETLED or "pio" not in NETRDY or "pio" not in RSTCNF:
|
||
self.text_ctrl_3.write(">>> pio的值没有按照规范填写(demo: pio0)\n")
|
||
return
|
||
elif 1 <= int(re.sub("\D", "", NETLED)) < 19 and 1 <= int(re.sub("\D", "", NETRDY)) < 19 and 1 <= int(
|
||
re.sub("\D", "", RSTCNF)) < 19:
|
||
pass
|
||
else:
|
||
self.text_ctrl_3.write(">>> pio的值不在规定范围内(pio1~pio19)\n")
|
||
return
|
||
pin_info["pins"] = [NETLED, NETRDY, RSTCNF]
|
||
print(pin_info)
|
||
password = config_password
|
||
self.text_ctrl_3.write(">>> 正在导入配置参数请勿其他操作....\n")
|
||
try:
|
||
for i in [plate, reg, version, fota]:
|
||
func_code = i[1]
|
||
data = i[0]
|
||
print(func_code, data)
|
||
self.Modify_config(func_code, data, password)
|
||
self.Modify_config(88, ser_info, password)
|
||
self.Modify_config(89, conf_info, password)
|
||
self.Modify_config(96, apn_info, password)
|
||
self.Modify_config(97, pin_info, password)
|
||
if self.combo_box_86.GetValue() == "开启":
|
||
if len(ota_list["ota"]) == 3:
|
||
print("导入ota")
|
||
self.Modify_config(98, ota_list, password)
|
||
restart_data = {}
|
||
self.Modify_config(255, restart_data, password)
|
||
if import_error:
|
||
self.text_ctrl_3.write(">>> 导入配置文件完成\n")
|
||
self.text_ctrl_3.write(">>> 重启DTU...\n")
|
||
except Exception as e:
|
||
self.text_ctrl_3.write(">>> 导入文件失败\n")
|
||
dlg.Destroy()
|
||
|
||
# 通道类型的标志位
|
||
def flag_bit(self, flag):
|
||
if flag == "HTTP":
|
||
return "http"
|
||
elif flag == "SOCKET TCP":
|
||
return "tcp"
|
||
elif flag == "SOCKET UDP":
|
||
return "udp"
|
||
elif flag == "MQTT":
|
||
return "mqtt"
|
||
elif flag == "阿里云":
|
||
return "aliyun"
|
||
elif flag == "腾讯云":
|
||
return "txyun"
|
||
elif flag == "移远云":
|
||
return "quecthing"
|
||
|
||
# 修改配置参数
|
||
def Modify_config(self, func_code, data, password):
|
||
try:
|
||
if func_code == 81: # password
|
||
data = {"password": password, "data": {"password": data}, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 82: # plate
|
||
data = {"password": password, "data": {"plate": data}, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 83: # reg
|
||
data = {"password": password, "data": {"reg": data}, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 84: # fota
|
||
data = {"password": password, "data": {"version": data}, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 85: # password
|
||
data = {"password": password, "data": {"fota": data}, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 88: # ser_info
|
||
data = {"password": password, "data": data, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 89: # conf_info
|
||
data = {"password": password, "data": data, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 96: # apn_info
|
||
data = {"password": password, "data": data, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 97: # pin_info
|
||
data = {"password": password, "data": data, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 98: # set_ota
|
||
data = {"password": password, "data": data, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
if func_code == 255: # restart dtu
|
||
data = {"password": password, "data": data, "cmd_code": func_code}
|
||
time.sleep(0.5)
|
||
# 向main口发送数据
|
||
# ts = TransferS(int(func_code), json.dumps(data))
|
||
# dt = ts.send()
|
||
|
||
format_datas = self.package_data(data)
|
||
ser.write(format_datas)
|
||
# 重启DTU
|
||
except Exception as e:
|
||
self.text_ctrl_3.write(">>> 导入配置文件失败 !")
|
||
|
||
# 销毁页面
|
||
def Destroy_Window(self, channel):
|
||
for i in eval("label_{}_list".format(channel)):
|
||
i.Destroy()
|
||
|
||
# 通道页面切换
|
||
def channel_stachange(self, event):
|
||
if event.GetId() == 802: # 通道 1
|
||
panel = "self.panel_12"
|
||
rb = self.combo_box_95.GetStringSelection()
|
||
channel = 1
|
||
self.interface_change(panel, rb, channel)
|
||
# self.combo_box_95.SetSelection(self.combox_select(rb))
|
||
|
||
if event.GetId() == 809: # 通道 2
|
||
panel = "self.panel_14"
|
||
rb = self.combo_box_100.GetStringSelection()
|
||
channel = 2
|
||
self.interface_change(panel, rb, channel)
|
||
# self.combo_box_100.SetSelection(self.combox_select(rb))
|
||
|
||
if event.GetId() == 828: # 通道 3
|
||
panel = "self.panel_15"
|
||
rb = self.combo_box_75.GetStringSelection()
|
||
channel = 3
|
||
self.interface_change(panel, rb, channel)
|
||
# self.combo_box_75.SetSelection(self.combox_select(rb))
|
||
|
||
if event.GetId() == 829: # 通道 4
|
||
panel = "self.panel_16"
|
||
rb = self.combo_box_79.GetStringSelection()
|
||
channel = 4
|
||
self.interface_change(panel, rb, channel)
|
||
# self.combo_box_79.SetSelection(self.combox_select(rb))
|
||
|
||
if event.GetId() == 830: # 通道 5
|
||
panel = "self.panel_29"
|
||
rb = self.combo_box_120.GetStringSelection()
|
||
channel = 5
|
||
self.interface_change(panel, rb, channel)
|
||
# self.combo_box_120.SetSelection(self.combox_select(rb))
|
||
|
||
if event.GetId() == 831: # 通道 6
|
||
panel = "self.panel_31"
|
||
rb = self.combo_box_125.GetStringSelection()
|
||
channel = 6
|
||
self.interface_change(panel, rb, channel)
|
||
# self.combo_box_125.SetSelection(self.combox_select(rb))
|
||
|
||
if event.GetId() == 832: # 通道 7
|
||
panel = "self.panel_33"
|
||
rb = self.combo_box_130.GetStringSelection()
|
||
channel = 7
|
||
self.interface_change(panel, rb, channel)
|
||
# self.combo_box_130.SetSelection(self.combox_select(rb))
|
||
|
||
def interface_change(self, panel, rb, channel):
|
||
if rb == 'HTTP':
|
||
self.Destroy_Window(channel)
|
||
self.clear_label_list(channel)
|
||
http_list = self.http_interface(panel)
|
||
self.generate_label(http_list, channel)
|
||
|
||
elif rb == 'SOCKET TCP' or rb == 'SOCKET UDP':
|
||
self.Destroy_Window(channel)
|
||
self.clear_label_list(channel)
|
||
socket_list = self.socket_interface(panel)
|
||
self.generate_label(socket_list, channel)
|
||
|
||
elif rb == 'MQTT':
|
||
self.Destroy_Window(channel)
|
||
self.clear_label_list(channel)
|
||
mqtt_list = self.mqtt_interface(panel)
|
||
self.generate_label(mqtt_list, channel)
|
||
|
||
elif rb == '阿里云' or rb == '腾讯云':
|
||
self.Destroy_Window(channel)
|
||
self.clear_label_list(channel)
|
||
aliyun_txyun_list = self.aliyun_txyun_interface(panel)
|
||
self.generate_label(aliyun_txyun_list, channel)
|
||
|
||
elif rb == '移远云':
|
||
self.Destroy_Window(channel)
|
||
self.clear_label_list(channel)
|
||
quecthing_list = self.quecthing_interface(panel)
|
||
self.generate_label(quecthing_list, channel)
|
||
|
||
|
||
def clear_label_list(self, channel):
|
||
eval("label_{}_list".format(channel)).clear()
|
||
|
||
# uart串口界面
|
||
def uart_interface(self, panel):
|
||
choices = ["1200", "2400", "4800", "9600", "14400", "19200", "28800", "38400", "57600", "115200", "230400",
|
||
"460800", "921600"]
|
||
choices1 = ["NONE", "ODD", "EVENT"]
|
||
uart_list = ['wx.StaticText({}, 700, "波特率", pos=(20, 5))'.format(panel),
|
||
'wx.ComboBox({}, 701, pos=(80, 5), choices={}, style=wx.CB_READONLY)'.format(panel, choices),
|
||
'wx.StaticText({}, 702, "数据位", pos=(20, 35))'.format(panel),
|
||
'wx.ComboBox({}, 703, pos=(80, 35), choices=["7", "8"], style=wx.CB_READONLY)'.format(panel),
|
||
'wx.StaticText({}, 704, "校验位", pos=(20, 65))'.format(panel),
|
||
'wx.ComboBox({}, 705, pos=(80, 65), choices={}, style=wx.CB_READONLY)'.format(panel, choices1),
|
||
'wx.StaticText({}, wx.ID_ANY, "停止位", pos=(20, 95))'.format(panel),
|
||
'wx.ComboBox({}, 706, pos=(80, 95), choices=["1", "2"], style=wx.CB_READONLY)'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "停止位", pos=(20, 95))'.format(panel),
|
||
'wx.ComboBox({}, 706, pos=(80, 95), choices=["1", "2"], style=wx.CB_READONLY)'.format(panel)
|
||
]
|
||
return uart_list
|
||
|
||
# http 界面模板
|
||
def http_interface(self, panel):
|
||
http_list = ['wx.StaticText({}, wx.ID_ANY, "method", pos=(20, 35))'.format(panel),
|
||
'wx.ComboBox({}, 803, pos=(170, 35), choices=["get", "post"], style=wx.CB_READONLY)'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:提交请求的方法", pos=(290, 35))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "url", pos=(20, 65))'.format(panel),
|
||
'wx.TextCtrl({}, 804, "", pos=(170, 65))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:HTTP请求的地址和参数", pos=(290, 65))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "data", pos=(20, 95))'.format(panel),
|
||
'wx.TextCtrl({}, 804, "", pos=(170, 95))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:post请求携带的数据,get请求不填写", pos=(290, 95))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "timeout", pos=(20, 125))'.format(panel),
|
||
'wx.TextCtrl({}, 805, "", pos=(170, 125))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:HTTP请求最长等待时间,可选", pos=(290, 125))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "serialD", pos=(20, 155))'.format(panel),
|
||
'wx.ComboBox({}, 806, pos=(170, 155), choices=["1", "2", "3"], style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:HTTP绑定的串口号(1~3)", pos=(290, 155))'.format(panel)]
|
||
return http_list
|
||
|
||
# socket 界面模板
|
||
def socket_interface(self, panel):
|
||
socket_list = ['wx.StaticText({}, wx.ID_ANY, "心跳包", pos=(20, 35))'.format(panel),
|
||
'wx.TextCtrl({}, 803, "", pos=(170, 35))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:自定义的心跳包,只支持数字和字母,建议2-4个字节,可选", pos=(290, 35))'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "心跳间隔时间", pos=(20, 65))'.format(panel),
|
||
'wx.TextCtrl({}, 804, "", pos=(170, 65))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:填入0为关闭心跳包建议60s~300s", pos=(290, 65))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "socket地址或域名", pos=(20, 95))'.format(panel),
|
||
'wx.TextCtrl({}, 805, "", pos=(170, 95))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:不包含端口号", pos=(290, 95))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "socket服务器的端口号", pos=(20, 125))'.format(panel),
|
||
'wx.TextCtrl({}, 806, "", pos=(170, 125))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:端口号范围 1~65536", pos=(290, 125))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "KeepAlive", pos=(20, 155))'.format(panel),
|
||
'wx.TextCtrl({}, 806, "", pos=(170, 155))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:链接超时最大时间单位秒,默认300秒,可选", pos=(290, 155))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "socket绑定的串口号", pos=(20, 185))'.format(panel),
|
||
'wx.ComboBox({}, 807, pos=(170, 185), choices=["1", "2", "3"], style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:tcp/udp绑定的串口号(1~3)", pos=(290, 185))'.format(panel)]
|
||
return socket_list
|
||
|
||
# mqtt 界面模板
|
||
def mqtt_interface(self, panel):
|
||
mqtt_list = ['wx.StaticText({}, wx.ID_ANY, "ClientID", pos=(20, 35))'.format(panel),
|
||
'wx.TextCtrl({}, 803, "", pos=(170, 35))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:自定义客户端", pos=(290, 35))'.format(panel),
|
||
|
||
'wx.StaticText({}, wx.ID_ANY, "KeepAlive", pos=(20, 65))'.format(panel),
|
||
'wx.TextCtrl({}, 804, "", pos=(170, 65))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:客户端的请求超时时间,默认60s,可选", pos=(290, 65))'.format(panel),
|
||
|
||
'wx.StaticText({}, wx.ID_ANY, u"MQTT的服务器地址或域名", pos=(20, 95))'.format(panel),
|
||
'wx.TextCtrl({}, 805, "", pos=(170, 95))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:不包含端口号", pos=(290, 95))'.format(panel),
|
||
|
||
'wx.StaticText({}, wx.ID_ANY, u"MQTT服务器的端口号", pos=(20, 125))'.format(panel),
|
||
'wx.TextCtrl({}, 806, "", pos=(170, 125))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:端口号范围 1~65536", pos=(290, 125))'.format(panel),
|
||
|
||
'wx.StaticText({}, wx.ID_ANY, u"CleanSession", pos=(20, 155))'.format(panel),
|
||
'wx.ComboBox({}, 807, choices=["0", "1"], style=wx.CB_READONLY, pos=(170, 155))'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:MQTT是否保存会话标志位,默认为0 可选", pos=(290, 155))'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"订阅主题", pos=(20, 185))'.format(panel),
|
||
'wx.TextCtrl({}, 808, "", pos=(170, 185))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:注意主题的格式", pos=(290, 185))'.format(panel),
|
||
|
||
'wx.StaticText({}, wx.ID_ANY, u"发布主题", pos=(20, 215))'.format(panel),
|
||
'wx.TextCtrl({}, 809, "", pos=(170, 215))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:注意主题的格式", pos=(290, 215))'.format(panel),
|
||
|
||
'wx.StaticText({}, wx.ID_ANY, u"QOS", pos=(20, 245))'.format(panel),
|
||
'wx.ComboBox({}, 810, choices=["0", "1", "2"], style=wx.CB_READONLY, pos=(170, 245))'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:MQTT的QOS级别,默认0,可选", pos=(290, 245))'.format(panel),
|
||
|
||
'wx.StaticText({}, wx.ID_ANY, u"retain", pos=(20, 275))'.format(panel),
|
||
'wx.ComboBox({}, 811, choices=["0", "1"], style=wx.CB_READONLY, pos=(170, 275))'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:retain = 1 boker会一直保留消息,默认0,可选", pos=(290, 275))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"serialD", pos=(20, 305))'.format(panel),
|
||
'wx.ComboBox({}, 812, choices=["1", "2","3"], style=wx.CB_READONLY, pos=(170, 305))'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:MQTT通道捆绑的串口ID (1~3)", pos=(290, 305))'.format(panel)]
|
||
return mqtt_list
|
||
|
||
# aliyun/txyun 界面模板
|
||
def aliyun_txyun_interface(self, panel):
|
||
aliyun_txyun_list = ['wx.StaticText({}, wx.ID_ANY, "type", pos=(20, 35))'.format(panel),
|
||
'wx.ComboBox({}, wx.ID_ANY, pos=(170, 35), choices=["mos", "tas"],style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:一型一密tas/一机一密mos", pos=(290, 35))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, "KeepAlive", pos=(20, 65))'.format(panel),
|
||
'wx.TextCtrl({}, 804, "", pos=(170, 65))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:客户端的请求超时时间,默认60s,可选", pos=(290, 65))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"ClientID", pos=(20, 95))'.format(panel),
|
||
'wx.TextCtrl({}, 805, "", pos=(170, 95))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:自定义客户端", pos=(290, 95))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"DeviceName", pos=(20, 125))'.format(panel),
|
||
'wx.TextCtrl({}, 806, "", pos=(170, 125))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:设备名称", pos=(290, 125))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"ProductKey", pos=(20, 155))'.format(panel),
|
||
'wx.TextCtrl({}, 807, "", pos=(170, 155))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:产品名称", pos=(290, 155))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"DeviceSecret", pos=(20, 185))'.format(panel),
|
||
'wx.TextCtrl({}, 808, "", pos=(170, 185))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:设备密钥(使用一型一密认证此参数为空)", pos=(290, 185))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"ProductSecret", pos=(20, 215))'.format(panel),
|
||
'wx.TextCtrl({}, 809, "", pos=(170, 215))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:产品密钥(使用一机一密认证时此参数为空)", pos=(290, 215))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"CleanSession", pos=(20, 245))'.format(panel),
|
||
'wx.ComboBox({}, wx.ID_ANY, pos=(170, 245), choices=["0", "1"],style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:MQTT是否保存会话标志,默认0,可选", pos=(290, 245))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"QOS", pos=(20, 275))'.format(panel),
|
||
'wx.ComboBox({}, wx.ID_ANY, pos=(170, 275), choices=["0", "1"],style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:MQTT的QOS级别,默认0,可选", pos=(290, 275))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"订阅主题", pos=(20, 305))'.format(panel),
|
||
'wx.TextCtrl({}, 812, "", pos=(170, 305))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:多主题请使用逗号分割", pos=(290, 305))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"发布主题", pos=(20, 335))'.format(panel),
|
||
'wx.TextCtrl({}, 813, "", pos=(170, 335))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:多主题请使用逗号分割", pos=(290, 335))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"serialD", pos=(20, 365))'.format(panel),
|
||
'wx.ComboBox({}, wx.ID_ANY, pos=(170, 365), choices=["1", "2", "3"],style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:MQTT通道捆绑的串口ID (1~3)", pos=(290, 365))'.format(panel)]
|
||
return aliyun_txyun_list
|
||
|
||
def quecthing_interface(self, panel):
|
||
quecthing_list = [
|
||
'wx.StaticText({}, wx.ID_ANY, "KeepAlive", pos=(20, 35))'.format(panel),
|
||
'wx.TextCtrl({}, 804, "", pos=(170, 35))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:客户端的请求超时时间,默认120s,可选", pos=(290, 35))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"ProductKey", pos=(20, 65))'.format(panel),
|
||
'wx.TextCtrl({}, 805, "", pos=(170, 65))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:产品Product Key", pos=(290, 65))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"ProductSecret", pos=(20, 95))'.format(panel),
|
||
'wx.TextCtrl({}, 806, "", pos=(170, 95))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:产品密钥", pos=(290, 95))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"QOS", pos=(20, 125))'.format(panel),
|
||
'wx.ComboBox({}, wx.ID_ANY, pos=(170, 125), choices=["0", "1"],style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:QOS级别,默认0,可选", pos=(290, 125))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"SessionFlag", pos=(20, 155))'.format(panel),
|
||
'wx.ComboBox({}, wx.ID_ANY, pos=(170, 155), choices=[u"关闭", u"开启"],style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:Session加密是否启用,默认关闭,可选", pos=(290, 155))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"SendMode", pos=(20, 185))'.format(panel),
|
||
'wx.ComboBox({}, wx.ID_ANY, pos=(170, 185), choices=[u"透传", u"物模型"],style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:发送模式设置", pos=(290, 185))'.format(panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"serialD", pos=(20, 215))'.format(panel),
|
||
'wx.ComboBox({}, wx.ID_ANY, pos=(170, 215), choices=["1", "2", "3"],style=wx.CB_READONLY)'.format(
|
||
panel),
|
||
'wx.StaticText({}, wx.ID_ANY, u"提示:MQTT通道捆绑的串口ID (1~3)", pos=(290, 215))'.format(panel)
|
||
]
|
||
return quecthing_list
|
||
|
||
|
||
# 动态生成通道参数标签
|
||
def generate_label(self, list, channel):
|
||
count = 1
|
||
print('channel:', channel)
|
||
for i in list:
|
||
if 'StaticText' in str(i):
|
||
locals()['self.label_{}_'.format(channel) + str(count)] = eval(i)
|
||
eval("label_{}_list".format(channel)).append(locals()['self.label_{}_'.format(channel) + str(count)])
|
||
if 'ComboBox' in str(i):
|
||
locals()['self.combo_box_{}_'.format(channel) + str(count)] = eval(i)
|
||
eval("label_{}_list".format(channel)).append(
|
||
locals()['self.combo_box_{}_'.format(channel) + str(count)])
|
||
if 'TextCtrl' in str(i):
|
||
locals()['self.text_ctrl_{}_'.format(channel) + str(count)] = eval(i)
|
||
eval("label_{}_list".format(channel)).append(
|
||
locals()['self.text_ctrl_{}_'.format(channel) + str(count)])
|
||
count += 1
|
||
|
||
# 动态生成串口参数标签
|
||
def generate_uart_label(self, list, uart_number):
|
||
count = 1
|
||
for i in list:
|
||
if 'StaticText' in str(i):
|
||
label = 'self.uart_label_{}_'.format(uart_number) + str(count)
|
||
locals()[label] = eval(i)
|
||
eval("uart_{}_list".format(uart_number)).append(locals()[label])
|
||
if 'ComboBox' in str(i):
|
||
label = 'self.uart_combo_box_{}_'.format(uart_number) + str(count)
|
||
locals()[label] = eval(i)
|
||
eval("uart_{}_list".format(uart_number)).append(locals()[label])
|
||
count += 1
|
||
|
||
def query_config(self, event):
|
||
print("查询当前配置参数")
|
||
password = self.text_ctrl_12.GetValue()
|
||
if not ser.isOpen():
|
||
wx.MessageBox(u'请先打开USB Serial Port 串口', u'提示', wx.YES_DEFAULT | wx.ICON_INFORMATION)
|
||
return None
|
||
if not password:
|
||
wx.MessageBox(u' 请在上方输入框输入密码', u'提示', wx.YES_DEFAULT | wx.ICON_INFORMATION)
|
||
return
|
||
data = {"password": password, "data": {}, "cmd_code": 4}
|
||
# func_code = 4
|
||
# ts = TransferS(int(func_code), json.dumps(data))
|
||
# dt = ts.send()
|
||
format_data = self.package_data(data)
|
||
ser.write(format_data)
|
||
|
||
def change_password(self, event):
|
||
password = self.text_ctrl_12.GetValue()
|
||
if not ser.isOpen():
|
||
wx.MessageBox(u'请先打开USB Serial Port 串口', u'提示', wx.YES_DEFAULT | wx.ICON_INFORMATION)
|
||
return None
|
||
if not self.text_ctrl_12.GetValue():
|
||
wx.MessageBox(u' 请在上方输入框输入原密码', u'提示', wx.YES_DEFAULT | wx.ICON_INFORMATION)
|
||
return
|
||
if not self.text_ctrl_14.GetValue():
|
||
wx.MessageBox(u' 请在下方输入框输入新密码', u'提示', wx.YES_DEFAULT | wx.ICON_INFORMATION)
|
||
return
|
||
new_password = self.text_ctrl_14.GetValue()
|
||
data = {"password": password, "data": {"password": new_password}}
|
||
dlg = wx.MessageDialog(None, u"是否确认修改密码 ?", u"提示", wx.YES_NO | wx.ICON_QUESTION)
|
||
if dlg.ShowModal() == wx.ID_YES:
|
||
# 向main口发送数据
|
||
func_code = 81
|
||
data['cmd_code'] = func_code
|
||
# ts = TransferS(int(func_code), json.dumps(data))
|
||
# dt = ts.send()
|
||
format_data = self.package_data(data)
|
||
ser.write(format_data)
|
||
dlg.Destroy()
|
||
|
||
# 密码输入框
|
||
def input_password(self, event):
|
||
global open_password
|
||
print(self.checkbox_1.GetValue())
|
||
if self.checkbox_1.GetValue():
|
||
self.text_ctrl_12.Enable()
|
||
open_password = True
|
||
else:
|
||
self.text_ctrl_12.Disable()
|
||
open_password = False
|
||
|
||
# 是否添加时间戳
|
||
def add_timestamp(self, event):
|
||
global add_time
|
||
if self.checkbox_6.GetValue():
|
||
print("添加时间戳")
|
||
add_time = True
|
||
else:
|
||
print("关闭时间戳")
|
||
add_time = False
|
||
|
||
# 是否将显示的内容转为HEX
|
||
def convert_hex(self, event):
|
||
global convet_to_hex
|
||
if self.checkbox_5.GetValue():
|
||
print("开启 convert to hex")
|
||
convet_to_hex = True
|
||
else:
|
||
print("关闭 convert to hex")
|
||
convet_to_hex = False
|
||
|
||
def package_data(self, datas):
|
||
if isinstance(datas, str):
|
||
str_datas = datas
|
||
else:
|
||
str_datas = json.dumps(datas)
|
||
crc32_vals = str(zlib.crc32(str_datas.encode("utf-8")))
|
||
# 减少报文长度,加入99开头的GUI识别码
|
||
data_format = "99,{},{},{}".format(len(str_datas), crc32_vals, str_datas)
|
||
return data_format.encode("utf-8")
|
||
|
||
|
||
# detect serialport
|
||
class serialDet(threading.Thread):
|
||
def __init__(self):
|
||
threading.Thread.__init__(self)
|
||
|
||
def run(self):
|
||
global serialList, deviceList
|
||
while True:
|
||
deviceList = [i.device for i in serPort.comports()]
|
||
if serialList == [] or serialList != serPort.comports():
|
||
if serialStatus == False:
|
||
serialList = serPort.comports()
|
||
pub.sendMessage('uiUpdate', arg1="serListUpd", arg2=serialList)
|
||
time.sleep(1)
|
||
|
||
|
||
class MyApp(wx.App):
|
||
def OnInit(self):
|
||
self.frame = _847017531_MyFrame(None, wx.ID_ANY, "")
|
||
self.SetTopWindow(self.frame)
|
||
self.frame.Show()
|
||
# thread: serialDet
|
||
global tSerialDet
|
||
tSerialDet = serialDet()
|
||
tSerialDet.setDaemon(True) # set as deamon, stop thread while main frame exit
|
||
tSerialDet.start()
|
||
return True
|
||
|
||
|
||
if __name__ == "__main__":
|
||
app = MyApp(0)
|
||
app.MainLoop()
|