Difference between revisions of "How to report data with timestamp"
From ESS-WIKI
(Created page with "In Handler, user can attach their timestamp into report data and capability with tag 'opTS'.") |
|||
Line 1: | Line 1: | ||
+ | == Situation == | ||
+ | |||
In Handler, user can attach their timestamp into report data and capability with tag 'opTS'. | In Handler, user can attach their timestamp into report data and capability with tag 'opTS'. | ||
+ | |||
+ | In original capability and report data, user only describe and report the sensor data without carry any timestamp or carried as a sensor data as below. | ||
+ | |||
+ | Capability Sample: | ||
+ | |||
+ | |||
+ | <syntaxhighlight lang="json">{ | ||
+ | "HWM": { | ||
+ | "e": [ | ||
+ | { | ||
+ | "n": "cpu1_volt", | ||
+ | "type": "volt", | ||
+ | "u": "V", | ||
+ | "max": 20, | ||
+ | "min": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "cpu2_volt", | ||
+ | "type": "volt", | ||
+ | "u": "V", | ||
+ | "max": 20, | ||
+ | "min": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "cpu1_temp", | ||
+ | "type": "temp", | ||
+ | "u": "Cel", | ||
+ | "max": 100, | ||
+ | "min": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "timestamp", | ||
+ | "type": "tick", | ||
+ | "u": "millisec" | ||
+ | } | ||
+ | ], | ||
+ | "bn": "HWM" | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight>Report Data Sample: | ||
+ | |||
+ | <syntaxhighlight lang="json"> { | ||
+ | "HWM": { | ||
+ | "e": [ | ||
+ | { | ||
+ | "n": "cpu1_volt", | ||
+ | "v": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "cpu2_volt", | ||
+ | "v": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "cpu1_temp", | ||
+ | "v": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "timestamp", | ||
+ | "v": 1508998354 | ||
+ | } | ||
+ | ], | ||
+ | "bn": "HWM" | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | === In this case, the report data carried timestamp as sensor data. But server process the timestamp as a single sensor data and cannot related to others snesor data. So user cannot query cpu1_volt with timestamp. === | ||
+ | |||
+ | == Solution == | ||
+ | |||
+ | For RMM 3.3, user can carried the timestamp as a special tag 'opTS' in the capability or report, the server will store the timestamp related with each sensor data. The 'opTS' format is "opTS":{"$date":1508998354000}. The '$date' must be the milli seconds since Jan 01 1970 (UTC). | ||
+ | |||
+ | === Capability Sample with Timestamp === | ||
+ | |||
+ | |||
+ | <syntaxhighlight lang="json">{ | ||
+ | "HWM": { | ||
+ | "e": [ | ||
+ | { | ||
+ | "n": "cpu1_volt", | ||
+ | "type": "volt", | ||
+ | "u": "V", | ||
+ | "max": 20, | ||
+ | "min": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "cpu2_volt", | ||
+ | "type": "volt", | ||
+ | "u": "V", | ||
+ | "max": 20, | ||
+ | "min": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "cpu1_temp", | ||
+ | "type": "temp", | ||
+ | "u": "Cel", | ||
+ | "max": 100, | ||
+ | "min": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "timestamp", | ||
+ | "type": "tick", | ||
+ | "u": "millisec" | ||
+ | } | ||
+ | ], | ||
+ | "bn": "HWM" | ||
+ | }, | ||
+ | "opTS":{"$date":1508998354000} | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | === Report Data Sample with Timestamp === | ||
+ | |||
+ | |||
+ | <syntaxhighlight lang="json">{ | ||
+ | "HWM": { | ||
+ | "e": [ | ||
+ | { | ||
+ | "n": "cpu1_volt", | ||
+ | "v": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "cpu2_volt", | ||
+ | "v": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "cpu1_temp", | ||
+ | "v": 10 | ||
+ | }, | ||
+ | { | ||
+ | "n": "timestamp", | ||
+ | "v": 1508998354 | ||
+ | } | ||
+ | ], | ||
+ | "bn": "HWM" | ||
+ | }, | ||
+ | "opTS":{"$date":1508998354000} | ||
+ | } | ||
+ | </syntaxhighlight> |
Revision as of 07:49, 26 October 2017
Contents
Situation
In Handler, user can attach their timestamp into report data and capability with tag 'opTS'.
In original capability and report data, user only describe and report the sensor data without carry any timestamp or carried as a sensor data as below.
Capability Sample:
{
"HWM": {
"e": [
{
"n": "cpu1_volt",
"type": "volt",
"u": "V",
"max": 20,
"min": 10
},
{
"n": "cpu2_volt",
"type": "volt",
"u": "V",
"max": 20,
"min": 10
},
{
"n": "cpu1_temp",
"type": "temp",
"u": "Cel",
"max": 100,
"min": 10
},
{
"n": "timestamp",
"type": "tick",
"u": "millisec"
}
],
"bn": "HWM"
}
}
{
"HWM": {
"e": [
{
"n": "cpu1_volt",
"v": 10
},
{
"n": "cpu2_volt",
"v": 10
},
{
"n": "cpu1_temp",
"v": 10
},
{
"n": "timestamp",
"v": 1508998354
}
],
"bn": "HWM"
}
}
Solution
For RMM 3.3, user can carried the timestamp as a special tag 'opTS' in the capability or report, the server will store the timestamp related with each sensor data. The 'opTS' format is "opTS":{"$date":1508998354000}. The '$date' must be the milli seconds since Jan 01 1970 (UTC).
Capability Sample with Timestamp
{
"HWM": {
"e": [
{
"n": "cpu1_volt",
"type": "volt",
"u": "V",
"max": 20,
"min": 10
},
{
"n": "cpu2_volt",
"type": "volt",
"u": "V",
"max": 20,
"min": 10
},
{
"n": "cpu1_temp",
"type": "temp",
"u": "Cel",
"max": 100,
"min": 10
},
{
"n": "timestamp",
"type": "tick",
"u": "millisec"
}
],
"bn": "HWM"
},
"opTS":{"$date":1508998354000}
}
Report Data Sample with Timestamp
{
"HWM": {
"e": [
{
"n": "cpu1_volt",
"v": 10
},
{
"n": "cpu2_volt",
"v": 10
},
{
"n": "cpu1_temp",
"v": 10
},
{
"n": "timestamp",
"v": 1508998354
}
],
"bn": "HWM"
},
"opTS":{"$date":1508998354000}
}