Procházet zdrojové kódy

周三:实现跳过记录相同日志数据的逻辑

casper před 4 měsíci
rodič
revize
da6678710c

+ 9 - 6
sri-server-bg02/lib/MessageListener.py

@@ -12,11 +12,12 @@ import os
 # save_dir = r'C:\SRI-DINO.Server-py\logs'  # sri内网测试环境
 save_dir = r'C:\logs'  # sri内网测试环境
 
+# last_log_key = str()
 
 class MessageListener(object):
     """
     """
-    log_key = str()
+    last_log_key = str()
 
     @staticmethod
     def v001(client, userdata, message):
@@ -80,14 +81,16 @@ class MessageListener(object):
         ]
 
         # --- check ---
-        if MessageListener.log_key and MessageListener.log_key == '-'.join(log_list[1:]):
+        log_key = '-'.join(log_list[1:])
+        if MessageListener.last_log_key and MessageListener.last_log_key == log_key:
+            # methods.debug_log(f"MessageListener24", f"#86: {MessageListener.last_log_key == log_key}")
             return
 
-        # --- check --
-        if not MessageListener.log_key:
-            MessageListener.log_key = '-'.join(log_list[1:])
+        # --- update --
+        MessageListener.last_log_key = log_key
 
-        print(f'MessageListener24: #log_list: {log_list}', flush=True)
+        # --- save ---
+        methods.debug_log(f"MessageListener24", f"#log_list: {log_list}")
         methods.write_text(log_file_path, ' | '.join(log_list) + '\n', 'a')
 
     @classmethod

+ 7 - 6
sri-server-bg03/lib/Connection_e1.py

@@ -172,8 +172,9 @@ class SRIConnection(asyncio.Protocol):
                 # 获取消息头
                 head_data = self.message_data[:self.head_size]
                 command_id, body_length = struct.unpack(self.head_sequence, head_data)
-                methods.debug_log(f'{self.connection_id}|SRIConnection130',
-                                  f"command_id: {command_id}, body_length: {body_length}")
+                if command_id not in [2008]:
+                    methods.debug_log(f'{self.connection_id}|SRIConnection176',
+                                    f"command_id: {command_id}, body_length: {body_length}")
 
                 # 检查命令ID是否有效
                 if not (2000 <= command_id < 5000):
@@ -210,14 +211,14 @@ class SRIConnection(asyncio.Protocol):
         """
         CSAdd: 消息体
         CSAdd.serial: string
-        CSAdd.type: int32 EgoType::Car | EgoType::None EgoType::User EgoType::Car
+        CSAdd.type: int32 EgoType::Car | 0 EgoType::None 1 EgoType::User 2 EgoType::Car
         CSAdd.name: string
         """
         object0 = protobuf.CSAdd()
         object0.ParseFromString(body_data)
-        methods.debug_log(f"{self.connection_id}|SRIConnection90", f"#serial: {object0.serial}")
-        methods.debug_log(f"{self.connection_id}|SRIConnection90", f"#name: {object0.name}")
-        methods.debug_log(f"{self.connection_id}|SRIConnection90", f"#type: {object0.type}")
+        methods.debug_log(f"{self.connection_id}|SRIConnection219", f"#serial: {object0.serial}")
+        # methods.debug_log(f"{self.connection_id}|SRIConnection90", f"#name: {object0.name}")
+        # methods.debug_log(f"{self.connection_id}|SRIConnection90", f"#type: {object0.type}")
 
         # --- update ---
         self.client_type = 'vehicle'