✅ update 参数调试
This commit is contained in:
@ -10,6 +10,7 @@ class TCPClient:
|
|||||||
self.port = port
|
self.port = port
|
||||||
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.client_socket.settimeout(5)
|
self.client_socket.settimeout(5)
|
||||||
|
self.connected = False
|
||||||
|
|
||||||
|
|
||||||
def CreatConnect(self):
|
def CreatConnect(self):
|
||||||
@ -26,9 +27,14 @@ class TCPClient:
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
time.sleep(30)
|
time.sleep(0.2)
|
||||||
if (self.send_Command() and self.send_Status()):
|
self.connected = self.error_count > 0
|
||||||
self.error_count=0
|
try:
|
||||||
|
#time.sleep(30)
|
||||||
|
if (self.send_Command() and self.send_Status()):
|
||||||
|
self.error_count = 0
|
||||||
|
except:
|
||||||
|
self.error_count += 1
|
||||||
|
|
||||||
|
|
||||||
def send_Command(self):
|
def send_Command(self):
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
from Model.Position import Real_Position
|
from Model.Position import Real_Position
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
from COM.COM_Robot import RobotClient
|
||||||
|
from Model.RobotModel import CMDInstructRequest
|
||||||
|
|
||||||
|
|
||||||
class FeedStatus(Enum):
|
class FeedStatus(Enum):
|
||||||
FNone = 0
|
FNone = 0
|
||||||
@ -39,22 +42,28 @@ class Feeding():
|
|||||||
def run(self):
|
def run(self):
|
||||||
# 获取事件坐标
|
# 获取事件坐标
|
||||||
real_position = Real_Position()
|
real_position = Real_Position()
|
||||||
real_position.init_position(self.robotClient.status_model.world_n[0],
|
# real_position.init_position(self.robotClient.status_model.world_n[0],
|
||||||
self.robotClient.status_model.world_n[1],
|
# self.robotClient.status_model.world_n[1],
|
||||||
self.robotClient.status_model.world_n[2],
|
# self.robotClient.status_model.world_n[2],
|
||||||
self.robotClient.status_model.world_n[3],
|
# self.robotClient.status_model.world_n[3],
|
||||||
self.robotClient.status_model.world_n[4],
|
# self.robotClient.status_model.world_n[4],
|
||||||
self.robotClient.status_model.world_n[5],
|
# self.robotClient.status_model.world_n[5],
|
||||||
self.robotClient.status_model.world_n[6]);
|
# self.robotClient.status_model.world_n[6]);
|
||||||
|
real_position.init_position(0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
|
||||||
|
|
||||||
if self.feedStatus==FeedStatus.FNone:
|
if self.feedStatus==FeedStatus.FNone:
|
||||||
|
|
||||||
pass
|
pass
|
||||||
elif self.feedStatus==FeedStatus.FStart:
|
elif self.feedStatus==FeedStatus.FStart:
|
||||||
if self.feedConfig.num != 0:
|
if self.feedConfig.num != 0:
|
||||||
self.feedStatus = FeedStatus.FSafeP
|
self.feedStatus = FeedStatus.FSafeP
|
||||||
|
|
||||||
sendTargPosition(self.feedConfig.safe_position)
|
self.sendTargPosition(self.feedConfig.safe_position)
|
||||||
#print(request_command)
|
#print(request_command)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
@ -62,7 +71,7 @@ class Feeding():
|
|||||||
|
|
||||||
if self.feedConfig.safe_position.compare(real_position):
|
if self.feedConfig.safe_position.compare(real_position):
|
||||||
self.feedStatus = FeedStatus.FPhoto
|
self.feedStatus = FeedStatus.FPhoto
|
||||||
sendTargPosition(self.feedConfig.photo_position)
|
self.sendTargPosition(self.feedConfig.photo_position)
|
||||||
|
|
||||||
elif self.feedStatus == FeedStatus.FPhoto:
|
elif self.feedStatus == FeedStatus.FPhoto:
|
||||||
if self.feedConfig.photo_position.compare(real_position):
|
if self.feedConfig.photo_position.compare(real_position):
|
||||||
@ -77,7 +86,7 @@ class Feeding():
|
|||||||
elif self.feedStatus == FeedStatus.FSafeF:
|
elif self.feedStatus == FeedStatus.FSafeF:
|
||||||
if self.feedConfig.safe_position.compare(real_position):
|
if self.feedConfig.safe_position.compare(real_position):
|
||||||
self.feedStatus = FeedStatus.FFeedP
|
self.feedStatus = FeedStatus.FFeedP
|
||||||
sendTargPosition(self.feedConfig.feed_position)
|
self.sendTargPosition(self.feedConfig.feed_position)
|
||||||
pass #吸嘴开始
|
pass #吸嘴开始
|
||||||
|
|
||||||
|
|
||||||
@ -88,10 +97,11 @@ class Feeding():
|
|||||||
self.feedStatus=FeedStatus.FNone
|
self.feedStatus=FeedStatus.FNone
|
||||||
else:
|
else:
|
||||||
self.feedStatus = FeedStatus.FSafeP
|
self.feedStatus = FeedStatus.FSafeP
|
||||||
sendTargPosition(self.feedConfig.safe_position)
|
self.sendTargPosition(self.feedConfig.safe_position)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def sendTargPosition(self,real_position):
|
def sendTargPosition(self,real_position):
|
||||||
|
from Model.RobotModel import Instruction
|
||||||
position_instruction = Instruction()
|
position_instruction = Instruction()
|
||||||
position_instruction.m0 = self.feedConfig.safe_position.X
|
position_instruction.m0 = self.feedConfig.safe_position.X
|
||||||
position_instruction.m1 = self.feedConfig.safe_position.Y
|
position_instruction.m1 = self.feedConfig.safe_position.Y
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from enum import Enum
|
|||||||
class Error_Code(Enum):
|
class Error_Code(Enum):
|
||||||
SYS_SUCCESS = 100
|
SYS_SUCCESS = 100
|
||||||
SYS_NETERROR = 104 #网络异常
|
SYS_NETERROR = 104 #网络异常
|
||||||
|
SYS_NONEPoint = 105
|
||||||
|
|
||||||
|
|
||||||
class VisionError_Code(Enum):
|
class VisionError_Code(Enum):
|
||||||
|
|||||||
163
app.py
163
app.py
@ -2,6 +2,9 @@ import configparser
|
|||||||
import json
|
import json
|
||||||
import queue
|
import queue
|
||||||
import sys
|
import sys
|
||||||
|
from multiprocessing import Process
|
||||||
|
from PySide6.QtCore import QThread, Signal, Slot
|
||||||
|
from PySide6.QtGui import QIntValidator
|
||||||
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
|
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from CU.Command import FeedCommand
|
from CU.Command import FeedCommand
|
||||||
@ -17,17 +20,16 @@ from Model.Position import Real_Position
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
from CU.Command import Status
|
from CU.Command import Status
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow,Ui_MainWindow):
|
class MainWindow(QMainWindow,Ui_MainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.init_UI()
|
self.init_UI()
|
||||||
self.init_Run()
|
self.init_Run()
|
||||||
self.init_FeedLine()
|
|
||||||
self.init_robot_info()
|
self.init_robot_info()
|
||||||
start_Runing()
|
self.init_FeedLine()
|
||||||
|
self.start_Runing()
|
||||||
|
|
||||||
|
|
||||||
def init_UI(self):
|
def init_UI(self):
|
||||||
self.horizontalSlider_J1.sliderReleased.connect(self.slider_valueChanged)
|
self.horizontalSlider_J1.sliderReleased.connect(self.slider_valueChanged)
|
||||||
@ -45,8 +47,15 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
self.pushButton_AddNum.clicked.connect(self.send_addNum_button_click)
|
self.pushButton_AddNum.clicked.connect(self.send_addNum_button_click)
|
||||||
self.pushButton_SubNum.clicked.connect(self.send_subNum_button_click)
|
self.pushButton_SubNum.clicked.connect(self.send_subNum_button_click)
|
||||||
self.pushButton_num_free.clicked.connect(self.send_num_button_click)
|
self.pushButton_num_free.clicked.connect(self.send_num_button_click)
|
||||||
|
self.lineEdit_j1.returnPressed.connect(self.send_position_returnPressed)
|
||||||
|
self.lineEdit_j2.returnPressed.connect(self.send_position_returnPressed)
|
||||||
|
self.lineEdit_j3.returnPressed.connect(self.send_position_returnPressed)
|
||||||
|
self.lineEdit_j4.returnPressed.connect(self.send_position_returnPressed)
|
||||||
|
self.lineEdit_j5.returnPressed.connect(self.send_position_returnPressed)
|
||||||
|
self.lineEdit_j6.returnPressed.connect(self.send_position_returnPressed)
|
||||||
|
|
||||||
self.lineEdit_num.returnPressed.connect(self.send_custom_num_returnPressed)
|
self.lineEdit_num.returnPressed.connect(self.send_custom_num_returnPressed)
|
||||||
int_validator = QIntValidator(0, 100, self)
|
int_validator = QIntValidator(0, 100, self.lineEdit_num)
|
||||||
self.lineEdit_num.setValidator(int_validator)
|
self.lineEdit_num.setValidator(int_validator)
|
||||||
|
|
||||||
# self.horizontalSlider_J1.sliderReleased
|
# self.horizontalSlider_J1.sliderReleased
|
||||||
@ -58,7 +67,7 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
|
|
||||||
self.command_position_quene = Queue()
|
self.command_position_quene = Queue()
|
||||||
self.status_address = DataAddress()
|
self.status_address = DataAddress()
|
||||||
self.feedLine_dict = dir()
|
self.feedLine_dict = {}
|
||||||
self.command_quene = Queue()
|
self.command_quene = Queue()
|
||||||
self.main_threading = None
|
self.main_threading = None
|
||||||
|
|
||||||
@ -66,65 +75,67 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
ip = self.configReader.get('Robot_Feed', 'IPAddress')
|
ip = self.configReader.get('Robot_Feed', 'IPAddress')
|
||||||
port = int(self.configReader.get('Robot_Feed', 'Port'))
|
port = int(self.configReader.get('Robot_Feed', 'Port'))
|
||||||
self.robotClient = RobotClient(ip, port, self.command_position_quene, self.status_address)
|
self.robotClient = RobotClient(ip, port, self.command_position_quene, self.status_address)
|
||||||
|
self.feeding = Feeding(self.robotClient) # 临时
|
||||||
|
self.last_time=time.time()
|
||||||
try:
|
try:
|
||||||
self.robotClient.CreatConnect()
|
self.robotClient.CreatConnect()
|
||||||
except:
|
except:
|
||||||
|
self.set_label_status_style(False)
|
||||||
return Error_Code.SYS_NETERROR
|
return Error_Code.SYS_NETERROR
|
||||||
|
if self.robotClient.connected:
|
||||||
if self.robotClient.is_Connect():
|
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
return Error_Code.NETERROR
|
return Error_Code.SYS_NETERROR
|
||||||
self.feeding = Feeding(self.robotClient) #临时
|
|
||||||
|
|
||||||
def init_FeedLine(self):
|
def init_FeedLine(self):
|
||||||
line_count = self.configReader.get('Robot_Feed', 'LineCount', fallback=0)
|
line_count = self.configReader.get('Robot_Feed', 'LineCount', fallback=0)
|
||||||
self.configReader.read('Config/FeedLine.ini')
|
self.configReader.read('Config/FeedLine.ini')
|
||||||
for i in range(line_count):
|
for i in range(int(line_count)):
|
||||||
line_str = f'FeedLine{i+1}'
|
line_str = f'FeedLine{i+1}'
|
||||||
safe_position = Real_Position()
|
safe_position = Real_Position()
|
||||||
photo_position = Real_Position()
|
photo_position = Real_Position()
|
||||||
feed_position = Real_Position()
|
feed_position = Real_Position()
|
||||||
|
|
||||||
safe_position.X = self.configReader.get(line_str, 'SafePosition_x', fallback=0)
|
safe_position.X = int(self.configReader.get(line_str, 'SafePosition_x', fallback=0))
|
||||||
safe_position.Y = self.configReader.get(line_str, 'SafePosition_y', fallback=0)
|
safe_position.Y = int(self.configReader.get(line_str, 'SafePosition_y', fallback=0))
|
||||||
safe_position.Z = self.configReader.get(line_str, 'SafePosition_z', fallback=0)
|
safe_position.Z = int(self.configReader.get(line_str, 'SafePosition_z', fallback=0))
|
||||||
safe_position.U = self.configReader.get(line_str, 'SafePosition_u', fallback=0)
|
safe_position.U = int(self.configReader.get(line_str, 'SafePosition_u', fallback=0))
|
||||||
safe_position.V = self.configReader.get(line_str, 'SafePosition_v', fallback=0)
|
safe_position.V = int(self.configReader.get(line_str, 'SafePosition_v', fallback=0))
|
||||||
safe_position.W = self.configReader.get(line_str, 'SafePosition_w', fallback=0)
|
safe_position.W = int(self.configReader.get(line_str, 'SafePosition_w', fallback=0))
|
||||||
|
|
||||||
photo_position.X = self.configReader.get(line_str, 'PhotoPosition_x', fallback=0)
|
photo_position.X = int(self.configReader.get(line_str, 'PhotoPosition_x', fallback=0))
|
||||||
photo_position.Y = self.configReader.get(line_str, 'PhotoPosition_y', fallback=0)
|
photo_position.Y = int(self.configReader.get(line_str, 'PhotoPosition_y', fallback=0))
|
||||||
photo_position.Z = self.configReader.get(line_str, 'PhotoPosition_z', fallback=0)
|
photo_position.Z = int(self.configReader.get(line_str, 'PhotoPosition_z', fallback=0))
|
||||||
photo_position.U = self.configReader.get(line_str, 'PhotoPosition_u', fallback=0)
|
photo_position.U = int(self.configReader.get(line_str, 'PhotoPosition_u', fallback=0))
|
||||||
photo_position.V = self.configReader.get(line_str, 'PhotoPosition_v', fallback=0)
|
photo_position.V = int(self.configReader.get(line_str, 'PhotoPosition_v', fallback=0))
|
||||||
photo_position.W = self.configReader.get(line_str, 'PhotoPosition_w', fallback=0)
|
photo_position.W = int(self.configReader.get(line_str, 'PhotoPosition_w', fallback=0))
|
||||||
|
|
||||||
|
|
||||||
feed_position.X = self.configReader.get(line_str, 'FeedPosition_x', fallback=0)
|
feed_position.X = int(self.configReader.get(line_str, 'FeedPosition_x', fallback=0))
|
||||||
feed_position.Y = self.configReader.get(line_str, 'FeedPosition_y', fallback=0)
|
feed_position.Y = int(self.configReader.get(line_str, 'FeedPosition_y', fallback=0))
|
||||||
feed_position.Z = self.configReader.get(line_str, 'FeedPosition_z', fallback=0)
|
feed_position.Z = int(self.configReader.get(line_str, 'FeedPosition_z', fallback=0))
|
||||||
feed_position.U = self.configReader.get(line_str, 'FeedPosition_u', fallback=0)
|
feed_position.U = int(self.configReader.get(line_str, 'FeedPosition_u', fallback=0))
|
||||||
feed_position.V = self.configReader.get(line_str, 'FeedPosition_v', fallback=0)
|
feed_position.V = int(self.configReader.get(line_str, 'FeedPosition_v', fallback=0))
|
||||||
feed_position.W = self.configReader.get(line_str, 'FeedPosition_w', fallback=0)
|
feed_position.W = int(self.configReader.get(line_str, 'FeedPosition_w', fallback=0))
|
||||||
|
|
||||||
self.feedLine_dict[str(i+1)] = FeedLine(safe_position, photo_position, feed_position)
|
self.feedLine_dict[str(i+1)] = FeedLine(safe_position, photo_position, feed_position)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def init_robot_info(self):
|
def init_robot_info(self):
|
||||||
j1_min = int(self.configReader.get('Robot', 'j1_min'))
|
j1_min = int(self.configReader.get('Robot_Feed', 'j1_min'))
|
||||||
j1_max = int(self.configReader.get('Robot', 'j1_max'))
|
j1_max = int(self.configReader.get('Robot_Feed', 'j1_max'))
|
||||||
j2_min = int(self.configReader.get('Robot', 'j2_min'))
|
j2_min = int(self.configReader.get('Robot_Feed', 'j2_min'))
|
||||||
j2_max = int(self.configReader.get('Robot', 'j2_max'))
|
j2_max = int(self.configReader.get('Robot_Feed', 'j2_max'))
|
||||||
j3_min = int(self.configReader.get('Robot', 'j3_min'))
|
j3_min = int(self.configReader.get('Robot_Feed', 'j3_min'))
|
||||||
j3_max = int(self.configReader.get('Robot', 'j3_max'))
|
j3_max = int(self.configReader.get('Robot_Feed', 'j3_max'))
|
||||||
j4_min = int(self.configReader.get('Robot', 'j4_min'))
|
j4_min = int(self.configReader.get('Robot_Feed', 'j4_min'))
|
||||||
j4_max = int(self.configReader.get('Robot', 'j4_max'))
|
j4_max = int(self.configReader.get('Robot_Feed', 'j4_max'))
|
||||||
j5_min = int(self.configReader.get('Robot', 'j5_min'))
|
j5_min = int(self.configReader.get('Robot_Feed', 'j5_min'))
|
||||||
j5_max = int(self.configReader.get('Robot', 'j5_max'))
|
j5_max = int(self.configReader.get('Robot_Feed', 'j5_max'))
|
||||||
j6_min = int(self.configReader.get('Robot', 'j6_min'))
|
j6_min = int(self.configReader.get('Robot_Feed', 'j6_min'))
|
||||||
j6_max = int(self.configReader.get('Robot', 'j6_max'))
|
j6_max = int(self.configReader.get('Robot_Feed', 'j6_max'))
|
||||||
self.horizontalSlider_J1.setMinimum(j1_min)
|
self.horizontalSlider_J1.setMinimum(j1_min)
|
||||||
self.horizontalSlider_J1.setMaximum(j1_max)
|
self.horizontalSlider_J1.setMaximum(j1_max)
|
||||||
self.horizontalSlider_J2.setMinimum(j2_min)
|
self.horizontalSlider_J2.setMinimum(j2_min)
|
||||||
@ -151,9 +162,14 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
self.label_j6_max.setText(str(j6_max))
|
self.label_j6_max.setText(str(j6_max))
|
||||||
|
|
||||||
def start_Runing(self):
|
def start_Runing(self):
|
||||||
self.main_threading = Thread(target=run)
|
self.main_threading = Thread(target=self.run)
|
||||||
|
self.robot_connect_threading = Thread(target=self.robotClient.run)
|
||||||
self.main_threading.start()
|
self.main_threading.start()
|
||||||
|
|
||||||
|
|
||||||
|
self.robot_connect_threading.start()
|
||||||
|
pass
|
||||||
|
|
||||||
def send_startFeed_button_click(self):
|
def send_startFeed_button_click(self):
|
||||||
num = self.horizontalSlider_feedingNum.value()
|
num = self.horizontalSlider_feedingNum.value()
|
||||||
line_index = str(self.comboBox_lineIndex.currentIndex()+1)
|
line_index = str(self.comboBox_lineIndex.currentIndex()+1)
|
||||||
@ -165,6 +181,7 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
if button.text() != "自定义":
|
if button.text() != "自定义":
|
||||||
num = int(button.text())
|
num = int(button.text())
|
||||||
self.horizontalSlider_feedingNum.setMaximum(num)
|
self.horizontalSlider_feedingNum.setMaximum(num)
|
||||||
|
self.label_maxNum.setText(str(num))
|
||||||
self.horizontalSlider_feedingNum.setValue(0)
|
self.horizontalSlider_feedingNum.setValue(0)
|
||||||
else:
|
else:
|
||||||
self.pushButton_num_free.hide()
|
self.pushButton_num_free.hide()
|
||||||
@ -180,14 +197,16 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
def send_custom_num_returnPressed(self):
|
def send_custom_num_returnPressed(self):
|
||||||
self.pushButton_num_free.show()
|
self.pushButton_num_free.show()
|
||||||
self.lineEdit_num.hide()
|
self.lineEdit_num.hide()
|
||||||
self.horizontalSlider_feedingNum.setValue(int(self.lineEdit_num.text()))
|
self.horizontalSlider_feedingNum.setMaximum(int(self.lineEdit_num.text()))
|
||||||
|
self.horizontalSlider_feedingNum.setValue(0)
|
||||||
|
self.label_maxNum.setText(self.lineEdit_num.text())
|
||||||
|
|
||||||
def slider_valueChanged(self):
|
def slider_valueChanged(self):
|
||||||
global last_time
|
|
||||||
now_time = time.time()
|
now_time = time.time()
|
||||||
if(now_time-last_time) < 2:
|
if(now_time-self.last_time) < 2:
|
||||||
return
|
return
|
||||||
last_time = now_time
|
self.last_time = now_time
|
||||||
position_instruction = Instruction()
|
position_instruction = Instruction()
|
||||||
position_instruction.m0 = self.horizontalSlider_J1.value()
|
position_instruction.m0 = self.horizontalSlider_J1.value()
|
||||||
position_instruction.m1 = self.horizontalSlider_J2.value()
|
position_instruction.m1 = self.horizontalSlider_J2.value()
|
||||||
@ -196,12 +215,14 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
position_instruction.m4 = self.horizontalSlider_J5.value()
|
position_instruction.m4 = self.horizontalSlider_J5.value()
|
||||||
position_instruction.m5 = self.horizontalSlider_J6.value()
|
position_instruction.m5 = self.horizontalSlider_J6.value()
|
||||||
|
|
||||||
self.textEdit_j1.setText(str(self.horizontalSlider_J1.value()))
|
|
||||||
self.textEdit_j2.setText(str(self.horizontalSlider_J2.value()))
|
|
||||||
self.textEdit_j3.setText(str(self.horizontalSlider_J3.value()))
|
self.lineEdit_j1.setText(str(self.horizontalSlider_J1.value()))
|
||||||
self.textEdit_j4.setText(str(self.horizontalSlider_J4.value()))
|
self.lineEdit_j2.setText(str(self.horizontalSlider_J2.value()))
|
||||||
self.textEdit_j5.setText(str(self.horizontalSlider_J5.value()))
|
self.lineEdit_j3.setText(str(self.horizontalSlider_J3.value()))
|
||||||
self.textEdit_j6.setText(str(self.horizontalSlider_J6.value()))
|
self.lineEdit_j4.setText(str(self.horizontalSlider_J4.value()))
|
||||||
|
self.lineEdit_j5.setText(str(self.horizontalSlider_J5.value()))
|
||||||
|
self.lineEdit_j6.setText(str(self.horizontalSlider_J6.value()))
|
||||||
|
|
||||||
instruction_command = CMDInstructRequest()
|
instruction_command = CMDInstructRequest()
|
||||||
instruction_command.instructions.append(vars(position_instruction))
|
instruction_command.instructions.append(vars(position_instruction))
|
||||||
@ -219,7 +240,27 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
# request_command = vars(cmd_command)
|
# request_command = vars(cmd_command)
|
||||||
# self.robotClient.add_sendQuene(request_command)
|
# self.robotClient.add_sendQuene(request_command)
|
||||||
return
|
return
|
||||||
|
def send_position_returnPressed(self):
|
||||||
|
position_instruction = Instruction()
|
||||||
|
position_instruction.m0 = int(self.lineEdit_j1.text())
|
||||||
|
position_instruction.m1 = int(self.lineEdit_j2.text())
|
||||||
|
position_instruction.m2 = int(self.lineEdit_j3.text())
|
||||||
|
position_instruction.m3 = int(self.lineEdit_j4.text())
|
||||||
|
position_instruction.m4 = int(self.lineEdit_j5.text())
|
||||||
|
position_instruction.m5 = int(self.lineEdit_j6.text())
|
||||||
|
|
||||||
|
self.horizontalSlider_J1.setValue(int(self.lineEdit_j1.text()))
|
||||||
|
self.horizontalSlider_J2.setValue(int(self.lineEdit_j2.text()))
|
||||||
|
self.horizontalSlider_J3.setValue(int(self.lineEdit_j3.text()))
|
||||||
|
self.horizontalSlider_J4.setValue(int(self.lineEdit_j4.text()))
|
||||||
|
self.horizontalSlider_J5.setValue(int(self.lineEdit_j5.text()))
|
||||||
|
self.horizontalSlider_J6.setValue(int(self.lineEdit_j6.text()))
|
||||||
|
|
||||||
|
instruction_command = CMDInstructRequest()
|
||||||
|
instruction_command.instructions.append(vars(position_instruction))
|
||||||
|
request_command = vars(instruction_command)
|
||||||
|
print(request_command)
|
||||||
|
self.robotClient.add_sendQuene(request_command)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -229,7 +270,7 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
|
time.sleep(0.2)
|
||||||
if not self.command_quene.empty():
|
if not self.command_quene.empty():
|
||||||
command = self.command_quene.get()
|
command = self.command_quene.get()
|
||||||
if isinstance(command, FeedCommand) and command.status == Status.Prepareing:
|
if isinstance(command, FeedCommand) and command.status == Status.Prepareing:
|
||||||
@ -238,18 +279,21 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
self.feeding.feedStatus = FeedStatus.FStart
|
self.feeding.feedStatus = FeedStatus.FStart
|
||||||
command.status = Status.Runing
|
command.status = Status.Runing
|
||||||
|
|
||||||
|
try:
|
||||||
self.feeding.run()
|
self.feeding.run()
|
||||||
updateUI(self)
|
except:
|
||||||
|
print(Error_Code.SYS_NONEPoint)
|
||||||
|
self.updateUI()
|
||||||
|
|
||||||
#pass #主线程
|
#pass #主线程
|
||||||
|
|
||||||
def updateUI(self):
|
def updateUI(self):
|
||||||
if self.robotClient.is_Connect():
|
if self.robotClient.connected:
|
||||||
self.set_label_status_style(True)
|
self.set_label_status_style(True)
|
||||||
else:
|
else:
|
||||||
self.set_label_status_style(False)
|
self.set_label_status_style(False)
|
||||||
self.horizontalSlider_feedingNum.setValue(self.horizontalSlider_feedingNum.maximum()-self.feeding.feedConfig.num)
|
if self.feeding.feedStatus != FeedStatus.FNone:
|
||||||
|
self.horizontalSlider_feedingNum.setValue(self.horizontalSlider_feedingNum.maximum()-self.feeding.feedConfig.num)
|
||||||
if self.horizontalSlider_feedingNum.value() == 0:
|
if self.horizontalSlider_feedingNum.value() == 0:
|
||||||
self.stackedWidget_num.setCurrentIndex(0)
|
self.stackedWidget_num.setCurrentIndex(0)
|
||||||
else:
|
else:
|
||||||
@ -258,8 +302,7 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
self.label_date.setText(datetime.now().strftime("%Y-%m-%d"))
|
self.label_date.setText(datetime.now().strftime("%Y-%m-%d"))
|
||||||
self.label_time.setText(datetime.now().strftime("%H:%M:%S"))
|
self.label_time.setText(datetime.now().strftime("%H:%M:%S"))
|
||||||
|
|
||||||
def set_label_status_style(self,connected:bool):
|
def set_label_status_style(self, connected: bool):
|
||||||
palette = self.label_connect_status.palette()
|
|
||||||
if connected:
|
if connected:
|
||||||
self.label_connect_status.setStyleSheet("""
|
self.label_connect_status.setStyleSheet("""
|
||||||
QLabel {
|
QLabel {
|
||||||
|
|||||||
49900
resources_rc.py
49900
resources_rc.py
File diff suppressed because it is too large
Load Diff
73
test.py
73
test.py
@ -0,0 +1,73 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from PySide6.QtCore import (QThread, Signal, Slot, QSize)
|
||||||
|
from PySide6.QtWidgets import (QApplication, QPushButton, QLabel, QVBoxLayout, QWidget)
|
||||||
|
class WorkerThread(QThread):
|
||||||
|
# 定义一个信号,用于在线程中发送数据给主线程
|
||||||
|
update_label = Signal(str)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
while True:
|
||||||
|
for i in range(5):
|
||||||
|
time.sleep(2) # 模拟耗时操作
|
||||||
|
self.update_label.emit(f"{i + 1}")
|
||||||
|
|
||||||
|
class MyThread(QThread):
|
||||||
|
signal_tuple = Signal(tuple)
|
||||||
|
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
while True:
|
||||||
|
for idx in range(1, 10):
|
||||||
|
time.sleep(2)
|
||||||
|
# 任务完成后发出信号
|
||||||
|
self.signal_tuple.emit((idx, ''))
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow(QWidget):
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent=parent)
|
||||||
|
self.setup_ui()
|
||||||
|
#
|
||||||
|
self.button.clicked.connect(self.setup_thread)
|
||||||
|
|
||||||
|
def setup_ui(self):
|
||||||
|
self.setWindowTitle('demo')
|
||||||
|
self.resize(QSize(250, 180))
|
||||||
|
# 创建一个垂直布局
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
# 创建一个标签
|
||||||
|
self.label = QLabel('This is a label => ')
|
||||||
|
layout.addWidget(self.label)
|
||||||
|
# 创建一个按钮
|
||||||
|
self.button = QPushButton('Send Request')
|
||||||
|
layout.addWidget(self.button)
|
||||||
|
# 将布局设置为主窗口的布局
|
||||||
|
self.setLayout(layout)
|
||||||
|
# 显示窗口
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
def setup_thread(self):
|
||||||
|
self.thread_ = MyThread()
|
||||||
|
self.thread_.signal_tuple.connect(self.thread_finished)
|
||||||
|
self.thread_.start()
|
||||||
|
|
||||||
|
def send_request(self):
|
||||||
|
return requests.get('https://www.csdn.net/').text[:15]
|
||||||
|
|
||||||
|
@Slot(tuple)
|
||||||
|
def thread_finished(self, item):
|
||||||
|
self.label.setText('This is a label => ' + str(item))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app = QApplication([])
|
||||||
|
window = MainWindow()
|
||||||
|
window.show()
|
||||||
|
app.exec()
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,8 @@ class Ui_MainWindow(object):
|
|||||||
self.label_4 = QLabel(self.frame_3)
|
self.label_4 = QLabel(self.frame_3)
|
||||||
self.label_4.setObjectName(u"label_4")
|
self.label_4.setObjectName(u"label_4")
|
||||||
self.label_4.setGeometry(QRect(10, 10, 481, 261))
|
self.label_4.setGeometry(QRect(10, 10, 481, 261))
|
||||||
self.label_4.setStyleSheet(u"border-image: url(:bg/Image/robot.png);\n"
|
self.label_4.setStyleSheet(u"\n"
|
||||||
|
"background-image: url(:/bg/Image/robot.png);\n"
|
||||||
"background-position:center;\n"
|
"background-position:center;\n"
|
||||||
"background-repeat:no-repeat;")
|
"background-repeat:no-repeat;")
|
||||||
self.label_4.setScaledContents(True)
|
self.label_4.setScaledContents(True)
|
||||||
@ -163,10 +164,10 @@ class Ui_MainWindow(object):
|
|||||||
"\n"
|
"\n"
|
||||||
"")
|
"")
|
||||||
self.horizontalSlider_feedingNum.setOrientation(Qt.Orientation.Horizontal)
|
self.horizontalSlider_feedingNum.setOrientation(Qt.Orientation.Horizontal)
|
||||||
self.label_5 = QLabel(self.frame_3)
|
self.label_maxNum = QLabel(self.frame_3)
|
||||||
self.label_5.setObjectName(u"label_5")
|
self.label_maxNum.setObjectName(u"label_maxNum")
|
||||||
self.label_5.setGeometry(QRect(800, 160, 31, 21))
|
self.label_maxNum.setGeometry(QRect(800, 160, 31, 21))
|
||||||
self.label_5.setStyleSheet(u"font: 9pt \"\u6977\u4f53\";")
|
self.label_maxNum.setStyleSheet(u"font: 9pt \"\u6977\u4f53\";")
|
||||||
self.frame_4 = QFrame(self.frame_3)
|
self.frame_4 = QFrame(self.frame_3)
|
||||||
self.frame_4.setObjectName(u"frame_4")
|
self.frame_4.setObjectName(u"frame_4")
|
||||||
self.frame_4.setGeometry(QRect(500, 200, 331, 251))
|
self.frame_4.setGeometry(QRect(500, 200, 331, 251))
|
||||||
@ -451,11 +452,29 @@ class Ui_MainWindow(object):
|
|||||||
"}\n"
|
"}\n"
|
||||||
"")
|
"")
|
||||||
self.pushButton_38.setIcon(icon)
|
self.pushButton_38.setIcon(icon)
|
||||||
|
self.lineEdit_j1 = QLineEdit(self.frame_4)
|
||||||
|
self.lineEdit_j1.setObjectName(u"lineEdit_j1")
|
||||||
|
self.lineEdit_j1.setGeometry(QRect(140, 3, 41, 21))
|
||||||
|
self.lineEdit_j2 = QLineEdit(self.frame_4)
|
||||||
|
self.lineEdit_j2.setObjectName(u"lineEdit_j2")
|
||||||
|
self.lineEdit_j2.setGeometry(QRect(140, 41, 41, 21))
|
||||||
|
self.lineEdit_j3 = QLineEdit(self.frame_4)
|
||||||
|
self.lineEdit_j3.setObjectName(u"lineEdit_j3")
|
||||||
|
self.lineEdit_j3.setGeometry(QRect(140, 82, 41, 21))
|
||||||
|
self.lineEdit_j4 = QLineEdit(self.frame_4)
|
||||||
|
self.lineEdit_j4.setObjectName(u"lineEdit_j4")
|
||||||
|
self.lineEdit_j4.setGeometry(QRect(140, 120, 41, 21))
|
||||||
|
self.lineEdit_j5 = QLineEdit(self.frame_4)
|
||||||
|
self.lineEdit_j5.setObjectName(u"lineEdit_j5")
|
||||||
|
self.lineEdit_j5.setGeometry(QRect(140, 162, 41, 21))
|
||||||
|
self.lineEdit_j6 = QLineEdit(self.frame_4)
|
||||||
|
self.lineEdit_j6.setObjectName(u"lineEdit_j6")
|
||||||
|
self.lineEdit_j6.setGeometry(QRect(140, 200, 41, 21))
|
||||||
self.textEdit_log = QTextEdit(self.frame_3)
|
self.textEdit_log = QTextEdit(self.frame_3)
|
||||||
self.textEdit_log.setObjectName(u"textEdit_log")
|
self.textEdit_log.setObjectName(u"textEdit_log")
|
||||||
self.textEdit_log.setGeometry(QRect(10, 280, 481, 171))
|
self.textEdit_log.setGeometry(QRect(10, 280, 481, 171))
|
||||||
self.textEdit_log.setStyleSheet(u"*{\n"
|
self.textEdit_log.setStyleSheet(u"*{\n"
|
||||||
" \n"
|
" background-image: url(:/bg/Image/robot.png);\n"
|
||||||
" background-color: #E6ECF5;\n"
|
" background-color: #E6ECF5;\n"
|
||||||
"}")
|
"}")
|
||||||
self.comboBox_lineIndex = QComboBox(self.frame_3)
|
self.comboBox_lineIndex = QComboBox(self.frame_3)
|
||||||
@ -815,7 +834,7 @@ class Ui_MainWindow(object):
|
|||||||
self.pushButton_4.setText(QCoreApplication.translate("MainWindow", u"\u6295\u6599\u8bbe\u7f6e", None))
|
self.pushButton_4.setText(QCoreApplication.translate("MainWindow", u"\u6295\u6599\u8bbe\u7f6e", None))
|
||||||
self.pushButton_5.setText(QCoreApplication.translate("MainWindow", u"IO\u8c03\u8bd5", None))
|
self.pushButton_5.setText(QCoreApplication.translate("MainWindow", u"IO\u8c03\u8bd5", None))
|
||||||
self.label_4.setText("")
|
self.label_4.setText("")
|
||||||
self.label_5.setText(QCoreApplication.translate("MainWindow", u"10", None))
|
self.label_maxNum.setText(QCoreApplication.translate("MainWindow", u"10", None))
|
||||||
self.label_j1_min.setText(QCoreApplication.translate("MainWindow", u"-10", None))
|
self.label_j1_min.setText(QCoreApplication.translate("MainWindow", u"-10", None))
|
||||||
self.label_j1_max.setText(QCoreApplication.translate("MainWindow", u"+10", None))
|
self.label_j1_max.setText(QCoreApplication.translate("MainWindow", u"+10", None))
|
||||||
self.label_j2_min.setText(QCoreApplication.translate("MainWindow", u"-150", None))
|
self.label_j2_min.setText(QCoreApplication.translate("MainWindow", u"-150", None))
|
||||||
@ -866,7 +885,8 @@ class Ui_MainWindow(object):
|
|||||||
self.pushButton_num4.setText(QCoreApplication.translate("MainWindow", u"40", None))
|
self.pushButton_num4.setText(QCoreApplication.translate("MainWindow", u"40", None))
|
||||||
self.pushButton_num_free.setText(QCoreApplication.translate("MainWindow", u"\u81ea\u5b9a\u4e49", None))
|
self.pushButton_num_free.setText(QCoreApplication.translate("MainWindow", u"\u81ea\u5b9a\u4e49", None))
|
||||||
self.pushButton_num2.setText(QCoreApplication.translate("MainWindow", u"20", None))
|
self.pushButton_num2.setText(QCoreApplication.translate("MainWindow", u"20", None))
|
||||||
self.lineEdit_num.setText(QCoreApplication.translate("MainWindow", u"123", None))
|
self.lineEdit_num.setText("")
|
||||||
|
self.lineEdit_num.setPlaceholderText(QCoreApplication.translate("MainWindow", u"0-100", None))
|
||||||
self.pushButton_AddNum.setText(QCoreApplication.translate("MainWindow", u"\u8865\u4e00\u888b", None))
|
self.pushButton_AddNum.setText(QCoreApplication.translate("MainWindow", u"\u8865\u4e00\u888b", None))
|
||||||
self.pushButton_SubNum.setText(QCoreApplication.translate("MainWindow", u"\u6263\u4e00\u888b", None))
|
self.pushButton_SubNum.setText(QCoreApplication.translate("MainWindow", u"\u6263\u4e00\u888b", None))
|
||||||
self.pushButton_16.setText(QCoreApplication.translate("MainWindow", u"\u6025\u505c", None))
|
self.pushButton_16.setText(QCoreApplication.translate("MainWindow", u"\u6025\u505c", None))
|
||||||
|
|||||||
72
untitled.ui
72
untitled.ui
@ -169,7 +169,8 @@ border-radius: 10px;</string>
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">border-image: url(:bg/Image/robot.png);
|
<string notr="true">
|
||||||
|
background-image: url(:/bg/Image/robot.png);
|
||||||
background-position:center;
|
background-position:center;
|
||||||
background-repeat:no-repeat;</string>
|
background-repeat:no-repeat;</string>
|
||||||
</property>
|
</property>
|
||||||
@ -263,7 +264,7 @@ QSlider::sub-page:horizontal
|
|||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_maxNum">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>800</x>
|
<x>800</x>
|
||||||
@ -987,6 +988,66 @@ font: 10pt "楷体";
|
|||||||
<iconset theme="QIcon::ThemeIcon::ListAdd"/>
|
<iconset theme="QIcon::ThemeIcon::ListAdd"/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_j1">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>140</x>
|
||||||
|
<y>3</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_j2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>140</x>
|
||||||
|
<y>41</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_j3">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>140</x>
|
||||||
|
<y>82</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_j4">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>140</x>
|
||||||
|
<y>120</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_j5">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>140</x>
|
||||||
|
<y>162</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_j6">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>140</x>
|
||||||
|
<y>200</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTextEdit" name="textEdit_log">
|
<widget class="QTextEdit" name="textEdit_log">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@ -999,7 +1060,7 @@ font: 10pt "楷体";
|
|||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">*{
|
<string notr="true">*{
|
||||||
|
background-image: url(:/bg/Image/robot.png);
|
||||||
background-color: #E6ECF5;
|
background-color: #E6ECF5;
|
||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1294,11 +1355,14 @@ border-radius: 10px;
|
|||||||
font: 10pt "楷体";</string>
|
font: 10pt "楷体";</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>123</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>0-100</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<zorder>lineEdit_num</zorder>
|
<zorder>lineEdit_num</zorder>
|
||||||
<zorder>pushButton_num5</zorder>
|
<zorder>pushButton_num5</zorder>
|
||||||
|
|||||||
Reference in New Issue
Block a user