In another Howto we looked at the measurement compares that are available in the decision matrix (DM) record (VSCP HOWTO: COMPARE VALUES WITHOUT CODING). Here we will look at an action that work in a similar equal manner.
The check measurement action
VSCP_DAEMON_ACTION_CODE_CHECK_MEASUREMENT
is defined to make it possible to check a measurement against a literal value and just as we described in the howto about the check variable actions it stores the logical outcome of the compare in a boolean remote variable.
Also here equal to, less than, greater than etc is available. A typical parameter row can look like this
0;0;99.5;gt;flag
This says that if a measurement comes in that have a value that is greater than 99.5 the remote variable “flag” will be set to true. In all other cases “flag” will be set to “false”. The “0;0” that is the first two values of the parameter line is unit and sensor index. In this case the measurement therefore must have unit=0 and sensor index = 0 as well for the test to be evaluated at all.
A complete example is available in the documentation of the action. You can find pre written samples here.
As a note. Instead of a literal value for the compare you can use another variable. The parameter above can be rewritten
0;0;%variable:[critical_value];gt;flag
and instead of the literal “99.5” the value of the remote variable 99.5 is used for the compare. VSCP DM escapes are evaluated before an action is carried out. There is many of them and they can be very useful when you want to make decision matrix rows act in a more dynamic way without go so far as to use full JavaScript or Lua. You can read more about the VSCP DM escapes here.
It isn’t harder than that actually.