<?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[How to get value from the two source points?]]></title><description><![CDATA[<p dir="auto">Hi,<br />
In our Mango system we should change the value of the target point based on the value of the <em>two source points</em>. We should show the alarm message in the public view to the end user immidiately after the value is over the low limit.<br />
We try to use <em>point linking</em>, but we need to also get the current value of two source points (source2.value) to change the target value.</p>
<pre><code>if (source.value &gt; source2.value) return true; return false;
// source is measured humidity value
// source2 is static value set by the Mango user as a low limit to Alarm
</code></pre>
<p dir="auto">We try to use "Point Linking", but It's not possible to use two source points there?<br />
Any other hints how to implement this?</p>
]]></description><link>https://forum.mango-os.com/topic/214/how-to-get-value-from-the-two-source-points</link><generator>RSS for Node</generator><lastBuildDate>Wed, 10 Jun 2026 08:46:34 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/214.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Oct 2009 11:12:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to get value from the two source points? on Sun, 29 Nov 2009 23:59:05 GMT]]></title><description><![CDATA[<p dir="auto">P.S. thanks again for contributing. You rock.</p>
]]></description><link>https://forum.mango-os.com/post/2883</link><guid isPermaLink="true">https://forum.mango-os.com/post/2883</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Sun, 29 Nov 2009 23:59:05 GMT</pubDate></item><item><title><![CDATA[Reply to How to get value from the two source points? on Sun, 29 Nov 2009 23:58:27 GMT]]></title><description><![CDATA[<p dir="auto">Hi Craig,</p>
<p dir="auto">I ported this code into the next Mango release with a couple of minor changes.</p>
<ol>
<li>The message properties key for the new logging type is "pointEdit.logging.type.tsChange".</li>
<li>The ScriptExecutor methods now return a PointValueTime object, rather than an Object. The two methods with similar signatures have been combined.</li>
</ol>
]]></description><link>https://forum.mango-os.com/post/2882</link><guid isPermaLink="true">https://forum.mango-os.com/post/2882</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Sun, 29 Nov 2009 23:58:27 GMT</pubDate></item><item><title><![CDATA[Reply to How to get value from the two source points? on Thu, 26 Nov 2009 21:24:30 GMT]]></title><description><![CDATA[<p dir="auto">Patch below adds a logging type for when a point's timestamp changes and reads the TIMESTAMP variable from the meta point script engine and sets the point's timestamp to TIMESTAMP if TIMESTAMP is set.</p>
<p dir="auto">This part of reading data tables is working fine. controlling the row pointer with point detectors and event handlers works OK but eventually gets hung up after some kind of exception.</p>
<pre><code>=== modified file 'src/com/serotonin/mango/rt/dataImage/DataPointRT.java'
--- src/com/serotonin/mango/rt/dataImage/DataPointRT.java       2009-10-20 21:08:00 +0000
+++ src/com/serotonin/mango/rt/dataImage/DataPointRT.java       2009-10-21 03:04:37 +0000
@@ -200,6 +200,17 @@
         case DataPointVO.LoggingTypes.ALL :
             logValue = true;
             break;
+        case DataPointVO.LoggingTypes.ON_TS_CHANGE :
+               if (pointValue == null) 
+                       logValue = true;
+               else {
+                       if (newValue.getTime() != pointValue.getTime())
+                               logValue = true;
+                       else
+                               logValue = false;
+               }
+               saveValue = logValue;
+               break;
         case DataPointVO.LoggingTypes.INTERVAL :
             intervalSave(newValue);
         default :

=== modified file 'src/com/serotonin/mango/rt/dataSource/meta/MetaPointLocatorRT.java'
--- src/com/serotonin/mango/rt/dataSource/meta/MetaPointLocatorRT.java  2009-10-20 21:08:00 +0000
+++ src/com/serotonin/mango/rt/dataSource/meta/MetaPointLocatorRT.java  2009-10-21 03:04:37 +0000
@@ -237,7 +237,10 @@
                 if (result == null)
                     dataSource.raiseScriptError(runtime, dataPoint, new LocalizableMessage("event.meta.nullResult"));
                 else
