IoT TS Aggregates Client for Java¶
Introduction¶
The IoT TS Aggregates Java client allows you to query aggregated time series data. Refer to IoT TS Aggregates for more information about the service.
Further implementation of the TS Aggregate SDK library has been shown in a sample project that you can download and test in local or on Insights Hub application. Please refer to this repository: industrial-iot-java-sdk-examples
Hint
In the IoT context, assets are referred to as entity and aspects as propertyset.
Placeholders in the following samples are indicated by angular brackets < >
.
TS Aggregates Operations¶
Client name: AggregatesClient
Read Aggregated Time Series¶
This section shows two options for reading aggregated time series data of a specific aspect of an asset from the specified time range. This feature is only available if aspect data is available within the specified time range.
Note
A query can only return up to 200 aggregate intervals in one response.
Aggregates can only be created from up to 5,000 raw time series entries.
// Construct the AggregatesClient object
AggregatesClient aggregate_client = AggregatesClient.builder()
.mindsphereCredentials(<credentials>)
.restClientConfig(<config>)
.build();
List<Aggregates> aggregate_list = null;
try {
aggregate_list = aggregate_client.getAggregateTimeseries(<entity_id>, <property_set>, <from>, <to>, <interval_value>, <interval_unit>, <select>);
} catch (MindsphereException e) {
// Exception handling
}
Alternatively, use the GetAggregateTimeseriesRequest
model.
// Construct the AggregatesClient object as shown above
GetAggregateTimeseriesRequest request_object = new GetAggregateTimeseriesRequest();
request_object.setEntity(<entity_id>);
request_object.setPropertyset(<property_set>);
request_object.setFrom(<from>);
request_object.setTo(<to>);
request_object.setIntervalValue(<interval_value>);
request_object.setIntervalUnit(<interval_unit>);
request_object.setSelect(<select>);
List<Aggregates> aggregate_list = null;
try {
aggregate_list = aggregate_client.getAggregateTimeseries(request_object);
} catch (MindsphereException e) {
// Exception handling
}