Importing Calculations into DataHub
Do you have an easy way to set up multiple calculations in DataHub?
Please find attached a calculation script and a csv file that contains all the calculations you need. Both files need to be placed in the "C:\Program Files\Cogent\Cogent DataHub\scripts" directory.
Adding Calculations to the CSV file
This script only reads from the calculations.csv and creates the needed information based on the formulas in the csv file. The file should have a single calculation per line. The left side is the calculation tag you are outputting to and the right is the input tags and formula. An example calculation is below.
$PLC:Tag_Calc = $PLC:Tag1 / (60 * $PLC:Tag2);
Anytime the value of PLC:Tag1 or PLC:Tag2 changes, DataHub will evaluate the equation and the value will be written to PLC:Tag_Calc.
The parsing engine requires there to be a space before the operators(*, /, +, -) or parenthesis () around each tag name. Let's look at the example above. Notice it has spaces before and after the =, * and /. This allows it to work. An alternative would be:
($PLC:Tag_Calc)=($PLC:Tag1)/(60*($PLC:Tag2));
If you did not include spaces or parenthesis then it will NOT function properly.
Running the Script
Go to the Scripting section in DataHub. Then click Add and point to the AutoCalculations.g. Once added to the list check the box to make it run on start up and click apply. This will ensure the script creates the calculations each time DataHub starts. Then you can highlight the script and click Load Now or restart DataHub to load the script.