Asset Connector Documentation
Loading...
Searching...
No Matches
python_connector.main Namespace Reference

Functions

ResponseBody root ()
 Root endpoint that returns available endpoints.
 
ResponseBody add_or_update_config (SetConfigPayload payload)
 Set or add configuration using an AID submodel.
 
ResponseBody get_value (GetValuePayload payload)
 Get a current reading from a protocol-specific endpoint of the asset as specified in the AID submodel.
 
ResponseBody set_value (SetValuePayload payload)
 Set a new value to a protocol-specific endpoint of the asset as specified in the AID submodel.
 
 start_app ()
 Function to start the FastAPI application.
 

Variables

 app = FastAPI()
 
 logger = logging.getLogger(__name__)
 
dict connector_store = {}
 
 connector_store_lock = threading.Lock()
 

Function Documentation

◆ add_or_update_config()

ResponseBody python_connector.main.add_or_update_config ( SetConfigPayload  payload)

Set or add configuration using an AID submodel.

All interfaces defined in the provided AID will be analyzed and cached in an internal data structure. An interface is defined by the unique combination of submodel ID (ID of the AID) and interface name (IDshort). If an interface with the same AID-ID and name already exists, it will be overwritten.

If the protocol of the interface it supported by the implementation, an according co-routine will be added to handle the communication with the asset via the specified protocol and endpoints. Supported protocols are: MQTT, OPC UA, HTTP.

Parameters
payloadJSON object that is parsed as SetConfigPayload
Returns
JSON object that is parsed as ResponseBody containing a status code and confirmation.

Definition at line 56 of file main.py.

◆ get_value()

ResponseBody python_connector.main.get_value ( GetValuePayload  payload)

Get a current reading from a protocol-specific endpoint of the asset as specified in the AID submodel.

Using a cached AID submodel (more concisely, an interface definition in the AID), a connection to the asset is established. A current reading from the endpoint of the asset if obtained and returned.

Parameters
payloadJSON object that is parsed as GetValuePayload
Returns
JSON object that is parsed as ResponseBody containing a status code and the read value.

Definition at line 140 of file main.py.

◆ root()

ResponseBody python_connector.main.root ( )

Root endpoint that returns available endpoints.

Definition at line 37 of file main.py.

◆ set_value()

ResponseBody python_connector.main.set_value ( SetValuePayload  payload)

Set a new value to a protocol-specific endpoint of the asset as specified in the AID submodel.

Using a cached AID submodel (more concisely, an interface definition in the AID), a connection to the asset is established. The provided value is written to the endpoint of the asset.

Parameters
payloadJSON object that is parsed as SetValuePayload
Returns
JSON object that is parsed as ResponseBody containing a status code and the read value.

Definition at line 177 of file main.py.

◆ start_app()

python_connector.main.start_app ( )

Function to start the FastAPI application.

Will use the APP_HOST and APP_PORT environment variables to specify IP interface and port for listening. Default 0.0.0.0:8090 Overwritten by Dockerfile: 0.0.0.0:8000

Definition at line 208 of file main.py.

Variable Documentation

◆ app

python_connector.main.app = FastAPI()

Definition at line 26 of file main.py.

◆ connector_store

dict python_connector.main.connector_store = {}

Definition at line 31 of file main.py.

◆ connector_store_lock

python_connector.main.connector_store_lock = threading.Lock()

Definition at line 32 of file main.py.

◆ logger

python_connector.main.logger = logging.getLogger(__name__)

Definition at line 28 of file main.py.