|
@@ -12,6 +12,7 @@ import os
|
|
|
|
|
|
save_dir = r'C:\logs'
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
class MessageListener(object):
|
|
@@ -20,12 +21,17 @@ class MessageListener(object):
|
|
|
last_log_key = str()
|
|
|
|
|
|
@staticmethod
|
|
|
- def v001(client, userdata, message):
|
|
|
+ def method_v001(client, userdata, message):
|
|
|
"""消息处理方法"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
file_name = methods.now_string('v001-%Y-%m-%d-%H.log')
|
|
|
log_file_path = os.path.join(save_dir, file_name)
|
|
@@ -94,30 +100,30 @@ class MessageListener(object):
|
|
|
methods.write_text(log_file_path, ' | '.join(log_list) + '\n', 'a')
|
|
|
|
|
|
@classmethod
|
|
|
- def subscribe001(cls):
|
|
|
+ def subscribe_v001(cls):
|
|
|
""""""
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
Global.emqx.start_subscribe_loop(
|
|
|
- decorate_method=MessageListener.v001,
|
|
|
-
|
|
|
+ decorate_method=MessageListener.method_v001,
|
|
|
subscribe_topic='Vehicle/ControlVehicle/Veh001'
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ @staticmethod
|
|
|
+ def method_c001(client, userdata, message):
|
|
|
+ """消息处理方法"""
|
|
|
+
|
|
|
+ methods.debug_log(f"MessageListener|114", f"#message.payload: {message.payload}")
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ def subscribe_c001(cls):
|
|
|
+ """"""
|
|
|
+ Global.emqx.start_subscribe_loop(
|
|
|
+ decorate_method=MessageListener.method_c001,
|
|
|
+ subscribe_topic='Cockpit/CanBus/CanId001/Cop001'
|
|
|
+ )
|
|
|
|
|
|
@classmethod
|
|
|
def run(cls, background_is=True):
|
|
|
thread_list = [
|
|
|
- threading.Thread(target=cls.subscribe001),
|
|
|
+ threading.Thread(target=cls.subscribe_v001),
|
|
|
]
|
|
|
for thread in thread_list:
|
|
|
thread.setDaemon(True)
|