|
@@ -18,24 +18,32 @@ class MessageListener(object):
|
|
|
"""
|
|
|
|
|
|
@staticmethod
|
|
|
- def decorate_method(client, userdata, message):
|
|
|
+ def v001(client, userdata, message):
|
|
|
"""消息处理方法"""
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
- file_name = methods.now_string('%Y-%m-%d-%H.log')
|
|
|
-
|
|
|
- log_file_path = os.path.join(save_dir, file_name)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
log_dict = json.loads(message.payload)
|
|
|
- log_list = list()
|
|
|
-
|
|
|
- item_count = 29
|
|
|
- for i in range(1, item_count + 1):
|
|
|
- v = str(log_dict.get(str(i)))
|
|
|
- log_list.append(v)
|
|
|
- methods.write_text(log_file_path, '|'.join(log_list) + '\n', 'a')
|
|
|
-
|
|
|
+
|
|
|
+ log_time = int(log_dict.get('timestamp'))/1000
|
|
|
+ log_time = methods.ts_to_string(log_time)
|
|
|
+ methods.debug_log(f"MessageListener24", f"#log_time: {log_time}")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@classmethod
|
|
|
def start_check_loop(cls):
|
|
@@ -46,8 +54,9 @@ class MessageListener(object):
|
|
|
|
|
|
|
|
|
Global.emqx.start_subscribe_loop(
|
|
|
- decorate_method=MessageListener.decorate_method,
|
|
|
- subscribe_topic='bg/log'
|
|
|
+ decorate_method=MessageListener.v001,
|
|
|
+
|
|
|
+ subscribe_topic='Vehicle/ControlVehicle/Veh001'
|
|
|
)
|
|
|
|
|
|
|