How-To Guides
Analytics Guides
Use the Switch Processor Function
7min
in this guide, we will use the switch processor function to manage the flow of data you will understand the various rules applicable to the switch processor, how input messages are evaluated, and the significance of output filtering before you begin get familiar with different rules of switch docid\ ifezzlax1g2rsdjncjstz processor the rules for comparison are done through golang strings compare functions user scenario review the following scenario for the switch processor function then, using an input processor, you will simulate plc data, apply certain rules from the switch processor, and then output only when rule checks are met in a manufacturing plant, you can use the switch processor to evaluate incoming messages from sensors that detect product specifications, such as tags and weight when a sensor reports a product that exceeds a predetermined threshold or set conditions, the switch processor checks this input against the available rules if the condition is met, floor operators can be notified to inspect the assembly line for potential issues or alternatively an alert can be triggered in this way, the switch processor helps ensure that only products meeting quality standards proceed down the production line, minimizing waste and enhancing overall operational efficiency step 1 add a device follow the steps to connect a device docid\ ish7bqhzxswtdx8vbnszb and configure the following parameters device type simulator driver name generator enable alias topics select the checkbox step 2 add tags after connecting the device, add the following tag see add tags docid\ xgwokqbtpevii7or82ll0 to learn more tag 1 tt1 name select s random value generator value type select string polling interval enter 1 tag name enter tt1 step 3 create analytics flows you can now create the analytics flows using data from the device and tag you previously created to create an analytics flow with the switch processor function in litmus edge, navigate to analytics on the analytics canvas, click add processor the create a processor dialog box displays select datahub subscribe in the topic field, click the search icon, select the device you previously created, and then select the alias topic for the tt1 tag click save click add processor again and select the switch processor the following information defines this function rule the rule specifies the condition to be checked for this example, we select contains rule from the drop down menu field name the field name indicates the specific field in the input message for comparison for this example, we input value as field check value the check value is the value against which the field name is evaluated for this example, we want ' h ' value to check for check value type the check value type defines the expected data type of the check value for this example, we input a value of 4 output (optional) the output determines where the result will be published or if it goes to all connected processors if left empty click save connect the datahub subscribe processor (tag tt1 ) to the switch processor with a wire and use the events connection on the analytics canvas, click save the configured analytics flows should look like the following step 4 view output of processor click the view icon in the switch processor to view the output values you can see the values that contain the letter ' h ' in the specified field are displayed in the output