/* All user scripts should derive from the base "Application" class */ require ("Application"); /* This script will wait until the value of DataSim:Amplitude changes * and then it will wait 10 seconds and write to DataSim:Test * You can change the tag names and the delay timer. */ class DelayedWrite Application { } method DelayedWrite.timeDelay (newValue) { //write takes a full tag name and a value //replace DataSim:Test with the tag that we write to datahub_write("DataSim:Test", newValue); } method DelayedWrite.valueChanged () { //we will write to a new tag after some time period //10 is in seconds, this can be changed .TimerAfter(10, `(@self).timeDelay(@value)); } /* Write the 'main line' of the program here. */ method DelayedWrite.constructor () { //replace DataSim:Amplitude with the tag that will be changing .OnChange( symbol("DataSim:Amplitude"), `(@self).valueChanged()); } /* Any code to be run when the program gets shut down. */ method DelayedWrite.destructor () { } /* Start the program by instantiating the class. If your * constructor code does not create a persistent reference to * the instance (self), then it will be destroyed by the * garbage collector soon after creation. If you do not want * this to happen, assign the instance to a global variable, or * create a static data member in your class to which you assign * 'self' during the construction process. ApplicationSingleton() * does this for you automatically. */ ApplicationSingleton (DelayedWrite);