Token

Description

A class that represents a Process Flow token.

Properties

activity Gets a reference to the token's current activity.
childRank Gets the rank of the child token.
children Accesses the token's children.
entryTime Gets the model time of when the token entered its current activity.
id Gets the token's unique ID.
instance Gets the token's Process Flow instance.
labelProperties Use your own named properties to get/set label values.
labels Accesses a node's labels as nodes.
name Gets and sets the token's name.
parent Gets the token's parent.
processFlow Gets the token's Process Flow object.
stopCount Gets the number of stops for the token.

Methods

byID Gets the token associated with the id.
release Releases the token from its current activity.
resume Removes a stop from the token.
setColor Sets the color of the token.
setShape Sets the shape of the token.
stop Adds a stop to the token

Constructor

create Creates a token and places it inside the activity for the given owner object (instance).

Static Methods

create Creates a token and places it inside the activity for the given owner object (instance).

Details

Do no remove, this fixes the anchor on doc.flexsim.com

Token.activity

readonly treenode activity

Description

Gets a reference to the token's current activity.

treenode curActivity = token.activity;
Do no remove, this fixes the anchor on doc.flexsim.com

Token.childRank

readonly int childRank

Description

Gets the rank of the child token.

Returns 0 if the token has no parent. int childRank = token.childRank;
Do no remove, this fixes the anchor on doc.flexsim.com

Token.children

readonly children

Description

Accesses the token's children.

Accessing the Number of Children

You can access the number of children on the token with the following code.

token.children.length

Accessing Children by Rank

You can access an individual child token by rank with the following code.


token.children[1] // first child
token.children[token.children.length] // last child
token.children[i] // i-th child
      

Getting an Array of Objects

You can get an Array of all child tokens with the following code.

Array childTokens = token.children.toArray();
Do no remove, this fixes the anchor on doc.flexsim.com

Token.entryTime

readonly double entryTime

Description

Gets the model time of when the token entered its current activity.

double entryTime = token.entryTime;
Do no remove, this fixes the anchor on doc.flexsim.com

Token.id

readonly int id

Description

Gets the token's unique ID.

int id = token.id;
Do no remove, this fixes the anchor on doc.flexsim.com

Token.instance

readonly treenode instance

Description

Gets the token's Process Flow instance.

treenode instance = token.instance;
Do no remove, this fixes the anchor on doc.flexsim.com

Token.labelProperties

Variant labelProperties

Description

Use your own named properties to get/set label values.

Works just like labelProperties on treenodes.

Do no remove, this fixes the anchor on doc.flexsim.com

Token.labels

readonly labels

Description

Accesses a node's labels as nodes.

Works just like labels on treenodes.

Do no remove, this fixes the anchor on doc.flexsim.com

Token.name

string name

Description

Gets and sets the token's name.

string name = token.name;
token.name = "Bottle";
Do no remove, this fixes the anchor on doc.flexsim.com

Token.parent

readonly Token parent

Description

Gets the token's parent.

Token parentToken = token.parent;
Do no remove, this fixes the anchor on doc.flexsim.com

Token.processFlow

readonly treenode processFlow

Description

Gets the token's Process Flow object.

treenode flow = token.processFlow;
Do no remove, this fixes the anchor on doc.flexsim.com

Token.stopCount

readonly int stopCount

Description

Gets the number of stops for the token.

This number increases with calls to the stop method, and decreases with calls to the resume method.

Do no remove, this fixes the anchor on doc.flexsim.com

Token.byID()

Token byID( int id , Variant processFlow = NULL )

Parameters

id The unique id number of the token.
processFlow If no process flow is defined, this will search through every ProcessFlow object in the model. When there are multiple process flow objects you can pass in the process flow object (or name) where the token resides for a faster search.

Description

Gets the token associated with the id.

Token's have their own unique id among all instances of all ProcessFlow objects.

Token token = Token.byID(25);
Token token = Token.byID(4, "ProcessFlow1");
Do no remove, this fixes the anchor on doc.flexsim.com

Token.release()

release( Variant connector )

Parameters

connector If this is a number or a string, it identifies the connector to be released to. If it is an object, it directly references the new activity to "jump" to.

Description

Releases the token from its current activity.

token.release("Failed");
Do no remove, this fixes the anchor on doc.flexsim.com

Token.resume()

resume( )

Description

Removes a stop from the token.

Should only be called on stopped tokens. If this call removes the last stop, the token will re-enter its current activity, and proceed normally. Stops are added through calls to the stop method.
Do no remove, this fixes the anchor on doc.flexsim.com

Token.setColor()

setColor( int red , int green , int blue , int alpha )

Parameters

red The red color component [0 - 255].
green The green color component [0 - 255].
blue The blue color component [0 - 255].
alpha The alpha color component [0 - 255].

Description

Sets the color of the token.

This overrides the Token Colors functionality defined in the visual properties of the process flow object. token.setColor(255, 0, 0);
Do no remove, this fixes the anchor on doc.flexsim.com

Token.setShape()

