Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
Change a data point with condition
-
Hello guys, I have a system and I want to control a data point with condition.
I have following data point, polled through modbus TCP every 15 seconds:- Grid THDi L1, L2 and L3
- Compensation Ratio
- THDi setpoint (I set as 10)
I want to make a Meta Data Point with following code:
maxTHDI = Math.max(thdi_l1.value, thdi_l2.value, thdi_l3.value); if (maxTHDI < (setpoint.value - 1)) { comp_ratio.set(comp_ratio.value - 0.01); } else if (maxTHDI > setpoint.value) { if (comp_ratio >0.95) { comp_ratio.set(1)} else { comp_ratio.set (comp_ratio.value + 0.05); } } RuntimeManager.sleep(15000);
My intention is:
- If the value of maxTHDi is lower than 9, then i lower the value of comp_ratio by 0.01.
- if the value of maxTHDi is above 10 then if comp_ratio > 0.95 then comp_ratio = 1 and if comp_ratio is lower 0.95, i will increase comp_ratio by 0.05.
I want to make this meta point run every 15 second, together with the polling of Modbus data point. However, every time I enable this meta point this kind of error appear in the logs and repeat lots of times:
INFO 2024-07-19T19:32:26,312 (com.serotonin.m2m2.rt.RuntimeManagerImpl.startDataSource:346) - Data source (name=Setpoint Controller, id=13, type=MetaDataSourceRT) took 12ms to start WARN 2024-07-19T19:34:54,511 (com.infiniteautomation.mango.rest.latest.websocket.pointValue.PointValueWebSocketHandler$PointValueWebSocketListener.pointUpdated:253) - Error sending websocket message com.infiniteautomation.mango.rest.latest.websocket.WebSocketClosedException: Websocket closed at com.infiniteautomation.mango.rest.latest.websocket.MangoWebSocketHandler.sendStringMessageAsync(MangoWebSocketHandler.java:121) ~[?:?] at com.infiniteautomation.mango.rest.latest.websocket.MangoWebSocketHandler.sendMessage(MangoWebSocketHandler.java:96) ~[?:?] at com.infiniteautomation.mango.rest.latest.websocket.pointValue.PointValueWebSocketHandler.sendMessage(PointValueWebSocketHandler.java:154) ~[?:?] at com.infiniteautomation.mango.rest.latest.websocket.pointValue.PointValueWebSocketHandler$PointValueWebSocketListener.sendNotification(PointValueWebSocketHandler.java:200) ~[?:?] at com.infiniteautomation.mango.rest.latest.websocket.pointValue.PointValueWebSocketHandler$PointValueWebSocketListener.pointUpdated(PointValueWebSocketHandler.java:250) ~[?:?] at com.serotonin.m2m2.rt.DataPointEventNotifyWorkItem.execute(DataPointEventNotifyWorkItem.java:64) ~[mango-5.1.4.jar:?] at com.serotonin.m2m2.rt.maint.BackgroundProcessingImpl$RejectableWorkItemRunnable.run(BackgroundProcessingImpl.java:531) ~[mango-5.1.4.jar:?] at com.serotonin.timer.Task.runTask(Task.java:176) ~[mango-5.1.4.jar:?] at com.serotonin.timer.TaskWrapper.run(TaskWrapper.java:22) ~[mango-5.1.4.jar:?] at com.serotonin.timer.OrderedThreadPoolExecutor$OrderedTaskCollection.run(OrderedThreadPoolExecutor.java:268) ~[mango-5.1.4.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] at java.lang.Thread.run(Thread.java:840) [?:?] WARN 2024-07-19T19:34:54,511 (com.infiniteautomation.mango.rest.latest.websocket.pointValue.PointValueWebSocketHandler$PointValueWebSocketListener.pointUpdated:253) - Error sending websocket message com.infiniteautomation.mango.rest.latest.websocket.WebSocketClosedException: Websocket closed at com.infiniteautomation.mango.rest.latest.websocket.MangoWebSocketHandler.sendStringMessageAsync(MangoWebSocketHandler.java:121) ~[?:?] at com.infiniteautomation.mango.rest.latest.websocket.MangoWebSocketHandler.sendMessage(MangoWebSocketHandler.java:96) ~[?:?] at com.infiniteautomation.mango.rest.latest.websocket.pointValue.PointValueWebSocketHandler.sendMessage(PointValueWebSocketHandler.java:154) ~[?:?] at com.infiniteautomation.mango.rest.latest.websocket.pointValue.PointValueWebSocketHandler$PointValueWebSocketListener.sendNotification(PointValueWebSocketHandler.java:200) ~[?:?] at com.infiniteautomation.mango.rest.latest.websocket.pointValue.PointValueWebSocketHandler$PointValueWebSocketListener.pointUpdated(PointValueWebSocketHandler.java:250) ~[?:?] at com.serotonin.m2m2.rt.DataPointEventNotifyWorkItem.execute(DataPointEventNotifyWorkItem.java:64) ~[mango-5.1.4.jar:?] at com.serotonin.m2m2.rt.maint.BackgroundProcessingImpl$RejectableWorkItemRunnable.run(BackgroundProcessingImpl.java:531) ~[mango-5.1.4.jar:?] at com.serotonin.timer.Task.runTask(Task.java:176) ~[mango-5.1.4.jar:?] at com.serotonin.timer.TaskWrapper.run(TaskWrapper.java:22) ~[mango-5.1.4.jar:?] at com.serotonin.timer.OrderedThreadPoolExecutor$OrderedTaskCollection.run(OrderedThreadPoolExecutor.java:268) ~[mango-5.1.4.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] at java.lang.Thread.run(Thread.java:840) [?:?]
Please suggest me some workaround.
Thank you -
@tungthanh500 get rid of the runtime sleep call. Set the context point related to the data point you are validating and set the script to trigger from one of them for a start.
Alternatively use a cron timer setting set to 15 seconds.Fox