Using Custom Variables with Math Operations
Previous Topic  Next Topic 


Overview


Let's take the scenario where it's desired to keep a counter tracking the amount of time a machine has been in cycle.  Each time the machine goes into cycle we want to start a counter, and then each time the machine stops we want the counter to stop accumulating the time. 



First, create an expression to track when the cycle stops. This will be in the body of the expression:

([PCSDB.general_equipment_status] !=[PCSDB.CYCLING]) AND ([PCSDB.prev_general_equipment_status] =[PCSDB.CYCLING])


Next we want to create a custom variable that will store the value. See here on how and where to create.


The target for this expression will be updating a PCSDB custom variable that we named cycle_counter:
[PCSDB.send_custom_variable_value] {cycle_counter} == ([PCSDB.custom_variable_value]{cycle_counter} PLUS [PCSDB.prev_general_equipment_status_time])

We use () parentheses around the portion of the expression we wish to have evaluated first.


Great, that part is done.  Now we need to trigger some sort of event when the counter hits a limit.  Let's say we want to send an email after the machine has run for 50 hours, which would be 180,000 seconds.

We would then create the following expression:

[PCSDB.custom_variable_time] {cycle_counter} > 180000)


We would want to use the same expression twice.  Once to trigger our email, and the second to reset the cycle_counter variable to zero.

[PCSDB.send_custom_variable_value] {cycle_counter} == 0

If we wish to set the value to NULL for reporting and charting purposes, we can use this as our target. See here for information on running reports for custom variables.

[PCSDB.send_custom_variable_value] {cycle_counter}


Adding the power of the Script Source into our arsenal of tools we really open up the doors to unlimited possibilities.

For example, the limit used to trigger an event can be pulled from a CMMS, and the target could automatically open a work order in the CMMS.


Contact your local reseller for more information.  Here


Other Links

How to create PCSDB Custom Variables

How to create an email template