This article describes how you can embed your own user-written logics into the signal processing of a ToolScope.

This filter "Signal processing script" allows you to write your own script for signal filtering. Within the script, signals can be read out, overwritten and output.

This filter has three different views, between which you can switch using tab pages (red frame). In the first view ("Input and output signals") you can configure the input signals which can be accessed within the script. You can also define the name and signal type of the output signal. If the number of input signals is not sufficient, you can increase the number of signals in the Other settings (variable "NumberOfInputs"). You can also increase the number of output signals in the same way (variable "NumberOfOutputs").

In the "Script to be executed" view, you can find the text input field for the script. Within the script, simple Java/C source code (not Javascript) is permitted. The use of pointers, as is possible in programming language C, is not possible here. As the script is called up by the ToolScope with the configured measuring frequency, it must be ensured that the script can be processed as quickly as possible (no queues).

The soft keys “Export/Import Script to/from Service” allows you to import or export the script to the Service Area.

In the “Compiler output” view, you can find the raw outputs of the script compiler. These can be helpful during troubleshooting, if the script cannot be compiled.

The view “Java Imports“ contains all program-libraries which can be accessed by the script. If more libraries are needed in the script, they can be added here.

The view “Parameter” allows you to declare and modify variables which are accessible via the script. Thereby it is possible to influence the outcome of the script, also for “none-programmers”. 

The following variables are available within the script:

time: This variable contains the time in seconds, since the sensors were started.

i1 -  i1n: These variables contain the values of the configured inputs. The number of inputs can be changed in Other settings (variable "NumberOfInputs"). The data type of the variable is dependent on the data type of the input signal. If the input signal is a number, then the variable is of type double. If it is a character string, then the variable is of type String.

p1 - p1n: These variables are static and can be used to save values for the next time the script is executed. If more than these 10 static variables are needed, then their quantity can be changed in Other settings (variable "NumberOfStaticVariables"). These variables can only save numbers.

s1 - s1n: These static variables fulfill the same task as variables p1n. However, they cannot save numbers, but rather character strings.

result1 - resultn: These variables represent the result of the script and are linked with the respective output signal. The result of the script must be assigned to these variables. The data type of the output variables (result1 - resultn) depends on the selected output signal type (decimal number, character string; see first screenshot).

In addition to the predefined variables (time, i, p, s and result), you can also define local user-defined variables (see second screenshot).

The following functions are also always available within the script:



[double] PI

Approximately Pi

[double] E

Approximately Euler's number

[double] sin ([double] var)

Sine function (radian)

[double] cos ([double] var)

Cosine function (radian)

[double] tan ([double] var)

Tangent function (radian)

[double] toRadians ([double] var)

Converts from degrees to radian

[double] toDegrees ([double] var)

Converts from radian to degrees

[double] exp ([double] var)

Exponential function to base of Euler's number

[double] log ([double] var)

Logarithm function to base of Euler's number

[double] log10 ([double] var)

Logarithm function to base 10

[double] sqrt ([double] var)

Square root function

[double] set (
[int] ID,
[double/String] var

Sets the value of the input signal with the specified ID (whole integer) to the given value. Any configured signal can be overwritten with this. The data type of the input signal and of the transferring signal (var) must match.

[double] toNumber ([String] var)

Tries to convert the transferring character string (var) into a number ([double]). If the conversion fails, 0 is returned.

[String] toString ([double/int] var)

Converts the transferring number (var) into a character string. Decimal numbers contain a period as the separator (.)

You can find a full list here.