Control Changes
Control Change Messages
Control Changes are a different kind of output Message, therefore, they require and extra flag to be set under its output definition (control_change: True):
app:
type: kelvin
kelvin:
outputs:
- data_type: number
name: motor_speed_set_point
control_change: true
The ControlChange Object supports the following attributes:
| Attribute | Required | Description |
|---|---|---|
resource |
required | The KRNAssetDatastream that this Control Change is meant for. |
expiration_date |
required | Absolute datetime or a timedelta (from now) when the Control Change will expire. |
payload |
required | The desired target value for the control change (Boolean, Integer, Float or String). |
retries |
optional | Number of retries. |
timeout |
optional | Timeout for each retry. |
control_change_id |
optional | Sets a specific ID for the control change (UUID). |
from_value |
optional | Initial (trigger) value of the control change. |
And this is how to create and publish them:
from datetime import timedelta
from kelvin.application import KelvinApp
from kelvin.message import ControlChange
from kelvin.krn import KRNAssetDataStream
(...)
# Create and Publish a Control Change
await app.publish(
ControlChange(
resource=KRNAssetDataStream("my-motor-asset", "motor_speed_set_point"),
payload=1000,
expiration_date=timedelta(minutes=5)
)
)