Compare commits

..

1 Commits

Author SHA1 Message Date
YuanHongbin c9186dfc12 重构Lora信道配置和自定义指令布局 2026-06-24 15:58:48 +08:00
+47 -58
View File
@@ -71,8 +71,8 @@ class GatewayConfigTool(QMainWindow):
def init_ui(self): def init_ui(self):
self.setWindowTitle("网关配置工具") self.setWindowTitle("网关配置工具")
self.setWindowIcon(QIcon(resource_path("物联网网关.png"))) self.setWindowIcon(QIcon(resource_path("物联网网关.png")))
self.setMinimumSize(800, 800) self.setMinimumSize(1000, 850)
self.resize(800, 800) self.resize(1000, 850)
central = QWidget() central = QWidget()
self.setCentralWidget(central) self.setCentralWidget(central)
@@ -314,72 +314,43 @@ class GatewayConfigTool(QMainWindow):
config_layout.addWidget(eth_group) config_layout.addWidget(eth_group)
# Lora参数 + 自定义指令(一行 # Lora信道配置(独立区块,类似ETH参数
bottom_row = QHBoxLayout() lora_group = QGroupBox("Lora信道配置")
bottom_row.setSpacing(4) lora_layout = QHBoxLayout(lora_group)
lora_layout.setSpacing(6)
bottom_row.addWidget(QLabel("Lora频率:")) lora_layout.addWidget(QLabel("信道:"))
self.combo_lora_fc = QComboBox() self.combo_lora_fc = QComboBox()
self.combo_lora_fc.setFixedWidth(120) self.combo_lora_fc.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
lora_freqs = [ lora_freqs = []
("433100000", "信道1: 433.1M"), fc_hz = 410100000
("433300000", "信道2: 433.3M"), ch_idx = 1
("433500000", "信道3: 433.5M"), while fc_hz < 525000000:
("433700000", "信道4: 433.7M"), mhz = fc_hz / 1000000
("433900000", "信道5: 433.9M"), lora_freqs.append((str(fc_hz), f"信道{ch_idx}: {mhz:.1f}MHz"))
("434100000", "信道6: 434.1M"), fc_hz += 200000
("434300000", "信道7: 434.3M"), ch_idx += 1
("434500000", "信道8: 434.5M"),
("434700000", "信道9: 434.7M"),
("434900000", "信道10: 434.9M"),
("435100000", "信道11: 435.1M"),
("435300000", "信道12: 435.3M"),
("435500000", "信道13: 435.5M"),
("435700000", "信道14: 435.7M"),
("435900000", "信道15: 435.9M"),
("436100000", "信道16: 436.1M"),
("436300000", "信道17: 436.3M"),
("436500000", "信道18: 436.5M"),
("436700000", "信道19: 436.7M"),
("436900000", "信道20: 436.9M"),
("437100000", "信道21: 437.1M"),
("437300000", "信道22: 437.3M"),
("437500000", "信道23: 437.5M"),
("437700000", "信道24: 437.7M"),
("437900000", "信道25: 437.9M"),
("438100000", "信道26: 438.1M"),
("438300000", "信道27: 438.3M"),
("438500000", "信道28: 438.5M"),
("438700000", "信道29: 438.7M"),
("438900000", "信道30: 438.9M"),
("439100000", "信道31: 439.1M"),
("439300000", "信道32: 439.3M"),
]
for freq, desc in lora_freqs: for freq, desc in lora_freqs:
self.combo_lora_fc.addItem(desc, freq) self.combo_lora_fc.addItem(desc, freq)
bottom_row.addWidget(self.combo_lora_fc) self.combo_lora_fc.view().setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.combo_lora_fc.view().setMinimumHeight(200)
lora_layout.addWidget(self.combo_lora_fc, 1)
self.btn_lora_fc = QPushButton("发送") self.btn_lora_fc = QPushButton("发送")
self.btn_lora_fc.setFixedWidth(50) self.btn_lora_fc.setFixedWidth(60)
self.btn_lora_fc.setStyleSheet("font-weight:bold;")
self.btn_lora_fc.clicked.connect(self.on_lora_send) self.btn_lora_fc.clicked.connect(self.on_lora_send)
bottom_row.addWidget(self.btn_lora_fc) lora_layout.addWidget(self.btn_lora_fc)
bottom_row.addSpacing(10) config_layout.addWidget(lora_group)
bottom_row.addWidget(QLabel("自定义:"))
self.edit_custom = QLineEdit()
self.edit_custom.setPlaceholderText("输入指令...")
self.edit_custom.returnPressed.connect(self.send_custom_command)
bottom_row.addWidget(self.edit_custom)
self.btn_custom_send = QPushButton("发送")
self.btn_custom_send.clicked.connect(self.send_custom_command)
bottom_row.addWidget(self.btn_custom_send)
config_layout.addLayout(bottom_row) # -- 下方:日志区 + 自定义指令 --
# -- 下方:日志区 --
log_widget = QWidget() log_widget = QWidget()
log_layout = QVBoxLayout(log_widget) log_layout = QHBoxLayout(log_widget)
log_layout.setContentsMargins(0, 0, 0, 0) log_layout.setContentsMargins(0, 0, 0, 0)
log_layout.setSpacing(4)
# 左侧:通讯日志
log_group = QGroupBox("通讯日志") log_group = QGroupBox("通讯日志")
log_inner = QVBoxLayout(log_group) log_inner = QVBoxLayout(log_group)
@@ -398,7 +369,25 @@ class GatewayConfigTool(QMainWindow):
log_btn_layout.addStretch() log_btn_layout.addStretch()
log_inner.addLayout(log_btn_layout) log_inner.addLayout(log_btn_layout)
log_layout.addWidget(log_group) # 右侧:自定义指令
custom_group = QGroupBox("自定义指令")
custom_inner = QVBoxLayout(custom_group)
custom_inner.setSpacing(6)
custom_inner.addWidget(QLabel("指令:"))
self.edit_custom = QLineEdit()
self.edit_custom.setPlaceholderText("输入指令...")
self.edit_custom.returnPressed.connect(self.send_custom_command)
custom_inner.addWidget(self.edit_custom)
self.btn_custom_send = QPushButton("发送")
self.btn_custom_send.setStyleSheet("font-weight:bold;")
self.btn_custom_send.clicked.connect(self.send_custom_command)
custom_inner.addWidget(self.btn_custom_send)
custom_inner.addStretch()
log_layout.addWidget(log_group, 4)
log_layout.addWidget(custom_group, 1)
splitter.addWidget(config_widget) splitter.addWidget(config_widget)
splitter.addWidget(log_widget) splitter.addWidget(log_widget)