feature/weight_show #2
@ -47,6 +47,7 @@ photo_v5 = 0.0
|
|||||||
photo_w5 = 1.0
|
photo_w5 = 1.0
|
||||||
linecount = 2
|
linecount = 2
|
||||||
remain_linename = 1
|
remain_linename = 1
|
||||||
|
remain_dropweight_kg = 50
|
||||||
remain_count = 10
|
remain_count = 10
|
||||||
maduo_count = 30
|
maduo_count = 30
|
||||||
io_take_addr = 8
|
io_take_addr = 8
|
||||||
|
|||||||
112
main.py
112
main.py
@ -48,6 +48,7 @@ from ui_MainWin import Ui_MainWindow
|
|||||||
from view.ResetView import StopDialog
|
from view.ResetView import StopDialog
|
||||||
from EMV.EMV import RelayController
|
from EMV.EMV import RelayController
|
||||||
from CU.drop import DropPositionManager
|
from CU.drop import DropPositionManager
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
@ -756,6 +757,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
self.last_time = time.time()
|
self.last_time = time.time()
|
||||||
self.remain_lineName = self.configReader.get('Robot_Feed', 'remain_lineName')
|
self.remain_lineName = self.configReader.get('Robot_Feed', 'remain_lineName')
|
||||||
|
self.remain_drop_weight = self.configReader.get("Robot_Feed", "remain_dropweight_kg") # 9/29 投料重量, 单位kg
|
||||||
self.remain_Count = int(self.configReader.get('Robot_Feed', 'remain_Count'))
|
self.remain_Count = int(self.configReader.get('Robot_Feed', 'remain_Count'))
|
||||||
self.maduo_Count = int(self.configReader.get('Robot_Feed', 'maduo_Count'))
|
self.maduo_Count = int(self.configReader.get('Robot_Feed', 'maduo_Count'))
|
||||||
self.label_remain_num.setText(str(self.remain_Count))
|
self.label_remain_num.setText(str(self.remain_Count))
|
||||||
@ -898,8 +900,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
if line_model:
|
if line_model:
|
||||||
self.feedLine_dict[f'{Constant.dropLine_set_section}{i}'] = line_model
|
self.feedLine_dict[f'{Constant.dropLine_set_section}{i}'] = line_model
|
||||||
|
|
||||||
self.updateUI_Select_Line()
|
# self.updateUI_Select_Line()
|
||||||
pass
|
# 9/29 初始化线名选择框 和 重量选择框
|
||||||
|
self.updateui_select_line_by_feedLine_ini()
|
||||||
|
self.updateui_select_dropweight_by_drop_ini()
|
||||||
|
|
||||||
def init_robot_info(self):
|
def init_robot_info(self):
|
||||||
j1_min = int(self.configReader.get('Robot_Feed', 'j1_min'))
|
j1_min = int(self.configReader.get('Robot_Feed', 'j1_min'))
|
||||||
@ -1729,6 +1733,90 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.comboBox_lineIndex.clear()
|
self.comboBox_lineIndex.clear()
|
||||||
for key, value in self.feedLine_dict.items():
|
for key, value in self.feedLine_dict.items():
|
||||||
self.comboBox_lineIndex.addItem(value.name, key)
|
self.comboBox_lineIndex.addItem(value.name, key)
|
||||||
|
|
||||||
|
# 9/29: 只需要加载FeedLine.ini中的name 作为comboBox_lineIndex的选项
|
||||||
|
def updateui_select_line_by_feedLine_ini(self):
|
||||||
|
self.comboBox_lineIndex.clear()
|
||||||
|
configReader = configparser.ConfigParser()
|
||||||
|
configReader.read(Constant.feedLine_set_file, encoding="utf-8")
|
||||||
|
for index in range(1, Constant.MAX_Line_num):
|
||||||
|
section = f"{Constant.feedLine_set_section}{index}"
|
||||||
|
if configReader.has_section(section):
|
||||||
|
line_name = configReader.get(section, "name")
|
||||||
|
self.comboBox_lineIndex.addItem(line_name, section)
|
||||||
|
|
||||||
|
# 设置初始化选中,初始选中 f'{Constant.feedLine_set_section}{self.remain_linename}'
|
||||||
|
if self.remain_lineName:
|
||||||
|
selected_value = f"{Constant.feedLine_set_section}{self.remain_lineName}"
|
||||||
|
selected_index = self.comboBox_lineIndex.findData(selected_value)
|
||||||
|
if selected_index >= 0:
|
||||||
|
self.comboBox_lineIndex.setCurrentIndex(selected_index)
|
||||||
|
|
||||||
|
# 9/29 初始化加载 drop.ini 中的name,获取预先设置的重量
|
||||||
|
def updateui_select_dropweight_by_drop_ini(self):
|
||||||
|
self.comboBox_dropWeight.clear()
|
||||||
|
configReader = configparser.ConfigParser()
|
||||||
|
# 读取重量路径配置文件 drop.ini
|
||||||
|
configReader.read(Constant.dropLine_set_file, encoding="utf-8")
|
||||||
|
|
||||||
|
# drop_name匹配xxxkg获取重量
|
||||||
|
weight_pattern = re.compile(r'(\d+kg)')
|
||||||
|
|
||||||
|
for index in range(1, Constant.MAX_Line_num):
|
||||||
|
section = f"{Constant.dropLine_set_section}{index}"
|
||||||
|
if configReader.has_section(section):
|
||||||
|
drop_name = configReader.get(section, "name")
|
||||||
|
match = weight_pattern.search(drop_name)
|
||||||
|
if match:
|
||||||
|
# 提取匹配到的内容(如"50kg")
|
||||||
|
weight_text = match.group(1)
|
||||||
|
else:
|
||||||
|
# 无法匹配xxxkg, 则使用"未知重量"
|
||||||
|
weight_text = "未知重量"
|
||||||
|
# userData: 如 DropLine50kg
|
||||||
|
userData = f"{Constant.dropLine_set_section}{weight_text}"
|
||||||
|
self.comboBox_dropWeight.addItem(weight_text, userData)
|
||||||
|
|
||||||
|
# 连接槽函数
|
||||||
|
self.comboBox_dropWeight.currentIndexChanged.connect(self.on_drop_weight_changed)
|
||||||
|
|
||||||
|
# 设置初始化选中的重量
|
||||||
|
if self.remain_drop_weight:
|
||||||
|
# selected_value: 如 DropLine50kg
|
||||||
|
selected_value = f"{Constant.dropLine_set_section}{self.remain_drop_weight}kg"
|
||||||
|
selected_index = self.comboBox_dropWeight.findData(selected_value)
|
||||||
|
if selected_index >= 0:
|
||||||
|
self.comboBox_dropWeight.setCurrentIndex(selected_index)
|
||||||
|
# 初始化重量提示标签
|
||||||
|
self.weight_label_info.setText(f"Tips: 当前选择的码垛重量为 {self.remain_drop_weight}kg")
|
||||||
|
|
||||||
|
|
||||||
|
"""9/29 重量下拉框选中项变化时, 更新self.remain_drop_weight"""
|
||||||
|
def on_drop_weight_changed(self, index):
|
||||||
|
# 默认的重量为 50 kg
|
||||||
|
default_weight = 50
|
||||||
|
|
||||||
|
if index < 0: # 没有选中项时(如下拉框为空)
|
||||||
|
self.remain_drop_weight = default_weight
|
||||||
|
return
|
||||||
|
|
||||||
|
# 获取当前选中项的显示文本(如"50kg")
|
||||||
|
selected_text = self.comboBox_dropWeight.currentText()
|
||||||
|
|
||||||
|
# 提取重量数值(从"50kg"中提取"50")
|
||||||
|
weight_pattern = re.compile(r'(\d+)kg')
|
||||||
|
match = weight_pattern.search(selected_text)
|
||||||
|
if match:
|
||||||
|
# 提取数字部分(如"50")
|
||||||
|
self.remain_drop_weight = match.group(1)
|
||||||
|
else:
|
||||||
|
# 若为"未知重量",remain_drop_weight 也为 default_weight
|
||||||
|
self.remain_drop_weight = default_weight
|
||||||
|
|
||||||
|
# 更新上方的码垛重量提示Tips:
|
||||||
|
self.weight_label_info.setText(f"Tips: 当前选择的码垛重量为 {selected_text}")
|
||||||
|
|
||||||
|
|
||||||
def updateUI_label_status(self):
|
def updateUI_label_status(self):
|
||||||
if self.robotClient.status_model.isMoving==1:
|
if self.robotClient.status_model.isMoving==1:
|
||||||
self.label_move_sign.show()
|
self.label_move_sign.show()
|
||||||
@ -2201,7 +2289,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
def send_click_change_stackView(self,index):
|
def send_click_change_stackView(self,index):
|
||||||
self.stackedWidget_view.setCurrentIndex(index)
|
self.stackedWidget_view.setCurrentIndex(index)
|
||||||
if index == 0:
|
if index == 0:
|
||||||
self.updateUI_Select_Line()
|
# 9/29: 切换界面,不刷新 线名选择框 comboBox_lineIndex
|
||||||
|
# self.updateUI_Select_Line()
|
||||||
|
pass
|
||||||
if index == 2:
|
if index == 2:
|
||||||
self.updateRobotSeting()
|
self.updateRobotSeting()
|
||||||
self.updateUI_Photo_Set()
|
self.updateUI_Photo_Set()
|
||||||
@ -2265,16 +2355,20 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
#记录投料袋数
|
#记录投料袋数
|
||||||
def record_remain_num(self):
|
def record_remain_num(self):
|
||||||
try:
|
try:
|
||||||
self.configReader = configparser.ConfigParser()
|
self.configReader = configparser.ConfigParser()
|
||||||
self.configReader.read(Constant.set_ini)
|
self.configReader.read(Constant.set_ini)
|
||||||
if self.feeding.feedConfig:
|
if self.feeding.feedConfig:
|
||||||
self.configReader.set('Robot_Feed', 'remain_linename', str(self.feeding.feedConfig.feedLine.id))
|
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))
|
self.configReader.set('Robot_Feed', 'remain_count', str(self.feeding.feedConfig.remain_count))
|
||||||
if self.cur_pushbutton_num:
|
if self.cur_pushbutton_num:
|
||||||
self.configReader.set('Robot_Feed', 'maduo_count', self.cur_pushbutton_num.text())
|
self.configReader.set('Robot_Feed', 'maduo_count', self.cur_pushbutton_num.text())
|
||||||
self.configReader.write(open(Constant.set_ini, 'w', encoding='utf-8'))
|
|
||||||
|
# 9/29 保存 remain_dropweight_kg 投料的重量,35、50 (单位kg)
|
||||||
|
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:
|
except:
|
||||||
log.log_message(logging.ERROR, Constant.str_sys_log_feedNum)
|
log.log_message(logging.ERROR, Constant.str_sys_log_feedNum)
|
||||||
|
|
||||||
|
|
||||||
class MyApplication(QApplication):
|
class MyApplication(QApplication):
|
||||||
|
|||||||
4064
ui_MainWin - 副本 (3).py
Normal file
4064
ui_MainWin - 副本 (3).py
Normal file
File diff suppressed because it is too large
Load Diff
@ -628,7 +628,36 @@ class Ui_MainWindow(object):
|
|||||||
"border-image: None;")
|
"border-image: None;")
|
||||||
self.frame_sign_2.setFrameShape(QFrame.Shape.StyledPanel)
|
self.frame_sign_2.setFrameShape(QFrame.Shape.StyledPanel)
|
||||||
self.frame_sign_2.setFrameShadow(QFrame.Shadow.Raised)
|
self.frame_sign_2.setFrameShadow(QFrame.Shadow.Raised)
|
||||||
self.gridLayout_4 = QGridLayout(self.frame_sign_2)
|
|
||||||
|
|
||||||
|
# 9/30 新增显示 投料的重量的信息
|
||||||
|
self.verticalLayout_sign = QVBoxLayout(self.frame_sign_2)
|
||||||
|
self.verticalLayout_sign.setObjectName(u"verticalLayout_sign")
|
||||||
|
self.verticalLayout_sign.setContentsMargins(0, 0, 0, 0) # 清除边距
|
||||||
|
self.verticalLayout_sign.setSpacing(5) # 新标签与下方网格布局的间距
|
||||||
|
|
||||||
|
# 1. 添加新的信息标签(放在上方)
|
||||||
|
self.weight_label_info = QLabel(self.frame_sign_2)
|
||||||
|
self.weight_label_info.setObjectName(u"label_info")
|
||||||
|
# 设置标签样式 background-color: #2c2c2c;
|
||||||
|
self.weight_label_info.setStyleSheet(u"""
|
||||||
|
QLabel {
|
||||||
|
background-color: rgba(255, 255, 255, 0);
|
||||||
|
color: red;
|
||||||
|
font: 11pt "Microsoft YaHei UI";
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
self.weight_label_info.setText("显示当前的重量") # 初始信息
|
||||||
|
# self.weight_label_info.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||||
|
self.weight_label_info.setAlignment(Qt.AlignmentFlag.AlignCenter) # 居中
|
||||||
|
self.verticalLayout_sign.addWidget(self.weight_label_info)
|
||||||
|
|
||||||
|
|
||||||
|
# 9/10
|
||||||
|
# self.gridLayout_4 = QGridLayout(self.frame_sign_2)
|
||||||
|
self.gridLayout_4 = QGridLayout()
|
||||||
self.gridLayout_4.setObjectName(u"gridLayout_4")
|
self.gridLayout_4.setObjectName(u"gridLayout_4")
|
||||||
self.pushButton_sign_go = QPushButton(self.frame_sign_2)
|
self.pushButton_sign_go = QPushButton(self.frame_sign_2)
|
||||||
self.pushButton_sign_go.setObjectName(u"pushButton_sign_go")
|
self.pushButton_sign_go.setObjectName(u"pushButton_sign_go")
|
||||||
@ -786,6 +815,9 @@ class Ui_MainWindow(object):
|
|||||||
|
|
||||||
self.gridLayout_4.addWidget(self.label_sign_feed, 0, 7, 1, 1)
|
self.gridLayout_4.addWidget(self.label_sign_feed, 0, 7, 1, 1)
|
||||||
|
|
||||||
|
# 9/10 添加 取料中、拍照中等布局
|
||||||
|
self.verticalLayout_sign.addLayout(self.gridLayout_4)
|
||||||
|
|
||||||
|
|
||||||
self.verticalLayout_14.addWidget(self.frame_sign_2)
|
self.verticalLayout_14.addWidget(self.frame_sign_2)
|
||||||
|
|
||||||
@ -3310,6 +3342,47 @@ class Ui_MainWindow(object):
|
|||||||
|
|
||||||
self.verticalLayout_11.addWidget(self.comboBox_lineIndex)
|
self.verticalLayout_11.addWidget(self.comboBox_lineIndex)
|
||||||
|
|
||||||
|
# 9/29 新增重量选择框 和 选择投料重量提示
|
||||||
|
weight_h_layout = QHBoxLayout()
|
||||||
|
# weight_h_layout.setSpacing(10)
|
||||||
|
self.weight_label = QLabel(self.frame_20)
|
||||||
|
self.weight_label.setText("选择码垛重量:")
|
||||||
|
self.weight_label.setStyleSheet("color: white;")
|
||||||
|
weight_h_layout.addWidget(self.weight_label)
|
||||||
|
|
||||||
|
self.comboBox_dropWeight = QComboBox(self.frame_20)
|
||||||
|
self.comboBox_dropWeight.setObjectName(u"comboBox_dropWeight")
|
||||||
|
self.comboBox_dropWeight.setStyleSheet(u"QComboBox {\n"
|
||||||
|
" border-radius: 10px;\n"
|
||||||
|
" padding: 5px 5px 5px 5px;\n"
|
||||||
|
" background-color: #2c2c2c;\n"
|
||||||
|
" color: white;\n"
|
||||||
|
" border: 1px solid #474747;\n"
|
||||||
|
" min-width: 80px;\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
|
"QComboBox::drop-down {\n"
|
||||||
|
" width: 0px;\n"
|
||||||
|
" border: none;\n"
|
||||||
|
"\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"QComboBox::down-arrow {\n"
|
||||||
|
" image: none;\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"QComboBox QAbstractItemView {\n"
|
||||||
|
" border-bottom-right-radius: 10px;\n"
|
||||||
|
" border-bottom-left-radius: 10px;\n"
|
||||||
|
" background-color: #D3D3D3;\n"
|
||||||
|
" border: 1px solid gray;\n"
|
||||||
|
" padding: 4px 4px 4px 4px;\n"
|
||||||
|
" outline: none;\n"
|
||||||
|
"}")
|
||||||
|
weight_h_layout.addWidget(self.comboBox_dropWeight)
|
||||||
|
self.verticalLayout_11.addLayout(weight_h_layout)
|
||||||
|
|
||||||
self.stackedWidget_num = QStackedWidget(self.frame_20)
|
self.stackedWidget_num = QStackedWidget(self.frame_20)
|
||||||
self.stackedWidget_num.setObjectName(u"stackedWidget_num")
|
self.stackedWidget_num.setObjectName(u"stackedWidget_num")
|
||||||
self.stackedWidget_num.setStyleSheet(u"border:none;")
|
self.stackedWidget_num.setStyleSheet(u"border:none;")
|
||||||
|
|||||||
Reference in New Issue
Block a user