[add] 增加了“开”和“关”命令
This commit is contained in:
parent
f85aea97ec
commit
1b7e0e7e31
@ -197,6 +197,13 @@ class SerialDataLogger(QObject):
|
||||
f.write(data)
|
||||
except Exception as e:
|
||||
print(f"保存数据出错: {e}")
|
||||
|
||||
def send_cmd(self, cmd):
|
||||
"""发送命令"""
|
||||
try:
|
||||
self.ser.write(cmd)
|
||||
except Exception as e:
|
||||
print(f"发送命令出错: {e}")
|
||||
|
||||
def test_connection(self):
|
||||
"""测试串口连接
|
||||
|
27
main.py
27
main.py
@ -9,10 +9,15 @@ from data_collector import SerialDataLogger
|
||||
import os
|
||||
|
||||
|
||||
CMD_ON = b'\x01\x00\x01\x02'
|
||||
CMD_OFF = b'\x01\x00\x00\x01'
|
||||
|
||||
|
||||
|
||||
class SerialUI(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("Signal Collector V1.0.5")
|
||||
self.setWindowTitle("Signal Collector V1.0.6 BUILD202503041320")
|
||||
self.resize(400, 300)
|
||||
|
||||
# 设置应用样式
|
||||
@ -125,6 +130,19 @@ class SerialUI(QMainWindow):
|
||||
baud_layout.addWidget(self.connect_btn)
|
||||
layout.addLayout(baud_layout)
|
||||
|
||||
# 开关按钮区域
|
||||
cmd_layout = QHBoxLayout()
|
||||
cmd_label = QLabel("开关命令:")
|
||||
self.cmd_btn_on = QPushButton("ON")
|
||||
self.cmd_btn_on.clicked.connect(self.on_cmd_btn_on)
|
||||
self.cmd_btn_off = QPushButton("OFF")
|
||||
self.cmd_btn_off.clicked.connect(self.on_cmd_btn_off)
|
||||
|
||||
cmd_layout.addWidget(baud_label)
|
||||
cmd_layout.addWidget(self.cmd_btn_on)
|
||||
cmd_layout.addWidget(self.cmd_btn_off)
|
||||
layout.addLayout(cmd_layout)
|
||||
|
||||
# 录制控制区域
|
||||
record_layout = QHBoxLayout()
|
||||
self.record_btn = QPushButton("开始录制")
|
||||
@ -204,6 +222,13 @@ class SerialUI(QMainWindow):
|
||||
# 添加退出时的确认标志
|
||||
self.exit_confirmed = False
|
||||
|
||||
def on_cmd_btn_on(self):
|
||||
self.serial_logger.send_cmd(CMD_ON)
|
||||
|
||||
|
||||
def on_cmd_btn_off(self):
|
||||
self.serial_logger.send_cmd(CMD_OFF)
|
||||
|
||||
def update_count_display(self):
|
||||
"""更新数据计数显示"""
|
||||
if self.serial_logger:
|
||||
|
38
signal collector 1.0.6.spec
Normal file
38
signal collector 1.0.6.spec
Normal file
@ -0,0 +1,38 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
|
||||
a = Analysis(
|
||||
['main.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
noarchive=False,
|
||||
optimize=0,
|
||||
)
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
[],
|
||||
name='signal collector 1.0.6',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
Loading…
Reference in New Issue
Block a user