- Overview
- Display Builder
- Display Runner
- Processed Variables
- Widgets
- Actions
- Borders
- Rules
- Scripts
- Macros
- Tuning
Yamcs Studio Release Notes
Source Code Documentation
DataUtilΒΆ
Helper methods for creating Java-compatible arguments.
- createDoubleArray( size )
Returns a new Java double array of the given size.
- createIntArray( size )
Returns a new Java int array of the given size.
- createMacrosInput( include_parent_macros )
Create a new
MacrosInput
object, useful when creating a container widget through scripting.include_parent_macros is a boolean value that indicates if the MacrosInput should inherit or start blank.
- toJavaDoubleArray( array )
Returns a Java array that matches the provided script array.
- toJavaIntArray( array )
Returns a Java array that matches the provided script array.
Example
The following scripts do the same but in different ways:
// Create a Java array, then add to it
var arr = DataUtil.createDoubleArray(100);
for (var i = 0; i < 100; i++) {
arr[i] = i;
}
pvs[0].setValue(arr);
// Create a JavaScript array, then convert it to Java
var arr = [];
for (var i = 0; i < 100; i++) {
arr[i] = i;
}
pvs[0].setValue(DataUtil.toJavaDoubleArray(arr));
Note that the same can actually also be achieved by not using
DataUtil
, but instead the Java
class available to
Nashorn scripts:
var arr = [];
for (var i = 0; i < 100; i++) {
arr[i] = i;
}
pvs[0].setValue(Java.to(arr, "double[]"));