update 更新
This commit is contained in:
@ -5,13 +5,13 @@ from Model.RobotModel import DataAddress,DATARequest
|
||||
|
||||
class RobotClient(TCPClient):
|
||||
|
||||
def __init__(self,ip,port,command_quene,status_model):
|
||||
super.__init__(ip,port)
|
||||
def __init__(self, ip, port, command_quene, status_model):
|
||||
super().__init__(ip, port)
|
||||
self.command_quene = command_quene
|
||||
self.status_model = status_model
|
||||
self.errorCommands = {}
|
||||
|
||||
def add_sendQuene(self,command):
|
||||
def add_sendQuene(self,command): #后面 命令分等级,紧急命令直接执行
|
||||
self.command_quene.put(command)
|
||||
return
|
||||
|
||||
@ -24,13 +24,14 @@ class RobotClient(TCPClient):
|
||||
command = self.command_quene.get()
|
||||
self.client_socket.send(json.dumps(command).encode('utf-8'))
|
||||
|
||||
response = self.client_socket.recv(1024).decode('utf-8')
|
||||
response_message = json.loads(response)
|
||||
if True:
|
||||
print('正确相应')
|
||||
else:
|
||||
self.errorCommands[json.dumps(command).encode('utf-8')] = response_message
|
||||
print('出错')
|
||||
if False:
|
||||
response = self.client_socket.recv(1024).decode('utf-8')
|
||||
response_message = json.loads(response)
|
||||
if True:
|
||||
print('正确相应')
|
||||
else:
|
||||
self.errorCommands[json.dumps(command).encode('utf-8')] = response_message
|
||||
print('出错')
|
||||
except Exception as e:
|
||||
print('连接断开')
|
||||
|
||||
@ -49,18 +50,19 @@ class RobotClient(TCPClient):
|
||||
while True:
|
||||
try:
|
||||
self.client_socket.send(json.dumps(request_status_json).encode('utf-8'))
|
||||
response = self.client_socket.recv(1024).decode('utf-8')
|
||||
response_message = json.loads(response)
|
||||
if True:
|
||||
data_status = DATARequest()
|
||||
data_status.__dict__ = response_message
|
||||
data_address_array = data_status.queryAddr
|
||||
data_Address = DataAddress()
|
||||
for i in attributes.count():
|
||||
setattr(data_Address,attributes[i],data_address_array[i])
|
||||
self.status_model = data_Address
|
||||
else:
|
||||
print('转换失败')
|
||||
if False:
|
||||
response = self.client_socket.recv(1024).decode('utf-8')
|
||||
response_message = json.loads(response)
|
||||
if True:
|
||||
data_status = DATARequest()
|
||||
data_status.__dict__ = response_message
|
||||
data_address_array = data_status.queryAddr
|
||||
data_Address = DataAddress()
|
||||
for i in attributes.count():
|
||||
setattr(data_Address,attributes[i],data_address_array[i])
|
||||
self.status_model = data_Address
|
||||
else:
|
||||
print('转换失败')
|
||||
except Exception as e:
|
||||
print('连接断开')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user