Running a batch script when a PLC tag changes using Cogent DataHub
How can I run a batch script when a tag changes using the Cogent DataHub?
Let me explain how to edit the script first.
1. Save the file RunBatchFile.g
2. Go to the scripting tab in DataHub, click Add and point to the RunBatchFile.g.
3. Highlight the script and click Edit.
4. Line 22 - Change this to the file path of your batch script.
5. Run the script by clicking the Play button in the Script Editor.
6. This example does not require you to connect to any tags. It creates a tag called “default:MyTag” and writes it to 0.
7. Click on View Data and find this tag in the data browser.
8. Highlight the tag, input a value of 1 and hit Enter. The batch file should execute when the tag changes and value equals 1.
The next step will be to connect to your OPC server and change the tag name in the script (Line 21) with the tag you want to monitor.