Graphical scripting
Introduction
A graphical script is an object that describes an algorithm in a way similar to IDA macros. The main difference is that the algorithm is executed by IDA Modeler without starting IDA Solver.
Graphical scripts may be inserted from palette to into any macro object.
Graphical scripts are edited like macro objects by inserting and connecting components. Most time-independent algorithmic components from control library (like Adder, Switch etc.) are available. Some extra models are added (EqualTo, CustomScript). More will be added in the future.
The components of graphical scripts contain variables and parameters. But the scripts are not simulated, so the variables are really not time-dependent. The variables are used only to make graphical scripts maximally similar to macro objects.
Special components are defined for input and output.
Connected scripts
We say that a graphical script is connected if all required input is connected via parameter mapping to appropriate sources outside of script macro. The output from connected script may be used as source for mapping to target object outside of the script macro.
The scripts that have unconnected input may still be executed using a call expression that establishes a temporary connection.
Execution
A graphical script is executed either by demand or on events.
The supported events are
- CHANGE, the script is executed on any change in script (parameter values, connections etc.)
- MODEL, the script is executed after creating math model.
- SIMULATION, the script is executed after simulation and composing result objects (but before removing math model).
Only the connected scripts may be called on events.
Scripts called on demand – simple
A connected graphical script may be also executed by calling script function (run-script-macro reference_to_script). This way may be appropriate for a button that resides in the script’s schematic view
Scripts called on demand – with parameters
Here is the syntax of (non-graphic) script that executes a graphical script:
(:call reference_to_script (:= in_1 value_1) … (=> out_1 target_1) … (=> ret))
Here
- in_i is the name of input component or interface that should get the result of evaluation of value_i;
- out_i is the name of output component or interface those value will be assigned the object referenced by target_i
- ret is the name of output component or interface those value is returned as the result of call.
A script executed by demand does not have to be connected. The source of the input and the utilization of the output is defined by the caller. Such a script cannot serve as source for parameter mapping because only a temporary copy of the script is executed.
Such scripts may reside either in any place of user’s system or in libraries provided by IDA application. It is also possible to call a component of a script.
The call may be inserted in any place where a script is accepted. Examples:
- :on-click method for buttons
- Column function in Parametric Runs interface
- Advanced mapping
Input
A connected graphical script takes the input via
- parameter mapping;
- custom script components that collect required data. This may not work for scripts called "on change"
Any parameter (incl. start values of variables) in a script macro may be mapped, but the special components of type SCRIPT-INPUT a preferable because of
- A better visualization of input
- Possibility to check if the input is actually connected
A non-connected graphical script may be prepared to get some input via interface references.
Output
The output signals from control models are defined as variables. This means that they cannot be used at sources for parameter mapping. Therefore special components of type SCRIPT-OUTPUT should collect the output signals in connected graphics scripts.
A non-connected graphical script may be prepared to deliver some output via interface references.
A graphical script may also contain components with side effect (e.g., CustomScript component).