casper 1 lună în urmă
părinte
comite
68d9f13365

+ 13 - 3
sri-server-bg02/hub.py

@@ -7,9 +7,19 @@ methods = importlib.import_module(f"xlib")
 
 
 class Global(object):
-    # --- 中间件服务器 ---
-    emqx001 = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
-    emqx002 = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
+
+    # todo 需要实现实例化emqx
+
+    # --- 中间件服务器 --- for test
+    emqx_MessageListenerC001 = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
+    emqx_MessageListenerV001 = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
+    
+    # --- 中间件服务器 --- for 湛江项目现场
+    emqx_Veh0533 = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
+    emqx_Veh0534 = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
+    emqx_Veh0535 = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
+    emqx_Veh0537 = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
+    emqx_Veh0538 = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
     
     aps = importlib.import_module(f"xpip.xapscheduler").APS(db_type='mongo',
                                                             db_host='127.0.0.1',

+ 12 - 0
sri-server-bg02/lib/MessageListener.py

@@ -26,9 +26,21 @@ class MessageListener(object):
         from lib.MessageListenerC001 import subscribe_c001
         from lib.MessageListenerV001 import subscribe_v001
 
+        from lib.MessageListenerZJV1 import subscribe_Veh0533
+        from lib.MessageListenerZJV2 import subscribe_Veh0534
+        from lib.MessageListenerZJV3 import subscribe_Veh0535
+        from lib.MessageListenerZJV4 import subscribe_Veh0537
+        from lib.MessageListenerZJV5 import subscribe_Veh0538
+
         thread_list = [
             threading.Thread(target=subscribe_c001),
             threading.Thread(target=subscribe_v001),
+
+            threading.Thread(target=subscribe_Veh0533),
+            threading.Thread(target=subscribe_Veh0534),
+            threading.Thread(target=subscribe_Veh0535),
+            threading.Thread(target=subscribe_Veh0537),
+            threading.Thread(target=subscribe_Veh0538),
         ]
         for thread in thread_list:
             thread.setDaemon(True)

+ 1 - 1
sri-server-bg02/lib/MessageListenerC001.py

@@ -161,7 +161,7 @@ def method_c001(client, userdata, message):
 
 def subscribe_c001():
     """"""
-    Global.emqx001.start_subscribe_loop(
+    Global.emqx_MessageListenerC001.start_subscribe_loop(
         decorate_method=method_c001,
         subscribe_topic='Cockpit/CanBus/CanId001/Cop001'
     )

+ 1 - 1
sri-server-bg02/lib/MessageListenerV001.py

@@ -120,7 +120,7 @@ def method_v001(client, userdata, message):
 
 def subscribe_v001():
     """"""
-    Global.emqx002.start_subscribe_loop(
+    Global.emqx_MessageListenerV001.start_subscribe_loop(
         decorate_method=method_v001,
         subscribe_topic='Vehicle/ControlVehicle/Veh001'
     )

+ 126 - 0
sri-server-bg02/lib/MessageListenerZJV1.py

@@ -0,0 +1,126 @@
+from hub import methods, Global
+
+import threading
+import traceback
+import time
+import json
+import os
+
+from lib.UserWorkRecord import UserWorkRecord
+
+# --- for linux
+# save_dir = f"/home/server/logs"
+
+# --- for windows
+# save_dir = r'C:\SRI-DINO.Server-py\logs'  # sri内网测试环境
+save_dir = r'C:\logs'  # sri内网测试环境
+
+
+class LocalClass(object):
+    last_log_key = str()
+
+
+def method_v001(client, userdata, message):
+    """消息处理方法"""
+    # --- log ---
+    # methods.debug_log(f"method_v001|26", f"#message.payload: {message.payload}")
+    # return
+
+    # --- check ---
+    # if not methods.is_dir(save_dir):
+    #     out = methods.run_command(f'mkdir -p {save_dir}', callback=True)
+    #     methods.debug_log('MessageListener46', f"#out: {out}")
+
+    # --- check ---
+    try:
+        log_dict = json.loads(message.payload)
+        log_time = int(log_dict.get('timestamp')) / 1000
+        user_uuid = log_dict.get('userID')
+        vehicle_id = log_dict.get('VehicleID')
+        cockpit_id = log_dict.get('cockpitID')
+    except Exception as exception:
+        methods.debug_log("method_v001|41", f"#message.payload: {message.payload}")
+        methods.debug_log("method_v001|41", f"#exception: {exception.__class__.__name__}")
+        methods.debug_log("method_v001|41", f"#traceback: {traceback.format_exc()}")
+        return
+
+    # --- check ---
+    log_uuid = UserWorkRecord.get_log_uuid(user_uuid, log_time, vehicle_id, cockpit_id)
+    if not log_uuid:
+        methods.debug_log(f"MessageListenerV001|error50", f"user_uuid: {user_uuid}, log_time: {log_time}")
+        return
+
+    # --- fill log_list ---
+    log_list = [
+
+        f"timestamp: {methods.ts_to_string(log_time)}",  # 时间
+        f"topic: Vehicle/ControlVehicle/Veh001",  # 话题
+        # f"userID: {log_dict.get('userID')}",  # 用户id
+        # f"VehicleID: {log_dict.get('VehicleID')}",  # 车id
+        # f"cockpitID: {log_dict.get('cockpitID')}",  # 舱id
+
+        f"directSwitch: {log_dict.get('baseControl')[0].get('directSwitch')}",  # 前后切换
+        f"eStop: {log_dict.get('baseControl')[0].get('eStop')}",  # 急停开关
+        f"gearCaontrol: {log_dict.get('baseControl')[0].get('gearCaontrol')}",  # 车辆档位控制
+        f"hazardLight: {log_dict.get('baseControl')[0].get('hazardLight')}",  # 双闪灯
+        f"keyStatus: {log_dict.get('baseControl')[0].get('keyStatus')}",  # 钥匙状态
+        f"parkControl: {log_dict.get('baseControl')[0].get('parkControl')}",  # 驻车控制
+        f"silencedAlarm: {log_dict.get('baseControl')[0].get('silencedAlarm')}",  # 消报警音按钮
+        f"travelLight: {log_dict.get('baseControl')[0].get('travelLight')}",  # 行驶灯光
+        f"travelMode: {log_dict.get('baseControl')[0].get('travelMode')}",  # 驾驶模式
+        f"vehicleHorn: {log_dict.get('baseControl')[0].get('vehicleHorn')}",  # 喇叭
+
+        f"accPedalF: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalF')}",  # 油门踏板.手油门
+        f"accPedalH: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalH')}",  # 油门踏板.脚油门
+
+        f"accPedalH: {log_dict.get('driveControl')[0].get('brakePedal')}",  # 刹车踏板
+        f"steeringWheel: {log_dict.get('driveControl')[0].get('steeringWheel')}",  # 方向盘转速
+        f"turnMode: {log_dict.get('driveControl')[0].get('turnMode')}",  # 转向模式
+        f"turnSignal: {log_dict.get('driveControl')[0].get('turnSignal')}",  # 转向灯
+
+        f"errAccPedal: {log_dict.get('errCode')[0].get('errAccPedal')}",  # 油门信号故障
+        f"errBasOperation: {log_dict.get('errCode')[0].get('errBasOperation')}",  # 基本操作故障
+        f"errBrakePedal: {log_dict.get('errCode')[0].get('errBrakePedal')}",  # 刹车信号故障
+        f"errEndTool: {log_dict.get('errCode')[0].get('errEndTool')}",  # 末端工具控制故障
+        f"errHandle: {log_dict.get('errCode')[0].get('errHandle')}",  # 手柄信号故障
+        f"errOther: {log_dict.get('errCode')[0].get('errOther')}",  # 其他故障
+        f"errSteeringWheel: {log_dict.get('errCode')[0].get('errSteeringWheel')}",  # 转向故障
+
+        f"baseLegControl: {log_dict.get('taskControl')[0].get('baseLegControl')}",  # 支腿动作控制
+        f"baseLegSwitch: {log_dict.get('taskControl')[0].get('baseLegSwitch')}",  # 支腿选择开关
+        f"bypassSwitch: {log_dict.get('taskControl')[0].get('bypassSwitch')}",  # 旁通开关
+        f"cabLift: {log_dict.get('taskControl')[0].get('cabLift')}",  # 驾驶室升降机构
+        f"coopSignal: {log_dict.get('taskControl')[0].get('coopSignal')}",  # 协同作业信号
+        f"enableHydraulic: {log_dict.get('taskControl')[0].get('enableHydraulic')}",  # 液压使能开关
+        f"endJoint: {log_dict.get('taskControl')[0].get('endJoint')}",  # 末端关节控制
+        f"esCabLift: {log_dict.get('taskControl')[0].get('esCabLift')}",  # 驾驶室应急下降开关
+        f"suckerSelect: {log_dict.get('taskControl')[0].get('suckerSelect')}",  # 吸盘选择开关
+        f"taskJoint_1: {log_dict.get('taskControl')[0].get('taskJoint_1')}",  # 第一个作业关节控制
+        f"taskJoint_2: {log_dict.get('taskControl')[0].get('taskJoint_2')}",  # 第二个作业关节控制
+        f"taskJoint_3: {log_dict.get('taskControl')[0].get('taskJoint_3')}",  # 第三个作业关节控制
+        f"toolControl: {log_dict.get('taskControl')[0].get('toolControl')}",  # 末端工具控制
+        f"workLight: {log_dict.get('taskControl')[0].get('workLight')}",  # 工作灯
+
+    ]
+
+    # --- check ---
+    log_key = '-'.join(log_list[1:])
+    if LocalClass.last_log_key and LocalClass.last_log_key == log_key:
+        # methods.debug_log(f"MessageListener24", f"#86: {LocalClass.last_log_key == log_key}")
+        return
+
+    # --- update --
+    LocalClass.last_log_key = log_key
+
+    # --- save ---
+    # methods.debug_log(f"MessageListenerV001|113", f"#log_list: {log_list}")
+    log_file_path = os.path.join(save_dir, f'{log_uuid}.log')
+    methods.write_text(log_file_path, ' | '.join(log_list) + '\n', 'a')
+
+
+def subscribe_Veh0533():
+    """"""
+    Global.emqx_Veh0533.start_subscribe_loop(
+        decorate_method=method_v001,
+        subscribe_topic='Vehicle/ControlVehicle/Veh0533'
+    )

+ 126 - 0
sri-server-bg02/lib/MessageListenerZJV2.py

@@ -0,0 +1,126 @@
+from hub import methods, Global
+
+import threading
+import traceback
+import time
+import json
+import os
+
+from lib.UserWorkRecord import UserWorkRecord
+
+# --- for linux
+# save_dir = f"/home/server/logs"
+
+# --- for windows
+# save_dir = r'C:\SRI-DINO.Server-py\logs'  # sri内网测试环境
+save_dir = r'C:\logs'  # sri内网测试环境
+
+
+class LocalClass(object):
+    last_log_key = str()
+
+
+def method_v001(client, userdata, message):
+    """消息处理方法"""
+    # --- log ---
+    # methods.debug_log(f"method_v001|26", f"#message.payload: {message.payload}")
+    # return
+
+    # --- check ---
+    # if not methods.is_dir(save_dir):
+    #     out = methods.run_command(f'mkdir -p {save_dir}', callback=True)
+    #     methods.debug_log('MessageListener46', f"#out: {out}")
+
+    # --- check ---
+    try:
+        log_dict = json.loads(message.payload)
+        log_time = int(log_dict.get('timestamp')) / 1000
+        user_uuid = log_dict.get('userID')
+        vehicle_id = log_dict.get('VehicleID')
+        cockpit_id = log_dict.get('cockpitID')
+    except Exception as exception:
+        methods.debug_log("method_v001|41", f"#message.payload: {message.payload}")
+        methods.debug_log("method_v001|41", f"#exception: {exception.__class__.__name__}")
+        methods.debug_log("method_v001|41", f"#traceback: {traceback.format_exc()}")
+        return
+
+    # --- check ---
+    log_uuid = UserWorkRecord.get_log_uuid(user_uuid, log_time, vehicle_id, cockpit_id)
+    if not log_uuid:
+        methods.debug_log(f"MessageListenerV001|error50", f"user_uuid: {user_uuid}, log_time: {log_time}")
+        return
+
+    # --- fill log_list ---
+    log_list = [
+
+        f"timestamp: {methods.ts_to_string(log_time)}",  # 时间
+        f"topic: Vehicle/ControlVehicle/Veh001",  # 话题
+        # f"userID: {log_dict.get('userID')}",  # 用户id
+        # f"VehicleID: {log_dict.get('VehicleID')}",  # 车id
+        # f"cockpitID: {log_dict.get('cockpitID')}",  # 舱id
+
+        f"directSwitch: {log_dict.get('baseControl')[0].get('directSwitch')}",  # 前后切换
+        f"eStop: {log_dict.get('baseControl')[0].get('eStop')}",  # 急停开关
+        f"gearCaontrol: {log_dict.get('baseControl')[0].get('gearCaontrol')}",  # 车辆档位控制
+        f"hazardLight: {log_dict.get('baseControl')[0].get('hazardLight')}",  # 双闪灯
+        f"keyStatus: {log_dict.get('baseControl')[0].get('keyStatus')}",  # 钥匙状态
+        f"parkControl: {log_dict.get('baseControl')[0].get('parkControl')}",  # 驻车控制
+        f"silencedAlarm: {log_dict.get('baseControl')[0].get('silencedAlarm')}",  # 消报警音按钮
+        f"travelLight: {log_dict.get('baseControl')[0].get('travelLight')}",  # 行驶灯光
+        f"travelMode: {log_dict.get('baseControl')[0].get('travelMode')}",  # 驾驶模式
+        f"vehicleHorn: {log_dict.get('baseControl')[0].get('vehicleHorn')}",  # 喇叭
+
+        f"accPedalF: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalF')}",  # 油门踏板.手油门
+        f"accPedalH: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalH')}",  # 油门踏板.脚油门
+
+        f"accPedalH: {log_dict.get('driveControl')[0].get('brakePedal')}",  # 刹车踏板
+        f"steeringWheel: {log_dict.get('driveControl')[0].get('steeringWheel')}",  # 方向盘转速
+        f"turnMode: {log_dict.get('driveControl')[0].get('turnMode')}",  # 转向模式
+        f"turnSignal: {log_dict.get('driveControl')[0].get('turnSignal')}",  # 转向灯
+
+        f"errAccPedal: {log_dict.get('errCode')[0].get('errAccPedal')}",  # 油门信号故障
+        f"errBasOperation: {log_dict.get('errCode')[0].get('errBasOperation')}",  # 基本操作故障
+        f"errBrakePedal: {log_dict.get('errCode')[0].get('errBrakePedal')}",  # 刹车信号故障
+        f"errEndTool: {log_dict.get('errCode')[0].get('errEndTool')}",  # 末端工具控制故障
+        f"errHandle: {log_dict.get('errCode')[0].get('errHandle')}",  # 手柄信号故障
+        f"errOther: {log_dict.get('errCode')[0].get('errOther')}",  # 其他故障
+        f"errSteeringWheel: {log_dict.get('errCode')[0].get('errSteeringWheel')}",  # 转向故障
+
+        f"baseLegControl: {log_dict.get('taskControl')[0].get('baseLegControl')}",  # 支腿动作控制
+        f"baseLegSwitch: {log_dict.get('taskControl')[0].get('baseLegSwitch')}",  # 支腿选择开关
+        f"bypassSwitch: {log_dict.get('taskControl')[0].get('bypassSwitch')}",  # 旁通开关
+        f"cabLift: {log_dict.get('taskControl')[0].get('cabLift')}",  # 驾驶室升降机构
+        f"coopSignal: {log_dict.get('taskControl')[0].get('coopSignal')}",  # 协同作业信号
+        f"enableHydraulic: {log_dict.get('taskControl')[0].get('enableHydraulic')}",  # 液压使能开关
+        f"endJoint: {log_dict.get('taskControl')[0].get('endJoint')}",  # 末端关节控制
+        f"esCabLift: {log_dict.get('taskControl')[0].get('esCabLift')}",  # 驾驶室应急下降开关
+        f"suckerSelect: {log_dict.get('taskControl')[0].get('suckerSelect')}",  # 吸盘选择开关
+        f"taskJoint_1: {log_dict.get('taskControl')[0].get('taskJoint_1')}",  # 第一个作业关节控制
+        f"taskJoint_2: {log_dict.get('taskControl')[0].get('taskJoint_2')}",  # 第二个作业关节控制
+        f"taskJoint_3: {log_dict.get('taskControl')[0].get('taskJoint_3')}",  # 第三个作业关节控制
+        f"toolControl: {log_dict.get('taskControl')[0].get('toolControl')}",  # 末端工具控制
+        f"workLight: {log_dict.get('taskControl')[0].get('workLight')}",  # 工作灯
+
+    ]
+
+    # --- check ---
+    log_key = '-'.join(log_list[1:])
+    if LocalClass.last_log_key and LocalClass.last_log_key == log_key:
+        # methods.debug_log(f"MessageListener24", f"#86: {LocalClass.last_log_key == log_key}")
+        return
+
+    # --- update --
+    LocalClass.last_log_key = log_key
+
+    # --- save ---
+    # methods.debug_log(f"MessageListenerV001|113", f"#log_list: {log_list}")
+    log_file_path = os.path.join(save_dir, f'{log_uuid}.log')
+    methods.write_text(log_file_path, ' | '.join(log_list) + '\n', 'a')
+
+
+def subscribe_Veh0534():
+    """"""
+    Global.emqx_Veh0534.start_subscribe_loop(
+        decorate_method=method_v001,
+        subscribe_topic='Vehicle/ControlVehicle/Veh0534'
+    )

+ 126 - 0
sri-server-bg02/lib/MessageListenerZJV3.py

@@ -0,0 +1,126 @@
+from hub import methods, Global
+
+import threading
+import traceback
+import time
+import json
+import os
+
+from lib.UserWorkRecord import UserWorkRecord
+
+# --- for linux
+# save_dir = f"/home/server/logs"
+
+# --- for windows
+# save_dir = r'C:\SRI-DINO.Server-py\logs'  # sri内网测试环境
+save_dir = r'C:\logs'  # sri内网测试环境
+
+
+class LocalClass(object):
+    last_log_key = str()
+
+
+def method_v001(client, userdata, message):
+    """消息处理方法"""
+    # --- log ---
+    # methods.debug_log(f"method_v001|26", f"#message.payload: {message.payload}")
+    # return
+
+    # --- check ---
+    # if not methods.is_dir(save_dir):
+    #     out = methods.run_command(f'mkdir -p {save_dir}', callback=True)
+    #     methods.debug_log('MessageListener46', f"#out: {out}")
+
+    # --- check ---
+    try:
+        log_dict = json.loads(message.payload)
+        log_time = int(log_dict.get('timestamp')) / 1000
+        user_uuid = log_dict.get('userID')
+        vehicle_id = log_dict.get('VehicleID')
+        cockpit_id = log_dict.get('cockpitID')
+    except Exception as exception:
+        methods.debug_log("method_v001|41", f"#message.payload: {message.payload}")
+        methods.debug_log("method_v001|41", f"#exception: {exception.__class__.__name__}")
+        methods.debug_log("method_v001|41", f"#traceback: {traceback.format_exc()}")
+        return
+
+    # --- check ---
+    log_uuid = UserWorkRecord.get_log_uuid(user_uuid, log_time, vehicle_id, cockpit_id)
+    if not log_uuid:
+        methods.debug_log(f"MessageListenerV001|error50", f"user_uuid: {user_uuid}, log_time: {log_time}")
+        return
+
+    # --- fill log_list ---
+    log_list = [
+
+        f"timestamp: {methods.ts_to_string(log_time)}",  # 时间
+        f"topic: Vehicle/ControlVehicle/Veh001",  # 话题
+        # f"userID: {log_dict.get('userID')}",  # 用户id
+        # f"VehicleID: {log_dict.get('VehicleID')}",  # 车id
+        # f"cockpitID: {log_dict.get('cockpitID')}",  # 舱id
+
+        f"directSwitch: {log_dict.get('baseControl')[0].get('directSwitch')}",  # 前后切换
+        f"eStop: {log_dict.get('baseControl')[0].get('eStop')}",  # 急停开关
+        f"gearCaontrol: {log_dict.get('baseControl')[0].get('gearCaontrol')}",  # 车辆档位控制
+        f"hazardLight: {log_dict.get('baseControl')[0].get('hazardLight')}",  # 双闪灯
+        f"keyStatus: {log_dict.get('baseControl')[0].get('keyStatus')}",  # 钥匙状态
+        f"parkControl: {log_dict.get('baseControl')[0].get('parkControl')}",  # 驻车控制
+        f"silencedAlarm: {log_dict.get('baseControl')[0].get('silencedAlarm')}",  # 消报警音按钮
+        f"travelLight: {log_dict.get('baseControl')[0].get('travelLight')}",  # 行驶灯光
+        f"travelMode: {log_dict.get('baseControl')[0].get('travelMode')}",  # 驾驶模式
+        f"vehicleHorn: {log_dict.get('baseControl')[0].get('vehicleHorn')}",  # 喇叭
+
+        f"accPedalF: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalF')}",  # 油门踏板.手油门
+        f"accPedalH: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalH')}",  # 油门踏板.脚油门
+
+        f"accPedalH: {log_dict.get('driveControl')[0].get('brakePedal')}",  # 刹车踏板
+        f"steeringWheel: {log_dict.get('driveControl')[0].get('steeringWheel')}",  # 方向盘转速
+        f"turnMode: {log_dict.get('driveControl')[0].get('turnMode')}",  # 转向模式
+        f"turnSignal: {log_dict.get('driveControl')[0].get('turnSignal')}",  # 转向灯
+
+        f"errAccPedal: {log_dict.get('errCode')[0].get('errAccPedal')}",  # 油门信号故障
+        f"errBasOperation: {log_dict.get('errCode')[0].get('errBasOperation')}",  # 基本操作故障
+        f"errBrakePedal: {log_dict.get('errCode')[0].get('errBrakePedal')}",  # 刹车信号故障
+        f"errEndTool: {log_dict.get('errCode')[0].get('errEndTool')}",  # 末端工具控制故障
+        f"errHandle: {log_dict.get('errCode')[0].get('errHandle')}",  # 手柄信号故障
+        f"errOther: {log_dict.get('errCode')[0].get('errOther')}",  # 其他故障
+        f"errSteeringWheel: {log_dict.get('errCode')[0].get('errSteeringWheel')}",  # 转向故障
+
+        f"baseLegControl: {log_dict.get('taskControl')[0].get('baseLegControl')}",  # 支腿动作控制
+        f"baseLegSwitch: {log_dict.get('taskControl')[0].get('baseLegSwitch')}",  # 支腿选择开关
+        f"bypassSwitch: {log_dict.get('taskControl')[0].get('bypassSwitch')}",  # 旁通开关
+        f"cabLift: {log_dict.get('taskControl')[0].get('cabLift')}",  # 驾驶室升降机构
+        f"coopSignal: {log_dict.get('taskControl')[0].get('coopSignal')}",  # 协同作业信号
+        f"enableHydraulic: {log_dict.get('taskControl')[0].get('enableHydraulic')}",  # 液压使能开关
+        f"endJoint: {log_dict.get('taskControl')[0].get('endJoint')}",  # 末端关节控制
+        f"esCabLift: {log_dict.get('taskControl')[0].get('esCabLift')}",  # 驾驶室应急下降开关
+        f"suckerSelect: {log_dict.get('taskControl')[0].get('suckerSelect')}",  # 吸盘选择开关
+        f"taskJoint_1: {log_dict.get('taskControl')[0].get('taskJoint_1')}",  # 第一个作业关节控制
+        f"taskJoint_2: {log_dict.get('taskControl')[0].get('taskJoint_2')}",  # 第二个作业关节控制
+        f"taskJoint_3: {log_dict.get('taskControl')[0].get('taskJoint_3')}",  # 第三个作业关节控制
+        f"toolControl: {log_dict.get('taskControl')[0].get('toolControl')}",  # 末端工具控制
+        f"workLight: {log_dict.get('taskControl')[0].get('workLight')}",  # 工作灯
+
+    ]
+
+    # --- check ---
+    log_key = '-'.join(log_list[1:])
+    if LocalClass.last_log_key and LocalClass.last_log_key == log_key:
+        # methods.debug_log(f"MessageListener24", f"#86: {LocalClass.last_log_key == log_key}")
+        return
+
+    # --- update --
+    LocalClass.last_log_key = log_key
+
+    # --- save ---
+    # methods.debug_log(f"MessageListenerV001|113", f"#log_list: {log_list}")
+    log_file_path = os.path.join(save_dir, f'{log_uuid}.log')
+    methods.write_text(log_file_path, ' | '.join(log_list) + '\n', 'a')
+
+
+def subscribe_Veh0535():
+    """"""
+    Global.emqx_Veh0535.start_subscribe_loop(
+        decorate_method=method_v001,
+        subscribe_topic='Vehicle/ControlVehicle/Veh0535'
+    )

+ 126 - 0
sri-server-bg02/lib/MessageListenerZJV4.py

@@ -0,0 +1,126 @@
+from hub import methods, Global
+
+import threading
+import traceback
+import time
+import json
+import os
+
+from lib.UserWorkRecord import UserWorkRecord
+
+# --- for linux
+# save_dir = f"/home/server/logs"
+
+# --- for windows
+# save_dir = r'C:\SRI-DINO.Server-py\logs'  # sri内网测试环境
+save_dir = r'C:\logs'  # sri内网测试环境
+
+
+class LocalClass(object):
+    last_log_key = str()
+
+
+def method_v001(client, userdata, message):
+    """消息处理方法"""
+    # --- log ---
+    # methods.debug_log(f"method_v001|26", f"#message.payload: {message.payload}")
+    # return
+
+    # --- check ---
+    # if not methods.is_dir(save_dir):
+    #     out = methods.run_command(f'mkdir -p {save_dir}', callback=True)
+    #     methods.debug_log('MessageListener46', f"#out: {out}")
+
+    # --- check ---
+    try:
+        log_dict = json.loads(message.payload)
+        log_time = int(log_dict.get('timestamp')) / 1000
+        user_uuid = log_dict.get('userID')
+        vehicle_id = log_dict.get('VehicleID')
+        cockpit_id = log_dict.get('cockpitID')
+    except Exception as exception:
+        methods.debug_log("method_v001|41", f"#message.payload: {message.payload}")
+        methods.debug_log("method_v001|41", f"#exception: {exception.__class__.__name__}")
+        methods.debug_log("method_v001|41", f"#traceback: {traceback.format_exc()}")
+        return
+
+    # --- check ---
+    log_uuid = UserWorkRecord.get_log_uuid(user_uuid, log_time, vehicle_id, cockpit_id)
+    if not log_uuid:
+        methods.debug_log(f"MessageListenerV001|error50", f"user_uuid: {user_uuid}, log_time: {log_time}")
+        return
+
+    # --- fill log_list ---
+    log_list = [
+
+        f"timestamp: {methods.ts_to_string(log_time)}",  # 时间
+        f"topic: Vehicle/ControlVehicle/Veh001",  # 话题
+        # f"userID: {log_dict.get('userID')}",  # 用户id
+        # f"VehicleID: {log_dict.get('VehicleID')}",  # 车id
+        # f"cockpitID: {log_dict.get('cockpitID')}",  # 舱id
+
+        f"directSwitch: {log_dict.get('baseControl')[0].get('directSwitch')}",  # 前后切换
+        f"eStop: {log_dict.get('baseControl')[0].get('eStop')}",  # 急停开关
+        f"gearCaontrol: {log_dict.get('baseControl')[0].get('gearCaontrol')}",  # 车辆档位控制
+        f"hazardLight: {log_dict.get('baseControl')[0].get('hazardLight')}",  # 双闪灯
+        f"keyStatus: {log_dict.get('baseControl')[0].get('keyStatus')}",  # 钥匙状态
+        f"parkControl: {log_dict.get('baseControl')[0].get('parkControl')}",  # 驻车控制
+        f"silencedAlarm: {log_dict.get('baseControl')[0].get('silencedAlarm')}",  # 消报警音按钮
+        f"travelLight: {log_dict.get('baseControl')[0].get('travelLight')}",  # 行驶灯光
+        f"travelMode: {log_dict.get('baseControl')[0].get('travelMode')}",  # 驾驶模式
+        f"vehicleHorn: {log_dict.get('baseControl')[0].get('vehicleHorn')}",  # 喇叭
+
+        f"accPedalF: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalF')}",  # 油门踏板.手油门
+        f"accPedalH: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalH')}",  # 油门踏板.脚油门
+
+        f"accPedalH: {log_dict.get('driveControl')[0].get('brakePedal')}",  # 刹车踏板
+        f"steeringWheel: {log_dict.get('driveControl')[0].get('steeringWheel')}",  # 方向盘转速
+        f"turnMode: {log_dict.get('driveControl')[0].get('turnMode')}",  # 转向模式
+        f"turnSignal: {log_dict.get('driveControl')[0].get('turnSignal')}",  # 转向灯
+
+        f"errAccPedal: {log_dict.get('errCode')[0].get('errAccPedal')}",  # 油门信号故障
+        f"errBasOperation: {log_dict.get('errCode')[0].get('errBasOperation')}",  # 基本操作故障
+        f"errBrakePedal: {log_dict.get('errCode')[0].get('errBrakePedal')}",  # 刹车信号故障
+        f"errEndTool: {log_dict.get('errCode')[0].get('errEndTool')}",  # 末端工具控制故障
+        f"errHandle: {log_dict.get('errCode')[0].get('errHandle')}",  # 手柄信号故障
+        f"errOther: {log_dict.get('errCode')[0].get('errOther')}",  # 其他故障
+        f"errSteeringWheel: {log_dict.get('errCode')[0].get('errSteeringWheel')}",  # 转向故障
+
+        f"baseLegControl: {log_dict.get('taskControl')[0].get('baseLegControl')}",  # 支腿动作控制
+        f"baseLegSwitch: {log_dict.get('taskControl')[0].get('baseLegSwitch')}",  # 支腿选择开关
+        f"bypassSwitch: {log_dict.get('taskControl')[0].get('bypassSwitch')}",  # 旁通开关
+        f"cabLift: {log_dict.get('taskControl')[0].get('cabLift')}",  # 驾驶室升降机构
+        f"coopSignal: {log_dict.get('taskControl')[0].get('coopSignal')}",  # 协同作业信号
+        f"enableHydraulic: {log_dict.get('taskControl')[0].get('enableHydraulic')}",  # 液压使能开关
+        f"endJoint: {log_dict.get('taskControl')[0].get('endJoint')}",  # 末端关节控制
+        f"esCabLift: {log_dict.get('taskControl')[0].get('esCabLift')}",  # 驾驶室应急下降开关
+        f"suckerSelect: {log_dict.get('taskControl')[0].get('suckerSelect')}",  # 吸盘选择开关
+        f"taskJoint_1: {log_dict.get('taskControl')[0].get('taskJoint_1')}",  # 第一个作业关节控制
+        f"taskJoint_2: {log_dict.get('taskControl')[0].get('taskJoint_2')}",  # 第二个作业关节控制
+        f"taskJoint_3: {log_dict.get('taskControl')[0].get('taskJoint_3')}",  # 第三个作业关节控制
+        f"toolControl: {log_dict.get('taskControl')[0].get('toolControl')}",  # 末端工具控制
+        f"workLight: {log_dict.get('taskControl')[0].get('workLight')}",  # 工作灯
+
+    ]
+
+    # --- check ---
+    log_key = '-'.join(log_list[1:])
+    if LocalClass.last_log_key and LocalClass.last_log_key == log_key:
+        # methods.debug_log(f"MessageListener24", f"#86: {LocalClass.last_log_key == log_key}")
+        return
+
+    # --- update --
+    LocalClass.last_log_key = log_key
+
+    # --- save ---
+    # methods.debug_log(f"MessageListenerV001|113", f"#log_list: {log_list}")
+    log_file_path = os.path.join(save_dir, f'{log_uuid}.log')
+    methods.write_text(log_file_path, ' | '.join(log_list) + '\n', 'a')
+
+
+def subscribe_Veh0537():
+    """"""
+    Global.emqx_Veh0537.start_subscribe_loop(
+        decorate_method=method_v001,
+        subscribe_topic='Vehicle/ControlVehicle/Veh0537'
+    )

+ 126 - 0
sri-server-bg02/lib/MessageListenerZJV5.py

@@ -0,0 +1,126 @@
+from hub import methods, Global
+
+import threading
+import traceback
+import time
+import json
+import os
+
+from lib.UserWorkRecord import UserWorkRecord
+
+# --- for linux
+# save_dir = f"/home/server/logs"
+
+# --- for windows
+# save_dir = r'C:\SRI-DINO.Server-py\logs'  # sri内网测试环境
+save_dir = r'C:\logs'  # sri内网测试环境
+
+
+class LocalClass(object):
+    last_log_key = str()
+
+
+def method_v001(client, userdata, message):
+    """消息处理方法"""
+    # --- log ---
+    # methods.debug_log(f"method_v001|26", f"#message.payload: {message.payload}")
+    # return
+
+    # --- check ---
+    # if not methods.is_dir(save_dir):
+    #     out = methods.run_command(f'mkdir -p {save_dir}', callback=True)
+    #     methods.debug_log('MessageListener46', f"#out: {out}")
+
+    # --- check ---
+    try:
+        log_dict = json.loads(message.payload)
+        log_time = int(log_dict.get('timestamp')) / 1000
+        user_uuid = log_dict.get('userID')
+        vehicle_id = log_dict.get('VehicleID')
+        cockpit_id = log_dict.get('cockpitID')
+    except Exception as exception:
+        methods.debug_log("method_v001|41", f"#message.payload: {message.payload}")
+        methods.debug_log("method_v001|41", f"#exception: {exception.__class__.__name__}")
+        methods.debug_log("method_v001|41", f"#traceback: {traceback.format_exc()}")
+        return
+
+    # --- check ---
+    log_uuid = UserWorkRecord.get_log_uuid(user_uuid, log_time, vehicle_id, cockpit_id)
+    if not log_uuid:
+        methods.debug_log(f"MessageListenerV001|error50", f"user_uuid: {user_uuid}, log_time: {log_time}")
+        return
+
+    # --- fill log_list ---
+    log_list = [
+
+        f"timestamp: {methods.ts_to_string(log_time)}",  # 时间
+        f"topic: Vehicle/ControlVehicle/Veh001",  # 话题
+        # f"userID: {log_dict.get('userID')}",  # 用户id
+        # f"VehicleID: {log_dict.get('VehicleID')}",  # 车id
+        # f"cockpitID: {log_dict.get('cockpitID')}",  # 舱id
+
+        f"directSwitch: {log_dict.get('baseControl')[0].get('directSwitch')}",  # 前后切换
+        f"eStop: {log_dict.get('baseControl')[0].get('eStop')}",  # 急停开关
+        f"gearCaontrol: {log_dict.get('baseControl')[0].get('gearCaontrol')}",  # 车辆档位控制
+        f"hazardLight: {log_dict.get('baseControl')[0].get('hazardLight')}",  # 双闪灯
+        f"keyStatus: {log_dict.get('baseControl')[0].get('keyStatus')}",  # 钥匙状态
+        f"parkControl: {log_dict.get('baseControl')[0].get('parkControl')}",  # 驻车控制
+        f"silencedAlarm: {log_dict.get('baseControl')[0].get('silencedAlarm')}",  # 消报警音按钮
+        f"travelLight: {log_dict.get('baseControl')[0].get('travelLight')}",  # 行驶灯光
+        f"travelMode: {log_dict.get('baseControl')[0].get('travelMode')}",  # 驾驶模式
+        f"vehicleHorn: {log_dict.get('baseControl')[0].get('vehicleHorn')}",  # 喇叭
+
+        f"accPedalF: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalF')}",  # 油门踏板.手油门
+        f"accPedalH: {log_dict.get('driveControl')[0].get('accPedal')[0].get('accPedalH')}",  # 油门踏板.脚油门
+
+        f"accPedalH: {log_dict.get('driveControl')[0].get('brakePedal')}",  # 刹车踏板
+        f"steeringWheel: {log_dict.get('driveControl')[0].get('steeringWheel')}",  # 方向盘转速
+        f"turnMode: {log_dict.get('driveControl')[0].get('turnMode')}",  # 转向模式
+        f"turnSignal: {log_dict.get('driveControl')[0].get('turnSignal')}",  # 转向灯
+
+        f"errAccPedal: {log_dict.get('errCode')[0].get('errAccPedal')}",  # 油门信号故障
+        f"errBasOperation: {log_dict.get('errCode')[0].get('errBasOperation')}",  # 基本操作故障
+        f"errBrakePedal: {log_dict.get('errCode')[0].get('errBrakePedal')}",  # 刹车信号故障
+        f"errEndTool: {log_dict.get('errCode')[0].get('errEndTool')}",  # 末端工具控制故障
+        f"errHandle: {log_dict.get('errCode')[0].get('errHandle')}",  # 手柄信号故障
+        f"errOther: {log_dict.get('errCode')[0].get('errOther')}",  # 其他故障
+        f"errSteeringWheel: {log_dict.get('errCode')[0].get('errSteeringWheel')}",  # 转向故障
+
+        f"baseLegControl: {log_dict.get('taskControl')[0].get('baseLegControl')}",  # 支腿动作控制
+        f"baseLegSwitch: {log_dict.get('taskControl')[0].get('baseLegSwitch')}",  # 支腿选择开关
+        f"bypassSwitch: {log_dict.get('taskControl')[0].get('bypassSwitch')}",  # 旁通开关
+        f"cabLift: {log_dict.get('taskControl')[0].get('cabLift')}",  # 驾驶室升降机构
+        f"coopSignal: {log_dict.get('taskControl')[0].get('coopSignal')}",  # 协同作业信号
+        f"enableHydraulic: {log_dict.get('taskControl')[0].get('enableHydraulic')}",  # 液压使能开关
+        f"endJoint: {log_dict.get('taskControl')[0].get('endJoint')}",  # 末端关节控制
+        f"esCabLift: {log_dict.get('taskControl')[0].get('esCabLift')}",  # 驾驶室应急下降开关
+        f"suckerSelect: {log_dict.get('taskControl')[0].get('suckerSelect')}",  # 吸盘选择开关
+        f"taskJoint_1: {log_dict.get('taskControl')[0].get('taskJoint_1')}",  # 第一个作业关节控制
+        f"taskJoint_2: {log_dict.get('taskControl')[0].get('taskJoint_2')}",  # 第二个作业关节控制
+        f"taskJoint_3: {log_dict.get('taskControl')[0].get('taskJoint_3')}",  # 第三个作业关节控制
+        f"toolControl: {log_dict.get('taskControl')[0].get('toolControl')}",  # 末端工具控制
+        f"workLight: {log_dict.get('taskControl')[0].get('workLight')}",  # 工作灯
+
+    ]
+
+    # --- check ---
+    log_key = '-'.join(log_list[1:])
+    if LocalClass.last_log_key and LocalClass.last_log_key == log_key:
+        # methods.debug_log(f"MessageListener24", f"#86: {LocalClass.last_log_key == log_key}")
+        return
+
+    # --- update --
+    LocalClass.last_log_key = log_key
+
+    # --- save ---
+    # methods.debug_log(f"MessageListenerV001|113", f"#log_list: {log_list}")
+    log_file_path = os.path.join(save_dir, f'{log_uuid}.log')
+    methods.write_text(log_file_path, ' | '.join(log_list) + '\n', 'a')
+
+
+def subscribe_Veh0538():
+    """"""
+    Global.emqx_Veh0538.start_subscribe_loop(
+        decorate_method=method_v001,
+        subscribe_topic='Vehicle/ControlVehicle/Veh0538'
+    )