question

Pinakin K avatar image
0 Likes"
Pinakin K asked Pinakin K commented

how to create independent tokens using code?

I want to create independent tokens (not child tokens) using custom code.

I am aware of the process flow activity "Create Tokens". but in this case have to use code to create independent tokens. Also when the independent tokens are created, the labels that were on the token that created it are needed to be on the created tokens.

FlexSim 19.0.2
create tokens
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

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Pinakin K commented

You can use the the Token.create method.

· 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.

tannerp avatar image tannerp commented ·

Hi @Pinakin K,

Please review the following example model for how to accomplish this. You can use the create command to create a token in a designated Process Flow activity. Then, once the new token is created, you can assign labels based on the old token.

The example below creates a token in the Process Flow activity called "Delay" and then copies the label "myLabel" from the old token to "transferLabel" on the new token. The values for tokens 1 and 2 are, respectively, 5 and 10.

I'm assuming this is what you're looking for, but there's a lot of variations of this. If you're looking for something more specific, you might consider posting a sample model to help us meet your need better.

Thanks!

create-token-code.fsm

1 Like 1 ·
Pinakin K avatar image Pinakin K tannerp commented ·

Thanks for your response. But the token does not move forward in your "Delay". I added a sink to in and the 2 tokens created are stuck in Delay activity.

I faced the same Problem. How would you solve it?

0 Likes 0 ·
tannerp avatar image tannerp Pinakin K commented ·

If you read the manual that Jordan referred to, you'll see that you can add the following line of code after the label assignment to allow for release:

newToken.release(0);

There are more parameters available for adjustment as well; I just gave a simple example.

1 Like 1 ·
Show more comments