question

Kari Payton avatar image
0 Likes"
Kari Payton asked Matt Long edited

Can preemption stop all tokens in a process flow?

On the preemption label is there a way to reference all tokens in the process flow? Or is there another way to stop all tokens when an event occurs? I could use zones but I have +15 sources that go through 8 different zones so I was trying to stop all the tokens at once.

FlexSim 17.0.3
preemption
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Matt Long avatar image
1 Like"
Matt Long answered Matt Long edited

There isn't currently a pick option to do this (though perhaps there should be), but here is the code (modified from the Tokens in Activity pick option):

Array tokens = gettokens(current, NULL); //Get all of the tokens in the process flow

Array newArray;
for (int i = 1; i <= tokens.length; i++) {
	Token otherToken = tokens[i];
	if (/** \nCondition: *//**/otherToken != token/**/)
		newArray.push(otherToken);		
}	
return newArray;

The condition makes sure that the token doing the preempting is not added to the array (as preempting himself would be very bad).

· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Kari Payton avatar image Kari Payton commented ·

@Matt Long is there also a way to get all of the tokens except tokens in a specific activity. Basically in our operations when we are "flying a blade" from one area to another, everything in operations has to stop until the blade is done flying. The issue I'm running into is all of the tokens reroute to the preemption including the one that is "flying a blade".

I tried a decision block where token.savePoint == "/Tools/ProcessFlow/ProcessFlow/Fly Blade Pull from Working Crane Control List" but that doesn't work.

0 Likes 0 ·
Matt Long avatar image Matt Long Kari Payton commented ·

To restrict a certain activity you could just add the following to the beginning:

treenode activity = getactivity(processFlow, "Activity Name");

Then inside the for loop:

if (otherToken != token && token.activity != activity)
0 Likes 0 ·
Kari Payton avatar image Kari Payton Matt Long commented ·
@Matt Long

I added the code but I got an error that saud "activity" was already being used. I then changed activity to flyBlade, so not to duplicate, but get the error that the label flyBlade is not on token. I tried to add the label to the token in the specific activity in the process flow but still getting the same error.

Object current = param(1);
treenode activity = param(2);
Token token = param(3);
Variant assignTo = param(4);
string labelName = param(5);
treenode processFlow = ownerobject(activity);
/***popup:TokensInObject:classType=Activity*/
/***tag:desc*//**Tokens in Activity*/
string name = /** \nActivity Named: *//***tag:name*//**/"Activity"/**/;
int flags = /** \nFlags: *//***tag:flags*//**/0/**list:GET_TOKENS_REQUESTS~0*/;
treenode flyBlade = getactivity(processFlow, "Fly Blade");


Array tokens = gettokens(current, NULL); //Get all of the tokens in the process flow


Array newArray;
for (int i = 1; i <= tokens.length; i++) {
	Token otherToken = tokens[i];
	if (/** \nCondition: *//**/otherToken != token && token.flyBlade != flyBlade/**/)
		newArray.push(otherToken);		
}	
return newArray;
0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.