Suche:

Javascript control

Dashboard-Control

Back to the overview

Description

In the Dashboard-Designer the Javascript control offers a JavaScript-Editor to create Javascript controls. You can set multiple in- and outputs to communicate with other controls.

Properties

Global

The global script will be execute on start of the online mode (Dashboard-view).

Here can be used the following objects:

Control

Here the following objects and functions are available. (Control can also be used for input and properties)

Cache Cache will be initialized with the start of the online mode. Following functions will be called with an value input.

Control.Cache = {
//id = The ID of the input, wich gets a value
//value = value object, wich arrive at the input
OnInput: function(id, value) { }
}

 GetPropVal GetPropVal can retrieve self-set values properties:

//Control.GetPropVal(PropID); //PropID = id(string), behind the Name of the property [ID=p1]
Control.GetPropVal("p1"); //now the value of the property "p1" will called

SetPropVal SetPropVal can set properties:

//Control.SetPropVal(PropID, value); //PropID = id(string), after the name of the property [ID=p1]
//e.g.:
Control.SetPropVal("p1", 5); //now the value of the property "p1" will be set to 5

IsEnabled  IsEnabled returns a boolean, wich indicates if the javascript-control is enabled in the input “Enabled”

Control.IsEnabled() //returns a boolean
//e.g.;
if (Control.IsEnabled() == true) {  }

OnEnabledChanged  Here you can set what should happen if the status of the “Enabled” input is changed.

Control.OnEnabledChanged = function(enabled) {  }

SendOutput With SendOutput you can call the specify outputs and send values.

//Control.SendOutput(OutputID, value); //OutputID = id(string)
Control.SendOutput("1", value); //send value with the output 1

OnTimer With the OnTimer, you can set, what happens by a tick of the timer.

//Bsp.:
Control.OnTimer=function(){
Control.SendOutput(1,1);
};

SetTimerInterval With SetTimerInterval you set the interval of the timer

//Control.SetTimerInterval(millisecond);
//Bsp.:
Control.SetTimerInterval(3000); //all 3 seconds

StartTimer StartTimer starts the Timer.

Control.StartTimer();

StopTimer StopTimer stops the timer. The timer will be stopped automatically with end of the online mode.

Control.StopTimer();

 

Create inputs

In the settings you can add as many inputs as you want with  and name them. The script, you can find in the same tab, will always be execute, if the input will called by another control. There you can use following variables and objects:
Value Returns the input value as a string, wich comes from the control through the input.
ValueObject Returns the input object, wich comes form the control through the input.
Name Returns the name of the input as a string (e.g. ‘Input#1’)
ID Returns the ID of the input as a string (e.g. “in1”).
Control Control is the object of the complete control. There are some functions available.
App App is the object of the complete Dashboard.

Create outputs

In the tab “Outputs” you can set as many outputs as you want with  and name them.

You can use the outputs like that:
//Control.SendOutput(OutputID, value);
Control.SendOutput(1, value);

The OutputID is the number after “ID=out”.

Properties

With the tap “Properties” you can create as many properties as you want with . You can set the Typ (e.g.: Text or Number) and you can set a Initial-value.

You can use the properties as following:

Get:

Control.GetPropVal(PropID); //PropID = id(string), after the name of the property [ID=p1]
Control.GetPropVal("p1"); //the value of property "p1" will be return

Set:

Control.SetPropVal(PropID, value); //PropID = id(string), after the name of the property [ID=p1]
//Bsp.:
Control.SetPropVal("p1", 5); //the value of the property "p1" will set to 5

Under the tap “Scripts” you can write a script, wich will called, if the value will change.

Example

Here is the script of the tap “Global” of a Javascript control, wich adds the value of two inputs and times a value of a property “p1”. Then the result will output.

Share this post