Simulators

Simulator Scripts Overview

Below is an overview of available Scripts to use for the Simulator.

Classes:
EntityAttributes
EntityLabels
EntityRelationships
EntitySimulation
InnoClass
InnoEntity
InnoProperties

entity/EntityAttributes.js

all()

Returns:
key value pairs for the attribute id: attribute value


get(name)

Parameters:

Name: Type: Description:
name String The name of the attribute to return ie: Duration

Returns:
key value pair units, value for the attribute passed.


getById(id)

Name: Type: Description:
id String The Id of the attribute to return. For action entities, 1 is duration, 2 is Start, 3 is Percent Complete. Added attributes will have different Ids

Returns:
key value pair units, value for the attribute passed.


getByName(name)

Helper function for get(name)

Name: Type: Description:
name String The name of the attribute to return ie: Duration

Returns:
key value pair units, value for the attribute passed.


getByProperty(property)

Name: Type: Description:
property Innoproperty InnoProperty object to get the value of

Returns:
key value pair units, value for the attribute passed.


getQualityScore()

Returns the value for the quality score attribute. If there is no quality score attribute, returns NaN.

Returns:
Quality score attribute.


hasQualityScore()

Used to see if there is a quality score associated with the entity.

Returns:
True if quality score exists, false if not.


set(value)

Name: Type: Description:
value String The value of the attribute to be set ie: 3 hours, 5, 2020-10-05 12:12:12

Returns:
True if quality score exists, false if not.


setById(id, value)

Name: Type: Description:
id integer The id number of the attribute to be set ie: Duration is 1
value String
The value to set the attribute to ie: 5 minutes

Returns:
InnoEntity Object of the current entity.


setByName(name, value)

Name: Type: Description:
name name Name of the attribute to be set ie: “Duration”
value String
The value to set the attribute to ie: 5 minutes

Returns:
InnoEntity Object of the current entity.


setByPropery(name, value)

Helper function for set

Name: Type: Description:
property Innoproperty The property to pass the value to
value String
The value to set the attribute to

Returns:
InnoEntity Object of the current entity.


entity/EntityLabels.js


add(label)

Adds label to entity

Name: Type: Description:
label Innolabel Label object to add to the entity

Returns:
InnoEntity Object with new label added.


addById(id)

Name: Type: Description:
id Integer The id of the label to add to the entity

Returns:
InnoEntity Object with new label added.


all()

Returns:
Key value pairs of the label id: and the InnoLabel object


contains(label)

Name: Type: Description:
label InnoLabel
The InnoLabel object to see if that current entity contains.

Returns:
True if the entity has the label, false if not


containsById(id)

Name: Type: Description:
id Integer
The Id of the label to see if that current entity contains.

Returns:
True if the entity has the label, false if not


containsByName(name)

Name: Type: Description:
id Integer
The Id of the label to see if that current entity contains.

Returns:
True if the entity has the label, false if not


ids()

Returns:
Array of the label ids for each label that the entity contains


remove(InnoLabel)

Removes label from entity

Name: Type: Description:
InnoLabel InnoLabel
Label object to remove from entity

entity/EntityRelationships.js


add(relationName, target)

Name: Type: Description:
relationName String The name of the relationship to be added
target InnoEntity
The target entity to which the current entity will be related with

Returns:
The current entity with the new relationship added.


addById(relationId, target)

Name: Type: Description:
relationId Integer The ID of the relationship to be added. You can find this information in the relations part of the schema editor
target InnoEntity
The target entity to which the current entity will be related with

Returns:
The current entity with the new relationship added.


addByName(relationName, target)

Helper function for add

Name: Type: Description:
name String The name of the relationship to be added.
target InnoEntity
The target entity to which the current entity will be related with

Returns:
The current entity with the new relationship added.


allLazy()

Returns:
An array of InnoEntity objects of all the entities the current one has relationships with.


allTargetIds()

Used to get the IDs of the entities the current one has relationships with.

Returns:
The IDs of the entities the current entity has relationships with.


allTargetIdsMap()

Used to get a map of the entities with which current one has relationships with along with their IDs.

Returns:
A map pf all of the entities’ IDs the current entity has relationships with key:targetId, value:targetId.


allTargets()

Get an array of the entities that the current one has relationships with,

Returns:
An array of InnoEntity objects that the current one has relationships with.


anyByIdLazy(id)

Name: Type: Description:
id Integer
Id number of the type of relationship to see if the current entity has towards other entities

Returns:
An array of InnoRelation objects for each entity that the current one has a relationship with.


anyLazy(name)

Name: Type: Description:
name String
Name of relationship you want to see if the current entities has towards other entities.

Returns:
An array of InnoRelation objects for each entity that the current one has a relationship with.


anyTargetIds(name)

Name: Type: Description:
name String
Name of the relationship type ie:”Decomposes”

Returns:
The ids of the entities the current entity has the given relationship with.


anyTargetIdsByIds(relationId)

Name: Type: Description:
relationId Integer The Id of the relationship

Returns:
The ids of the entities the current entity has the given relationship with.


contains(Relationship)

Name: Type: Description:
Relationship EntityRelationship Relationship to see if the current entity contains

Returns:
True if the entity contains the passed relationship, false if not.


containsAny(relationName)