setShape( int shapeIndex )

Parameters

shapeIndex The index of the shape.

Description

Sets the shape of the token.

This overrides the Token Shapes functionality defined in the visual properties of the process flow object. token.setShape(1);
Do no remove, this fixes the anchor on doc.flexsim.com

Token.stop()

stop( )

Description

Adds a stop to the token

Usually, this method is called when the token is blocked in an activity, such as a Delay. In this case, the token will not leave the activity. The following table describes the effect of stopping the token in various activities, if the token was not previously stopped:
ActivityEffect of stop()
DelayThe token's exit time is postponed.
Push To ListThe token's Push Value is removed from the list.
Pull From ListThe token's back order is removed from the list.
Enter ZoneThe token's request to enter the zone is destroyed.
AcquireThe token's request to acquire the resource is destroyed.
BatchThe token is remove from its batch. If it was the only token in the batch, the batch is destroyed.
Wait for EventThe token's listener for the specified event is destroyed.
Synchronize/JoinThe token is removed from its wave. If it was the only token in the wave, the wave is destroyed.
TravelThe task sequence created by this activity is preempted. This is true for all Task Sequence activities.
If the token is not currently blocked, it will stop as soon as it becomes blocked. The token will not continue until all stops have been removed from the token, through calls to the resume method. Stopped tokens are marked with a red octogon.
Do no remove, this fixes the anchor on doc.flexsim.com

Token Constructor

static create( treenode ownerNode , Variant activity , int start = 1 , Token parent = NULL , int labelAcess = 1 )

Parameters

ownerNode The owner object of the process flow. For a General Process Flow this is the process flow object. For a Fixed Resource, Task Executer or Sub Flow, this is the attached object.
activity This can be the activity node or the name of the activity. If this is the activity node in a General Process Flow, ownerNode may be NULL.
start If start is 1, the default, the token will immediately call the activity's start and begin moving through the process flow. If start is 0, the token will sit in the activity until it is manually released. Calling the release method on the token will fire the activity's finish causing the activity's start to never be called. This may affect how the token responds to the activity it was created in. For example, if a token is created in an Assign Labels activity with a start of 1, the created token will evaluate the Assign Labels as if entering the activity and receive whatever labels are assigned to it. If a token is created in the same Assign Labels with a start of 0 and then later it is released, the token will never evaluate the Assign Labels and no labels will be assigned.
parent If another token is specified here, the new token will be created as a child of this one.
labelAccess This defines what access the child token has to its parent's labels. The possible access types are:
  • TOKEN_LABEL_ACCESS_NONE
  • TOKEN_LABEL_ACCESS_READ
  • TOKEN_LABEL_ACCESS_READ_WRITE
  • TOKEN_LABEL_ACCESS_READ_WRITE_ADD
See the Create Tokens activity for more information about label access types.

Description

Creates a token and places it inside the activity for the given owner object (instance).


Token aToken = Token.create(NULL, getactivity("ProcessFlow", "Start"), 0); //General Process Flow
Token newToken = Token.create(Model.find("Processor1"), "Start", 0, aToken, TOKEN_LABEL_ACCESS_READ);
newToken.Type = 1;
newToken.release(0);
Do no remove, this fixes the anchor on doc.flexsim.com

Token Constructor

static create( treenode ownerNode , Variant activity , int start = 1 , Token parent = NULL , int labelAcess = 1 )

Parameters

ownerNode The owner object of the process flow. For a General Process Flow this is the process flow object. For a Fixed Resource, Task Executer or Sub Flow, this is the attached object.
activity This can be the activity node or the name of the activity. If this is the activity node in a General Process Flow, ownerNode may be NULL.
start If start is 1, the default, the token will immediately call the activity's start and begin moving through the process flow. If start is 0, the token will sit in the activity until it is manually released. Calling the release method on the token will fire the activity's finish causing the activity's start to never be called. This may affect how the token responds to the activity it was created in. For example, if a token is created in an Assign Labels activity with a start of 1, the created token will evaluate the Assign Labels as if entering the activity and receive whatever labels are assigned to it. If a token is created in the same Assign Labels with a start of 0 and then later it is released, the token will never evaluate the Assign Labels and no labels will be assigned.
parent If another token is specified here, the new token will be created as a child of this one.
labelAccess This defines what access the child token has to its parent's labels. The possible access types are:
  • TOKEN_LABEL_ACCESS_NONE
  • TOKEN_LABEL_ACCESS_READ
  • TOKEN_LABEL_ACCESS_READ_WRITE
  • TOKEN_LABEL_ACCESS_READ_WRITE_ADD
See the Create Tokens activity for more information about label access types.

Description

Creates a token and places it inside the activity for the given owner object (instance).


Token aToken = Token.create(NULL, getactivity("ProcessFlow", "Start"), 0); //General Process Flow
Token newToken = Token.create(Model.find("Processor1"), "Start", 0, aToken, TOKEN_LABEL_ACCESS_READ);
newToken.Type = 1;
newToken.release(0);