EthNmController
- class mtf.network_port.nm_controller.EthNmController
Ethernet Network Management controller
- data_type = 128
- __init__(channel_name: str)
Creates a new instance using the given parameters.
- Args:
bus_name (str): The name of the bus to listen on.
- Returns:
BusListener: The newly created instance.
- get_nm_signal(signal_name: str, update_nm_signal_data=None)
Get network management signal value
- Args:
signal_name (UdpNmSignals): NM signal name update_nm_signal_data(Function): Update NM signal data
- Returns:
Union[int, List[int]]: requested signal value.
- static __new__(cls, *args, **kwargs)
Creates a new instance.
- Args:
*args: The variable arguments list. **wargs: The keyword arguments list.
- Returns:
ControllersBase: The newly created instance.
Note:
Note
The instance will be automatically added to the list of controllers to be cleaned up later. It guarantees that all the controller instances are followed up and cleaned up when the associate method ‘controllers_cleanup(cls)’ is called.
Important
Do not override this method in subclasses to maintain this functionality.
- clean_up()
This method cleans up resources used by the listener by stopping any ongoing operations and resetting the listener’s internal state to ensure it is in a clean and ready state for future use.
- Returns:
bool: Returns True if the cleanup is successfully done. False if an exception occurs.
- classmethod controllers_cleanup()
Cleans up all controller instances.
It calls clean_up() for each controller in the list. If a cleanup fails, an error is raised, but the method continues processing the remaining controllers.
- Returns:
- bool: True indicating that all controllers were cleaned up successfully.
Otherwise, False is returned when an error occurs during the cleanup process.
- get_queue() list[dict[str, Any]]
Reset the internal state of an instance of the EthBusListener class
- get_timestamp_queue() list[int]
Retrieve the private attribute _timestamp_queue Return:
list[int]
- register_callback(callback_fnc: Callable[[IEthernetProtocol], None])
- Parameters:
callback_fnc – callback function with parameter of type
MessageEthernet
Setting a callback# ... from andisdk import MessageEthernet # ... def eth_listener_callback(msg: MessageEthernet): # do things # ... creating listener # register our callback listener.register_callback(eth_listener_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.
- reset() None
Resets the state of the bus listener by clearing its history and emptying the event queue.
- set_queue_size(max_size: int)
This call of set queue size will clear the queue and resize it better to call it at the beginning : before start listening if max_size <= 0 the queue size is infinite
- start_listening(keep_cache: bool = False, silent_mode: bool = True) bool
Starts listening on a bus and can be configured to operate in silent mode or to reset cached data before beginning to listen
- Args:
keep_cache (bool) silent_mode (bool): Specify whether the listening should be done in silent mode or not
- Return:
bool
- stop_listening(flush_event_history: bool = True) bool
Stops listening on the bus and optionally handles the remaining buffered events.
- Args:
- flush_event_history (bool):
If True (default), full event details are stored into the queues If False, only minimal information is stored from the remaining events
- Returns:
bool: True if the listener stopped successfully, False otherwise.
- unregister_callback(callback_fnc: Callable[[IEthernetProtocol], None])
- Parameters:
callback_fnc – callback function with parameter of type
MessageEthernet
Remove a callback# ... from andisdk import MessageEthernet # ... def eth_listener_callback(msg: MessageEthernet): # do things # ... creating listener # ... do work # unregister our callback listener.unregister_callback(eth_listener_callback)
- adapt_queue_elements() Queue[BaseEvent]
ensure the object.timestamp, object.payload