is there a "delay" command?

is there a "delay" command?

enrique.elizaga
Advocate Advocate
20 Views
6 Replies
Message 1 of 7

is there a "delay" command?

enrique.elizaga
Advocate
Advocate

[ FlexSim 17.2.2 ]

Hi guys. Is there a delay command like "delay(minutes(2),STATE_PROCESSING)" and why not? Not in process flow, just hard code.

It would be very convenient.

0 Likes
Accepted solutions (1)
21 Views
6 Replies
Replies (6)
Message 2 of 7

joerg_vogel_HsH
Mentor
Mentor

There is only a couple of commands. stopobject - resumeobject. An object that a stopobject command is called on is dead. The object isn't able to receive messages or send messages. The resumeobject command must be called by another active object. The delay time is event driven by a message, an user event or any other trigger.

Message 3 of 7

joerg_vogel_HsH
Mentor
Mentor

If you think a delay command is needed in Flexsim, then you shouldn't ask a question why it isn't. Much better is it to post an idea. The users can vote and support the idea.

0 Likes
Message 4 of 7

fstmodule_talumis
Not applicable
Accepted solution

@Enrique Elizaga Until now we have never had the need for such a command. So could you explain exactly what you want to use it for? Then we probably can give you an answer on how you can do it.

For now check out the stopobject() or the senddelayedmessage() commands. They give you probably all the functionality you are looking for.

Message 5 of 7

enrique.elizaga
Advocate
Advocate

@FSTModule Talumis I acknowledge this, I always use the senddelayed message, yet this implies a certain complexity if you have local variables or pointers. You have to store them inside a label, table or global variable not to lose them when for later use. The msgparam(1 to 3) does not allow pointers, arrays or bundles. Please comment.

0 Likes
Message 6 of 7

philboboADSK
Autodesk
Autodesk

FlexScript compiles to machine code, which is executed by the CPU one instruction at a time. When it is done executing one line, it moves onto the next line.

FlexScript code executes immediately. It is not a logic builder that runs in simulation time using discrete events being processed within the simulation timeline like ProcessFlow activities. You can't arbitrarily delay the code execution in the middle of the code based on simulation time.

If you want to write logic that delays, you should use Process Flow or senddelayedmessage().



Phil BoBo
Sr. Manager, Software Development
Message 7 of 7

joerg_vogel_HsH
Mentor
Mentor

You can convert a pointer to a number and put the number in a message. OnMessage you convert the number back to a node.

Local variables should be in a local scope. If you need them in another scope, you have to make them global. Maybe it isn't a modern method accessing local variables. Then you are able to write directly c++ code, but you are forced to compile your model.

But in my opinion, this is a totally different question then just delaying the execution of an object process and seting a state.

0 Likes