How to filter or route variables

Revision as of 10:08, 17 August 2020 by Registered User

1. How to filter or route variable to UI?

In some cases it is useful to filter some variables. For instance, when you perform post-processing you may want to plot only the post-processed variable and not the original one. Here are the solutions to :

  • Hide useless variables
  • Plot 2 variables on 2 charts
  • Hide a "post processing" variable. When a variable is hide in the chart this variable is taken into account to calculate minimum and maximum values.

Several solutions can perform this routing or filtering.

1.1. Create 2 groups of variables

You can create 2 different groups of variables (variable nodes), and consequently the same amount of processing nodes. One can be connected to the gauge and the other one to the chart.

1.2. Use the "switch node"

You can use the “switch node”, used like a filtering node on the output of the processing node. The switch node filters your variable on the following property : msg.payload.variablename and set == myVariable.

Here is the switch node configuration :

   [{
       "id": "2ca79e6f.a68e72",
       "type": "switch",
       "z": "8bf74b4c.0fa5f8",
       "name": "filter variable",
       "property": "payload.variablename",
       "propertyType": "msg",
       "rules": [
           {
               "t": "eq",
               "v": "myVariable",
               "vt": "str"
           }
       ],
       "checkall": "true",
       "repair": false,
       "outputs": 1,
       "x": 630,
       "y": 220,
       "wires": [
           [
               "b9d7ae86.0da72"
           ]
       ]
   } ]

You first have to import it into your STM32CubeMonitor tool following these steps :

  • Click on the “Hamburger” menu, at the top right of your window
  • Select “Import”
  • In “Clipboard” paste your json configuration and click on “Import”

The switch node will automatically appear in your design window. Link it to your processing node output.
In the switch node configuration panel, replace “myVariable” by the variable name you want to filter.

You can either use several “switch nodes” in series or in parallels to filter multiple variables :

1.2.1. "Switch nodes" in series

In the previous flow, the first switch node allows to route the "counter" variable to a new chart. The second switch node allows to plot all remaining variables in the other chart excluding only one variable.

1.2.2. "Switch nodes" in parallel

In the previous flow, the first switch node allows to route all variables except the counter value. The second switch node allows to route only the counter variable to a new chart.