Is there a way to generate a tag change event "on write" such that if a tag holds one value, if the exact same value is written to it but at a different point in time which is later than its last update, a tag change event is generated?
The application is we use a kafka history sink to send data to central repository and we have been requested to send the value sent 4 times per hour on 0, 15, 30, and 45 minutes.
If we can make the tag change happen each time we write to the tag regardless of whether the value is changed or not, I will always end up with 4 values per hour in the central cloud DB.
If we can't do that, we will do interpolation on the query that pulls from the central repo.
History Provider
Transmission Mechanism
@Override
public void storeData(HistoricalData data) throws IOException {
int pathIndex = 0;
for (HistoricalData row : BasicDataTransaction.class.cast(data).getData()) {
BasicScanclassHistorySet scanset = BasicScanclassHistorySet.class.cast(row);
if (scanset.size() == 0) continue;
String gatewayName = this.hostName;
String provider = scanset.getProviderName();
pathIndex = provider.length() + 2;
for (HistoricalTagValue tagValue : scanset) {
try{
String json = new JSONObject()
.put("gatewayName", gatewayName)
.put("provider", provider)
.put("tagPath", tagValue.getSource().toString().replace("["+provider+"]", ""))
.put("type", tagValue.getTypeClass())
.put("quality", tagValue.getQuality())
.put("value", String.valueOf(tagValue.getValue()))
.put("epochms", tagValue.getTimestamp().getTime())
.toString();
SinkData value = new SinkData(topic, json, this.getPipelineName());
this.sendDataWithProducer(value);
} catch (JSONException e) {
logger.error("Error sending tag: " + e.toString());
}
}
}
if (pathIndex > 0) {
setLastMessageTime(this.name);
}
}
Thanks,
Nick