Problem description
Sometimes your devices send a measurement in a unit that your user cannot interpret or understand. E.g. the device sends 5 unit a. By interpreting this, some people wants to see the values not as unit a they want to see them as unit b.
A different Scenario would be that your device sends for example 5 mV (milli Volt) and you need to convert this to meter or inches or kilogram.
There are some questions out of this which you need to answer yourself.
- In which unit are you storing the measurement in the platform?
- Which are the unit my users want to see?
- Where do I manage and maintain the unit conversion from a UI perspective?
- How often do I need one measurement in the platform?
Assumption
It is assumed that the device sends a unit which cannot be changed on the device.
How to convert
Several options are available to solve this.
Option 1
This option uses a self-developed microservice that receives the measurement from the device and uses one or multiple managed objects to convert the unit.
Option 2
This option uses a self-developed microservice which polls for a new measurement from the device and uses one or multiple managed objects to convert the unit to create a second measurement.
Option 3
This option uses a self developed Apama code to poll for a new measurement from the device and uses Apama Memory to convert the unit to create a second measurement.
Option 4
This option uses a self developed Apama code to receive a new measurement from the device directly to CEP Engine and uses Apama Memory to convert the unit to create a the measurement.
Option 5
This Option uses a self developed UI Application which will do the unit conversion every time the user access the measurement.
Conclusion
Out there are different kinds of devices with a Hugh variety of measurement type’s. I would differentiate them into categories.
- Devices that can send a measurement in cumulocity style like where the unit and value already made cumulocity ready on the Agent side
"c8y_SpeedMeasurement": {
"Speed": { "value": 1234, "unit": "km/h" }
}
- Devices which can send a measurement in cumulocity style like where the unit and value already made cumulocity ready on the Agent side but the unit need to be convert to the users extend
"c8y_BatteryLevel": {
"level": { "value": 1234, "unit": "mV" }
}
- Devices which can send only values to the platform and based on some additional information (stored in a managed object) the value needs to converted into a measurement with a converted value and an unit. e.g a sensor sends the value of 12 and the system needs to convert this 12 mV into a distance of 10 cm.
"c8y_Compression": {
"comp": { "value": 12}
}
Try to find the best solution for your use case. My Intention was to give you something on the hand to solve this problem.