adapter.transforms.transform_utils

File containing utility functions for the transforms.

class omotes_simulator_core.adapter.transforms.transform_utils.Port(port_id: str, port_name: str, port_type: PortType)

Bases: object

Dataclass to hold the port information.

port_id: str
port_name: str
port_type: PortType
class omotes_simulator_core.adapter.transforms.transform_utils.PortType(value)

Bases: Enum

Enum to define the type of port.

IN = 1
OUT = 2
omotes_simulator_core.adapter.transforms.transform_utils.order_prim_sec_ports(connected_ports: list[Port]) list[Port]

Order the primary and secondary ports. in correct order.

The correct order is first primary port, then secondary port. This can only be done by checking the port names. In primary port prim is in the name for secondary port sec is in the name.

Parameters:

connected_ports – List of connected ports to be sorted.

Returns:

List of connected ports sorted by primary and secondary ports.

omotes_simulator_core.adapter.transforms.transform_utils.reverse_dict(original_dict: dict) dict[str, list[type]]

Method to reverse a dict.

Creates a dict with set(values) as keys and the keys of the original dict as list values.

Parameters:

original_dict (dict) – Dict to be reversed {keys:values}.

Returns:

Reversed dict with {set(values):list[keys]}.

omotes_simulator_core.adapter.transforms.transform_utils.sort_ports(connected_ports: list[Port]) list[str]

Sort the ports of the asset based on the port type.

The sort order is Inport, Outport, Starting with the first inport, then the first outport and so on.

Parameters:

connected_ports – List of tuples with the port id, name and the port type.

Returns:

List of port ids sorted by port type.