Name: Type: Description:
relationName String The name of the relation ie: “decomposed by”

Returns:
True if the entity has any relationships of the given type, false if not.


containsAnyById(id)

Name: Type: Description:
id Integer The Id number of the relation

Returns:
True if the entity has any relationships of the given type, false if not.

containsAnyByName(relationName)

Name: Type: Description:
relationName String The name of the relation ie: “decomposed by”

Returns:
True if the entity has any relationships of the given type, false if not.


containsByName(relationName, target)

Name: Type: Description:
relationName String Type of relationship ie: “decomposes”
target InnoEntity
Entity you want to check to see if the current entity posseses the given relationName with

Returns:
True if the current entity has the given relationship with the one passed as parameter, false if not.


countAny(relationName)

Returns the number of relationships of the given type that the current entity has.

Name: Type: Description:
relationName String The name of the relation ie: “decomposed by”

Returns:
Integer of how many other entities the current entity has the specified relationship with.


containsAnyById(id)

Helper function for countAnyByName Returns the number of relationships of the given type by ID number that the current entity has.

Name: Type: Description:
id Integer
The ID number for the type of relation you want to count that the entity has. ie 15 for decomposed by

Returns:
Integer of how many other entities the current entity has the specified relationship with.


get(name, target)

Name: Type: Description:
name String The name of the type of relationship (ie. decomposes, consumes, connects to) to return
target InnoEntity
The entity with which the current entity has the relation towards.

Returns:
EntityRelationship object if the given relationship exists form the current entity towards the target entity parameter.


getAndRemove(name, target)

Name: Type: Description:
name String The name of the type of relationship (ie. decomposes, consumes, connects to) to return
target InnoEntity
The entity with which the current entity has the relation towards to get rid of

get(name, target)

Returns:
EntityRelationship object if the given relationship exists form the current entity towards the target entity parameter, false if none exists


getByName(name, target)

Helper function for get.

Name: Type: Description:
name String The name of the type of relationship (ie. decomposes, consumes, connects to) to return
target InnoEntity
The entity with which the current entity has the relation towards.

Returns:
EntityRelationship object if the given relationship exists form the current entity towards the target entity parameter.


remove(relationship)

Function used to remove a relationship from an entity.

Name: Type: Description:
relationship EntityRelationship
The relationship to remove from the entity.

Returns:
True if successful.

entity/EntitySimulation.js


getScript()

Function for getting the script that the entity has

Returns:
True if successful.


setScript(script)

Adds passed script to current entity

Name: Type: Description:
script String
The script to add to the entity

InnoClass.js

getLocalProperties()

Returns a map of the properties for the current class key: property ID: Innoproperty

Returns:
Properties for current class.


getParent()

Get the parent class

Returns:
Returns the parent class object of the current entity’s class if it exists.


getProperties()

Used to return all the properties within a class.

Returns:
Map of the properties that the given class has.


isAbstract()

Used to find if a class is abstract

Returns:
True if the class an abstract class ie: Connection or Location


InnoEntity.js


attributes()

Function used to access the EntityAttributes.js functions


getInnoClassId()

Get the Id of the entity’s class

Returns:
The Id number of the class according to the schema. ie: Action is 1, Input/Output is 14, etc.


getNumber()

Returns:
The entity’s number attribute.


hasChanged()

Used to find out if there has been any change to the entity over the course of the simulation run.

Returns:
True if any properties in the entity have changed over the course of simulation running, false if not.


instanceOf(name)

Name: Type: Description:
name String Name of the class to find if the entity is the type of ie: “Action” or “Input/Output”

Returns:
True if the entity is an instance of given class, false if not.


instanceOfById(id)

Name: Type: Description:
id Integer
ID of the class to find if the entity is the type of

Returns:
True if the entity is an instance of given class, false if not.


labels()

Function used to access all of the EntityLabels.js functions.


relationships()

Function used to access the EntityRelationships.js functions


setInnoClass(name)

Change the schema class of the entity during simulation.

Name: Type: Description:
name String
Name of the class to change to

Returns:
Entity object.


setInnoClassById(id)

Change the schema class of the entity during simulation.

Name: Type: Description:
id Integer
Id of the class to change to

Returns:
Entity object.


setNumber(number)

Change entity’s number during simulation run.

Name: Type: Description:
number Integer
The number to give the current entity.

Returns:
Current entity.


simulation()

Function used to access the EntitySimulation.js functions


InnoObject.js


getCreated()

Get the time the entity was created

Returns:
Time in milliseconds, can be converted to date.


getDescription()

Returns:
Description text of the object.


getId()

Returns:
Id of the entity.


getInnoDB()

Returns:
Id of the entity.


getModified()

Returns:
Modified time in milliseconds, which can be converted to date and time.


setDescription(text)

Name: Type: Description:
text String
Description text for the object.

Returns:
The entity with the new description added.


setName(name)

Name: Type: Description:
name String
Name to give to object

Returns:
The entity with the new name added.


InnoProperty.js


getOrder()

Returns:
The order in which the property appears in its class’s list of properties in the schema.

getType()

Returns:
The order in which the property appears in its class’s list of properties in the schema.

 

To continue learning about Simulators, Click Here.

(Next Article: Asset Utilization Over Time)