About Scripting in Isight Models

You can use scripts in a number of places in Isight models to customize behavior.

Using Scripts in Isight Models

You can use scripts in a number of places in Isight models to customize behavior.

You can use scripts in the following places:

  • The Script Component (as described in Script Component). This component is used to manipulate array and string parameters in ways that the Calculator component cannot handle.

  • Component Prologue/Epilogue Scripts (as described in Defining Prologue/Epilogue Information). Prologue scripts can be used to perform component reconfiguration during model execution or to set up files or other resources for the component to use. Epilogue scripts can be used to collect process output files or to calculate flags used in subsequent conditional simulation process flow expressions.

  • Model and Component Customization Scripts (as described in Customizing Models in the Isight User’s Guide). Customization scripts can reconfigure a model based on the model inputs, allowing more dynamic modeling.

    The same basic scripting facilities and editors are available in all of these locations.

Available Scripting Languages

Isight supports two scripting languages.

  • Jython. A version of the Python language written in Java.

  • DynamicJava. A scripting language that uses Java syntax.

Both languages provide access to parameters (or the value of a parameter), to select global variables that provide access to the Isight SDK, and to arbitrary Java classes and objects; however, the way in which they provide access differs slightly for each language. Jython is the recommended scripting language. It has a simpler syntax and more flexible type system than DynamicJava. DynamicJava is provided for backward compatibility with existing models.

Script Execution

The script is evaluated statement-by-statement at run time until the last statement completes.

When the script's last statement completes, the Script component is considered to have finished successfully. If any statement gets an error or the script throws an uncaught exception, the Script component is considered to have failed.

The standard exception to throw to indicate a failure is RtException. For example, using Jython syntax:

if not resultsUsable:
    raise RtException("the results are not usable")

Note: Scripts should be written carefully so as to not interfere with the environment used to execute them. For example, scripts cannot contain calls to System.exit() or Runtime.getRuntime().exit(), because these method calls would terminate the supporting Isight Gateway or SIMULIA Execution Engine station.