How-To Guides
Analytics Guides
Use the Expression Processor Function
13min
you can use a single input or multiple inputs to create a mathematical expression with your desired topic single inputs use events or values type connection and multiple inputs use only values type connection user scenario review the following scenario for the expression processor function then, you will simulate plc data and calculate mathematical expression outputs using the expression processor function user scenario 1 (using one input function) in a cold storage facility, maintaining the right humidity levels is crucial for preserving the quality of perishable goods an alert system needs to be in place to signal if the humidity goes beyond the acceptable range expression for humidity alert (humidity value < 30 || humidity value > 50) ? "alert humidity out of range" "humidity normal" user scenario 2 (using multiple input functions) in a solar power plant, it's essential to constantly monitor the efficiency of solar panels to ensure optimal energy production efficiency can be calculated based on the ratio of the output power to the input solar radiation, along with the surface area of the solar panel expression for efficiency calculation (p value / (s value area value)) 100 step 1 add a device follow the steps to connect a device docid\ nm1lqfefya dsiffitity 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 tags see add tags docid\ h5heqicxrcy3nch9kbg9i to learn more each tag will represent one of the user scenario mentioned above tag 1 (user scenario 1) name select s random value generator value type select int64 polling interval enter 5 tag name enter humidity min value enter 25 max value enter 55 tag 2 (user scenario 2) name select s random value generator value type select float64 polling interval enter 5 tag name enter power min value enter 75 max value enter 100 tag 3 (user scenario 2) name select s random value generator value type select float64 polling interval enter 5 tag name enter solar radiation min value enter 50 max value enter 75 tag 4 (user scenario 2) name select s random value generator value type select int64 polling interval enter 5 tag name enter area min value enter 250 max value enter 500 step 3 create analytics flows you can now create the analytics flows using data from the device and tag you previously created follow the appropriate step out of 3a or 3b based on the two user scenarios for the expression processor function you want to use step 3a configure single input expression (user scenario 1) 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 humidity tag click save click add processor again and select expression processor the following information defines this function expression enter the mathematical expression from the user scenario 1 you must define the connection of the input tag as a variable name (humidity) and then use that in the mathematical expression (such as humidity value) output field name enter value as the field to appear in the output click save connect the datahub subscribe processor (tag humidity) to the expression processor with a wire and enter the definition of humidity for the value type connection on the analytics canvas, click save the configured analytics flows should look like the following step 3b configure multiple inputs expression (user scenario 2) 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 power tag repeat steps 2 4 in step3b to add another datahub subscribe node select the alias topic for the solar radiation and area tag respectively click save click add processor again and select expression processor the following information defines this function expression enter the mathematical expression from the user scenario 2 you must define the connection of the input tag as a variable name (p, s, area) and then use that in the mathematical expression (such as p value, s value, and area value) output field name enter value as the field to appear in the output click save connect the datahub subscribe processor (tag power) to the expression processor with a wire and enter the definition of p for the value type connection connect the datahub subscribe processor (tag solar radiation) to the expression processor with a wire and enter the definition of s for the value type connection connect the datahub subscribe processor (tag area) to the expression processor with a wire and enter the definition of area for the value type 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 expression processor to view the output values view output for user scenario 1 the expression function calculates the humidity from the defined tag values and gives the output for the mathematical expression view output for user scenario 2 the expression function calculates the efficiency from the defined tag values and gives the output for the mathematical expression