Meta Point ClassCastException
-
Hi all,
I'm doing a pretty simple meta data point that just scales a data point.
Once an hour, the original data point is updated with 4 readings.Upon doing a simple:
// original is the external context point return original.value/100;
This works great for history generation but when triggered by the actual point, I end up with 4 entries with the correct timestamps but all having the same value as the most recent reading. Not entirely sure why.
Original Point Meta Point ------------------------------- ---------------------------- TS Value => TS Value ------------------------------- ---------------------------- 7/7/2020 12:00:00 503633.00 7/7/2020 12:00:00 5036.3 7/7/2020 11:45:00 503584.00 7/7/2020 11:45:00 5036.3 7/7/2020 11:30:00 503520.00 7/7/2020 11:30:00 5036.3 7/7/2020 11:15:00 503383.00 7/7/2020 11:15:00 5036.3
I then tried to be a bit more verbose with:
// scaled is my meta data point scaled.set(original.value/100, original.time);
but this causes a ClassCastException when generating historic data
ERROR 2020-07-07T11:42:44,559 (com.serotonin.m2m2.meta.MetaPointLocatorRT.execute:301) - Meta script failed for point Water com.serotonin.ShouldNeverHappenException: java.lang.ClassCastException at com.infiniteautomation.mango.spring.service.MangoJavaScriptService.execute(MangoJavaScriptService.java:466) ~[mango-3.7.7.jar:?] at com.infiniteautomation.mango.spring.service.MangoJavaScriptService.execute(MangoJavaScriptService.java:482) ~[mango-3.7.7.jar:?] at com.infiniteautomation.mango.util.script.CompiledMangoJavaScript.execute(CompiledMangoJavaScript.java:240) ~[mango-3.7.7.jar:?] at com.serotonin.m2m2.meta.JavaScriptPointLocatorRT.executeImpl(JavaScriptPointLocatorRT.java:92) ~[?:?] at com.serotonin.m2m2.meta.HistoricalMetaPointLocatorRT.executeImpl(HistoricalMetaPointLocatorRT.java:159) ~[?:?] at com.serotonin.m2m2.meta.MetaPointLocatorRT.execute(MetaPointLocatorRT.java:283) ~[?:?] at com.serotonin.m2m2.meta.MetaPointLocatorRT$ExecutionDelayTimeout.run(MetaPointLocatorRT.java:242) ~[?:?] at com.serotonin.timer.Task.runTask(Task.java:179) ~[mango-3.7.7.jar:?] at com.serotonin.timer.SimulationTimer.fastForwardTo(SimulationTimer.java:89) ~[mango-3.7.7.jar:?] at com.serotonin.m2m2.meta.HistoricalContextPointRT.consumeHistorical(HistoricalContextPointRT.java:59) ~[?:?] at com.infiniteautomation.mango.rest.v2.MetaDataSourceRestController$MetaHistoryGenerationTask.chunkHistoryGeneration(MetaDataSourceRestController.java:792) ~[?:?] at com.infiniteautomation.mango.rest.v2.MetaDataSourceRestController$MetaHistoryGenerationTask.lambda$run$6(MetaDataSourceRestController.java:589) ~[?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?] at java.lang.Thread.run(Thread.java:834) [?:?] Caused by: java.lang.ClassCastException
After a bit more testing, it seems that the meta data script gets run the correct amount of times but only uses the most recent value for each execution.
edit 2:
After a bit more debugging, I can confirm that the script will run for each new entry but only uses the value of the most recent entry.