<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Change a data point with condition]]></title><description><![CDATA[<p dir="auto">Hello guys, I have a system and I want to control a data point with condition.<br />
I have following data point, polled through modbus TCP every 15 seconds:</p>
<ul>
<li>Grid THDi L1, L2 and L3</li>
<li>Compensation Ratio</li>
<li>THDi setpoint (I set as 10)</li>
</ul>
<p dir="auto">I want to make a Meta Data Point with following code:</p>
<pre><code>maxTHDI = Math.max(thdi_l1.value, thdi_l2.value, thdi_l3.value);

if (maxTHDI &lt; (setpoint.value - 1)) {
    comp_ratio.set(comp_ratio.value - 0.01);
} else if (maxTHDI &gt; setpoint.value) {
    if (comp_ratio &gt;0.95) {
        comp_ratio.set(1)}
    else {
        comp_ratio.set (comp_ratio.value + 0.05);
}
}

RuntimeManager.sleep(15000);
</code></pre>
<p dir="auto">My intention is:</p>
<ul>
<li>If the value of maxTHDi is lower than 9, then i lower the value of comp_ratio by 0.01.</li>
<li>if the value of maxTHDi is above 10 then if comp_ratio &gt; 0.95 then comp_ratio = 1 and if comp_ratio is lower 0.95, i will increase comp_ratio by 0.05.</li>
</ul>
<p dir="auto">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:</p>
<pre><code>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) [?:?]
</code></pre>
<p dir="auto">Please suggest me some workaround.<br />
Thank you</p>
]]></description><link>https://forum.mango-os.com/topic/5836/change-a-data-point-with-condition</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 02:02:27 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/5836.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Jul 2024 02:45:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Change a data point with condition on Tue, 30 Jul 2024 13:18:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tungthanh500" aria-label="Profile: tungthanh500">@<bdi>tungthanh500</bdi></a> 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.<br />
Alternatively use a cron timer setting set to 15 seconds.</p>
<p dir="auto">Fox</p>
]]></description><link>https://forum.mango-os.com/post/28225</link><guid isPermaLink="true">https://forum.mango-os.com/post/28225</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Tue, 30 Jul 2024 13:18:26 GMT</pubDate></item></channel></rss>