IoT Time Series Aggregates Service – 示例
请求聚合数据
性能实体
在本例中,asset type 为 forklift
,aspect 为 tireMonitor
,三个 variables 为 pressure
、temperature
和 treadDepth
。Variable pressure
的质量代码值为 Y
,其它两个 variable 的质量代码值为 N
。定义了一个 forklift
类型的实例,其 asset ID 为 978528e7a124458f87c8f1d38fd9400f
。
以下调用请求从 2017-05-01T00:08:00
到 2017-05-01T00:16:00Z
之间间隔时长为 4 分钟、aspect 为 tireMonitor
的聚合数据:
https://gateway.{region}-{environment}.{mindsphere-domain}/api/iottsaggregates/v3/aggregates/978528e7a124458f87c8f1d38fd9400f/tireMonitor?from=2017-05-01T00:08:00Z&to=2017-05-01T00:16:00Z&select=pressure,temperature&intervalUnit=minute&intervalValue=4
该请求返回以下响应代码
[
{
"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"
}
]
获取具有用于性能实体的时区的特定时间范围的聚合数据
使用 URL 参数 from 和 to 指定所需的时间范围:
https://gateway.{region}-{environment}.{mindsphere-domain}/api/iottsaggregates/v3/aggregates/{assetId}/{aspectName}?from=2017-05-01T00:08:00%2B02:00&to=2017-05-01T00:16:00%2B02:00&intervalUnit=minute&intervalValue=4
仿真实体
以下调用请求从 2017-05-01T00:08:00.001
到 2017-05-01T00:08:00.003Z
之间间隔时长为 1 毫秒、aspect 为 tireMonitor
的聚合数据:
https://gateway.{region}-{environment}.{mindsphere-domain}/api/iottsaggregates/v3/aggregates/978528e7a124458f87c8f1d38fd9400f/tireMonitor?from=2017-05-01T00:08:00.001Z&to=2017-05-01T00:08:00.003Z&select=pressure,temperature&intervalUnit=millisecond&intervalValue=1
该请求返回以下响应代码
[
{
"pressure": {
"firsttime": "2017-05-01T00:08:00.001015Z",
"average": 93.75,
"lasttime": "2017-05-01T00:08:00.001018Z",
"maxvalue": 95,
"firstvalue": 93,
"mintime": "2017-05-01T00:08:00.001016Z",
"lastvalue": 94,
"countgood": 4,
"countuncertain": 0,
"countbad": 0,
"sum": 375,
"minvalue": 93,
"maxtime": "2017-05-01T00:08:00.001017Z",
"sd": 14.36
},
"temperature": {
"firsttime": "2017-05-01T00:08:00.001015Z",
"average": 44.25,
"lasttime": "2017-05-01T00:08:00.001018Z",
"maxvalue": 45,
"firstvalue": 43,
"mintime": "2017-05-01T00:08:.001012Z",
"lastvalue": 44,
"countgood": 4,
"countuncertain": 0,
"countbad": 0,
"sum": 177,
"minvalue": 43,
"maxtime": "2017-05-01T00:08:00.001019Z",
"sd": 14.36
},
"starttime": "2017-05-01T00:08:00.001Z",
"endtime": "2017-05-01T00:08:00.002Z"
},
{
"pressure": {
"firsttime": "2017-05-01T00:08:00.002015Z",
"average": 95,
"lasttime": "2017-05-01T00:08:00.2018Z",
"maxvalue": 96,
"firstvalue": 95,
"mintime": "2017-05-01T00:08:00.002010Z",
"lastvalue": 96,
"countgood": 4,
"countuncertain": 0,
"countbad": 0,
"sum": 380,
"minvalue": 94,
"maxtime": "2017-05-01T00:08:00.002019Z",
"sd": 14.36
},
"temperature": {
"firsttime": "2017-05-01T00:08:00.002014",
"average": 44.5,
"lasttime": "2017-05-01T00:08:00.2018Z",
"maxvalue": 45,
"firstvalue": 44,
"mintime": "2017-05-01T00:08:00.002010Z",
"lastvalue": 44,
"countgood": 4,
"countuncertain": 0,
"countbad": 0,
"sum": 178,
"minvalue": 43,
"maxtime": "2017-05-01T00:08:00.002011Z",
"sd": 14.36
},
"starttime": "2017-05-01T00:08:00.002Z",
"endtime": "2017-05-01T00:08:00.003Z"
}
]
获取具有模拟实体时区的特定时间范围的聚合数据
使用 URL 参数 from 和 to 指定所需的时间范围:
https://gateway.{region}-{environment}.{mindsphere-domain}/api/iottsaggregates/v3/aggregates/{assetId}/{aspectName}?from=2017-05-01T00:08:00.001%2B02:00&to=2017-05-01T00:08:00.003%2B02:00&intervalUnit=millisecond&intervalValue=1
用于在时间戳中包含时区的 '+' 字符必须在时间范围内编码为 '%2B'。例如, 应编码为 2017-05-01T00:08:00%2B02:00 而非 2017-05-01T00:08:00+02:00。
定义开始时间和时间范围
根据请求聚合中的描述,开始时间和结束时间的精度不能高于时间范围的精度。为便于说明,下表列出了开始时间、结束时间和间隔时长的组合,并说明了预期的响应代码:
开始时间 | 结束时间 | 间隔时长 | 返回的间隔 | 说明 |
---|---|---|---|---|
14:00:01.000 | 14:00:01.300 | 1 毫秒 | - | 拒绝 - 响应会包含超过200个间隔 间隔时长仅对仿真实体适用 |
14:00:01.005 | 14:00:01.015 | 10 毫秒 | - | 拒绝 - 开始时间和结束时间的精度不能定义为高于间隔时长的精度 间隔时长仅对仿真实体适用 |
14:00:01.000 | 14:00:02.000 | 1 秒 | 1 | 间隔时长仅对仿真实体适用 |
14:00 | 15:00 | 2 分钟 | 30 | 间隔时长仅对性能实体适用 |
14:00 | 15:00 | 4 分钟 | 15 | 间隔时长仅对性能实体适用 |
14:00 | 15:00 | 1 分钟 | 60 | 基于原始时间序列数据实时计算 间隔时长仅对性能实体适用 |
14:00 | 15:00 | 3 分钟 | 20 | 根据预先计算的间隔和时间序列数据计算 间隔时长仅对性能实体适用 |
14:01 | 15:01 | 2 分钟 | 30 | 基于原始时间序列数据实时计算 间隔时长仅对性能实体适用 |
14:30 | 16:30 | 1 小时 | - | 拒绝 - 开始时间和结束时间的精度不能定义为高于间隔时长的精度 间隔时长仅对性能实体适用 |
14:30 | 16:30 | 60 分钟 | 2 | 间隔时长仅对性能实体适用 |
14:30 | 16:30 | 30 分钟 | 4 | 间隔时长仅对性能实体适用 |
3 月 1 日 10:00 | 3 月 5 日 10:00 | 1 天 | - | 拒绝 - 开始时间和结束时间的精度不能定义为高于间隔时长的精度 间隔时长仅对性能实体适用 |
3 月 1 日 10:00 | 3 月 5 日 10:00 | 24 小时 | 4 | 间隔时长仅对性能实体适用 |
3 月 1 日(周三)00:00 | 4 月 1 日 00:00 | 1 周 | - | 拒绝 - 开始时间和结束时间的精度不能定义为高于间隔时长的精度(假设该租户每周的开始时间为周一) 间隔时长仅对性能实体适用 |
3 月 1 日 00:00 | 4 月 5 日 00:00 | 7 天 | 5 | 间隔时长仅对性能实体适用 |
3 月 1 日 00:00 | 6 月 1 日 00:00 | 1 个月 | 3 | 间隔时长仅对性能实体适用 |
3 月 1 日 00:00 | 6 月 29 日 00:00 | 30 天 | 4 | 间隔时长仅对性能实体适用 |
还有问题?
除非另行声明,该网站内容遵循MindSphere开发许可协议.
Last update: April 30, 2020