Skip to content

adapter

Adapter

Bases: ABC

Abstract base class for adapters.

start() abstractmethod

Start the adapter.

This method is called when the tool loop is started. It should be used to initialize the adapter, start any background processes and establish connections to the CPS.

Source code in src/flowcean/core/adapter/adapter.py
 9
10
11
12
13
14
15
16
@abstractmethod
def start(self) -> None:
    """Start the adapter.

    This method is called when the tool loop is started.
    It should be used to initialize the adapter, start any
    background processes and establish connections to the CPS.
    """

stop() abstractmethod

Stop the adapter.

This method is called when the tool loop is stopped. It should be used to clean up resources, stop any background processes and close connections to the CPS.

Source code in src/flowcean/core/adapter/adapter.py
18
19
20
21
22
23
24
25
@abstractmethod
def stop(self) -> None:
    """Stop the adapter.

    This method is called when the tool loop is stopped.
    It should be used to clean up resources, stop any background
    processes and close connections to the CPS.
    """

get_data() abstractmethod

Get data from the CPS through the adapter.

Retrieve a data record from the CPS. This method should block until data is available. If no more data is available, it should raise a Stop exception.

Returns:

Type Description
Data

The data retrieved from the CPS.

Source code in src/flowcean/core/adapter/adapter.py
27
28
29
30
31
32
33
34
35
36
37
@abstractmethod
def get_data(self) -> Data:
    """Get data from the CPS through the adapter.

    Retrieve a data record from the CPS. This method should block until
    data is available. If no more data is available, it should raise a
    Stop exception.

    Returns:
        The data retrieved from the CPS.
    """

send_data(data) abstractmethod

Send data to the CPS through the adapter.

This method allows sending data to the CPS. It is used by the tool loop to send the results for the tool evaluation back to the CPS for further processing.

Parameters:

Name Type Description Default
data Data

The data to send.

required
Source code in src/flowcean/core/adapter/adapter.py
39
40
41
42
43
44
45
46
47
48
49
@abstractmethod
def send_data(self, data: Data) -> None:
    """Send data to the CPS through the adapter.

    This method allows sending data to the CPS. It is used by the tool loop
    to send the results for the tool evaluation back to the CPS for further
    processing.

    Args:
        data: The data to send.
    """

Stop

Bases: Exception

Exception raised when the tool loop should be stopped.