how to create independent tokens using code?

how to create independent tokens using code?

pinakin_k
Not applicable
65 Views
5 Replies
Message 1 of 6

how to create independent tokens using code?

pinakin_k
Not applicable

[ FlexSim 19.0.2 ]

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.

0 Likes
Accepted solutions (1)
66 Views
5 Replies
Replies (5)
Message 2 of 6

JordanLJohnson
Autodesk
Autodesk
Accepted solution

You can use the the Token.create method.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 3 of 6

tanner_p
Not applicable

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.

18837-create-token-code.png

Thanks!

create-token-code.fsm

Message 4 of 6

pinakin_k
Not applicable

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
Message 5 of 6

tanner_p
Not applicable

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.

Message 6 of 6

pinakin_k
Not applicable

Thank You! it works.

0 Likes