|
@@ -13,7 +13,6 @@ import os
|
|
|
save_dir = r'C:\logs' # sri内网测试环境
|
|
|
|
|
|
|
|
|
-
|
|
|
class MessageListener(object):
|
|
|
"""
|
|
|
"""
|
|
@@ -31,13 +30,53 @@ class MessageListener(object):
|
|
|
log_file_path = os.path.join(save_dir, file_name)
|
|
|
log_dict = json.loads(message.payload)
|
|
|
log_list = [
|
|
|
- f"timestamp: {methods.ts_to_string(int(log_dict.get('timestamp'))/1000)}", # 时间
|
|
|
+
|
|
|
+ f"timestamp: {methods.ts_to_string(int(log_dict.get('timestamp')) / 1000)}", # 时间
|
|
|
f"userID: {log_dict.get('userID')}", # 用户id
|
|
|
f"VehicleID: {log_dict.get('VehicleID')}", # 车id
|
|
|
+
|
|
|
f"directSwitch: {log_dict.get('baseControl')[0].get('directSwitch')}", # 前后切换
|
|
|
- f"eStop: {log_dict.get('eStop')[0].get('eStop')}", # 急停开关
|
|
|
- f"gearCaontrol: {log_dict.get('gearCaontrol')[0].get('gearCaontrol')}", # 车辆档位控制
|
|
|
- f"hazardLight: {log_dict.get('hazardLight')[0].get('hazardLight')}", # 双闪灯
|
|
|
+ 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 ---
|
|
@@ -47,7 +86,7 @@ class MessageListener(object):
|
|
|
# --- check --
|
|
|
if not MessageListener.log_key:
|
|
|
MessageListener.log_key = '-'.join(log_list[1:])
|
|
|
-
|
|
|
+
|
|
|
print(f'MessageListener24: #log_list: {log_list}', flush=True)
|
|
|
methods.write_text(log_file_path, ' | '.join(log_list) + '\n', 'a')
|
|
|
|
|
@@ -68,7 +107,7 @@ class MessageListener(object):
|
|
|
# @classmethod
|
|
|
# def run_background(cls, background_is=True):
|
|
|
# """"""
|
|
|
-
|
|
|
+
|
|
|
# p1 = threading.Thread(target=cls.subscribe001)
|
|
|
# p1.start()
|
|
|
|
|
@@ -85,6 +124,7 @@ class MessageListener(object):
|
|
|
for thread in thread_list:
|
|
|
thread.join()
|
|
|
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
# --- test ---
|
|
|
MessageListener.run()
|