Example property paths that group related properties
The MTConnect protocol provides metadata about each data value that you collect. This metadata includes the data type, category, device ID, component ID, and data item ID. You may want to include this metadata in the JSON documents generated by FairCom's MTConnect connector. This metadata is useful for troubleshooting and providing context. The MTConnect timestamp is particularly useful because it tracks the actual time the device collected the data.
You can use property paths to organize a JSON document to associate a data value with its metadata. One approach is to nest related properties inside the same JSON object. Another approach is to add the same name prefix to related properties.
The examples in this topic use the following MTConnect XML as the data source for generating JSON results.
<MTConnectStreams>
<Streams>
<DeviceStream
name="X1"
uuid="X1_373f-4ab9-9c7a-173edd23e4f3">
<ComponentStream
component="Device"
name="Stamper1"
componentId="X1_Stamper1">
<Samples>
<REAL
dataItemId="X1_Stamper1_Temperature"
name="Temperature"
sequence="5"
timestamp="2010-04-06T06:19:35.153141"
>20.1</REAL>
</Samples>
</ComponentStream>
</DeviceStream>
</Streams>
</MTConnectStreams>Grouping related properties in the same parent object
The following "createInput" example configures the MTConnect Connector to nest related properties inside a "temperature" object. This approach has the advantage of a short, easy-to-read property names, but the disadvantage of a more complex JSON structure.
{
"api": "hub",
"action": "createInput",
"params": {
"inputName": "mymtconnect",
"serviceName": "mtconnect",
"settings": {
"host": "195.167.1.5:5000",
"propertyMapList": [
{
"propertyPath": "temperature.value",
"dataType": "string",
"mtconnectDeviceUuid": "X1_373f-4ab9-9c7a-173edd23e4f3",
"mtconnectDataItemId": "X1_Stamper1_Temperature",
"mtconnectCategoryPropertyPath": "temperature.category",
"mtconnectComponentNamePropertyPath": "temperature.component",
"mtconnectDataItemIdPropertyPath": "temperature.dataItemId",
"mtconnectDataNamePropertyPath": "temperature.dataName",
"mtconnectDataTypePropertyPath": "temperature.dataType",
"mtconnectDeviceNamePropertyPath": "temperature.device",
"mtconnectDeviceUuidPropertyPath": "temperature.deviceUuid",
"mtconnectSequencePropertyPath": "temperature.sequence",
"mtconnectTimestampPropertyPath": "temperature.timestamp"
}
]
},
"tableName": "mtconnectTable"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
When configured with the previous "createInput" example, FairCom's MTConnect Connector collects data and generates a JSON document like the following example.
{
"temperature":
{
"value": 20.1,
"category": "SAMPLE",
"component": "Stamper1",
"dataItemId": "X1_Stamper1_Temperature",
"dataName": "Temperature",
"dataType": "REAL",
"device": "Device1",
"deviceUuid": "X1_373f-4ab9-9c7a-173edd23e4f3",
"sequence": 5,
"timestamp": "2010-04-06T06:19:35.153141"
}
}
Grouping related properties using prefixed property names
The following "createInput" example configures the MTConnect Connector to name related properties with the same "temperature" prefix. This approach has the advantage of a simpler JSON structure, but the disadvantage of longer property names.
{
"api": "hub",
"action": "createInput",
"params": {
"inputName": "mymtconnect",
"serviceName": "mtconnect",
"settings": {
"host": "195.167.1.5:5000",
"propertyMapList": [
{
"propertyPath": "temperatureValue",
"dataType": "string",
"mtconnectDeviceUuid": "X1_373f-4ab9-9c7a-173edd23e4f3",
"mtconnectDataItemId": "X1_Stamper1_Temperature",
"mtconnectCategoryPropertyPath": "temperatureCategory",
"mtconnectComponentNamePropertyPath": "temperatureComponent",
"mtconnectDataItemIdPropertyPath": "temperatureDataItemId",
"mtconnectDataNamePropertyPath": "temperatureDataName",
"mtconnectDataTypePropertyPath": "temperatureDataType",
"mtconnectDeviceNamePropertyPath": "temperatureDevice",
"mtconnectDeviceUuidPropertyPath": "temperatureDeviceUuid",
"mtconnectSequencePropertyPath": "temperatureSequence",
"mtconnectTimestampPropertyPath": "temperatureTimestamp"
}
]
},
"tableName": "mtconnectTable"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
When configured with the previous "createInput" example, FairCom's MTConnect Connector collects data and generates a JSON document like the following example.
{
"temperatureValue": 20.1,
"temperatureCategory": "SAMPLE",
"temperatureComponent": "Stamper1",
"temperatureDataItemId": "X1_Stamper1_Temperature",
"temperatureDataName": "Temperature",
"temperatureDataType": "REAL",
"temperatureDevice": "Device1",
"temperatureDeviceUuid": "X1_373f-4ab9-9c7a-173edd23e4f3",
"temperatureSequence": 5,
"temperatureTimestamp": "2010-04-06T06:19:35.153141"
}