driver: Add handling for warning msgs

This commit is contained in:
linuswck 2025-01-22 18:21:30 +08:00
parent b3a9f61648
commit 7bdb7e48df

View File

@ -675,6 +675,7 @@ class Kirdy:
self._report_sig = None # Dict
self._connected_sig = None # Bool
self._err_msg_sig = None # Str
self._warning_msg_sig = None # Str
self.connected_event = None
@ -703,6 +704,12 @@ class Kirdy:
Emit a error message to a PyQt Signal(str) when a cmd fails to execute
"""
self._err_msg_sig = sig
def set_warning_msg_sig(self, sig):
"""
Emit a warning message to a PyQt Signal(str) when a cmd fails to execute
"""
self._warning_msg_sig = sig
def start_session(self, host='192.168.1.128', port=1550):
"""
@ -924,6 +931,10 @@ class Kirdy:
if msg["msg_type"] == msg_type:
if sig is not None:
sig.emit(msg)
elif msg["msg_type"] == "Warning":
logging.warn(f"{msg['msg_type']}:{msg['msg']}")
if self._warning_msg_sig is not None:
self._warning_msg_sig.emit(f"{msg['msg_type']}:{str(msg['msg'])}")
else:
logging.warn(f"Commands fail to execute. {msg['msg_type']}:{msg['msg']}")
if self._err_msg_sig is not None: