Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Simulation Scripts

You can perform dynamic simulation of your models using scripts written in JavaScript. All simulation objects and variables are created in the Java run time environment.

The current simulation objects have a root element sim and the object or Class type SimObject. The sim element is the root of the tree structure of generated simulation objects and their properties shown in the Locals window, although - unlike user interfaces or Java variables - sim itself as the root is not shown. Each SimObject has properties, some of which are themselves SimObjects. For example: sim.a.b can be a simulation object, having a single value - an integer or a string.

Java variables created by Java data types, such as var, Object and Array are not shown in the Locals window, though they exist in the Java runtime environment. You can check for them using code; for example:

     var a = 5; sim.a = a;

In this way, sim.a will be shown in the Locals window.

You can also create an Array or an Object using this code:

     sim.a = new Array();

     sim.a = [1000,1100,1200,1300];

     sim.simArray = nativeArray; //nativeArray is a Java Array

     sim.o = new Object();

     sim.o = {property1:5,property2:"myString"};

The resulting objects are simulation objects but not Java objects; that is, this is a transformation process, creating Java objects and transforming them into simulation objects.