IoT Time Series Aggregates Service – v4.x 示例¶
请求聚合数据¶
性能实体¶
在本例中,asset type 为 forklift
,aspect 为 tireMonitor
,三个 variables 为 pressure
、temperature
和 treadDepth
。Variable pressure
的质量代码值为 Y
,其它两个 variable 的质量代码值为 N
。定义了一个 forklift
类型的实例,其 asset ID 为 978528e7a124458f87c8f1d38fd9400f
。
以下调用请求从 2017-05-01T00:08:00Z
到 2017-05-01T00:16:00Z
之间间隔时长为 4 分钟、aspect 为 tireMonitor
的聚合数据:
https://gateway.{region}-{environment}.{mindsphere-domain}/api/iottsaggregates/v4/aggregates?assetId=978528e7a124458f87c8f1d38fd9400f&aspectName=tireMonitor&from=2017-05-01T00:08:00Z&to=2017-05-01T00:16:00Z&select=pressure,temperature&intervalUnit=minute&intervalValue=4
该请求返回以下响应代码:
Response
{
"aggregates": [
{
"pressure": {
"firsttime": "2017-05-01T00:09:00Z",
"average": 93.75,
"lasttime": "2017-05-01T00:12:00Z",
"maxvalue": 95,
"firstvalue": 93,
"mintime": "2017-05-01T00:10:00Z",
"lastvalue": 94,
"countgood": 4,
"countuncertain": 0,
"countbad": 0,
"sum": 375,
"minvalue": 93,
"maxtime": "2017-05-01T00:11:00Z",
"sd": 14.36
},
"temperature": {
"firsttime": "2017-05-01T00:09:00Z",
"average": 44.25,
"lasttime": "2017-05-01T00:12:00Z",
"maxvalue": 45,
"firstvalue": 43,
"mintime": "2017-05-01T00:09:00Z",
"lastvalue": 44,
"countgood": 4,
"countuncertain": 0,
"countbad": 0,
"sum": 177,
"minvalue": 43,
"maxtime": "2017-05-01T00:11:00Z",
"sd": 14.36
},
"starttime": "2017-05-01T00:08:00Z",
"endtime": "2017-05-01T00:12:00Z"
},
{
"pressure": {
"firsttime": "2017-05-01T00:13:00Z",
"average": 95,
"lasttime": "2017-05-01T00:16:00Z",
"maxvalue": 96,
"firstvalue": 95,
"mintime": "2017-05-01T00:15:00Z",
"lastvalue": 96,
"countgood": 4,
"countuncertain": 0,
"countbad": 0,
"sum": 380,
"minvalue": 94,
"maxtime": "2017-05-01T00:16:00Z",
"sd": 14.36
},
"temperature": {
"firsttime": "2017-05-01T00:13:00Z",
"average": 44.5,
"lasttime": "2017-05-01T00:16:00Z",
"maxvalue": 45,
"firstvalue": 44,
"mintime": "2017-05-01T00:14:00Z",
"lastvalue": 44,
"countgood": 4,
"countuncertain": 0,
"countbad": 0,
"sum": 178,
"minvalue": 43,
"maxtime": "2017-05-01T00:15:00Z",
"sd": 14.36
},
"starttime": "2017-05-01T00:12:00Z",
"endtime": "2017-05-01T00:16:00Z"
}
]
}
定义时间范围和间隔时长¶
下表列出了开始时间、结束时间和间隔时长的组合,并说明了预期的响应:
Start Time | End Time | Interval Unit | Interval Value | Count | 说明 |
---|---|---|---|---|---|
2019-02-01Z | day | 1 | 7 | End time calculated using Interval Unit, Interval Value and count. End Time = (2019-02-01Z) + (1 day) * 7 = (2019-02-08Z) | |
2019-02-01T10:00:00Z | hour | 1 | Current system time is '2019-02-01T20:00:00Z', then End time calculated as End Time = 2019-02-01T20:00:00 and count = (End time - Start time) / Interval Length, i.e. (2019-02-01T20:00:00Z - 2019-02-01T10:00:00Z) / 1 hour = 10 | ||
2020-10-10T10:00:00Z | 2020-10-10T10:30:00Z | Since the difference between Start Time and End time is less than 1 hour, Interval Length is calculated as '2 minute' with count = 15 | |||
2020-10-10T10:00:00Z | 2020-10-10T12:00:00Z | Since the difference between Start Time and End time is more than 1 hour and less than 1 day, Interval Length is calculated as '1 hour' with count = 2 | |||
2020-10-10T00:00:00Z | 2020-10-15T00:00:00Z | Since the difference between Start Time and End time is more than 1 day, Interval Length is calculated as '1 day' with count = 5 | |||
2020-10-10T10:00:00Z | 2020-10-15T10:30:00Z | 3 | Since the difference between from and to date is 30 minute, and count asked is 3, Interval Length is calculated as '10 minute' | ||
2020-10-10T02:10:00Z | 2020-10-10T09:10:00Z | hour | 1 | Since aggregate is queried for 1 hour and dates are not aligned to Hour boundary, dates are adjusted to Hour boundary From = 2020-10-10T02:00:00Z and to = 2020-10-10T10:00:00Z | |
2020-10-10T00:00:00Z | 2020-10-11T00:00:00Z | hour | 4 | Since pre-computed aggregate exists for every HOUR, Hourly aggregates will be combined and a response bucket every 4 hours will be returned |
Last update: December 1, 2023