Service Integration¶
User can perform integration with the following modules of TCUP with the help of Action Service.
TCUP Data Explorer (TDE)
Sensor Observation Service (SOS)
Device Management
MQTT
Asset Service
TDE¶
Users need to create two types of rule to insert data into TDE.
Register Sensor
Insert Observation
Users can also update or delete sensor in TDE.
Update Sensor
Delete Sensor
Register Sensor¶
Users need to register sensor in TDE before inserting any observation data.
{
"RuleId": 261,
"RuleName": "Register Sensor",
"Status": "Created",
"RuleDescription": "Register Sensor",
"noOfInstance": 3,
"input": {
"type": "Direct",
"exchange": "Direct.Exchange.Register",
"topic": "",
"MQName": ""
},
"actions": [
{
"type": "HTTPAllAction",
"parameter": [
{
"name": "payload",
"value": "asInput"
},
{
"name": "noOfRetry",
"value": "2"
},
{
"name": "connectionTimeout",
"value": "6000"
},
{
"name": "Content-Type",
"value": "application/json",
"type": "header",
"dataType": "string"
},
{
"name": "project",
"value": "project_name",
"type": "header",
"dataType": "string"
},
{
"name": "method",
"value": "POST"
},
{
"name": "connectorURL",
"value": "http://tde:9000/tde/api/v2.1/sensors"
}
]
}
]
}
Note
Users need to create project first using TDE before registration.
Insert Observation¶
Elastic Search insert action type is used for inserting data in elastic search.
Sample JSON for Elastic Search Insert create rule
is listed in the section below:
{
"RuleName": "Insert Observation",
"RuleDescription": "Insert Observation",
"noOfInstance": 3,
"input": {
"type": "Direct",
"exchange": "Direct.Exchange",
"topic": "",
"MQName": ""
},
"actions": [
{
"type": "ESINSERT",
"parameter": [
{
"name": "connectorURL",
"value": "elasticsearch:9200"
},
{
"name": "connectionTimeout",
"value": "6000"
},
{
"name": "clusterName",
"value": "cto_dev_cluster"
},
{
"name": "mappingName",
"value": "sensor"
},
{
"name": "rootNode",
"value": "observations"
},
{
"name": "indexName",
"value": "username_projectname"
},
{
"name": "schema",
"value": "[{\"operation\":\"shift\",\"spec\":{\"record\":{\"*\":{\"output\":{\"*\":{\"@value\":\"[&3].@name\"}},\"checktime1\":\"[&1].checktime1\",\"checktime\":\"[&1].checktime\",\"@(2,feature)\":\"[&1].feature\",\"endtime\":\"[&1].endtime\",\"starttime\":\"[&1].starttime\",\"@(2,sensor)\":\"[&1].sensor\",\"@(3,sensor)\":\"[&1].category\",\"@(2,offering)\":\"[&1].offering\"}}}}]"
},
{
"name": "inputDateFormat",
"value": "dd-MMM-yyyy hh:mm:ss.SSS ZZZ"
},
{
"name": "outputDateFormat",
"value": "yyyy-MM-dd'T'HH:mm:ss.SSS"
}
]
}
]
}
Note
Users need to send sensor observation data to the input of these rules.
Index name will be in the format of
username_projectname
orprojectname
and the user needs to first create the project using TDE before registration.SOS sends all observed property value as String which is generic in nature. TDE output may not come as expected all the time for this reason. To overcome this problem the user may consider the next example.
If the observation coming from SOS contains integer, float or double in the value field then action rule can convert these values to double using jolt spec. The schema will be different for this case. The sample rule is given below:
{
"RuleName": "Insert Observation 2",
"RuleDescription": "Insert Observation",
"noOfInstance": 3,
"input": {
"type": "Direct",
"exchange": "Direct.Exchange",
"topic": "",
"MQName": ""
},
"actions": [
{
"type": "ESINSERT",
"parameter": [{
"name": "connectorURL",
"value": "elasticsearch:9200"
},
{
"name": "connectionTimeout",
"value": "6000"
},
{
"name": "clusterName",
"value": "cto_dev_cluster"
},
{
"name": "mappingName",
"value": "sensor"
},
{
"name": "rootNode",
"value": "observations"
},
{
"name": "indexName",
"value": "username_projectname"
},
{
"name": "schema",
"value": "[{\"operation\":\"modify-overwrite-beta\",\"spec\":{\"record\":{\"*\":{\"output\":{\"*\":{\"value\":[\"=toDouble\"]}}}}}},{\"spec\":{\"sensor\":\"sensor\",\"feature\":\"feature\",\"@sensor\":\"category\",\"@offering\":\"offering\",\"record\":{\"*\":{\"starttime\":\"starttime\",\"endtime\":\"endtime\",\"checktime1\":\"checktime1\",\"checktime\":\"checktime\",\"output\":{\"*\":{\"@value\":\"@name\"}}}}},\"operation\":\"shift\"}]"
},
{
"name": "inputDateFormat",
"value": "dd-MMM-yyyy hh:mm:ss.SSS ZZZ"
},
{
"name": "outputDateFormat",
"value": "yyyy-MM-dd'T'HH:mm:ss.SSS"
}
]
}
]
}
Update Sensor¶
User can update sensor using the following rule:
{
"RuleId": 261,
"RuleName": "Update Sensor",
"Status": "Created",
"RuleDescription": "Update Sensor",
"noOfInstance": 3,
"input": {
"type": "Direct",
"exchange": "Direct.Exchange.Sensor.Update",
"topic": "",
"MQName": ""
},
"actions": [
{
"type": "HTTPAllAction",
"parameter": [
{
"name": "payload",
"value": "asInput"
},
{
"name": "noOfRetry",
"value": "2"
},
{
"name": "connectionTimeout",
"value": "6000"
},
{
"name": "Content-Type",
"value": "application/json",
"type": "header",
"dataType": "string"
},
{
"name": "project",
"value": "project_name",
"type": "header",
"dataType": "string"
},
{
"name": "method",
"value": "PUT"
},
{
"name": "connectorURL",
"value": "http://tde:9000/tde/api/v2.1/sensors"
}
]
}
]
}
Delete Sensor¶
User can delete sensor using the following rule:
{
"RuleId": 121,
"RuleName": "Sensor deletion",
"Status": "Running",
"RuleDescription": "checking",
"noOfInstance": 3,
"input": {
"type": "Direct",
"exchange": "Direct.Exchange.Sensor.Delete",
"topic": "",
"MQName": ""
},
"actions": [{
"type": "HTTPAllAction",
"parameter": [{
"name": "payload",
"value": ""
}, {
"name": "noOfRetry",
"value": "2"
}, {
"name": "connectionTimeout",
"value": "6000"
}, {
"name": "project",
"value": "TestingQA",
"type": "header",
"dataType": "string"
}, {
"name": "method",
"value": "DELETE"
}, {
"name": "connectorURL",
"value": "http://tde:9000/tde/api/v2.1/sensors/{param1}"
}, {
"name": "param1",
"value": "sensor",
"type": "path",
"dataType": "string"
}]
}]
}
SOS¶
User can integrate any service to SOS with the help of the following action rule:
{
"RuleName": "TestRule7",
"RuleDescription": "checking",
"noOfInstance": 3,
"input": {
"type": "Direct",
"exchange": "DM.Exchange",
"topic": "",
"MQName": ""
},
"actions": [
{
"type": "SOS",
"parameter": [
{
"name": "content-type",
"value": "application/json",
"type": "header",
"dataType": ""
},
{
"name": "payload",
"value": "asInput"
},
{
"name": "connectorURL",
"value": "http://sos:8080/api/sos/v2.0/observations"
},
{
"name": "connectionTimeout",
"value": "5000"
}
]
}
]
}
Device Management¶
This rule is used to integrate Device Management to SOS
{
"RuleName": "TestRule7",
"RuleDescription": "checking",
"noOfInstance": 3,
"input": {
"type": "Direct",
"exchange": "DM.Exchange",
"topic": "",
"MQName": ""
},
"actions": [
{
"type": "SOS",
"parameter": [
{
"name": "content-type",
"value": "application/json",
"type": "header",
"dataType": ""
},
{
"name": "payload",
"value": "asInput"
},
{
"name": "connectorURL",
"value": "http://sos:8080/api/sos/v2.0/observations"
},
{
"name": "connectionTimeout",
"value": "5000"
}
]
}
]
}
MQTT¶
This rule is used to integrate MQTT to SOS.
{
"RuleName": "TestRule7",
"RuleDescription": "checking",
"noOfInstance": 3,
"input": {
"type": "Direct",
"exchange": "Direct.Exchange.MQTT",
"topic": "",
"MQName": ""
},
"actions": [
{
"type": "MQTTSOSAction",
"parameter": [
{
"name": "connectionTimeout",
"value": "5000"
},
{
"name": "connectorURL",
"value": "http://sos:8080/"
},
{
"name": "payload",
"value": "asInput"
},
{
"name": "content-type",
"value": "application/json",
"type": "header",
"dataType": ""
},
{
"name": "x-api-key",
"value": "e22IWwUV4RUp0AXHWGMcotgtI8=",
"type": "header",
"dataType": ""
}
]
}
]
}
Note
User needs to set input type as
Direct
, exchange name asDM.Exchange
and topic asblank
to send the data from DM to SOS.User need to set input type as
Direct
,exchange name asDirect.Exchange.MQTT
and topic asblank
to send the data from MQTT to SOS.Each user needs to create his/ her own rule to pass the data to SOS.
Asset Service¶
This rule is used to integrate SOS to Asset Service.
{
"RuleId": 145,
"RuleName": "SOS To Asset",
"Status": "Running",
"RuleDescription": "SOS To Asset",
"noOfInstance": 10,
"input": {
"type": "Direct",
"exchange": "Direct.Exchange",
"topic": "",
"MQName": ""
},
"actions": [
{
"type": "HTTPAllAction",
"parameter": [
{
"name": "connectionTimeout",
"value": "6000"
},
{
"name": "method",
"value": "POST"
},
{
"name": "noOfRetry",
"value": "1"
},
{
"name": "content-type",
"value": "application/json",
"type": "header",
"dataType": "string"
},
{
"name": "connectorURL",
"value": "http://assetservice:8080/AssetService/asset/process/observation"
},
{
"name": "payload",
"value": "asInput"
}
]
}
]
}
Note
User needs to set input type as
Direct
, exchange name asDirect.Exchange
and topic asblank
and send the data to SOS.