Hi Team,
I would like to know on how to provide delay while executing flexscript code.
For example:
1. Check Machine Availability?
2. Delay 5 mins
Repeat 1 & 2
Can you help me with the flexscript code for delay?
Thank you!
Hi Team,
I would like to know on how to provide delay while executing flexscript code.
For example:
1. Check Machine Availability?
2. Delay 5 mins
Repeat 1 & 2
Can you help me with the flexscript code for delay?
Thank you!
Hi @Ankur A3, 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 unaccept and comment back to reopen your question.
Discrete event simulation source code expects an immediate result or a new event. Because you want to delay a source code, then you do this by an event that execute the treenode 5 minutes later again. You can use a delayed message, a user event, a process time.
OR you do this in process flow which naturally supports delays of tokens!
Just a quick note that from version 22.1 you can do this using coroutines where the syntax would be:
await Delay.minutes(5);
...but since the OP is in 21.1 it doesn't apply.
Generally I'd avoid polling and instead detect the availability at the time it becomes available, and (if needed) then wait for the next poll time. This approach fits well with discrete event simulation where you try an model just the events that you need.
Hi Jason,
I do agree with the point on tracking the object until it becomes available but how can it be done while using source code in one of the object triggers.
Can you help me with it?
How can we write the condition to track multiple objects until it becomes available?
For eg:
How can we track the status of machine 1 or 2 using source code?
Thank you!
Hi @Joerg Vogel,
I agree with your point, but I am not able to use this using process flow.
I am using a code under fluid library object where I need to refill the object once its level gets down up to certain limit. Also, I need to first track the availability of other things before start refilling procedure. That's the reason I am thing to delay the code for the time when other equipments become available.
What will you prefer to use for delay in this case?
Thank you!
You can still use Process Flow, by creating a token by code. The relevant methods can be seen for example when selecting to use a SubFlow in a fixed resource's transporter field.
To do everything in code you could
- write the time an equipment will be available again to a label on it, then use one of the methods described by Jason and Jörg to re-run the code at that time (of course only possible if the time when the objects becomes available can be known beforehand, so it might be difficult in a model with constand flow)
- build the logic "in reverse". Have the relevant equipment send a message to the tank whenever it becomes available. The passing mark code would set a label on the tank if the equipment is not available at that time, which then causes it to evaluate the refill code when it next receive a message.
@Ankur A3, you can call from any source code editor from within source code a process flow by command. But you are not allowed to delay a process flow token advance progress.
You can think of reevaluating this source code trigger by run cycle event controlled in process flow. This flow object trigger checks only all necessary conditions.
20 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved