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:

  1. // definition: gettokens (obj instanceObject, obj activityOrAsset[, num flags])
  2.  
  3.  
  4. Array theseTokens = gettokens(NULL, NULL);
  5.  
  6. // passing NULL into the first argument should select all process flow instances,
  7. // and passing NULL into the second argument should select all tokens for each
  8. // instance
  9.  
  10. // 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:

  1. treenode flows = Model.find("Tools/ProcessFlow");
  2. Array tokens = [];
  3.  
  4. for(int i = 1; i <= flows.subnodes.length; i++) {
  5. treenode flow = flows.subnodes[i];
  6. for(int j = 1; j <= flow.subnodes.length; j++) {
  7. treenode activity = flow.subnodes[j];
  8. tokens.append(gettokens(NULL, activity));
  9. }
  10. }
  11.  
  12. 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.