--- /dev/null
+# e:\YN\CODE\BatteryTest\battery_test\tools\test.py
+
+import sys
+import serial
+import serial.tools.list_ports
+from datetime import datetime
+
+import ser
+import crcmod
+
+# 设置递归深度限制
+sys.setrecursionlimit(2000)
+
+from PyQt5.QtWidgets import (QApplication, QDialog, QMessageBox,
+ QVBoxLayout, QLabel, QPushButton, QComboBox, QLineEdit, QTextEdit)
+from PyQt5.QtCore import Qt, QTimer
+
+print("=== 启动程序 ===")
+
+# 导入编译好的UI模块
+try:
+ from test_ui import Ui_Dialog
+ print("成功导入 test_ui 模块")
+except ImportError as e:
+ print(f"导入UI模块失败: {e}")
+ Ui_Dialog = None
+
+class ModbusRTU:
+ """Modbus RTU协议实现"""
+
+ @staticmethod
+ def crc16(data):
+ """计算Modbus CRC16"""
+ crc = 0xFFFF
+ for byte in data:
+ crc ^= byte
+ for _ in range(8):
+ if crc & 0x0001:
+ crc >>= 1
+ crc ^= 0xA001
+ else:
+ crc >>= 1
+ return crc.to_bytes(2, byteorder='little')
+
+ @staticmethod
+ def read_holding_registers(slave_addr, start_reg, count):
+ """构建读取保持寄存器指令"""
+ data = bytearray([slave_addr, 0x03])
+ data.extend(start_reg.to_bytes(2, byteorder='big'))
+ data.extend(count.to_bytes(2, byteorder='big'))
+ data.extend(ModbusRTU.crc16(data))
+ return bytes(data)
+
+ @staticmethod
+ def write_multiple_registers(slave_addr, start_reg, values):
+ """构建写入多个寄存器指令"""
+ data = bytearray([slave_addr, 0x10])
+ data.extend(start_reg.to_bytes(2, byteorder='big'))
+ data.extend(len(values).to_bytes(2, byteorder='big'))
+ data.append(len(values) * 2)
+ for value in values:
+ data.extend(value.to_bytes(2, byteorder='big'))
+ data.extend(ModbusRTU.crc16(data))
+ return bytes(data)
+
+ @staticmethod
+ def parse_response(response):
+ """解析Modbus响应"""
+ if len(response) < 5:
+ return None
+
+ crc_received = int.from_bytes(response[-2:], byteorder='little')
+ crc_calculated = int.from_bytes(ModbusRTU.crc16(response[:-2]), byteorder='little')
+
+ if crc_received != crc_calculated:
+ return None
+
+ func_code = response[1]
+ if func_code & 0x80:
+ return {'error': response[2]}
+
+ if func_code == 0x03:
+ byte_count = response[2]
+ registers = []
+ for i in range(0, byte_count, 2):
+ reg_value = int.from_bytes(response[3+i:5+i], byteorder='big')
+ registers.append(reg_value)
+ return {'function': 'read', 'registers': registers}
+
+ elif func_code == 0x10:
+ start_addr = int.from_bytes(response[2:4], byteorder='big')
+ count = int.from_bytes(response[4:6], byteorder='big')
+ return {'function': 'write_multiple', 'start_address': start_addr, 'count': count}
+
+ return None
+
+class MainDialog(QDialog):
+ """主对话框类"""
+
+ def __init__(self):
+ super(MainDialog, self).__init__()
+
+ print("初始化 MainDialog...")
+ self.setWindowTitle("Modbus继电器测试工具")
+
+ # 串口对象
+ self.serial_port = None
+ self.is_connected = False
+ self.slave_addr = 1
+
+ # 寄存器状态 (0=断开/灰色, 1=吸合/绿色)
+ self.register_states = [0] * 19
+
+ # 19个继电器label列表
+ self.relay_labels = []
+
+ # 是否使用备用UI
+ self.use_fallback_ui = False
+
+ # 日志窗口是否已初始化
+ self.log_initialized = False
+
+ # 尝试加载UI
+ self.init_ui()
+
+ self.ser_opened = False
+ self.ser = ser.ser()
+ self.io_timer = QTimer()
+ self.io_timer.timeout.connect(self.on_scan_timer)
+ self.io_timer.start(2000)
+ self.crc16 = crcmod.mkCrcFun(0x18005, rev=True, initCrc=0xFFFF, xorOut=0x0000)
+ self.comports = []
+ self.line_baud.setText( "9600" )
+ self.ser = ser.ser()
+ self.scan_port()
+ print("MainDialog 初始化完成")
+
+ def init_ui(self):
+ """初始化UI"""
+ if Ui_Dialog is not None:
+ try:
+ print("尝试使用 test_ui.py 创建UI...")
+ self.ui = Ui_Dialog()
+ self.ui.setupUi(self)
+
+ # 获取UI控件引用
+ self.cb_serial = self.ui.cb_serial
+ self.line_baud = self.ui.line_baud
+ self.btn_ser_open = self.ui.btn_ser_open
+ self.btn_read = self.ui.btn_read
+ self.btn_write = self.ui.btn_write
+ self.text_log = self.ui.text_log
+ self.btn_mode_0 = self.ui.btn_mode_0
+
+ # 获取继电器标签
+ self.relay_labels = [
+ self.ui.lab_relay_1, self.ui.lab_relay_2, self.ui.lab_relay_3,
+ self.ui.lab_relay_4, self.ui.lab_relay_5, self.ui.lab_relay_6,
+ self.ui.lab_relay_7, self.ui.lab_relay_8, self.ui.lab_relay_9,
+ self.ui.lab_relay_10, self.ui.lab_relay_11, self.ui.lab_relay_12,
+ self.ui.lab_relay_13, self.ui.lab_relay_14, self.ui.lab_relay_15,
+ self.ui.lab_relay_16, self.ui.lab_relay_17, self.ui.lab_relay_18,
+ self.ui.lab_relay_19
+ ]
+
+ # 获取模式按钮
+ self.mode_buttons = [
+ self.ui.btn_mode_0, self.ui.btn_mode_1, self.ui.btn_mode_2,
+ self.ui.btn_mode_3, self.ui.btn_mode_4, self.ui.btn_mode_5,
+ self.ui.btn_mode_6, self.ui.btn_mode_7, self.ui.btn_mode_8,
+ self.ui.btn_mode_9, self.ui.btn_mode_10, self.ui.btn_mode_11,
+ self.ui.btn_mode_12, self.ui.btn_mode_13, self.ui.btn_mode_14,
+ self.ui.btn_mode_15, self.ui.btn_mode_16
+ ]
+
+ self.log_initialized = True
+ print("成功加载UI控件")
+
+ except Exception as e:
+ print(f"加载UI失败: {e}")
+ self.create_fallback_ui()
+ return
+ else:
+ print("Ui_Dialog 不可用,创建备用UI")
+ self.create_fallback_ui()
+ return
+
+ # 初始化控件状态
+ self.btn_read.setEnabled(False)
+ self.btn_write.setEnabled(False)
+ self.line_baud.setText("9600")
+
+ # 连接信号槽
+ self.init_connections()
+
+ # 定时读取定时器
+ self.read_timer = QTimer()
+ self.read_timer.timeout.connect(self.read_registers)
+ self.read_timer.setInterval(1000)
+
+ def create_fallback_ui(self):
+ """创建备用UI"""
+ print("创建备用UI...")
+ self.use_fallback_ui = True
+
+ layout = QVBoxLayout()
+
+ # 串口配置
+ hbox1 = QHBoxLayout()
+ hbox1.addWidget(QLabel("串口号:"))
+ self.cb_serial = QComboBox()
+ hbox1.addWidget(self.cb_serial)
+
+ hbox1.addWidget(QLabel("波特率:"))
+ self.line_baud = QLineEdit("9600")
+ hbox1.addWidget(self.line_baud)
+
+ self.btn_ser_open = QPushButton("打开串口")
+ hbox1.addWidget(self.btn_ser_open)
+ layout.addLayout(hbox1)
+
+ # 继电器状态
+ layout.addWidget(QLabel("继电器状态:"))
+ self.relay_labels = []
+ relay_hbox = QHBoxLayout()
+ for i in range(19):
+ label = QLabel(f" {i+1} ")
+ label.setStyleSheet("background-color: rgb(140, 135, 140); padding: 5px;")
+ label.setFixedWidth(30)
+ self.relay_labels.append(label)
+ relay_hbox.addWidget(label)
+ layout.addLayout(relay_hbox)
+
+ # 控制按钮
+ hbox2 = QHBoxLayout()
+ self.btn_read = QPushButton("读取")
+ self.btn_read.setEnabled(False)
+ hbox2.addWidget(self.btn_read)
+
+ self.btn_write = QPushButton("写入")
+ self.btn_write.setEnabled(False)
+ hbox2.addWidget(self.btn_write)
+
+ self.btn_mode_0 = QPushButton("全部关闭")
+ hbox2.addWidget(self.btn_mode_0)
+ layout.addLayout(hbox2)
+
+ # 日志窗口
+ layout.addWidget(QLabel("操作日志:"))
+ self.text_log = QTextEdit()
+ self.text_log.setReadOnly(True)
+ layout.addWidget(self.text_log)
+ self.log_initialized = True
+
+ self.setLayout(layout)
+
+ # 连接信号槽
+ self.init_connections()
+
+ # 初始化串口列表(使用安全方式)
+ self.safe_refresh_ports()
+
+ # 定时读取定时器
+ self.read_timer = QTimer()
+ self.read_timer.timeout.connect(self.read_registers)
+ self.read_timer.setInterval(1000)
+
+ print("备用UI创建完成")
+
+ def init_connections(self):
+ """初始化信号槽连接"""
+ print("连接信号槽...")
+
+ # 串口选择框 - 不自动刷新,避免递归问题
+ # self.cb_serial.currentIndexChanged.connect(self.safe_refresh_ports)
+
+ # 打开/关闭串口按钮
+ self.btn_ser_open.clicked.connect(self.toggle_connection)
+
+ # 读取按钮
+ self.btn_read.clicked.connect(self.read_registers)
+
+ # 写入按钮
+ self.btn_write.clicked.connect(self.write_registers)
+
+ # 模式按钮0
+ self.btn_mode_0.clicked.connect(lambda: self.on_mode_button_click(0))
+
+ # 如果有其他模式按钮(仅在使用完整UI时)
+ if not self.use_fallback_ui and hasattr(self, 'mode_buttons'):
+ for i, btn in enumerate(self.mode_buttons):
+ btn.clicked.connect(lambda checked, idx=i: self.on_mode_button_click(idx))
+
+ # 继电器标签点击事件
+ for i, label in enumerate(self.relay_labels):
+ label.mousePressEvent = lambda event, idx=i: self.on_relay_label_click(idx)
+
+ print("信号槽连接完成")
+
+ def add_log(self, message):
+ """添加日志信息"""
+ timestamp = datetime.now().strftime("%H:%M:%S")
+ log_msg = f"[{timestamp}] {message}"
+ # 仅在日志窗口初始化后才写入
+ if self.log_initialized and hasattr(self, 'text_log'):
+ try:
+ self.text_log.append(log_msg)
+ except:
+ pass
+ print(log_msg)
+
+ def on_serial_rx_cb( self, data ):
+ self.rx_buf += data
+ while len(self.rx_buf)>=2 and self.rx_buf[0] != 0x5A and self.rx_buf[1] != 0xA5:
+ self.rx_buf = self.rx_buf[1:]
+ if len( self.rx_buf )>=8:
+ print( "rx ", self.rx_buf[:8].hex())
+ flag, pkt_sz, cmd = struct.unpack( '>HHH', self.rx_buf[:6] )
+ if flag==0x5AA5:
+ if len(self.rx_buf)>= pkt_sz:
+ crc = self.crc16( self.rx_buf[0:pkt_sz-2])
+ crc2 = struct.unpack( '>H', self.rx_buf[pkt_sz-2:pkt_sz] )[0]
+ print( 'crc--', crc )
+ print( 'crc2-', crc2 )
+ if crc == crc2:
+ pkt_data = self.rx_buf[6:pkt_sz-2]
+ self.trigger_rx_pkt.emit( (cmd, self.rx_buf[6:pkt_sz-2]))
+ self.rx_buf = self.rx_buf[pkt_sz:]
+ else:
+ pass #wait
+ else:
+ self.rx_buf = b''
+
+ def ser_close( self ):
+ self.port = self.cb_serial.currentText()
+ self.baud = self.line_baud.text()
+ #self.on_disconnect()
+ if self.ser_opened:
+ self.ser.close()
+ self.ser_opened = False
+ self.btn_write.setEnabled(False)
+ self.btn_read.setEnabled(False)
+ self.btn_ser_open.setText("打开串口")
+ self.btn_ser_open.setStyleSheet("background-color: gray;")
+
+ def ser_open( self ):
+ self.port = self.cb_serial.currentText()
+ self.baud = self.line_baud.text()
+ self.ser.open( port=self.port, baudrate=self.baud, rx_handler=self.on_serial_rx_cb )
+ if self.ser.ser.is_open:
+ self.ser_opened = True
+ self.btn_write.setEnabled(True)
+ self.btn_read.setEnabled(True)
+ self.btn_ser_open.setText("关闭串口")
+ self.btn_ser_open.setStyleSheet("background-color: green;")
+ else:
+ print( "open serial fail" )
+ return self.ser_opened
+
+ def scan_port( self ):
+ comports=ser.scan()
+ if not self.comports == comports:
+ s = self.cb_serial.currentText()
+ self.cb_serial.clear()
+
+ for com in comports:
+ self.cb_serial.addItem( com )
+ if s in comports:
+ self.cb_serial.setEditText(s)
+ self.comports = comports
+
+ def on_scan_timer( self ):
+ if not self.ser_opened:
+ self.scan_port()
+
+ def toggle_connection(self):
+ """切换连接状态"""
+ if self.ser_opened:
+ self.ser_close()
+ print("ser close")
+ else:
+ self.ser_open()
+ print("ser open")
+
+ def disconnect_serial(self):
+ """断开串口"""
+ if self.serial_port:
+ self.serial_port.close()
+ self.serial_port = None
+
+ self.is_connected = False
+ self.btn_ser_open.setText("打开串口")
+ self.btn_read.setEnabled(False)
+ self.btn_write.setEnabled(False)
+ self.cb_serial.setEnabled(True)
+ self.line_baud.setEnabled(True)
+ self.add_log("串口已关闭")
+
+ self.read_timer.stop()
+
+ for label in self.relay_labels:
+ label.setStyleSheet("background-color: rgb(140, 135, 140);")
+
+ def on_relay_label_click(self, idx):
+ """点击继电器label切换颜色"""
+ self.register_states[idx] = 1 - self.register_states[idx]
+ self.update_relay_label(idx)
+ self.add_log(f"继电器 {idx+1} 状态切换为 {self.register_states[idx]}")
+
+ def update_relay_label(self, idx):
+ """更新单个继电器label颜色"""
+ if self.register_states[idx] == 1:
+ self.relay_labels[idx].setStyleSheet("background-color: rgb(0, 200, 0);")
+ else:
+ self.relay_labels[idx].setStyleSheet("background-color: rgb(140, 135, 140);")
+
+ def read_registers(self):
+ """读取所有寄存器状态"""
+ if not self.is_connected or not self.serial_port:
+ return
+
+ try:
+ self.serial_port.write(ModbusRTU.read_holding_registers(self.slave_addr, 0, 19))
+
+ response = self.serial_port.read(50)
+ if response:
+ result = ModbusRTU.parse_response(response)
+ if result and 'registers' in result:
+ self.register_states = result['registers']
+ self.update_status_display()
+ self.add_log("寄存器状态读取成功")
+
+ except Exception as e:
+ self.add_log(f"读取失败: {str(e)}")
+
+ def update_status_display(self):
+ """更新所有继电器状态显示"""
+ for i in range(19):
+ if i < len(self.register_states):
+ self.update_relay_label(i)
+
+ def write_registers(self):
+ """写入寄存器状态"""
+ state_str = "继电器状态: "
+ for i in range(19):
+ state_str += f"{self.register_states[i]}"
+ if i < 18:
+ state_str += ","
+
+ self.add_log(state_str)
+ print(state_str)
+
+ if not self.is_connected or not self.serial_port:
+ self.add_log("未连接串口,仅打印状态")
+ return
+
+ try:
+ self.serial_port.write(ModbusRTU.write_multiple_registers(self.slave_addr, 0, self.register_states))
+
+ response = self.serial_port.read(10)
+ if response:
+ result = ModbusRTU.parse_response(response)
+ if result and 'write_multiple' in result:
+ self.add_log("寄存器状态写入成功")
+ else:
+ self.add_log("寄存器状态写入失败")
+
+ except Exception as e:
+ self.add_log(f"写入失败: {str(e)}")
+
+ def on_mode_button_click(self, mode_idx):
+ """Mode按钮点击事件"""
+ self.add_log(f"模式 {mode_idx} 按钮被点击")
+
+ if mode_idx == 0:
+ for i in range(19):
+ self.register_states[i] = 0
+ self.update_relay_label(i)
+ self.add_log("所有继电器已关闭")
+
+ def closeEvent(self, event):
+ """窗口关闭事件"""
+ self.disconnect_serial()
+ event.accept()
+
+if __name__ == "__main__":
+ print("=== 主程序入口 ===")
+ try:
+ print("创建QApplication...")
+ app = QApplication(sys.argv)
+ print("QApplication 创建成功")
+
+ print("创建MainDialog...")
+ dialog = MainDialog()
+ print("MainDialog 创建成功")
+
+ print("显示窗口...")
+ dialog.show()
+ print("窗口已显示")
+
+ print("进入事件循环...")
+ sys.exit(app.exec_())
+
+ except Exception as e:
+ print(f"运行错误: {e}")
+ import traceback
+ traceback.print_exc()
+ sys.exit(1)
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>749</width>
+ <height>715</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <widget class="QFrame" name="frame_board">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>601</width>
+ <height>281</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">
+ QFrame#frame_board {
+ background-image: url(:/res/bg3.png);
+ background-image: url(:/res/bg3.png);
+ }
+ QFrame#frame_board *{
+ background: transparent;
+ }
+</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QFrame" name="frame">
+ <property name="geometry">
+ <rect>
+ <x>35</x>
+ <y>227</y>
+ <width>101</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QLabel" name="lab_relay_1">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>1</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_2">
+ <property name="geometry">
+ <rect>
+ <x>39</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>2</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_3">
+ <property name="geometry">
+ <rect>
+ <x>78</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>3</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QFrame" name="frame_2">
+ <property name="geometry">
+ <rect>
+ <x>184</x>
+ <y>227</y>
+ <width>101</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QLabel" name="lab_relay_4">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>4</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_5">
+ <property name="geometry">
+ <rect>
+ <x>39</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>5</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_6">
+ <property name="geometry">
+ <rect>
+ <x>78</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>6</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QFrame" name="frame_3">
+ <property name="geometry">
+ <rect>
+ <x>335</x>
+ <y>227</y>
+ <width>101</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QLabel" name="lab_relay_7">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>7</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_8">
+ <property name="geometry">
+ <rect>
+ <x>39</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>8</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_9">
+ <property name="geometry">
+ <rect>
+ <x>78</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>9</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QFrame" name="frame_4">
+ <property name="geometry">
+ <rect>
+ <x>484</x>
+ <y>227</y>
+ <width>101</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QLabel" name="lab_relay_10">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>10</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_11">
+ <property name="geometry">
+ <rect>
+ <x>39</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>11</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_12">
+ <property name="geometry">
+ <rect>
+ <x>78</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>12</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QFrame" name="frame_5">
+ <property name="geometry">
+ <rect>
+ <x>34</x>
+ <y>14</y>
+ <width>71</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QLabel" name="lab_relay_13">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>13</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_14">
+ <property name="geometry">
+ <rect>
+ <x>39</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>14</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QFrame" name="frame_6">
+ <property name="geometry">
+ <rect>
+ <x>164</x>
+ <y>77</y>
+ <width>51</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QLabel" name="lab_relay_16">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>16</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_17">
+ <property name="geometry">
+ <rect>
+ <x>25</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>17</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QFrame" name="frame_7">
+ <property name="geometry">
+ <rect>
+ <x>236</x>
+ <y>76</y>
+ <width>51</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QLabel" name="lab_relay_18">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>18</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="lab_relay_19">
+ <property name="geometry">
+ <rect>
+ <x>25</x>
+ <y>0</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>19</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QLabel" name="lab_relay_15">
+ <property name="geometry">
+ <rect>
+ <x>215</x>
+ <y>15</y>
+ <width>20</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background-color: rgb(140, 135, 140);</string>
+ </property>
+ <property name="text">
+ <string>15</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="geometry">
+ <rect>
+ <x>600</x>
+ <y>0</y>
+ <width>131</width>
+ <height>131</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <widget class="QComboBox" name="cb_serial">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>40</y>
+ <width>121</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="frame">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>10</y>
+ <width>31</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>串口</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="line_baud">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>100</y>
+ <width>121</width>
+ <height>31</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_2">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>70</y>
+ <width>41</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>波特率</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QPushButton" name="btn_read">
+ <property name="geometry">
+ <rect>
+ <x>610</x>
+ <y>200</y>
+ <width>121</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>读取</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>290</y>
+ <width>151</width>
+ <height>141</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>通道一</string>
+ </property>
+ <widget class="QPushButton" name="btn_mode_2">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>20</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>电压</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_4">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>80</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>负/外壳</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_1">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>内阻</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_3">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>80</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>正/外壳</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QPushButton" name="btn_ser_open">
+ <property name="geometry">
+ <rect>
+ <x>610</x>
+ <y>140</y>
+ <width>121</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>打开串口</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_write">
+ <property name="geometry">
+ <rect>
+ <x>610</x>
+ <y>260</y>
+ <width>121</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>写入</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>290</y>
+ <width>151</width>
+ <height>141</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>通道一</string>
+ </property>
+ <widget class="QPushButton" name="btn_mode_6">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>20</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>电压</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_8">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>80</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>负/外壳</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_5">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>内阻</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_7">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>80</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>正/外壳</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="groupBox_4">
+ <property name="geometry">
+ <rect>
+ <x>300</x>
+ <y>290</y>
+ <width>151</width>
+ <height>141</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>通道一</string>
+ </property>
+ <widget class="QPushButton" name="btn_mode_10">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>20</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>电压</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_12">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>80</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>负/外壳</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_9">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>内阻</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_11">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>80</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>正/外壳</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="groupBox_5">
+ <property name="geometry">
+ <rect>
+ <x>450</x>
+ <y>290</y>
+ <width>151</width>
+ <height>141</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>通道一</string>
+ </property>
+ <widget class="QPushButton" name="btn_mode_14">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>20</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>电压</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_16">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>80</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>负/外壳</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_13">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>内阻</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_15">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>80</y>
+ <width>61</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>正/外壳</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QTextEdit" name="text_log">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>440</y>
+ <width>731</width>
+ <height>261</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btn_mode_0">
+ <property name="geometry">
+ <rect>
+ <x>610</x>
+ <y>370</y>
+ <width>51</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>全部关闭</string>
+ </property>
+ </widget>
+ </widget>
+ <resources>
+ <include location="test.qrc"/>
+ </resources>
+ <connections/>
+</ui>