Categories
HowTo's VSCP

#VSCP HOWTO: DM – Check variables – store result

A common operation handling flowing data and measurements  is to compare results and the decision matrix (DM) has plenty of functionality built-in for this. Here we will look at three of the actions available for this.

They are

Check variable, set variable
VSCP_DAEMON_ACTION_CODE_CHECK_VARIABLE
Check variable, set to true
VSCP_DAEMON_ACTION_CODE_CHECK_VARIABLE_TRUE
Check variable, set to false
VSCP_DAEMON_ACTION_CODE_CHECK_VARIABLE_FALSE

What they all do is to compare (less than, greater than equal etc) a literal value with the content of a remote variable  and they

Check variable, set variable

This action check the value of a variable against a literal and the set the named boolean remote variable to the outcome of the logic operation. So

3.14;eq;pi;myflag

will set the remote variable myflag to true if the remote variable pi is equal to 3.14 (false otherwise) and

32;lt;temp;alarm

will set the boolean remote variable alarm to true when the remote variable alarm have a value that is greater than 32 and to false otherwise.. The last will look like this in its complete form

<row enable="true" groupid="Variable compare" >

<comment>
 Test the variables tamp if its greater than 32 
 every second
</comment>

<mask priority="0" 
 class="0xFFFF" 
 type="0xFFFF" 
 GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

<filter priority="0" 
 class="65535" 
 type="5" 
 GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

<action>0x58</action>
 <param>
 32;lt;temp;alarm
 </param>

</row>

Check variable, set to true

This is just a variant of the above. Instead of the result of the logical compare true is always stored when the calculated result is true.

So the example above

32;lt;temp;alarm

will no actually do the same as before. If the result is true it stores true and false if not.

Check variable, set to false

Another variant of the same. Instead of the result of the logical compare false is always stored when the calculated result is true.

So for the example above

32;lt;temp;alarm

alarm will be false when temp is greater than 32 and vice versa.

————————————————————————————

Some ready-made test code is available here.

 

.

2 replies on “#VSCP HOWTO: DM – Check variables – store result”

One can think so… 🙂 But actually I am going through all the old functionality before the release to see that everything still works and decided to write a howto for most of them as I go.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.