This commit is contained in:
2025-09-30 17:51:45 +08:00
parent a2619ea237
commit 65e90ce8a0
6 changed files with 231 additions and 166 deletions

73
main.py
View File

@ -65,6 +65,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.last_status_printed = None
self.last_pause_printed = None
self.cur_pushbutton_num = None
self.drop_weight_index=0
self.pushbutton_num_style = """
QPushButton { background-color: #101F3F;color:#ffffff }
"""
@ -603,7 +604,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
background-color: #888888;
}
""")
self.label_showDetection.setScaledContents(True)
self.comboBox_dropWeight.wheelEvent=lambda e:None
if self.label_showDetection.size().width() < 100 or self.label_showDetection.size().height() < 100:
self.label_showDetection.setMinimumSize(541, 321)
@ -913,7 +916,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def send_startFeed_button_click(self):
if self.feeding.feedStatus != FeedStatus.FNone:
self.show_infomessage_box("正在执行")
self.show_infomessage_box("已启动,无需重复启动")
return
# 触发自动运行
if self.robotClient.status_model.curMode != 7:
@ -935,20 +938,25 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if msg_box_person.clickedButton() == cancel_button:
return
log.log_message(logging.INFO, '第一层确认生产')
has_person = False
#region 人员检测,暂无
# has_person = False
# has_person, _ = self.detection_person.get_person() # TODO
if has_person: # TODO
# if has_person: # TODO
# self.feeding.pause = True
# self.send_pause_command(True)
#
# self.show_messagebox_of_person()
msg_box_person.setText("检测到安全区域后人是否继续生产?")
result = msg_box_person.exec()
if msg_box_person.clickedButton() == cancel_button:
return
log.log_message(logging.ERROR, '人员进入安全区')
# msg_box_person.setText("检测到安全区域后人是否继续生产?")
# result = msg_box_person.exec()
# if msg_box_person.clickedButton() == cancel_button:
# return
# log.log_message(logging.ERROR, '人员进入安全区')
#QSlide控件默认的最大值为99
msg_box_person.setText(f"确认当前码垛重量是 {self.remain_drop_weight}KG")
result = msg_box_person.exec()
if msg_box_person.clickedButton() == cancel_button:
return
num = self.horizontalSlider_feedingNum.maximum()
# if num==99:
# num = 30 #默认是30包
@ -961,8 +969,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
return
self.label_button_status.setText("运行中...")
self.drop_position_manager=DropPositionManager(Constant.dropLine_set_file_35)
self.relay_controller.set_drop_35(True)
if self.remain_drop_weight == '35':
self.drop_position_manager=DropPositionManager(Constant.dropLine_set_file_35)
self.relay_controller.set_drop_35(True)
else:
self.drop_position_manager=DropPositionManager(Constant.dropLine_set_file)
self.relay_controller.set_drop_35(False)
#注意码垛数和码垛总数
# num=25 #先默认30包码垛
self.command_quene.put(
@ -1540,7 +1552,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.comboBox_dropWeight.addItem(weight_text, userData)
# 连接槽函数
self.comboBox_dropWeight.currentIndexChanged.connect(self.on_drop_weight_changed)
self.comboBox_dropWeight.activated.connect(self.on_drop_weight_changed)
# 设置初始化选中的重量
if self.remain_drop_weight:
@ -1549,14 +1561,25 @@ class MainWindow(QMainWindow, Ui_MainWindow):
selected_index = self.comboBox_dropWeight.findData(selected_value)
if selected_index >= 0:
self.comboBox_dropWeight.setCurrentIndex(selected_index)
self.drop_weight_index=selected_index
# 初始化重量提示标签
self.weight_label_info.setText(f"Tips: 当前选择的码垛重量 {self.remain_drop_weight}kg")
self.weight_label_info.setText(f"当前码垛重量 {self.remain_drop_weight}kg")
"""9/29 重量下拉框选中项变化时, 更新self.remain_drop_weight"""
def on_drop_weight_changed(self, index):
#提示
msgBox = QMessageBox(self)
msgBox.setText("修改码垛重量会从第1包开始是否继续")
msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
result = msgBox.exec()
if result != QMessageBox.StandardButton.Yes:
self.comboBox_dropWeight.setCurrentIndex(self.drop_weight_index)
return
else:
self.drop_weight_index=index
# 默认的重量为 50 kg
default_weight = 50
default_weight = '50'
if index < 0: # 没有选中项时(如下拉框为空)
self.remain_drop_weight = default_weight
@ -1576,8 +1599,22 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.remain_drop_weight = default_weight
# 更新上方的码垛重量提示Tips
self.weight_label_info.setText(f"Tips: 当前选择的码垛重量 {selected_text}")
self.weight_label_info.setText(f"当前码垛重量 {selected_text}")
self.remain_Count=0
if self.feeding.feedConfig:
self.feeding.feedConfig.remain_count = 0
self.label_remain_num.setText('0')
#35KG
if self.remain_drop_weight=='35':
self.label_maxNum.setText('42')
self.horizontalSlider_feedingNum.setMaximum(42)
self.maduo_Count=42
else:
self.label_maxNum.setText('30')
self.horizontalSlider_feedingNum.setMaximum(30)
self.maduo_Count=30
def updateUI_label_status(self):
if self.robotClient.status_model.isMoving==1:
@ -2104,6 +2141,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if self.feeding.feedConfig:
self.configReader.set('Robot_Feed', 'remain_linename', str(self.feeding.feedConfig.feedLine.id))
self.configReader.set('Robot_Feed', 'remain_count', str(self.feeding.feedConfig.remain_count))
else:
self.configReader.set('Robot_Feed', 'remain_count', str(self.remain_Count))
if self.cur_pushbutton_num:
self.configReader.set('Robot_Feed', 'maduo_count', self.cur_pushbutton_num.text())
@ -2111,8 +2150,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.configReader.set("Robot_Feed", "remain_dropweight_kg", str(self.remain_drop_weight))
self.configReader.write(open(Constant.set_ini, 'w', encoding='utf-8'))
except:
log.log_message(logging.ERROR, Constant.str_sys_log_feedNum)
except Exception as ex:
log.log_message(logging.ERROR, Constant.str_sys_log_feedNum + str(ex))
class MyApplication(QApplication):