ControlInterface

This script defines the ControlInterface class that handles the writing and reading of data to and from the Ankaios control interface.

Classes

  • ControlInterface:

    Handles the interaction with the Ankaios control interface.

Enums

  • ControlInterfaceState:

    Represents the state of the control interface.

Usage

  • Create a Control Interface instance, connect and disconnect.
    ci = ControlInterface(<callbacks from Ankaios>)
    ci.connect()
    ...
    ci.disconnect()
    
  • Change the state of the control interface.
    ci.change_state(ControlInterfaceState.CONNECTED)
    

ControlInterface Class

class ankaios_sdk._components.control_interface.ControlInterface(add_response_callback, state_changed_callback)[source]

Bases: object

This class handles the interaction with the Ankaios control interface. It provides methods to send and receive data to and from the control interface pipes.

path

The path to the control interface.

Type:

str

ANKAIOS_CONTROL_INTERFACE_BASE_PATH = '/run/ankaios/control_interface'

The base path for the Ankaios control interface.

Type:

(str)

__init__(add_response_callback, state_changed_callback)[source]

Initialize the ControlInterface object. This is used to interact with the control interface.

Parameters:
  • add_response_callback (Callable) – The callback function to add a response to the Ankaios class.

  • state_changed_callback (Callable) – The callback function to to call when the state of the control interface changes.

property state: ControlInterfaceState

Returns the current state of the control interface.

Returns:

The state of the control interface.

Return type:

ControlInterfaceState

connect()[source]

Connect to the control interface by starting to read from the input fifo and opening the output fifo.

Raises:

AnkaiosConnectionException – If an error occurred.

Return type:

None

disconnect()[source]

Disconnect from the control interface.

Return type:

None

change_state(state)[source]

Change the state of the control interface.

Parameters:

state (ControlInterfaceState) – The new state.

Return type:

None

write_request(request)[source]

Writes the request into the control interface output fifo.

Parameters:

request (Request) – The request object to be written.

Raises:

AnkaiosConnectionException – If not connected.

Return type:

None

ControlInterfaceState Enum

class ankaios_sdk._components.control_interface.ControlInterfaceState(value)[source]

Bases: Enum

The state of the control interface.

INITIALIZED = 1

Connection established state.

Type:

(int)

TERMINATED = 2

Connection stopped state.

Type:

(int)

AGENT_DISCONNECTED = 3

Agent disconnected state.

Type:

(int)

CONNECTION_CLOSED = 4

Connection closed state.

Type:

(int)

__str__()[source]

Returns the string representation of the state.

Returns:

The state as a string.

Return type:

str