ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 05-23-2008
qin tian qin tian is offline
Flexsim User
 
Join Date: Dec 2007
Location: Shanghai, China
Posts: 137
Downloads: 115
Uploads: 0
Thanks: 59
Thanked 3 Times in 3 Posts
Rep Power: 161
qin tian is on a distinguished road
Default TE and TS learning?

TE and TS is great in flexsim, but hard to learn for me. I want to learn more about it.

In the mannual, in the TASKTYPE_SENDMESSAGE section, it says:

You might think that delayed message sending is a bit redundant, because if you want to send a delayed message, why not insert a delay task followed by a regular send message task. There is a subtle difference. Say, for example, you want the TaskExecuter to wait until a certain number of requirements are met, and the only way you can check those requirements is by executing code. The way that you would do this is, when the TaskExecuter gets to the point where he needs to wait for the requirements to be met, he sends a message to some object, and then either does a utilize task, or a stop request begin task. When the other object gets the message, he is responsible for checking if the requirements are met. If they are already met, then he is to immediately call resumeobject() or freeoperators() on the TaskExecuter. Otherwise he must wait until the requirements are met, and then call resumeobject() or freeoperators(). A problem arises, however, when the requirements are already met and he can immediately allow the TaskExecuter to continue. If the message has been sent immediately, then the TaskExecuter hasn't started the utilize of stoprequestbegin task yet. He is still working on the send message task. So the other object can't immediately call freeoperators() or resumeobject() because he must wait until the TaskExecuter finishes the send message task, and goes on to the utilize or stop request begin. Sending a delayed message in 0 time allows the TaskExecuter to do exactly that, and thus allow the other object to immediately free him if the requirements are met.

I hope someone to provide a model example to help those like me to understand the above description.

Thanks
  #2  
Old 05-27-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Qin Tian,

Your question has more to do with messages than it does with task sequences. The section that you quoted from is for the 4th variable for TASKTYPE_SENDMESSAGE. What this is saying is that all messages by default will be sent as normal messages with no delay. If you want a delayed message then you need to enter a value for the delay or a -1 for a delay of 0.

Normally it is fine to send a message with no delay (beneficial even). However, if there is code that needs to be executed after the send message function call but before the message gets recieved then you need to use a delayed message with a delay time of zero. This ensures that the message happens as a seperate event at the same simulation time instead of happening as part of the current event.

I hope that this has answered your question. If you have more questions or need more detail let us know.

Brandon
__________________
thats not normal.
The Following User Says Thank You to Brandon Peterson For This Useful Post:
qin tian (06-01-2008)
  #3  
Old 06-01-2008
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
 
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 225
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default

Qian Tian,

Your question is better understood with an example. As Brandon pointed out, the question is more about the difference between sendmessage and senddelayedmessage with 0 delay time.

I made a simple example to illustrate the difference. To understand the difference, you have to think about the way that the discrete event simulation works.
  • The sendmessage is as you insert a piece of code (whatever the code in the message will do) which will be executed immediately after you call it.
  • However, the senddelayedmessage with 0 delay time is to insert an event with current simulation time in the simulation event list. So the code in the message trigger will be executed later after all the rest of the code in the function/command called the senddelayedmessage is executed and after the Flexsim finished some extra work such as updating statistics.
In the attached model, you can check the code in OnMessage and OnExit trigger of the Source1 object. In the OnExit trigger, I called sendmessage and senddelayedmessage based on that the current output of the Source1 is odd number or even number. And in the OnMessage trigger, I simply output some messages. As you can see after run the model, in the sendmessage case, the output of the Source1 is not updated (pay attention to the current output in the message box) yet and the print in the OnExit trigger is executed after you click the OK in the MSG_SENDMESSAGE message box). However in the senddelayedmessage case, the output of the Source1 is updated before the MSG_SENDMDELAYEDMESSAGE message box shows, and the print is executed before you click the OK in the MSG_SENDDELAYEDMESSAGE message box.

I have to say that the difference of the two is very subtle. And to figure out when to use which is even more subtle. But I guess the example illustrate the main difference of the two. And it is up to you to choose the right one according to the different circumstance.
Attached Files
File Type: zip sendmessage & senddelayedmessage.zip (40.0 KB, 289 views)
__________________
Best,
Alan
The Following User Says Thank You to AlanZhang For This Useful Post:
qin tian (06-01-2008)
  #4  
Old 06-01-2008
qin tian qin tian is offline
Flexsim User
 
Join Date: Dec 2007
Location: Shanghai, China
Posts: 137
Downloads: 115
Uploads: 0
Thanks: 59
Thanked 3 Times in 3 Posts
Rep Power: 161
qin tian is on a distinguished road
Default

Thanks very much.
But what is the difference between send delayed message with 0 and with -1 .
  #5  
Old 06-02-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Qin Tian,

When you send a delayed message with the senddelayedmessage command you should use a 0 to denote that you want the message to happen in zero time. In contrast when you send a message using a task sequence you need to use a -1 to denote that you want the message to happen as a seperate event but in zero simulation time, this would be the same as saying senddelayedmessage with a 0. If you use a 0 in the sendmessage task sequence the message will occur immediately and not as a seperate event, this is the equivelant of using the sendmessage command.

Brandon
__________________
thats not normal.
The Following 4 Users Say Thank You to Brandon Peterson For This Useful Post:
Tom David (06-02-2008)
  #6  
Old 08-07-2008
Yasemin Vatandas's Avatar
Yasemin Vatandas Yasemin Vatandas is offline
Flexsim User
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 36
Downloads: 9
Uploads: 0
Thanks: 29
Thanked 3 Times in 3 Posts
Rep Power: 146
Yasemin Vatandas is on a distinguished road
Question sendmessage- 'fromobject' parameter

Hello,

I would like to use a "sendmessage" command in my user-event, but do not want to reference an object which sends the message, because the message doesn't depend on a condition fulfilled by another object, i.e. the message is not occurence-based but time-based.

Is it possible to leave out the 'fromobject' parameter in that command?
If not, how can I send a message to an object after other sequences of commands in a user-event are completed?

Thanks.
  #7  
Old 08-07-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Yasemin,

The oject put in the from object field is referenced by the msgsendingobject variable in the message trigger, it's not used for anything else. So, you can put a pointer to any object or node in that field that you would want to have a reference to in the message trigger. If you absolutely want the field to be blank then you can always use NULL.

Good Luck,
Brandon
__________________
thats not normal.
The Following 2 Users Say Thank You to Brandon Peterson For This Useful Post:
Yasemin Vatandas (08-07-2008)



All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.