Browse Source

2022/12/09 入口提示节点增加显示车牌号,检查节点重写

wk 2 years ago
parent
commit
dc45dbb13d

+ 1 - 0
.gitignore

@@ -36,3 +36,4 @@ packages/
 .idea*
 *.dll
 终端/ct_terminal/ct_terminal/Resource*
+管理节点/*

+ 5 - 0
message.proto

@@ -146,3 +146,8 @@ message dispatch_node_statu{
     repeated dispatch_region_info           dispatch_region_info_vector = 8;        //调度入口汽车范围的修正信息
 
 }
+message terminal_node_statu
+{
+  int32   terminal_id=1;                //入口终端编号, 1~6
+  string  car_number=2;	//车牌号
+}

File diff suppressed because it is too large
+ 58 - 644
入口引导提示节点/message_pb2.py


+ 5 - 1
入口引导提示节点/node.py

@@ -22,10 +22,13 @@ prj_parameter=config.get("prj")
 #启动入口单片机,向rabbitmq发送数据,并接收关门请求
 #[消息服务器ip,port,用户,密码,状态交换机名称,状态消息key]
 statu_ex_keys=[["statu_ex","in_mcpu_%d_statu_port"%node_id],
-               ["statu_ex","measure_%d_statu_port"%node_id]
+               ["statu_ex","measure_%d_statu_port"%node_id],
+               ["statu_ex","terminal_node_%d_statu_port"%node_id]
 ]
 cpu_ex,cpu_key=statu_ex_keys[0]
 measure_ex,measure_key=statu_ex_keys[1]
+terminal_ex,terminal_key=statu_ex_keys[2]
+
 g_rabbitmq=CM.RabbitAsyncCommunicator(rabbitmq_cfg["ip"],rabbitmq_cfg["port"],
                          rabbitmq_cfg["user"],rabbitmq_cfg["password"])
 g_rabbitmq.Init(None,statu_ex_keys)
@@ -79,6 +82,7 @@ frame.setWindowFlags(Qt.WindowMaximizeButtonHint|Qt.WindowCloseButtonHint)
 frame.showMaximized()
 g_rabbitmq.bind_statu_callback(cpu_ex,cpu_key,frame.receive_icpu)
 g_rabbitmq.bind_statu_callback(measure_ex,measure_key,frame.receive_measureInfo)
+g_rabbitmq.bind_statu_callback(terminal_ex,terminal_key,frame.receive_terminal)
 
 app.exec()
 DBSearcher.close()

+ 4 - 4
入口引导提示节点/ui_config.json

@@ -1,8 +1,8 @@
 {
   "db": {"ip": "192.168.1.233","port": 3306,"database": "ct_project","user": "zx","password": "zx123456"},
   "rabbitmq": {"ip":"192.168.1.233","port":5672,"user":"zx","password":"zx123456"},
-  "led": {"ip": "192.168.1.161","port": 5005},
-  "entrance_id": 2,
-  "unit":1,
-  "prj": {"ip": "192.168.1.191","port": 4352,"type": 0}
+  "led": {"ip": "192.168.1.164","port": 5005},
+  "entrance_id": 5,
+  "unit":3,
+  "prj": {"ip": "192.168.1.194","port": 4352,"type": 2}
 }

+ 29 - 8
入口引导提示节点/window_screen_pyqt.py

@@ -49,6 +49,7 @@ class Frame(QMainWindow):
         self.images = {}
         self.icpu_statu = CM.TimeStatu(timeout=0.1)
         self.measure_statu = CM.TimeStatu(timeout=0.1)
+        self.terminal_statu = CM.TimeStatu(timeout=0.1)
 
         for key, file in images.items():
             self.images[key] =  pix = QPixmap(file)
@@ -87,6 +88,9 @@ class Frame(QMainWindow):
 
     def InitUI(self):
         self.measure_info_txt=QLabel(self)
+        self.car_number_txt = QLabel(self)
+        self.car_number_txt.setStyleSheet("border-width:1px;border-style:solid;border-color:rgb(150,150,150)")
+        self.car_number_txt.setAlignment(Qt.AlignCenter)
         self.measure_info_txt.setStyleSheet("color:blue")
         self.panel_txt=PicLabel(self)
         self.panel_arrow=PicLabel(self)
@@ -95,7 +99,8 @@ class Frame(QMainWindow):
         self.icpu_statu=statu
     def receive_measureInfo(self,statu):
         self.measure_statu=statu
-
+    def receive_terminal(self,statu):
+        self.terminal_statu=statu
     def closeEvent(self, a0: QCloseEvent) -> None:
         if self.pjc_ is not None:
             self.pjc_.lightOff()
@@ -105,18 +110,22 @@ class Frame(QMainWindow):
         w, h = a0.size().width(), a0.size().height()
         w, h = self.size().width(), self.size().height()
         top_w, top_h = w, int(h * 0.15)
-        txt_w, txt_h = w, int(h * 0.25)
-        arrow_w, arrow_h = w, int(h * 0.6)
+        car_number_w,car_number_h=w, int(h * 0.10)
+        txt_w, txt_h = w, int(h * 0.20)
+        arrow_w, arrow_h = w, int(h * 0.55)
         font = QFont()
         font.setBold(True)
         font.setPixelSize(int(w / 40))
         self.measure_info_txt.setFont(font)
         self.measure_info_txt.setGeometry(0, 0, top_w, top_h)
-        self.panel_txt.setGeometry(0, top_h, txt_w, txt_h)
-        self.panel_arrow.setGeometry(0, top_h + txt_h, arrow_w, arrow_h)
+        font.setPixelSize(int(w / 20))
+        self.car_number_txt.setFont(font)
+        self.car_number_txt.setGeometry(0, top_h, car_number_w, car_number_h)
 
-    def Switch(self):
+        self.panel_txt.setGeometry(0, top_h+car_number_h, txt_w, txt_h)
+        self.panel_arrow.setGeometry(0, top_h +car_number_h+ txt_h, arrow_w, arrow_h)
 
+    def Switch(self):
         #先判断连接状态
         if self.icpu_statu.timeout():
             self.panel_txt.ShowImg(self.images['传感器超时'])
@@ -131,6 +140,17 @@ class Frame(QMainWindow):
         #有车才显示
         icpu_statu=message.in_mcpu_statu()
         tf.Parse(self.icpu_statu.statu,icpu_statu)
+        measure_info=message.measure_info()
+        tf.Parse(self.measure_statu.statu,measure_info)
+
+        if self.terminal_statu.timeout() is False and measure_info.ground_status != MeasureStatu["无数据"]:
+            terminal_statu = message.terminal_node_statu()
+            tf.Parse(self.terminal_statu.statu, terminal_statu)
+            self.car_number_txt.setText(terminal_statu.car_number)
+            self.car_number_txt.setStyleSheet("border-width:1px;border-style:solid;border-color:rgb(150,150,150);color:green")
+        else:
+            self.car_number_txt.setText("未拍摄到号码牌!")
+            self.car_number_txt.setStyleSheet("border-width:1px;border-style:solid;border-color:rgb(150,150,150);color:red")
         #外门状态控制投影仪
         if self.pjc_ is not None:
             if icpu_statu.door_statu==3: #关门状态
@@ -147,8 +167,7 @@ class Frame(QMainWindow):
 
         #以下是有车的处理
         #1,显示测量数据(实时和静态)
-        measure_info=message.measure_info()
-        tf.Parse(self.measure_statu.statu,measure_info)
+
         realtime_info_txt=''
         static_info_txt=''
 
@@ -243,6 +262,8 @@ class Frame(QMainWindow):
                 self.last_show="超宽"
                 return
             border=border_statu&0x0f
+
+
             if ArrowType[border] == "正确图片":
                 self.panel_arrow.ShowImg(self.images[ArrowType[border]])
                 self.panel_txt.ShowImg(self.images['正确文字'])

+ 187 - 0
指令检查节点/CheckEntrance.py

@@ -0,0 +1,187 @@
+import threading
+import time
+
+import async_communication as CM
+import message_pb2 as message
+import google.protobuf.text_format as tf
+
+MeasureStatu={"ok":0,"无数据":1,"噪声":2,"超界":3}
+ArrowType={0:"正确图片",0x01:"向后调整",0x02:"向前调整",0x04:"向右调整",0x08:"向左调整"
+           ,0x10:"左前调整",0x06:"右前调整",0x09:"右后调整",0x05:"左后调整"}
+
+class EntranceChecker(threading.Thread):
+    def __init__(self):
+        threading.Thread.__init__(self)
+        self.icpu_statu = CM.TimeStatu(timeout=0.1)
+        self.measure_statu = CM.TimeStatu(timeout=0.1)
+
+        self.last_door_statu=None
+        self.last_moving_statu = None
+        self.last_show = None
+        self.lock = threading.Lock()
+        self.error_str=""
+
+        self.is_close = False
+
+    def receive_icpu(self,statu):
+        self.icpu_statu=statu
+    def receive_measureInfo(self,statu):
+        self.measure_statu=statu
+
+    def exit_isOK(self, msg):
+        pick = message.park_table()
+        tf.Parse(msg, pick)
+        if pick.primary_key is None:
+            pick.statu.execute_statu = message.eError
+            pick.statu.statu_description = " 唯一码不能为空!"
+            return tf.MessageToString(pick, as_utf8=True)
+        return tf.MessageToString(pick, as_utf8=True)
+
+    def entrance_isOK(self,park_table):
+
+        measure_info = message.measure_info()
+        tf.Parse(self.measure_statu.statu, measure_info)
+        park = message.park_table()
+        park.CopyFrom(park_table)
+
+
+
+        if self.error_str == 'OK' and (measure_info.border_statu == MeasureStatu["ok"] or  measure_info.border_statu == MeasureStatu["超界"]):
+            park.statu.execute_statu = message.eNormal
+            park.statu.statu_description = self.error_str
+            if measure_info.border_statu == MeasureStatu["ok"]:
+                park.entrance_measure_info.CopyFrom(measure_info)
+            elif measure_info.border_statu == MeasureStatu["超界"]:
+                park.entrance_measure_info.CopyFrom(self.last_moving_statu)
+            im_mcpu_statu = message.in_mcpu_statu()
+            tf.Parse(self.icpu_statu.statu, im_mcpu_statu)
+            if im_mcpu_statu.heighth == 2:
+                park.entrance_measure_info.height = 1.50
+            elif im_mcpu_statu.heighth == 3:
+                park.entrance_measure_info.height = 1.70
+            elif im_mcpu_statu.heighth == 4:
+                park.entrance_measure_info.height = 1.90
+            return tf.MessageToString(park, as_utf8=True)
+        else:
+            park.statu.execute_statu = message.eError
+            park.statu.statu_description = self.error_str
+            return tf.MessageToString(park, as_utf8=True)
+
+    def run(self):
+
+        while self.is_close is False:
+            print(self.error_str)
+            time.sleep(0.05)
+            #先判断连接状态
+            with self.lock:
+                if self.icpu_statu.timeout():
+                    self.error_str="传感器未连接"
+                    continue
+                if self.measure_statu.timeout():
+                    self.error_str='测绘超时'
+                    continue
+                #有车才显示
+                icpu_statu=message.in_mcpu_statu()
+                try:
+                    tf.Parse(self.icpu_statu.statu,icpu_statu)
+                except:
+                    print(self.icpu_statu.statu)
+                    continue
+
+                if icpu_statu.heighth == 1:
+                    self.error_str = '未知车高'
+                    continue
+
+                if icpu_statu.heighth == 5:
+                    self.error_str = '车辆超高'
+                    continue
+                #以下是有车的处理
+                #1,显示测量数据(实时和静态)
+                measure_info=message.measure_info()
+                tf.Parse(self.measure_statu.statu,measure_info)
+
+                #2,获取车辆运动状态(静止or动态)
+                border_statu=measure_info.border_statu
+                is_moving = ((border_statu >> 11) & 0x01) == 1
+                lidar_statu=measure_info.ground_status  # 测量状态(正常,无数据、噪声、超界)
+                if is_moving:
+                    self.last_moving_statu=None
+                else:
+                    #当前静止
+                    if lidar_statu==MeasureStatu["ok"]:
+                        self.last_moving_statu=measure_info
+                    elif lidar_statu==MeasureStatu["超界"]:
+                        if not self.last_moving_statu ==None:
+                            #上一刻静止且数据正确,当前静止,不可能出现超界,将超界清除
+                            new_border=border_statu
+                            new_border = (new_border & (~(0x01 << 0)))
+                            new_border = (new_border & (~(0x01 << 1)))
+                            new_border = (new_border & (~(0x01 << 2)))
+                            new_border = (new_border & (~(0x01 << 3)))
+                            new_border = (new_border & (~(0x01 << 6)))
+                            new_border = (new_border & (~(0x01 << 7)))
+                            new_border = (new_border & (~(0x01 << 8)))
+                            new_border = (new_border & (~(0x01 << 9)))
+                            border_statu=new_border
+                    elif lidar_statu==MeasureStatu["无数据"]:
+                        #当前静止无车,清除上一时刻数据
+                        self.last_moving_statu=None
+                    elif lidar_statu==MeasureStatu["噪声"]:
+                        if not self.last_moving_statu==None:
+                            #上一时刻静止且正确,当前噪声,不显示当前数据,显示上一正确数据
+                            measure_info.CopyFrom(self.last_moving_statu)
+                #先判断光电
+                if is_moving:
+                    if icpu_statu.back_io==1:
+                        self.error_str='请按提示调整'
+                        self.last_show="调整"
+                        continue
+
+                #光电正常
+                if lidar_statu==MeasureStatu["无数据"]:
+                    self.error_str='请按提示调整'
+                    self.last_show="空闲"
+                    continue
+                elif lidar_statu==MeasureStatu["噪声"]:
+                    if self.last_show=="超时":
+                        self.error_str='请按提示调整'
+                        self.last_show="空闲"
+                    continue
+                elif lidar_statu==MeasureStatu["ok"]:
+                    self.error_str='OK'
+                    continue
+                elif lidar_statu==MeasureStatu["超界"]:
+                    if (border_statu>>7)&0x01==1:
+                        self.error_str='轴距超差'
+                        self.last_show="轴距超差"
+                        continue
+                    if (border_statu>>9)&0x01==1:
+                        self.error_str='请按提示调整'
+                        self.last_show="请调整"
+                        continue
+                    if (border_statu>>8)&0x01==1:
+                        self.error_str='请按提示调整'
+                        self.last_show="请调整"
+                        continue
+                    if (border_statu>>10)&0x01==1:
+                        self.error_str='请按提示调整'
+                        self.last_show="请调整"
+                        continue
+                    if (border_statu>>6)&0x01==1:
+                        self.error_str='请按提示调整'
+                        self.last_show="超宽"
+                        continue
+                    border=border_statu&0x0f
+
+
+                    if ArrowType[border] == "正确图片":
+                        self.error_str="OK"
+                        self.last_show="正确"
+                    else:
+                        self.error_str="请按提示调整"
+                        self.last_show="请调整"
+
+
+
+
+

+ 9 - 20
指令检查节点/async_communication.py

@@ -12,10 +12,10 @@ class TimeStatu:
 
     def timeout(self):
         tm=time.time()
-        return tm-self.time>self.timeout_ms
+        return tm-self.time>self.timeout_ms or self.statu==None
 
 class RabbitAsyncCommunicator(threading.Thread):
-    def InitRabbitmq(self, host,port, user, password):
+    def __init__(self, host,port, user, password):
         threading.Thread.__init__(self)
         self._host = host
         self._port=port
@@ -34,7 +34,7 @@ class RabbitAsyncCommunicator(threading.Thread):
         self._statu_callbacks={}
         self._closing = False
 
-    def InitConsumer(self,consumer_callbacks,recv_status):
+    def Init(self,consumer_callbacks,recv_status):
         self._consumer_callbacks=consumer_callbacks
         self._recv_status=recv_status
         if self._recv_status==None:
@@ -79,8 +79,6 @@ class RabbitAsyncCommunicator(threading.Thread):
         self._status[key]=value
 
     async def recv(self,queue,callback):
-        await asyncio.sleep(2)
-        print("   订阅队列:%s" % queue)
         async with queue.iterator() as queue_iter:
             async for message in queue_iter:
                 if not callback==None:
@@ -94,7 +92,6 @@ class RabbitAsyncCommunicator(threading.Thread):
         arg["x-message-ttl"]=ttl
         queue=await self._channel_statu.declare_queue("", auto_delete=True,arguments=arg)
         await queue.bind(statu_ex,routing_key=key)
-        print("订阅状态端口:%s" % key)
         async with queue.iterator() as queue_iter:
             async for message in queue_iter:
                 async with message.process():
@@ -103,22 +100,15 @@ class RabbitAsyncCommunicator(threading.Thread):
                     return
 
     async def send(self):
-        ex_map={}
         while self._closing==False:
             if self._publish_msg_queue.qsize()>0:
-                try:
-                    msg_bag = self._publish_msg_queue.get(False)
-                    if not msg_bag == None:
-                        ex_name, key, msg = msg_bag
-                        ex=ex_map.get(ex_name)
-                        if ex == None:
-                            ex = await self._channel_send.get_exchange(ex_name)
-                            ex_map[ex_name]=ex
-                        await ex.publish(aio_pika.Message(body=msg.encode()), routing_key=key)
-                except:
-                    await asyncio.sleep(1)
+                msg_bag=self._publish_msg_queue.get(False)
+                if not msg_bag==None:
+                    ex_name,key,msg=msg_bag
+                    ex= await self._channel_send.get_exchange(ex_name)
+                    await ex.publish(aio_pika.Message(body=msg.encode()),routing_key=key)
             await asyncio.sleep(0)
-            time.sleep(0.001)
+            #time.sleep(0.001)
 
 
     async def main(self):
@@ -134,4 +124,3 @@ class RabbitAsyncCommunicator(threading.Thread):
         await asyncio.gather(*tasks)
     def run(self):
         asyncio.run(self.main())
-rabbit_async_communicator = RabbitAsyncCommunicator()

+ 29 - 11
指令检查节点/node.py

@@ -1,10 +1,10 @@
 
 import datetime
 import time
-from async_communication import rabbit_async_communicator as g_rabbitmq
+import async_communication as CM
 import message_pb2 as message
 import google.protobuf.text_format as tf
-from CheckCommand import check_command as g_check
+import CheckEntrance as CHE
 import threading
 # 状态消息接收器参数
 statu_ex_keys = [
@@ -42,8 +42,10 @@ def user_command_callback(body):
         print("指令类型错误!\n%s" % body)
 def check_park_command(body):
     print("recieve park_command_queue message:%s" % body)
-    table = g_check.check_park_command(body)
-    cmd = message.park_table()
+    park = message.park_table()
+    tf.Parse(body, park)
+    table = EntranceCheckers[park.terminal_id-1].entrance_isOK(park)
+    cmd = message.pick_table()
     tf.Parse(table, cmd)
     if cmd.statu.execute_statu == message.eNormal:
         # 指令检查正常
@@ -61,7 +63,9 @@ def check_park_command(body):
 
 def check_pick_command(body):
     print("recv pick_command_queue message:%s" % body)
-    table = g_check.check_pick_command(body)
+    pick = message.pick_table()
+    tf.Parse(body, pick)
+    table = EntranceCheckers[pick.terminal_id-1].exit_isOK(pick)
     cmd = message.pick_table()
     tf.Parse(table, cmd)
     if cmd.statu.execute_statu == message.eNormal:
@@ -87,18 +91,32 @@ def statu_msg_thread():
         g_rabbitmq.publish("statu_ex", "command_check_statu_port",body)
         time.sleep(1)
 
+
+
+cmd_callbacks=[["user_command_queue",user_command_callback]]
+
+g_rabbitmq=CM.RabbitAsyncCommunicator(mq_ip,mq_port,mq_user,mq_password)
+g_rabbitmq.Init(cmd_callbacks,statu_ex_keys)
+g_rabbitmq.start()
+
+
+EntranceCheckers=[]
+for i in range(6):
+    checker=CHE.EntranceChecker()
+    g_rabbitmq.bind_statu_callback("statu_ex", "in_mcpu_%d_statu_port"%(i+1), checker.receive_icpu)
+    g_rabbitmq.bind_statu_callback("statu_ex", "measure_%d_statu_port"%(i+1), checker.receive_measureInfo)
+    EntranceCheckers.append(checker)
+    if i == 4:
+        checker.run()
+
+
 if __name__ == '__main__':
-# 消费指令消息
-    cmd_callbacks=[["user_command_queue",user_command_callback]]
-    g_rabbitmq.InitRabbitmq(mq_ip,mq_port,mq_user,mq_password)
-    g_rabbitmq.InitConsumer(cmd_callbacks,statu_ex_keys)
-    g_rabbitmq.start()
 
+# 消费指令消息
     statu = message.table_statu()
     statu.execute_statu = message.eNormal
     body = tf.MessageToString(statu, as_utf8=True)
     while True:
         g_rabbitmq.publish("statu_ex", "command_check_statu_port",body)
         time.sleep(1)
-    g_rabbitmq.join()
 

+ 1 - 1
管理节点/mcpu_communication.py

@@ -119,7 +119,7 @@ class McpuCommunicator:
                     head = length_data.find(b'@')
                     tail = length_data.find(b'$')
                     if head >= 0 and tail >= 0:
-                        bytes = length_data[head + 4:-1]
+                        bytes = length_data[head + 4:-3]
                         self._mcpu_iomsg[key] = TimeStatu(self.recieve2message(bytes), 3)
                     else:
                         print('\033[0;33m{}   data error:{}\033[m'.format(key, length_data))

+ 57 - 51
管理节点/node.py

@@ -22,22 +22,22 @@ import mcpu_communication as mcn
 from led import Led
 
 # db参数
-# db_ip = "192.168.1.233"
-db_ip = "127.0.0.1"
+db_ip = "192.168.1.233"
+# db_ip = "127.0.0.1"
 db_port = 3306
 db_name = "ct_project"
-# db_user = "zx"
-# db_password = "zx123456"
-db_user = "root"
-db_password = "123456"
+db_user = "zx"
+db_password = "zx123456"
+# db_user = "root"
+# db_password = "123456"
 # mq参数
-# mq_ip = "192.168.1.233"
-mq_ip = "127.0.0.1"
+mq_ip = "192.168.1.233"
+# mq_ip = "127.0.0.1"
 mq_port = 5672
-# mq_user = "zx"
-# mq_password = "zx123456"
-mq_user = "wk"
-mq_password = "123456"
+mq_user = "zx"
+mq_password = "zx123456"
+# mq_user = "wk"
+# mq_password = "123456"
 
 statu_ex_keys = [
     ["statu_ex", "in_mcpu_1_statu_port"],
@@ -55,18 +55,18 @@ statu_ex_keys = [
 ]
 
 mcpu_keys = [
-    ["in", 1, "192.168.2.25", 40000],
-    ["in", 2, "192.168.2.25", 40001],
-    # ["in", 3, "192.168.1.132", 40005],
-    # ["in", 4, "192.168.1.133", 40005],
-    # ["in", 5, "192.168.1.134", 40005],
-    # ["in", 6, "192.168.2.25", 40002],
-    ["out", 1, "192.168.2.25", 40005]
-    # ["out", 2, "192.168.1.130", 40005],
-    # ["out", 3, "192.168.1.130", 40005],
-    # ["out", 4, "192.168.1.130", 40005],
-    # ["out", 5, "192.168.1.130", 40005],
-    # ["out", 6, "192.168.1.130", 40005]
+    ["in", 1, "192.168.1.120", 40005],
+    ["in", 2, "192.168.1.121", 40005],
+    ["in", 3, "192.168.1.122", 40005],
+    ["in", 4, "192.168.1.123", 40005],
+    ["in", 5, "192.168.1.124", 40005],
+    ["in", 6, "192.168.1.125", 40005],
+    ["out", 1, "192.168.1.130", 40005],
+    ["out", 2, "192.168.1.131", 40005],
+    ["out", 3, "192.168.1.132", 40005],
+    ["out", 4, "192.168.1.133", 40005],
+    ["out", 5, "192.168.1.134", 40005],
+    ["out", 6, "192.168.1.135", 40005]
 ]
 
 
@@ -142,6 +142,7 @@ class MainWindow(QMainWindow, threading.Thread):
         if g_mcpu.GetMcpuConnectStatus(key) is True or iomsg.timeout() is False:
             btn.setText(btn.text()[:10] + "正常")
             btn.setStyleSheet(self.getBackGroundColor("green"))
+
             btn.setToolTip(str(iomsg.statu))
         else:
             btn.setText(btn.text()[:10] + "断连")
@@ -149,23 +150,27 @@ class MainWindow(QMainWindow, threading.Thread):
             btn.setStyleSheet(self.getBackGroundColor("gray"))
 
     def drawUnitProcess(self):
+        return
         if g_space.command_queue_dict is not False and g_space.command_queue_dict is not None:
             # if self.command_queue_dict != g_space.command_queue_dict
 
-            # for Aindex in range(self.ui.A_verticalLayout.count()):
-            #     item = self.ui.A_verticalLayout.itemAt(Aindex)
-            #     self.ui.A_verticalLayout.removeItem(item)
-            #     sip.delete(item.widget())
-            #
-            # for Bindex in range(self.ui.B_verticalLayout.count()):
-            #     wid = self.ui.B_verticalLayout.itemAt(Bindex).widget()
-            #     self.ui.B_verticalLayout.removeWidget(wid)
-            #     sip.delete(wid)
-            #
-            # for Cindex in range(self.ui.C_verticalLayout.count()):
-            #     wid = self.ui.C_verticalLayout.itemAt(Cindex).widget()
-            #     self.ui.C_verticalLayout.removeWidget(wid)
-            #     sip.delete(wid)
+            for Aindex in range(self.ui.A_verticalLayout.count()):
+                item = self.ui.A_verticalLayout.itemAt(Aindex)
+                if item is not None:
+                    self.ui.A_verticalLayout.removeItem(item)
+                    sip.delete(item.widget())
+
+            for Bindex in range(self.ui.B_verticalLayout.count()):
+                wid = self.ui.B_verticalLayout.itemAt(Bindex).widget()
+                if item is not None:
+                    self.ui.B_verticalLayout.removeWidget(wid)
+                    sip.delete(wid)
+
+            for Cindex in range(self.ui.C_verticalLayout.count()):
+                wid = self.ui.C_verticalLayout.itemAt(Cindex).widget()
+                if item is not None:
+                    self.ui.C_verticalLayout.removeWidget(wid)
+                    sip.delete(wid)
 
             for dict in g_space.command_queue_dict:
                 btn = QPBtn()
@@ -173,7 +178,7 @@ class MainWindow(QMainWindow, threading.Thread):
                 # tf.Parse(dict["measure_info"],measure)
                 a = 1.50
                 str = "%s任务-------车牌号:%s 车高:%f" % (
-                    "存车" if dict["type"] is 1 else "取车", dict["car_number"], a)
+                    "存车" if dict["type"] == 1 else "取车", dict["car_number"], a)
                 color = ""
                 if dict["statu"] == 1:
                     color = self.getBackGroundColor("green")
@@ -195,7 +200,7 @@ class MainWindow(QMainWindow, threading.Thread):
                 #     "orange" if dict["type"] is 1 else "blue") + color)
                 #     continue
                 btn.setStyleSheet('border:3px groove %s;border-radius:10px;padding:2px 4px;' % (
-                    "orange" if dict["type"] is 1 else "blue") + color)
+                    "orange" if dict["type"] == 1 else "blue") + color)
                 btn.setObjectName(dict["car_number"])
                 btn.setMinimumHeight(80)
                 font = QFont()
@@ -359,12 +364,10 @@ class MainWindow(QMainWindow, threading.Thread):
         action.triggered.connect(partial(self.manual_open_door, mcpu_key_list))
         action = menu.addAction('手动关门')
         action.triggered.connect(partial(self.manual_close_door, mcpu_key_list))
-        if mcpu_key_list[0] == 'in':
-            action = menu.addAction('半自动开门')
-            action.triggered.connect(partial(self.automatic_open_door, mcpu_key_list))
-        elif mcpu_key_list[0] == 'out':
-            action = menu.addAction('半自动关门')
-            action.triggered.connect(partial(self.automatic_close_door, mcpu_key_list))
+        action = menu.addAction('恢复半自动')
+        action.triggered.connect(partial(self.automatic_door, mcpu_key_list))
+        action = menu.addAction('恢复全自动')
+        action.triggered.connect(partial(self.fully_automatic_door, mcpu_key_list))
         menu.exec_(QCursor.pos())
 
     def manual_open_door(self,mcpu_key_list):
@@ -387,23 +390,26 @@ class MainWindow(QMainWindow, threading.Thread):
             int(mcpu_key_list[2]) - 1, dispatch_direction)
         key = mcpu_key_list[0] + ":mcpu_" + mcpu_key_list[2]
         g_mcpu.publish(key, msg)
-    def automatic_open_door(self,mcpu_key_list):
+    def automatic_door(self,mcpu_key_list):
         dispatch_direction = 0
+        ProcessControl = 0
         if mcpu_key_list[0] == 'in':
+            ProcessControl = 3
             dispatch_direction = 1
         elif mcpu_key_list[0] == 'out':
+            ProcessControl = 4
             dispatch_direction = 2
-        msg = b'{ "TerminalID": %d, "DispatchDirection": %d, "ProcessControl": 4, "OutPutDo": { "Do0": 0, "Do1": 0, "Do2": 0, "Do3": 0, "Do4": 0, "Do5": 0, "Do6": 0, "Do7": 0 }}' % (
-            int(mcpu_key_list[2]) - 1, dispatch_direction)
+        msg = b'{ "TerminalID": %d, "DispatchDirection": %d, "ProcessControl": %d, "OutPutDo": { "Do0": 0, "Do1": 0, "Do2": 0, "Do3": 0, "Do4": 0, "Do5": 0, "Do6": 0, "Do7": 0 }}' % (
+            int(mcpu_key_list[2]) - 1, dispatch_direction,ProcessControl)
         key = mcpu_key_list[0] + ":mcpu_" + mcpu_key_list[2]
         g_mcpu.publish(key, msg)
-    def automatic_close_door(self,mcpu_key_list):
+    def fully_automatic_door(self,mcpu_key_list):
         dispatch_direction = 0
         if mcpu_key_list[0] == 'in':
             dispatch_direction = 1
         elif mcpu_key_list[0] == 'out':
             dispatch_direction = 2
-        msg = b'{ "TerminalID": %d, "DispatchDirection": %d, "ProcessControl": 3, "OutPutDo": { "Do0": 0, "Do1": 0, "Do2": 0, "Do3": 0, "Do4": 0, "Do5": 0, "Do6": 0, "Do7": 0 }}' % (
+        msg = b'{ "TerminalID": %d, "DispatchDirection": %d, "ProcessControl": 1, "OutPutDo": { "Do0": 0, "Do1": 0, "Do2": 0, "Do3": 0, "Do4": 0, "Do5": 0, "Do6": 0, "Do7": 0 }}' % (
             int(mcpu_key_list[2]) - 1, dispatch_direction)
         key = mcpu_key_list[0] + ":mcpu_" + mcpu_key_list[2]
         g_mcpu.publish(key, msg)