更新控制
This commit is contained in:
@ -12,13 +12,16 @@ from Util.util_log import log
|
||||
|
||||
class RobotClient(TCPClient):
|
||||
|
||||
def __init__(self, ip, port, photo_locs,command_quene, status_model:DataAddress,con_ios):
|
||||
def __init__(self, ip, port, photo_locs,command_quene, status_model:DataAddress,con_ios, time_delay_take,time_delay_put,time_delay_shake):
|
||||
super().__init__(ip, port)
|
||||
self.command_quene = command_quene
|
||||
self.status_model = status_model
|
||||
self.errorCommands = {}
|
||||
self.photo_locs = photo_locs
|
||||
self.con_ios = con_ios
|
||||
self.time_delay_take= time_delay_take
|
||||
self.time_delay_put = time_delay_put
|
||||
self.time_delay_shake = time_delay_shake
|
||||
def add_sendQuene(self,command): #后面 命令分等级,紧急命令直接执行
|
||||
self.command_quene.put(command)
|
||||
return
|
||||
@ -29,21 +32,16 @@ class RobotClient(TCPClient):
|
||||
command = self.command_quene.get()
|
||||
self.client_socket.send(command.encode())
|
||||
|
||||
if False:
|
||||
if True:
|
||||
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('出错')
|
||||
# response_message = json.loads(response)
|
||||
return True
|
||||
else:
|
||||
return True
|
||||
except Exception as e:
|
||||
log.log_message(logging.ERROR, str_tcp_robot_connect_fail)
|
||||
raise
|
||||
|
||||
log.log_message(logging.ERROR, Constant.str_tcp_robot_connect_fail)
|
||||
raise
|
||||
|
||||
|
||||
|
||||
def send_Status(self):
|
||||
|
||||
@ -12,7 +12,7 @@ class TCPClient:
|
||||
self.error_count=0
|
||||
self.IPAddress = ip
|
||||
self.port = port
|
||||
|
||||
self.thread_signal = True
|
||||
self.connected = False
|
||||
|
||||
|
||||
@ -31,8 +31,8 @@ class TCPClient:
|
||||
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
time.sleep(0.2)
|
||||
while self.thread_signal:
|
||||
time.sleep(0.4)
|
||||
self.connected = (self.error_count <= 3)
|
||||
try:
|
||||
if (self.send_Status() and self.send_Command()):
|
||||
@ -53,7 +53,9 @@ class TCPClient:
|
||||
except Exception as e2:
|
||||
print(e2)
|
||||
|
||||
|
||||
def close(self):
|
||||
self.thread_signal = False
|
||||
self.client_socket.close()
|
||||
|
||||
def send_Command(self):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user