IoController

class mtf.network_port.io_controller.IoController

This class implements a singleton I/O controller to be used in the entire system.

__init__()

Creates a new instance.

Returns:

IoController: The newly created instance.

set_io_value(channel_name: str, value: float)

Sets io value.

Args:

channel_name (str): The IO channel name. value (float): IO value to be set.

Returns:

bool: True if IO value is set; otherwise False .

set_io_raw_value(channel_name: str, value: float)

Sets the I/O value of the given channel.

Args:

channel_name (str): The I/O channel to set. value (float): The raw value to set.

Returns:

bool: True on success; otherwise False .

io_apply_faulty(channel_name: str, fault_type: int | IoFaultyTypes)

Applies a faulty value or type to the given I/O channel.

Args:

channel_name (str): The I/O channel to manipulate. fault_type (Union[int, IoFaultyTypes]): The fault type to apply.

Returns:

bool: True on success; otherwise False.

Note:

..note:

``fault_type`` codes:

    - 0 or ShortCutToGnd : shortcut to oGND.
    - 1 or ShortcutToVbat: shortcut to battery (BAT).
    - 2 or CableBreak: simulate a cable break.
io_stop_faulty(channel_name: str, fault_type: int | IoFaultyTypes)

Remove a faulty value or type to the given I/O channel.

Args:

channel_name (str): The I/O channel to manipulate. fault_type (Union[int, IoFaultyTypes]): The fault type to apply.

Returns:

bool: True on success; otherwise False.

Note:

..note:

``fault_type`` codes::

    - 0 or ShortCutToGnd : shortcut to GND.
    - 1 or ShortcutToVbat: shortcut to battery (BAT).
    - 2 or CableBreak: simulate a cable break.
io_set_current(channel_name: str, value: float)

Sets the current value for the given I/O channel.

Args:

channel_name (str): The I/O channel to modify. value (float): The current value (in Ampere) to set.

Returns:

bool: True if IO current is set, otherwise False.

io_set_resistance(channel_name: str, value: int)

Sets the resistance of the given I/O channel.

Args:

channel_name (str): The I/O channel to modify. value (float): The resistance value (in Ohm) to set.

Returns:

bool: True if IO resistance is set, otherwise False.

io_set_voltage(channel_name: str, value: float)

Sets the voltage of the given I/O channel.

Args:

channel_name (str): The I/O channel to modify. value (float): The voltage (in Volt) to set.

Returns:

bool: True if the value is set, otherwise False.

io_generate_pattern(channel_name: str, value: list)

Sets a pattern for the given I/O channel.

Args:

channel_name (str): The I/O channel to modify. value (list): The list of values generating the desired pattern.

Returns:

bool: True if the pattern is generated; otherwise False.

is_channel_available(channel_name: str)

Checks for physical connection of the given I/O channel.

Args:

channel_name (str): The I/O channel to be checked.

Returns:

bool: True if channel name is available; otherwise False.

io_get_last_value(channel_name: str, property_name: IoProperty)

Gets the latest value of the given I/O channel property.

Args:

channel_name (str): The I/O channel to be checked. property_name (str): The property to be checked.

Returns:

float: The last received value of the given property.

io_read_current(channel_name: str)

Gets the current value of the given I/O channel.

Args:

channel_name (str): The I/O channel to read from.

Returns:

float: The current value (in Ampere).

io_read_voltage(channel_name: str)

Gets the voltage of the given I/O channel.

Args:

channel_name (str): The I/O channel to read from.

Returns:

float: The voltage value (in Volt).