|
@@ -95,10 +95,17 @@ class ExportIO(threading.Thread):
|
|
|
print("Connected to {}:{}".format(self._ip, self._port))
|
|
|
return reader, writer
|
|
|
async def recv_loop(self):
|
|
|
+ if (self._id == 5):
|
|
|
+ print(" test 1 ")
|
|
|
while self._close==False:
|
|
|
+ if (self._id == 5):
|
|
|
+ print(" test 2 ")
|
|
|
try:
|
|
|
recieve=await self._reader.readuntil(b'$')
|
|
|
+ if (self._id == 5):
|
|
|
+ print(" 00 recieve = " + str(recieve))
|
|
|
except Exception as e:
|
|
|
+ print("self._reader.readuntil(b'$') error")
|
|
|
print(" e: {}".format(e))
|
|
|
self._reader,self._writer=await self.connect()
|
|
|
await asyncio.sleep(0.001)
|
|
@@ -113,16 +120,24 @@ class ExportIO(threading.Thread):
|
|
|
self._latest_iomsg =self.recieve2message(bytes)
|
|
|
if (not self._rabbit_mq == None) and (not self._latest_iomsg == None):
|
|
|
if self._latest_iomsg.outside_safety == 0 or self._latest_iomsg.door_statu == 0:
|
|
|
+ print("self._latest_iomsg error")
|
|
|
continue
|
|
|
else:
|
|
|
+ if (self._id == 5):
|
|
|
+ print(" 11 recieve = " + str(recieve))
|
|
|
ex_name = "statu_ex"
|
|
|
key = "out_mcpu_%d_statu_port" % self._id
|
|
|
self._rabbit_mq.publish(ex_name, key, tf.MessageToString(self._latest_iomsg, as_utf8=True))
|
|
|
+ else:
|
|
|
+ print("self._rabbit_mq")
|
|
|
+ print(self._rabbit_mq)
|
|
|
+ print("self._latest_iomsg")
|
|
|
+ print(self._latest_iomsg)
|
|
|
else:
|
|
|
print(" start_index = %s"%start_index)
|
|
|
print("end_index = %s"%end_index)
|
|
|
print("WARNING : mcpu recieve format error , time = %s"%time.time())
|
|
|
- print(" recieve = " + str(recieve))
|
|
|
+ print(" 22 recieve = " + str(recieve))
|
|
|
await asyncio.sleep(0)
|
|
|
|
|
|
continue
|
|
@@ -160,11 +175,15 @@ class ExportIO(threading.Thread):
|
|
|
if 'InsideExistenceFlag' in data.keys():
|
|
|
statu_msg.outside_safety = data['InsideExistenceFlag'] + 1
|
|
|
else:
|
|
|
+ print("statu_msg.outside_safety not live")
|
|
|
+ print(bytes)
|
|
|
statu_msg.outside_safety = 0
|
|
|
|
|
|
if 'OutsideDoorStatus' in data.keys():
|
|
|
statu_msg.door_statu = data["OutsideDoorStatus"] + 1 # 1 k 2g 3 running
|
|
|
else:
|
|
|
+ print("statu_msg.door_statu not live ")
|
|
|
+ print(bytes)
|
|
|
statu_msg.door_statu = 0
|
|
|
|
|
|
return statu_msg
|