AMQP - Readers
Asset publishes on AMQP broker |
AuthN User |
<model_name>/<asset_name> - pass: sha1( <asset_name> + SEED)
|
Seed |
Seed is defined in miimetiq.conf using variable: DEVICE_AUTH_HASH_SEED
, default SEED value is miimetiq
|
AuthZ |
device ‘A’ can only publish on its readers, if device ‘A’ has to publish on readers associated with device ‘B’; it has to be declared in miimetiq.conf using variable MIIMETIQ_RELAY_TO_RELATED_ASSET
and they have to be related using miimetiq.types.related_asset
|
|
Required to restrict with the variable in AMQP_AUTHZ_RESTRICTED_MODELS
in miimetiq.conf the listed devices if they should only publish and subscribe data of itself or it related assets |
|
Instrument type required to be connected to AMQP CL exchange is: miimetiq.types.instrument.connection_layer
|
Exchange |
cl.<model-name>.<asset name>
|
Topic |
miimetiq.ds.reader.<type>.<model_name>.<device_id>.<reader_path>
|
AMQP - Reader - Example
DEVICE_AUTH_HASH_SEED = ‘miimetiq’
authn: u: generator/54282d2405ec - p: sha1( 54282d2405ec + miimetiq)
exchange: cl.generator.54282d2405ec
topic: miimetiq.ds.reader.integer.generator.54282d2405ec.engine.running_hours
payload:
{
'task': 'async',
'id': '627727b5-1bd1-4fdf-9348-d453dfa17841',
'args': ['generator.54282d2405ec.engine.running_hours 1412525558.01 128'],
'kwargs': {}
}
|
MQTT - Readers
AuthN |
Same as amqp authn |
Topic |
miimetiq/ds/reader/<type>/<asset_model>/<asset_name>/<reader_path>
|
PayLoad |
<asset_model>.<asset_name>.<reader_path> <ts> <value>
|
MQTT - Readers - Example
AuthN: |
Same as amqp authn |
Topic: |
miimetiq/ds/reader/integer/generator/my_generator-1/engine/running_hours
|
Payload: |
DG2014-1P.device-30-Shanghai.engine.oil_temp 1412525558.01 128
|
MQTT - Writers - Example
AuthN |
Same as amqp authn |
Topic |
miimetiq/ds/writer/boolean/DG2014-1P/device-30-Shanghai/generator/power
|
Payload |
{ "value": true, "correlation_id": "ef1ha567e" }
|
MQTT - Writers
AuthN |
Same as amqp authn |
Topic |
miimetiq/ds/writer/<type>/<asset_model>/<asset_name>/<writer_path>
|
Payload |
{ "value": <value>, "correlation_id": <uuid.without.dashes> }
|
MQTT - Writers - Feedback
AuthN |
Same as amqp authn |
Topic |
miimetiq/ds/writer_results/<asset_model>/<asset_name>/<correlation_id>
|
Payload |
{ "status": "OK", "any": "something" }
|
MQTT - Writer Feedback - Example
AuthN |
Same as amqp authn |
Topic |
miimetiq/ds/devices/generator/my_generator-1/engine/power
|
Payload |
{ "status": "Failed", "any": "anything" }
|
|
|
AMQP - Writer
Asset subscribes to AMQP broker |
Exchange |
cl.<model-name>.<asset name>
|
Topic to be subscribed or where to publish: |
miimetiq.ds.writer.<type>.<model_name>.<asset_id>.<writer_path>
|
Payload |
{ 'task': 'async', 'id': <uuid>, 'args': [{"value": <value>}], 'kwargs': {} }
|
AMQP - Writer - Example
Authn: u: --- / p: ---
Exchange:
Topic: miimetiq.ds.writer.boolean.6-diesel_generator_schema.5609022ee7e466125aa1c032.generator.power
Payload:
{
'task': 'async',
'id': <uuid>,
'args': [{"value": <value>}],
'kwargs': {}
}
|
Writers Rest Push
User submit a writer value in REST API |
URL: |
|
Required headers |
Content-Type: application/json Access-Token: <session token>
|
Payload |
´{"value": <value>}´ |
|
|
Payload reporting an OK:
{
"status": "SUCCESS",
"result": {
"status": "OK",
"any_field": "any_value", # not required, customer
},
"task_id": <uuid>
}
|
Writers feedback
Asset publish a message to AMQP broker |
Exchange |
celeryresults |
Topic |
correlation_id.replace(‘-’,’’)
|
Payload reporting a fail
{
"status": "SUCCESS",
"result": {
"status": "KO",
"any_field": "any_value", # not required, customer
},
"task_id": <uuid>
}
|
|