Tutorial 1
(Your first Watchdog trigger)
This is the the main window of the Watchdog user interface.
It consists of 5 parts:
  • The application menu.
  • The code editor. (Trigger)
  • The trigger list. (Triggers)
  • The outputs. (Log/Error)
  • The data watch list. (Global Data)
To create a new trigger, right click anywhere on the trigger list and select "Add trigger".
This will open up a new dialog window where you can specifiy the title of your new trigger and if you wish, a description and/or tag.
When you are done, click OK to continue and the trigger will be created with a pre-defined example code.
Every trigger consists of 3 functions.
  • setDataDependency: This function lets the watchdog know what data the trigger needs.
  • onEvent: This function is the core of the trigger and it's executed when any data requested in setDataDependency is updated.
  • validate: This function is mainly used for testing purposes, if needed. It can also be used as for the core code while developing the trigger so that no code is accidentally published/launched before it's done.
All functions should return 0 if they were executed successfully.
The only 2 lines of code that actually does anything are line 10 and 17.
These lines add a row to the Watchdog log. To test the example, click the run (play) button above the script.
If successfull, you should get this result in the debug-box:
The variable eventType is passed to the onEvent function and can be used to determine if the event was triggered manually inside the Watchdog interface (eventType == "Manual") or by an update of any data that the trigger is depending on (eventType != "Manual"). This way you can filter out code ment only for testing purposes.
Try editing the text inside the string quotation marks and run it to see what happens!
You can also trigger the validate function by clicking the validate button (broom). Good luck.

This concludes the first tutorial.