Sensor Model | All |
Firmware Version | 3.x, 4.x, 5.x, 6.x |
SDK Version | n/a |
Question
How does scripting work?
Answer
Scripting support (Script tool) in the Gocator allows you to provide code to extend the existing measurement tools. PicoC is used as the scripting engine, which is a very small C interpreter, suitable for embedded devices. The language is very similar to C, with following supported elements:
- Control operators (if, while, do, for, switch and return).
-
Data types (char, int, unsigned int, float, double, long long).
- Standard C arithmetic and logical operators.
- Standard C function declarations with arguments passed by values.
- Standard C array declarations.
- Standard arithmetic functions (+ , −, *, /, %, ++, --).
There are also some limitations:
- Explicit type casting (e.g. int a = (int) a_float) is not supported. Values are cast implicitly.
- Ternary operator (a ? b : c) is not supported.
- The “const” keyword is not supported.
- Pointers are not supported.
The scripting language allows the definition of functions; everything outside of a function definition is executed in order of parsing. The script is executed once when a full set of real measurements are available. Only one script tool can be added to a job file and the script is always executed last in a program.
The script tool can only access tool measurements (not features or data), stamp information (frame, time, encoder, inputs, etc.) and runtime variables. The script tool can also save scalar values to memory for future use (such as adding/accumulating measurement values from previous scans).
For complete list of supported functions see the documentation here.
Comments
0 comments
Please sign in to leave a comment.