{"id":2932,"date":"2017-12-10T16:52:08","date_gmt":"2017-12-10T16:52:08","guid":{"rendered":"http:\/\/grodansparadis.com\/wordpress\/?p=2932"},"modified":"2017-12-10T16:52:55","modified_gmt":"2017-12-10T16:52:55","slug":"vscp-howto-dm-check-variables-store-result","status":"publish","type":"post","link":"https:\/\/grodansparadis.com\/wordpress\/?p=2932","title":{"rendered":"#VSCP HOWTO: DM &#8211; Check variables &#8211; store result"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/184923704.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2935\" data-permalink=\"https:\/\/grodansparadis.com\/wordpress\/?attachment_id=2935\" data-orig-file=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/184923704.jpg?fit=556%2C612&amp;ssl=1\" data-orig-size=\"556,612\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"184923704\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/184923704.jpg?fit=556%2C612&amp;ssl=1\" class=\"alignnone wp-image-2935\" src=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/184923704.jpg?resize=255%2C281\" alt=\"\" width=\"255\" height=\"281\" srcset=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/184923704.jpg?w=556&amp;ssl=1 556w, https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/184923704.jpg?resize=273%2C300&amp;ssl=1 273w\" sizes=\"auto, (max-width: 255px) 100vw, 255px\" \/><\/a><\/p>\n<p>A common operation handling flowing data and measurements\u00a0 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.<\/p>\n<p>They are<\/p>\n<pre class=\"code\"><a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#check_variable_set_variable\">Check variable, set variable\r\nVSCP_DAEMON_ACTION_CODE_CHECK_VARIABLE<\/a><\/pre>\n<pre class=\"code\"><a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#check_variable_set_to_true\">Check variable, set to true\r\nVSCP_DAEMON_ACTION_CODE_CHECK_VARIABLE_TRUE<\/a><\/pre>\n<pre class=\"code\"><a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#check_variable_set_to_false\">Check variable, set to false\r\nVSCP_DAEMON_ACTION_CODE_CHECK_VARIABLE_FALSE<\/a><\/pre>\n<p>What they all do is to compare (less than, greater than equal etc) a literal value with the content of a remote variable\u00a0 and they<\/p>\n<ul>\n<li><a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#check_variable_set_variable\">Store the outcome of the compare\u00a0 in a boolean remote variable.<\/a><\/li>\n<li><a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#check_variable_set_to_true\">Set a boolean remote variable to true.<\/a><\/li>\n<li><a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#check_variable_set_to_false\">Set a boolean remote variable to false.<\/a><\/li>\n<\/ul>\n<h4>Check variable, set variable<\/h4>\n<p>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<\/p>\n<pre>3.14;eq;pi;myflag<\/pre>\n<p>will set the remote variable myflag to true if the remote variable pi is equal to 3.14 (false otherwise) and<\/p>\n<pre>32;lt;temp;alarm<\/pre>\n<p>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<\/p>\n<blockquote>\n<pre>&lt;row enable=\"true\" groupid=\"Variable compare\" &gt;\r\n\r\n&lt;comment&gt;\r\n Test the variables tamp if its greater than 32 \r\n every second\r\n&lt;\/comment&gt;\r\n\r\n&lt;mask priority=\"0\" \r\n class=\"0xFFFF\" \r\n type=\"0xFFFF\" \r\n GUID=\" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00\" \/&gt;\r\n\r\n&lt;filter priority=\"0\" \r\n class=\"65535\" \r\n type=\"5\" \r\n GUID=\" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00\" \/&gt;\r\n\r\n&lt;action&gt;0x58&lt;\/action&gt;\r\n &lt;param&gt;\r\n 32;lt;temp;alarm\r\n &lt;\/param&gt;\r\n\r\n&lt;\/row&gt;<\/pre>\n<\/blockquote>\n<h3 id=\"check_variable_set_to_true\" class=\"sectionedit41\">Check variable, set to true<\/h3>\n<p>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.<\/p>\n<p>So the example above<\/p>\n<pre>32;lt;temp;alarm<\/pre>\n<p>will no actually do the same as before. If the result is true it stores true and false if not.<\/p>\n<h3 id=\"check_variable_set_to_false\" class=\"sectionedit43\">Check variable, set to false<\/h3>\n<p>Another variant of the same.\u00a0Instead of the result of the logical compare false is always stored when the calculated result is true.<\/p>\n<p>So for the example above<\/p>\n<pre>32;lt;temp;alarm<\/pre>\n<p>alarm will be false when temp is greater than 32 and vice versa.<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>Some ready-made test code is <a href=\"https:\/\/github.com\/grodansparadis\/vscp\/tree\/master\/tests\/dm\/variable_compare\">available here<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A common operation handling flowing data and measurements\u00a0 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[53,13],"tags":[],"class_list":["post-2932","post","type-post","status-publish","format-standard","hentry","category-howtos","category-vscp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4raCZ-Li","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2932"}],"version-history":[{"count":2,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2932\/revisions"}],"predecessor-version":[{"id":2937,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2932\/revisions\/2937"}],"wp:attachment":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}