question

IEThai avatar image
0 Likes"
IEThai asked Logan Gold commented

How to use Custom Code: Stop Token

If I set the token to stop and want to continue, what methods can I use?

Process 1 will continuously loop, while Process 2 will generate a token that will stop the work in Process 1 and run Process 2 one token at a time until it completes. After that, Process 1 will continue its work.1730432600705.png1.fsm

FlexSim 24.2.0
proces flowtokencustomcode
1730432600705.png (52.4 KiB)
1.fsm (35.9 KiB)
· 1
5 |100000

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

Logan Gold avatar image Logan Gold ♦♦ commented ·

Hi @IEThai, was Joerg Vogel's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·

1 Answer

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel edited

Preemption

https://docs.flexsim.com/en/24.2/Reference/ProcessFlowObjects/Preemption/SaveTokenContext/SaveTokenContext.html

Edit:

https://docs.flexsim.com/en/24.2/Reference/CodingInFlexSim/FlexScriptAPIReference/ProcessFlow/Token.html#Method-stop

Token.stop() is a direct method to set a referenced token to stay in its activity.

Token.resume() remove last stop call. If there aren’t any other stops pending, the token does its current activity again.
https://docs.flexsim.com/en/24.2/Reference/CodingInFlexSim/FlexScriptAPIReference/ProcessFlow/Token.html#Method-resume

Untested: If a token behaves similar to an item, then you can call stops more often on it. Then you need to recall resume as often as you have called stop on it.

You can access a token by command gettoken, if there aren’t any lokal variables declared. Other command gettokens or Token class method byID.

5 |100000

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