Node.js 的 IoT TS Aggregates Client¶
简介¶
IoT TS Aggregates Node.js client 允许您查询聚合事件序列数据。更多有关此服务的信息请参考IoT TS Aggregates。
提示
在 IoT 环境中,assets 指 entity ,aspects 指 propertyset。
下面示例中的占位符用尖括号 < >
表示。
TS Aggregates 操作¶
客户端名称: AggregatesClient
读取聚合时间序列¶
读取特定 asset 和 aspect 的聚合时间序列数据。只有 aspect 数据在指定的时间范围内可用时,此功能才可用。
说明
查询在一个响应中最多只能返回200个聚合间隔。
聚合最多只能从5000个原始时间序列条目创建。
// Import the mindsphere-sdk-node-core module and require AppCredentials and ClientConfig
let AppCredentials = require('mindsphere-sdk-node-core').AppCredentials;
let ClientConfig = require('mindsphere-sdk-node-core').ClientConfig;
// Import the timeseriesaggregate module and require AggregatesClient
const AggregatesClient = require('tsaggregates-sdk').AggregatesClient;
// Construct the ClientConfig and AppCredentials objects
let config = new ClientConfig();
let credentials = new AppCredentials();
// Construct the AggregatesClient object
let aggregates_client = new AggregatesClient(config, credentials);
try {
const request_object = {
entity: <entity_id>,
propertyset : <property_set>,
from: <from_date>,
to: <to_date>,
intervalValue: <interval_length>,
intervalUnit: <interval_unit>,
select: <select>
};
let aggregates_data = await aggregates_client.getAggregateTimeseries(request_object);
} catch (ex) {
// Exception handling
}
Last update: March 22, 2023