question

Patrick Crowley avatar image
0 Likes"
Patrick Crowley asked Matthew Gillespie commented

Using gettokens to preempt all tokens from all process flows

Hello,

I am attempting to select all tokens in all process flows using the gettokens command, so that particular ones can be selected and preempted. The problem that I am having is that general process flows and task executor process flows require different inputs in the gettokens command to work.

Any help would be appreciated, thank you.

According to the user manual, the following should work:

// definition: gettokens (obj instanceObject, obj activityOrAsset[, num flags])


Array theseTokens = gettokens(NULL, NULL);

// passing NULL into the first argument should select all process flow instances,
// and passing NULL into the second argument should select all tokens for each
// instance

// This however returns no tokens in the array....
FlexSim 19.1.1
process flowtokenspreemptiongettokens
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

·
Matthew Gillespie avatar image
2 Likes"
Matthew Gillespie answered Matthew Gillespie commented

Yeah, the documentation is worded poorly. It doesn't say this, but you can't pass NULL in for both parameters. It's only describing what happens when you pass NULL into one of the parameters at a time.

You could loop over all activities in the model and pass NULL into the first parameter like this:

treenode flows = Model.find("Tools/ProcessFlow");
Array tokens = [];

for(int i = 1; i <= flows.subnodes.length; i++) {
	treenode flow = flows.subnodes[i];
	for(int j = 1; j <= flow.subnodes.length; j++) {
		treenode activity = flow.subnodes[j];
		tokens.append(gettokens(NULL, activity));
	}
}

return tokens;
· 2
5 |100000

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

Patrick Crowley avatar image Patrick Crowley commented ·

@Matthew Gillespie,

Thanks for the reply, that worked like a charm. As a followup question, is there anything preventing tokens from being preempted across multiple process flows? The tokens in the process flow where that code is located are pulled, but the tokens in the task executor process flows I have throw an "invalid destination" error during the "release token" activity.

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Patrick Crowley commented ·

You can't move tokens between process flows. The closest thing is using a Create Tokens or Run Subflow activity to have one token create another token in a different flow.

0 Likes 0 ·

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.