-                    dataPoint.updatePointValue(new PointValueTime(result, runtime));
+                       if (result instanceof PointValueTime)
+                               dataPoint.updatePointValue((PointValueTime)result);
+                       else 
+                               dataPoint.updatePointValue(new PointValueTime(result, runtime));
             }
             catch (ScriptException e) {
                 dataSource.raiseScriptError(runtime, dataPoint, new LocalizableMessage("common.default",

=== modified file 'src/com/serotonin/mango/rt/dataSource/meta/ScriptExecutor.java'
--- src/com/serotonin/mango/rt/dataSource/meta/ScriptExecutor.java      2009-10-20 21:08:00 +0000
+++ src/com/serotonin/mango/rt/dataSource/meta/ScriptExecutor.java      2009-10-21 03:04:37 +0000
@@ -38,6 +38,7 @@
 import com.serotonin.mango.rt.RuntimeManager;
 import com.serotonin.mango.rt.dataImage.DataPointRT;
 import com.serotonin.mango.rt.dataImage.IDataPoint;
+import com.serotonin.mango.rt.dataImage.PointValueTime;
 import com.serotonin.web.i18n.LocalizableMessage;
 
 /**
@@ -84,6 +85,25 @@
             return null;
         }
         
+        // i've changed things so we may have a pointvalue time with
+        // an obj and a ts. need to return a PVT here with obj cast correctly.
+        if (result instanceof PointValueTime) {
+        	PointValueTime pvt = (PointValueTime)result;
+        	Object value = pvt.getValue();
+        	long timestamp = pvt.getTime();
+        	
+            // See if the type matches.
+            if (dataTypeId == DataTypes.BINARY &amp;&amp; value instanceof Boolean)
+                return new PointValueTime(value, timestamp);
+            if (dataTypeId == DataTypes.MULTISTATE &amp;&amp; value instanceof Number)
+                return new PointValueTime(((Number)value).intValue(), timestamp);
+            if (dataTypeId == DataTypes.NUMERIC &amp;&amp; value instanceof Number)
+                return new PointValueTime(((Number)value).doubleValue(), timestamp);
+            if (dataTypeId == DataTypes.ALPHANUMERIC &amp;&amp; value instanceof String)
+                return new PointValueTime(value, timestamp);
+        }
+        
+        
         // See if the type matches.
         if (dataTypeId == DataTypes.BINARY &amp;&amp; result instanceof Boolean)
             return result;
@@ -120,6 +140,9 @@
         engine.put("MONTH", Common.TimePeriods.MONTHS);
         engine.put("YEAR", Common.TimePeriods.YEARS);
         
+        // a variable to put the script-generated timestamp in.
+        engine.put("TIMESTAMP", null);
+        
         // Put the context variables into the engine with engine scope.
         for (String varName : context.keySet()) {
             IDataPoint point = context.get(varName);
@@ -151,6 +174,11 @@
         if (result instanceof AbstractPointWrapper)
             result = ((AbstractPointWrapper)result).getValueImpl();
         
+        Object ts = engine.get("TIMESTAMP");
+        if (ts != null &amp;&amp; ts instanceof Number) {
+        	return new PointValueTime(result, ((Number)ts).longValue() );
+        }
+        
         return result;
     }
     

=== modified file 'src/com/serotonin/mango/vo/DataPointVO.java'
--- src/com/serotonin/mango/vo/DataPointVO.java	2009-10-20 21:08:00 +0000
+++ src/com/serotonin/mango/vo/DataPointVO.java	2009-10-21 03:04:37 +0000
@@ -64,6 +64,7 @@
         int ALL = 2;
         int NONE = 3;
         int INTERVAL = 4;
+        int ON_TS_CHANGE = 10;
     }
     private static final ExportCodes LOGGING_TYPE_CODES = new ExportCodes();
     static {
@@ -71,6 +72,7 @@
         LOGGING_TYPE_CODES.addElement(LoggingTypes.ALL, "ALL", "pointEdit.logging.type.all");
         LOGGING_TYPE_CODES.addElement(LoggingTypes.NONE, "NONE", "pointEdit.logging.type.never");
         LOGGING_TYPE_CODES.addElement(LoggingTypes.INTERVAL, "INTERVAL", "pointEdit.logging.type.interval");
+        LOGGING_TYPE_CODES.addElement(LoggingTypes.ON_TS_CHANGE, "TIMESTAMP", "pointEdit.logging.type.timestamp");
     }
     
     public interface PurgeTypes {

=== modified file 'src/com/serotonin/mango/web/mvc/controller/DataPointEditController.java'
--- src/com/serotonin/mango/web/mvc/controller/DataPointEditController.java	2009-10-20 21:08:00 +0000
+++ src/com/serotonin/mango/web/mvc/controller/DataPointEditController.java	2009-10-21 03:04:37 +0000
@@ -128,7 +128,8 @@
         if (point.getLoggingType() != DataPointVO.LoggingTypes.ON_CHANGE &amp;&amp; 
                 point.getLoggingType() != DataPointVO.LoggingTypes.ALL &amp;&amp;
                 point.getLoggingType() != DataPointVO.LoggingTypes.NONE &amp;&amp;
-                point.getLoggingType() != DataPointVO.LoggingTypes.INTERVAL)
+                point.getLoggingType() != DataPointVO.LoggingTypes.INTERVAL &amp;&amp;
+                point.getLoggingType() != DataPointVO.LoggingTypes.ON_TS_CHANGE)
             ValidationUtils.rejectValue(errors, "loggingType", "validate.required");
         
         if (point.getLoggingType() == DataPointVO.LoggingTypes.INTERVAL) {

=== modified file 'war/WEB-INF/classes/messages_en.properties'
--- war/WEB-INF/classes/messages_en.properties	2009-10-20 21:08:00 +0000
+++ war/WEB-INF/classes/messages_en.properties	2009-10-21 03:04:37 +0000
@@ -1144,6 +1144,7 @@
 pointEdit.logging.type.all=All data
 pointEdit.logging.type.never=Do not log
 pointEdit.logging.type.interval=Interval
+pointEdit.logging.type.ts_change=When point timestamp changes
 pointEdit.logging.period=Interval logging period
 pointEdit.logging.every=Every
 pointEdit.logging.valueType=Value type

=== modified file 'war/WEB-INF/jsp/pointEdit/loggingProperties.jsp'
--- war/WEB-INF/jsp/pointEdit/loggingProperties.jsp	2009-10-20 21:08:00 +0000
+++ war/WEB-INF/jsp/pointEdit/loggingProperties.jsp	2009-10-21 03:04:37 +0000
@@ -33,7 +33,8 @@
       else
           tolerance.disabled = true;
       
-      if (loggingType == &lt;%= DataPointVO.LoggingTypes.NONE %&gt;) {
+      if (loggingType == &lt;%= DataPointVO.LoggingTypes.NONE %&gt; || 
+          loggingType == &lt;%= DataPointVO.LoggingTypes.ON_TS_CHANGE %&gt; ) {
           purgePeriod.disabled = true;
           purgeType.disabled = true;
       }
@@ -75,6 +76,7 @@
             &lt;sst:option value="&lt;%= Integer.toString(DataPointVO.LoggingTypes.ALL) %&gt;"&gt;&lt;fmt:message key="pointEdit.logging.type.all"/&gt;&lt;/sst:option&gt;
             &lt;sst:option value="&lt;%= Integer.toString(DataPointVO.LoggingTypes.NONE) %&gt;"&gt;&lt;fmt:message key="pointEdit.logging.type.never"/&gt;&lt;/sst:option&gt;
             &lt;sst:option value="&lt;%= Integer.toString(DataPointVO.LoggingTypes.INTERVAL) %&gt;"&gt;&lt;fmt:message key="pointEdit.logging.type.interval"/&gt;&lt;/sst:option&gt;
+            &lt;sst:option value="&lt;%= Integer.toString(DataPointVO.LoggingTypes.ON_TS_CHANGE) %&gt;"&gt;&lt;fmt:message key="pointEdit.logging.type.ts_change"/&gt;&lt;/sst:option&gt;
           &lt;/sst:select&gt;
         &lt;/td&gt;
         &lt;td class="formError"&gt;${status.errorMessage}&lt;/td&gt;

</code></pre>
]]></description><link>https://forum.mango-os.com/post/2866</link><guid isPermaLink="true">https://forum.mango-os.com/post/2866</guid><dc:creator><![CDATA[craig]]></dc:creator><pubDate>Thu, 26 Nov 2009 21:24:30 GMT</pubDate></item><item><title><![CDATA[Reply to How to get value from the two source points? on Thu, 26 Nov 2009 19:25:59 GMT]]></title><description><![CDATA[<p dir="auto">How does it work? A separate script?</p>
]]></description><link>https://forum.mango-os.com/post/2865</link><guid isPermaLink="true">https://forum.mango-os.com/post/2865</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Thu, 26 Nov 2009 19:25:59 GMT</pubDate></item><item><title><![CDATA[Reply to How to get value from the two source points? on Tue, 24 Nov 2009 07:35:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mlohbihler" aria-label="Profile: mlohbihler">@<bdi>mlohbihler</bdi></a> said:</p>
<blockquote>
<p dir="auto">I've added typical date related functions including things like this:</p>
<p dir="auto">p.time --&amp;gt returns the timestamp of the value in milliseconds since the epoch</p>
</blockquote>
<p dir="auto">I've got a patch that allows the timestamp of a meta point to be set.  This is useful when data is being read from a table and some point values are the date &amp; time for the rest of the data in the row.</p>
]]></description><link>https://forum.mango-os.com/post/2859</link><guid isPermaLink="true">https://forum.mango-os.com/post/2859</guid><dc:creator><![CDATA[craig]]></dc:creator><pubDate>Tue, 24 Nov 2009 07:35:21 GMT</pubDate></item><item><title><![CDATA[Reply to How to get value from the two source points? on Tue, 17 Nov 2009 01:37:39 GMT]]></title><description><![CDATA[<p dir="auto">Hi Petteri,</p>
<p dir="auto">This was missing, but is added now and in for the next release. I've added typical date related functions including things like this:</p>
<p dir="auto">p.time --&amp;gt returns the timestamp of the value in milliseconds since the epoch<br />
p.millis --&amp;gt 0-999 the millisecond portion of p.time<br />
p.second --&amp;gt 0-60<br />
p.minute --&amp;gt 0-60<br />
p.hour --&amp;gt 0-23<br />
p.day --&amp;gt 1-28,31<br />
p.dayOfWeek --&amp;gt 1-7 where 1 is Sunday<br />
p.dayOfYear --&amp;gt 1-365,366<br />
p.month --&amp;gt 1-12<br />
p.year --&amp;gt four digits</p>
]]></description><link>https://forum.mango-os.com/post/2840</link><guid isPermaLink="true">https://forum.mango-os.com/post/2840</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Tue, 17 Nov 2009 01:37:39 GMT</pubDate></item><item><title><![CDATA[Reply to How to get value from the two source points? on Mon, 16 Nov 2009 18:31:35 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I need to get the timestamp value of a point and compare it with another time period value, saved in another point value.<br />
Is this possible using a meta point..? e.g. "if (p100.time &gt; p99.value) return something;"</p>
<p dir="auto">Regards,<br />
Petteri</p>
]]></description><link>https://forum.mango-os.com/post/2839</link><guid isPermaLink="true">https://forum.mango-os.com/post/2839</guid><dc:creator><![CDATA[Petteri Weckstrom]]></dc:creator><pubDate>Mon, 16 Nov 2009 18:31:35 GMT</pubDate></item><item><title><![CDATA[Reply to How to get value from the two source points? on Fri, 30 Oct 2009 13:56:23 GMT]]></title><description><![CDATA[<p dir="auto">Use a meta point to combine the values of the two points into one. Then add your detectors and handlers to the meta point.</p>
]]></description><link>https://forum.mango-os.com/post/2790</link><guid isPermaLink="true">https://forum.mango-os.com/post/2790</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Fri, 30 Oct 2009 13:56:23 GMT</pubDate></item></channel></rss>