Usage
The ServiceWrapper will resolve all necessary communications with the SystemManager to register your service, resolve dependencies, and inject OTA tuning states. You can access retrieved information and service.yaml
configurations through your shell environment. This page highlights where all information is injected.
All injected environment variables injected, are prefixed with ASE_SW_
to avoid interference with an already present environment. The ServiceWrapper will not check if an environment variable is already present.
Static information
After successful registration and dependency resolution, the following environment variables will be injected
Key | Value |
---|---|
ASE_SW_ServiceName | The name of your service, as defined in your service.yaml file and as used to register your service |
ASE_SW_ServicePID | The PID used to register your service |
For every output defined in your service.yaml
, the output name will be part of the key, and the ZMQ address will be the value, as defined below:
Key | Value |
---|---|
ASE_SW_Output_<OUTPUT_NAME> | The ZMQ address defined in the service.yaml for this output |
For every tuning option, its value will be injected in the environment based on the parameter name. You can also fetch the type of this parameter to aid parsing the parameter, as defined below:
Key | Value |
---|---|
ASE_SW_TuningParameterValue_<PARAMETER_NAME> | The tuning parameter value at startup |
ASE_SW_TuningParameterType_<PARAMETER_NAME> | The tuning parameter type (INT ), FLOAT or STRING |
The tuning parameter value might change due to a new broadcasted tuning state, but this will not update the environment variable during execution.
Dependency information
The ServiceWrapper will only start your binary or script when all dependencies are resolved. Then, for each dependency name and endpoint name combination it will inject the found ZMQ address, as defined below:
Key | Value |
---|---|
ASE_SW_Dependency_<SERVICE_NAME>_<ENDPOINT_NAME> | The resolved ZMQ address of this service and endpoint combination |
Example
To illustrate the created environment variables, we will consider two services: ServiceA and ServiceB, with ServiceB depending on ServiceA. Their service.yaml
files ere defined below, together with the created environment variables.
Service A
Configuration
# Service identifying information
name: serviceA
description: empty service
# Depends on no service
dependencies: []
# Outputs images on the "image" endpoint
outputs:
- name: image
address: tcp://localhost:4242
# Tuning options
options:
# proportional gain for PID
- name: mytuningparam
type: float
mutable: false
default: 0.2
- name: cameraBrightness
type: int
mutable: false
default: 200
Environment created by mod-ServiceWrapper
# identifying info
ASE_SW_ServiceName=serviceA
ASE_SW_ServicePID=1234
# outputs
ASE_SW_Output_image=tcp://localhost:4242
# tuning options
ASE_SW_TuningParameterValue_mytuningparam="0.2"
ASE_SW_TuningParameterType_mytuningparam=FLOAT
ASE_SW_TuningParameterValue_cameraBrightness=200
ASE_SW_TuningParameterType_cameraBrightness=INT
# dependencies (none)
Service B
Configuration
# Service identifying information
name: serviceB
description: empty service
# Depends on service A's "image" output
dependencies:
- service: serviceA
output: image
# Exposes no outputs
outputs: []
# Tuning options
options:
# proportional gain for PID
- name: imagethreshold
type: float
mutable: false
default: 0.8
Environment created by mod-ServiceWrapper
# identifying info
ASE_SW_ServiceName=serviceB
ASE_SW_ServicePID=5678
# outputs (none)
# tuning options
ASE_SW_TuningParameterValue_imageThreshold="0.8"
ASE_SW_TuningParameterType_imageThreshold=FLOAT
# dependencies
ASE_SW_Dependency_serviceA_image=tcp://localhost:4242