update 添加三个拍照点位的显示设置

This commit is contained in:
FrankCV2048
2024-10-09 22:36:30 +08:00
parent 2fd734562d
commit 9a70f9c850
6 changed files with 756 additions and 23 deletions

96
app.py
View File

@ -136,6 +136,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.pushButton_stopFeed.clicked.connect(self.send_stopFeed_button_click)
self.pushButton_pauseFeed.clicked.connect(self.send_pauseFeed_button_click)
self.pushButton_get_p1.clicked.connect(self.get_p1_button_click)
self.pushButton_get_p2.clicked.connect(self.get_p2_button_click)
self.pushButton_get_p3.clicked.connect(self.get_p3_button_click)
self.pushButton_set_p1.clicked.connect(self.set_p1_button_click)
self.pushButton_set_p2.clicked.connect(self.set_p2_button_click)
self.pushButton_set_p3.clicked.connect(self.set_p3_button_click)
self.pushButton_clearAlarm.clicked.connect(self.send_clear_alarm_command)
self.pushButton_reset.clicked.connect(self.send_reset_button_click)
self.pushButton_speed.setText(str(Constant.speed))
@ -177,11 +184,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
ip = self.configReader.get('Robot_Feed', 'IPAddress')
port = int(self.configReader.get('Robot_Feed', 'Port'))
photo_locs = [(int(self.configReader.get('Robot_Feed', 'photo_x1')),
int(self.configReader.get('Robot_Feed', 'photo_y1'))),
int(self.configReader.get('Robot_Feed', 'photo_y1')), int(self.configReader.get('Robot_Feed', 'photo_z1'))),
(int(self.configReader.get('Robot_Feed', 'photo_x2')),
int(self.configReader.get('Robot_Feed', 'photo_y2'))),
int(self.configReader.get('Robot_Feed', 'photo_y2')), int(self.configReader.get('Robot_Feed', 'photo_z2'))),
(int(self.configReader.get('Robot_Feed', 'photo_x3')),
int(self.configReader.get('Robot_Feed', 'photo_y3')))
int(self.configReader.get('Robot_Feed', 'photo_y3')),int(self.configReader.get('Robot_Feed', 'photo_z3')))
]
self.robotClient = RobotClient(ip, port, photo_locs,self.command_position_quene, self.status_address)
@ -483,6 +490,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.stackedWidget_feed.setCurrentIndex(index)
if index == 0:
self.updateUI_Select_Line()
if index == 1:
self.updateUI_Photo_Set()
def on_button_click(self):
self.button.setText("Clicked!")
@ -922,6 +931,87 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.feeding.pause = False
self.send_pause_command(False)
### 设置界面
def get_p1_button_click(self):
realPosition = self.robotClient.status_model.getRealPosition()
self.lineEdit_x1.setText(realPosition.X)
self.lineEdit_y1.setText(realPosition.Y)
self.lineEdit_z1.setText(realPosition.Z)
def get_p2_button_click(self):
realPosition = self.robotClient.status_model.getRealPosition()
self.lineEdit_x2.setText(realPosition.X)
self.lineEdit_y2.setText(realPosition.Y)
self.lineEdit_z2.setText(realPosition.Z)
def get_p3_button_click(self):
realPosition = self.robotClient.status_model.getRealPosition()
self.lineEdit_x3.setText(realPosition.X)
self.lineEdit_y3.setText(realPosition.Y)
self.lineEdit_z3.setText(realPosition.Z)
def set_p1_button_click(self):
try:
x1 = float(self.lineEdit_x1.text())
y1 = float(self.lineEdit_y1.text())
z1 = float(self.lineEdit_z1.text())
self.robotClient.photo_locs[0] = (x1, y1, z1)
self.configReader.read(Constant.set_ini)
self.configReader.set('Robot_Feed', 'photo_x1', str(x1))
self.configReader.set('Robot_Feed', 'photo_y1', str(y1))
self.configReader.set('Robot_Feed', 'photo_z1', str(z1))
log.log_message(logging.INFO, f'设置拍照点1:{x1},{y1},{z1}')
except:
self.show_infomessage_box("设置拍照点1失败")
def set_p2_button_click(self):
try:
x2 = float(self.lineEdit_x2.text())
y2 = float(self.lineEdit_y2.text())
z2 = float(self.lineEdit_z2.text())
self.robotClient.photo_locs[1] = (x2, y2, z2)
self.configReader.read(Constant.set_ini)
self.configReader.set('Robot_Feed', 'photo_x2', str(x2))
self.configReader.set('Robot_Feed', 'photo_y2', str(y2))
self.configReader.set('Robot_Feed', 'photo_z2', str(z2))
log.log_message(logging.INFO, f'设置拍照点2:{x2},{y2},{z2}')
except:
self.show_infomessage_box("设置拍照点2失败")
def set_p3_button_click(self):
try:
x3 = float(self.lineEdit_x3.text())
y3 = float(self.lineEdit_y3.text())
z3 = float(self.lineEdit_z3.text())
self.robotClient.photo_locs[2] = (x3, y3, z3)
self.configReader.read(Constant.set_ini)
self.configReader.set('Robot_Feed', 'photo_x3', str(x3))
self.configReader.set('Robot_Feed', 'photo_y3', str(y3))
self.configReader.set('Robot_Feed', 'photo_z3', str(z3))
log.log_message(logging.INFO, f'设置拍照点3:{x3},{y3},{z3}')
except:
self.show_infomessage_box("设置拍照点3失败")
def updateUI_Photo_Set(self):
self.lineEdit_x1.setText(str(self.robotClient.photo_locs[0][0]))
self.lineEdit_y1.setText(str(self.robotClient.photo_locs[0][1]))
self.lineEdit_z1.setText(str(self.robotClient.photo_locs[0][2]))
self.lineEdit_x2.setText(str(self.robotClient.photo_locs[1][0]))
self.lineEdit_y2.setText(str(self.robotClient.photo_locs[1][1]))
self.lineEdit_z2.setText(str(self.robotClient.photo_locs[1][2]))
self.lineEdit_x3.setText(str(self.robotClient.photo_locs[2][0]))
self.lineEdit_y3.setText(str(self.robotClient.photo_locs[2][1]))
self.lineEdit_z3.setText(str(self.robotClient.photo_locs[2][2]))
pass
def show_infomessage_box(self,message):
msg_box = QMessageBox(self)
msg_box.setWindowTitle("提示")
msg_box.setText(message)
msg_box.setIcon(QMessageBox.Information)
msg_box.setStandardButtons(QMessageBox.OK)
if __name__ == "__main__":