Overview of Building a Model

This section describes many of the common steps involved in building a model using the API. The classes mentioned here contain many other methods you will find useful, depending on the type of model you are building.

Important: The first thing you must do in your application is to logon. For more detailed information about logging on, see Logging On.

Creating a New Empty Model

The main class for building and interacting with a model at the highest level is the DtModelManager class found in the com.engineous.sdk.model package.

DtModelManager modelMgr = DtModelManager.createEmptyModel();

This class creates an empty model that does not have a root component in it. Adding components is described later. The Dt prefix refers to this class as “design time” (a class used for building and editing models) and is not applicable or has no use at “run time.”

Loading an Existing Model

A common scenario is to start with an existing model as a template and then use the API to edit various aspects of that model (instead of always building one from scratch).

InputStream inputStream = new
FileInputStream("c:\\temp\\MyTemplateModel.zmf");
DtModelManager modelMgr = 
DtModelManager.createModel(inputStream);

Accessing and Setting Model Properties Using the ModelProperties Object

ModelProperties modelProps = modelMgr.getModelProperties();
modelProps.setModelName("My Model");
modelProps.setModelDescription("This is my model…");
modelProps.setUseFixedSeed(true);
modelProps.setDBLookupMode(ModelProperties.MODEL_DBLUMODE_ALL_J
OBS);

If you do not make the call to setModelName, you will see validation warnings if you open the model in the Design Gateway. Therefore, it is suggested that you always set the model name.

For other properties that can be accessed and set using the ModelProperties object, refer to the javadocs in the following directory:

<Isight_install_directory>/Doc/docs/api/_index/main.html

Creating a Component and Setting the Root Component for the Model

DtComponent myTask =
DtModelManager.createComponent("com.engineous.component.Task
", "My root task"); 
modelMgr.setRootComponent(myTask);

The root component does not need to be a Task. It can be any component that is published to the Library, specified using the full path name under which that component is published.

Creating Components and Adding Them to the Existing Task Component

DtComponent mySimcode =
DtModelManager.createComponent("com.engineous.component.Simc
ode", "My simcode");
myTask.addComponent(mySimcode, true);

The “true” value for the second argument adds the component to the end of the simulation process flow.

DtComponent myExcel = 
DtModelManager.createComponent("com.engineous.component.Exce
l", "My Excel");
myTask.addComponent(myExcel);

The true argument for the second argument is not provided, and the component is added as a child of the Task but is left out of the simulation process flow. The simulation process flow will need to be constructed as described below.