use of io.openems.backend.timedata.api.TimedataService in project openems by OpenEMS.
the class EdgeWebsocketHandler method historicData.
private void historicData(JsonObject jMessageId, JsonObject jHistoricData) {
// select first QueryablePersistence (by default the running InfluxdbPersistence)
TimedataService timedataSource = null;
for (QueryablePersistence queryablePersistence : ThingRepository.getInstance().getQueryablePersistences()) {
timedataSource = queryablePersistence;
break;
}
if (timedataSource == null) {
WebSocketUtils.sendNotificationOrLogError(this.websocket, new JsonObject(), LogBehaviour.WRITE_TO_LOG, Notification.NO_TIMEDATA_SOURCE_AVAILABLE);
return;
}
JsonArray jData;
try {
jData = timedataSource.queryHistoricData(jHistoricData);
WebSocketUtils.send(this.websocket, DefaultMessages.historicDataQueryReply(jMessageId, jData));
} catch (OpenemsException e) {
WebSocketUtils.sendNotificationOrLogError(this.websocket, jMessageId, LogBehaviour.WRITE_TO_LOG, Notification.UNABLE_TO_QUERY_HISTORIC_DATA, e.getMessage());
}
return;
}
Aggregations