update 通信方式
This commit is contained in:
@ -39,13 +39,11 @@ class RobotClient(TCPClient):
|
|||||||
|
|
||||||
def send_Status(self):
|
def send_Status(self):
|
||||||
request = DATARequest()
|
request = DATARequest()
|
||||||
|
dataAddr = DataAddress()
|
||||||
attributes = dir(DataAddress())
|
request.queryAddr.append(dataAddr)
|
||||||
|
|
||||||
# 移除特殊属性和方法
|
# 移除特殊属性和方法
|
||||||
attributes = [attr for attr in attributes if not attr.startswith('__')]
|
request_status_json = request.toString()
|
||||||
request.queryAddr= attributes
|
|
||||||
request_status_json = vars(request)
|
|
||||||
# 转字符串
|
# 转字符串
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class TCPClient:
|
|||||||
self.connected = self.error_count > 0
|
self.connected = self.error_count > 0
|
||||||
try:
|
try:
|
||||||
#time.sleep(30)
|
#time.sleep(30)
|
||||||
if (self.send_Command() and self.send_Status()):
|
if (self.send_Status() and self.send_Command()):
|
||||||
self.error_count = 0
|
self.error_count = 0
|
||||||
except:
|
except:
|
||||||
self.error_count += 1
|
self.error_count += 1
|
||||||
|
|||||||
@ -3,6 +3,10 @@ class DATARequest:
|
|||||||
self.dsID = 'www.hc-system.com.RemoteMonitor"'
|
self.dsID = 'www.hc-system.com.RemoteMonitor"'
|
||||||
self.reqType = 'query'
|
self.reqType = 'query'
|
||||||
self.queryAddr = []
|
self.queryAddr = []
|
||||||
|
def toString(self):
|
||||||
|
model_str = '{'+f'"dsID":"{self.dsID}","reqType":"{self.reqType}","queryAddr":[' \
|
||||||
|
f'"{self.queryAddr[0].toString()}"]'+'}'
|
||||||
|
return model_str
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -32,6 +36,10 @@ class DataAddress:
|
|||||||
self.M_n = ''
|
self.M_n = ''
|
||||||
#return
|
#return
|
||||||
|
|
||||||
|
def toString(self):
|
||||||
|
model_str = f'"world_n"'
|
||||||
|
return model_str
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -71,11 +79,17 @@ class Instruction:
|
|||||||
self.m3 = 0.0
|
self.m3 = 0.0
|
||||||
self.m4 = 0.0
|
self.m4 = 0.0
|
||||||
self.m5 = 0.0
|
self.m5 = 0.0
|
||||||
self.skStatus = '0x3F'
|
self.ckStatus = '0x3F'
|
||||||
self.speed =10
|
self.speed =10
|
||||||
self.delay = 0
|
self.delay = 1.0
|
||||||
self.smooth = 0
|
self.smooth = 0
|
||||||
|
|
||||||
|
def toString(self):
|
||||||
|
model_str = f'"oneshot":"{self.oneshot}","action":"{self.action}","m0":"{self.m0}","m1":"{self.m1}","m2":"{self.m2}",' \
|
||||||
|
f'"m3":"{self.m3}","m4":"{self.m4}","m5":"{self.m5}"'
|
||||||
|
return model_str
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CMDInstructRequest:
|
class CMDInstructRequest:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -83,8 +97,11 @@ class CMDInstructRequest:
|
|||||||
self.reqType = "AddRCC"
|
self.reqType = "AddRCC"
|
||||||
self.emptyList = '1'
|
self.emptyList = '1'
|
||||||
self.instructions = []
|
self.instructions = []
|
||||||
return
|
|
||||||
|
|
||||||
|
def toString(self):
|
||||||
|
model_str = '{'+f'"dsID":"{self.dsID}","reqType":"{self.reqType}","emptyList":"{self.emptyList}","instructions":'
|
||||||
|
model_str = model_str+"[{"+self.instructions[0].toString()+"}]"+"}"
|
||||||
|
return model_str
|
||||||
|
|
||||||
class CMDInstructReply:
|
class CMDInstructReply:
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
[Robot_Feed]
|
[Robot_Feed]
|
||||||
IPAddress=192.168.3.5
|
IPAddress=192.168.10.4
|
||||||
Port=8111
|
Port=502
|
||||||
j1_min=-150
|
j1_min=-150
|
||||||
j1_max=+150
|
j1_max=+150
|
||||||
j2_min=-150
|
j2_min=-150
|
||||||
|
|||||||
4
app.py
4
app.py
@ -225,8 +225,8 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
|||||||
self.lineEdit_j6.setText(str(self.horizontalSlider_J6.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(position_instruction)
|
||||||
request_command = vars(instruction_command)
|
request_command = instruction_command.toString()
|
||||||
print(request_command)
|
print(request_command)
|
||||||
self.robotClient.add_sendQuene(request_command)
|
self.robotClient.add_sendQuene(request_command)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user