Application Programming Interface

The Application Programming Inferface (API) allows a JaamSim model to be constructed and/or launched from another program.  

The API is implemented through the JaamSimModel class.  There is one constructor for this class:

JaamSimModel()        Constructs a new instance of the JaamSimModel class.

The following methods can be used.

Method Summary for JaamSimModel

Modifier and Type

Method and Description

void

autoLoad()

Pre-loads the simulation model with basic objects such as Simulation and Units.

void

configure(File file)

Loads the specified configuration file to create the objects in the model.  The autoLoad() method must be executed first.

void

start()

Starts the simulation model on a new thread.

void

pause()

Suspends model execution at the present simulation time.

void

resume(double simTime)

Resumes a paused simulation model.  The model will continue execution until the specified simulation time at which the model will be paused.  Events scheduled at the next pause time will not be executed until the model is resumed.

void

reset()

Sets the simulation time to zero and re-initialises the model.  The start() method can be used to begin a new simulation run.

void

clear()

Deletes all the objects in the present model and prepares the JaamSimModel to load a new input file using the autoLoad() and configure() methods.

double

getSimTime()

Returns the present simulation time in seconds.

boolean

isRunning()

Returns true if the simulation is executing.

void

defineEntity(String type, String name)

Creates a new entity with the specified type and name.  If the name already used, "_1", "_2", etc. will be appended to the name until an unused name is found.

void

setInput(String entName, String keyword, String arg)

Sets the input for the specified entity and keyword to the specified string.

String

getStringValue(String expString)

Evaluates the specified expression and returns its value as a string.  Any type of result can be returned by the expression, including an entity or an array.  If it returns a number, it must be dimensionless.

double

getDoubleValue(String expString)

Evaluates the specified expression and returns its value.  The expression must return a dimensionless number.  All other types of expressions return NaN.

void

save(File file)

Writes the inputs for the simulation model to the specified file.

Also provided are 'setValue' methods for the FileToVector, FileToMatrix, and FileToHashMap classes.  The setValue method sets the data for these objects directly from a Java data structure, without the use of the DataFile input which can be left blank.