如何使用 TSI Gen2 Rest API (Azure) 计算停机报告

How to calculate downtime report using TSI Gen2 Rest APIs (Azure)

我们正在使用 Azure IoT Hub 将数据发送到 Azure TSI,我们正在利用 TSI Rest API 从中获取数据。

数据格式-

原始遥测看起来像-

{"status":0, "timestamp":123456, plc_id:1}
{"status":0, "timestamp":123456, plc_id:1}
{"status":0, "timestamp":123456, plc_id:1}
{"status":0, "timestamp":123456, plc_id:1}
{"status":1, "timestamp":123456, plc_id:1}
{"status":1, "timestamp":123456, plc_id:1}
{"status":1, "timestamp":123456, plc_id:1}
{"status":1, "timestamp":123456, plc_id:1}
{"status":0, "timestamp":123456, plc_id:1}

我在时间戳中使用了 123456 作为示例。

我需要计算停机时间(最后一次出现 0 - 第一次出现 0), 然后忽略状态 1,再次计算 1 之后的下一个 0 的停机时间。

我们只需要使用 TSI Rest API 来完成。有什么想法吗?

TSI 查询引擎不提供事件之间的窗口化计算。无法通过比较两个时间戳来计算停机时间。

TSI 仅支持使用聚合序列基于时间间隔的窗口 API。您将需要在客户端使用 GetEvents API 和 perform/apply 自定义窗口计算来检索原始事件。