Events

With the help of events, you can have parts of your code executed as soon as certain events occur. The following events are explained below:


Events.onProjectLoaded

Events.onPageLoaded

Events.onVarChanged

Events.onVariablesInitialized


Events.onProjectLoaded


The onProjectLoaded event is triggered once as soon as the project is loaded and the main interface is available.

Only after this event is it possible to communicate with the mainInterface and, for example, to manipulate variables.


Events.onProjectLoaded(function);

A function that is to be called when this event is triggered must be passed as a function parameter. When the event is triggered, this function is called without parameters.

Events.onPageLoaded


The onPageLoaded event is triggered after individual pages have been loaded.


Events.onPageLoaded(function);

A function must be passed as a function parameter that is to be called when this event is triggered. When the event is triggered, this function is called with the page name as the only parameter.


Events.onPageLoaded(selector, function);

The name of a page or a regular expression must be passed as the selector parameter. If a page is loaded and the name of the page matches the selector, the function passed as function will be called.

A function that is to be called when this event is triggered must be passed as the function parameter. When the event is triggered, this function is called with the page name as the only parameter.


Events.onVarChanged


The onVarChanged event is used to react to the change of one or more variables.


Events.onVarChanged(selector, function);

A function that is to be called when this event is triggered must be passed as a function parameter. 

When the event is triggered, a parameter with the following structure is passed to the function:



args[„variable“][„name“] 

(args.variable.name) 


Contains the name of the variable.

args[„variable“][„datasource_name“] 

(args.variable.name) 


Contains the name of the data source for the variable.

args[„variable“][„value“] 

(args.variable.value) 


Contains the current value of the variable. 

args[„variable“][„lastvalue“] 

(args.variable.lastvalue) 


Contains the old value of the variable. 

args[„variable“][„quality“] 

(args.variable.quality) 


Contains the current quality of the variable. 

args[„variable“][„timestamp“] 

(args.variable.timestamp) 


Contains the time of the last change. 



The name of a variable or a regular expression must be passed as the selector parameter. If a variable changes and the name of the variable matches the selector, the function passed as function is called.


Events.onVariablesInitialized


The onVariablesInitialized event is triggered once as soon as all variables have been initialised. This event occurs shortly after the onProjectLoaded event. 


Events.onVariablesInitialized(function);

A function that is to be called when this event is triggered must be passed as a function parameter. When the event is triggered, this function is called without parameters.