feat: 完善上料操作逻辑,增加托盘类型验证及Modbus操作处理
This commit is contained in:
parent
dfa09ea585
commit
428df1d388
BIN
db/jtDB.db
BIN
db/jtDB.db
Binary file not shown.
@ -355,11 +355,44 @@ class MainWindow(MainWindowUI):
|
|||||||
# 显示对话框
|
# 显示对话框
|
||||||
result = dialog.exec()
|
result = dialog.exec()
|
||||||
|
|
||||||
# 如果用户点击确认按钮
|
# 如果用户确认,则执行上料操作
|
||||||
if result == QDialog.Accepted:
|
if result == QDialog.Accepted:
|
||||||
# TODO: 在这里添加上料操作的具体逻辑
|
# 获取托盘料值作为拆垛层数
|
||||||
logging.info(f"上料对话框已确认,托盘号: {self.tray_edit.currentText()}")
|
stow_num = dialog.pallet_material_value.text()
|
||||||
pass
|
if stow_num == "--" or not stow_num:
|
||||||
|
QMessageBox.warning(self, "错误", "未获取到托盘料信息,请重试")
|
||||||
|
return
|
||||||
|
|
||||||
|
# 获取托盘号对应的托盘类型
|
||||||
|
pallet_type = self.pallet_type_manager.get_pallet_type_by_pallet_id(tray_id)
|
||||||
|
# 初始化托盘号对应的序号
|
||||||
|
if tray_id not in self.init_seq:
|
||||||
|
self.init_seq[tray_id] = 1
|
||||||
|
|
||||||
|
if not pallet_type:
|
||||||
|
QMessageBox.warning(self, "错误", "未查到对应下料托盘类型")
|
||||||
|
return
|
||||||
|
|
||||||
|
# 执行Modbus操作
|
||||||
|
modbus = ModbusUtils()
|
||||||
|
client = modbus.get_client()
|
||||||
|
try:
|
||||||
|
# 上料 D2 寄存器写入 1, D0 寄存器写入拆垛层数
|
||||||
|
success0 = modbus.write_register_until_success(client, 0, int(stow_num))
|
||||||
|
success2 = modbus.write_register_until_success(client, 2, 1)
|
||||||
|
success3 = modbus.write_register_until_success(client, 3, 1)
|
||||||
|
|
||||||
|
# 上料 D2 寄存器写入 1, D0 寄存器写入拆垛层数
|
||||||
|
if success0 and success2 and success3:
|
||||||
|
# 创建状态标签并显示在右上角
|
||||||
|
self.show_operation_status("拆垛层数", "input", stow_num)
|
||||||
|
else:
|
||||||
|
QMessageBox.information(self, "操作提示", "上料失败")
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"上料操作失败: {str(e)}")
|
||||||
|
QMessageBox.critical(self, "错误", f"上料操作失败: {str(e)}")
|
||||||
|
finally:
|
||||||
|
modbus.close_client(client)
|
||||||
|
|
||||||
def handle_output(self):
|
def handle_output(self):
|
||||||
"""处理下料按钮点击事件"""
|
"""处理下料按钮点击事件"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user