IoListener

class mtf.network_port.bus_listener.IoListener
__init__(bus_name: str)
property last_value
adapt_queue_elements() Queue[BaseEvent]

ensure the object.timestamp, object.payload

get_queue() Queue[IoEvent]

Get the queue

register_callback(callback_fnc)
Parameters:

callback_fnc – callback function with parameter of type IoEvent

Setting a callback
# ...
from mtf.mtf_types import IoEvent
# ...

def my_callback(msg: IoEvent):
    # do things

# ... creating listener 
# register our callback
listener.register_callback(my_callback)

Warning

The callback function should be lightweight without logs. Otherwise, it will reduce the performance dramatically. The object that is passed to callback functions is mutable. So the user must be careful. In case of silent mode, the callback functions will be invoked only when getting the queue.

unregister_callback(callback_fnc)
Parameters:

callback_fnc – callback function with parameter of type BusEvent, which has been registered

:Example def io_listener_callabck(io_event :IoEvent)

callback_(io_event: IoEvent)
static __new__(cls, *args, **kwargs)

Initialize a new instance of the ControllerBase.

The instance will be automatically added to the list of controllers.

clean_up()
classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.

reset()

cleanup the queue

start_listening(silent_mode: bool = False) bool
stop_listening() bool