question

Enrique Elizaga avatar image
0 Likes"
Enrique Elizaga asked Joerg Vogel edited

is there a "delay" command?

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.

FlexSim 17.2.2
codedelaycomand
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·

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 0 ·
FSTModule Talumis avatar image
3 Likes"
FSTModule Talumis answered Joerg Vogel edited

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

· 3
5 |100000

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

Enrique Elizaga avatar image Enrique Elizaga commented ·

@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 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Enrique Elizaga commented ·

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().

2 Likes 2 ·
Joerg Vogel avatar image Joerg Vogel Enrique Elizaga commented ·

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 0 ·
Joerg Vogel avatar image
1 Like"
Joerg Vogel answered

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.

5 |100000

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