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 10-31-2007
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 104
Downloads: 100
Uploads: 1
Thanks: 103
Thanked 52 Times in 37 Posts
Rep Power: 232
Pablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nice
Default stopping the MultiProcessor

Hi,

-i wanted to use the multiprocessor to represent a service box of a medical facility, so i can have different process/operators for different patients. One of the things that i have to do is stop the multiprocessor when a patient is waiting for an exam result and resume operation when the exam is ready. The thing is, i cant stop the multiprocessor using stopobject function through a message on the process finish, i'm not sure if i'm doing something wrong.

-i did a small example model of the problem in wich i send a message from the multiprocessor to a queue and on that message stop the multiprocessor. if i sent it as an instant message i get a weird behavior of the multiprocessor, but if i send it delayed it works as i first though it should work, just wanted to know why the different results...

-the top multiprocessor is sending the message instantly, and the bottom one is sending a delayed message 0.01 time units later..i was resumming operation through the script windows (var1 for the top multiprocessor, var2 for the bottom one)


thanks in advance

Pablo Concha E.
Attached Files
File Type: zip test_er_box.zip (51.2 KB, 353 views)
  #2  
Old 10-31-2007
Brenton King's Avatar
Brenton King Brenton King is offline
Flexsim Technical Support
 
Join Date: Jul 2007
Posts: 44
Downloads: 60
Uploads: 5
Thanks: 10
Thanked 41 Times in 15 Posts
Rep Power: 271
Brenton King is a name known to allBrenton King is a name known to allBrenton King is a name known to allBrenton King is a name known to allBrenton King is a name known to allBrenton King is a name known to all
Default

Pablo,
Your example illustrates the difference between the senddelayedmessage command and the sendmessage command. The pick option you used contains an 'if' statement that decides whether to use the senddelayedmessage command (if delay time is positive or 0) or a sendmessage command (when a -1 or any negative number is passed in as the delay time). The difference between these two commands is that a sendmessage command is sent out right at that instance in your code; it won't have any knowledge of the code that is to be executed after it. Whereas a senddelayedmessage command is sent after all the code and related events have taken place. Hope this helps. There is a difference between sending at -1 and sending at 0.

Last edited by Cliff King; 10-31-2007 at 07:49 PM.
  #3  
Old 10-31-2007
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 104
Downloads: 100
Uploads: 1
Thanks: 103
Thanked 52 Times in 37 Posts
Rep Power: 232
Pablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nice
Default

Brenton,
Thanks for the explanation, i had not realized the difference between the commands,

regards,

Pablo Concha E.
  #4  
Old 10-31-2007
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

This is interesting. I never realized that there is a -1 parameter value for senddelayedmessage() and there is a difference between sendmessage() and senddelaymessge() with 0 as the delayed time. This should be documented better in the Flexsim command help. Wierd problems may occur if you are not aware of the difference.

Last edited by Cliff King; 10-31-2007 at 07:50 PM.
  #5  
Old 10-31-2007
Cliff King's Avatar
Cliff King Cliff King is offline
Vice President Technical Services
 
Join Date: Jul 2007
Location: Utah
Posts: 272
Downloads: 158
Uploads: 14
Thanks: 102
Thanked 304 Times in 110 Posts
Rep Power: 412
Cliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud of
Default Difference between sendmessage() and senddelayedmessage()

Alan you are right that there is weak command documentation for the differences between using a senddelayedmessage() with a delaytime of 0 and using the sendmessage() command, so let me try to explain things a little further...


First of all, there is no -1 parameter for the senddelayedmessage(). The -1 is a value you can pass into one of the picklist options for a trigger field to invoke something special - let me explain.


It's important to note that there are two commands avalaible in Flexsim for sending messages: sendmessage() and senddelayedmessage(). The first command sends a message immediately so it is more like calling a subroutine. The second command creates an event to send a message at a later time. If the "later time" is 0 seconds, then it will send the message at the same simulation time as now, but the message won't be sent until all pending events associated with the current simulation time have finished.

Now, if you look at the code for the picklist option named "Send Message" that is found in a lot of the trigger fields, you will see that in order to accomodate both types of messaging schemes using a single picklist option, we use a conditional statement that simply says if the number typed into the picklist template for the "Delay Time: " is a number less than 0, then call the sendmessage() command as opposed to the senddelayedmessage() command.

I'm afraid we've introduced some confusion by trying to put two entirely different commands into a single picklist option. Because of this confusion, I rarely use the Send Message picklist option, and usually choose to just type in either the sendmessage or senddelayedmessage command depending on which one I want to use!

Let me throw out one more bit of information that's related to this. If you're building your own task sequences and you want to use the TASKTYPE_SENDMESSAGE, you will run into similar confusion. Once again the confusion comes due to the fact that we only have one task type for sending messages, and yet we wanted to give the user the ability to send an immediate message or create an event to send a delayed message. To accomplish this, we use var4 of the inserttask command. By default a message will be sent immediately if var4 is not specified or is 0. If var4 is a -1 a delayed message will be sent in 0 time, and if var4 is a value greater than 0, a delayed message will be sent in that many time units. As you can see, this is opposite from the way the "Send Message" picklist option was set up. I think we will redesign the picklist option in a future release in order to avoid mistakes.

Now to really screw with you, I need to warn you that there is currently a bug in v4.01 that keeps var4 of the inserttask command from even being passed properly in flexscript (it works fine in C++ however). This will be fixed in the next release.

Last edited by Cliff King; 11-13-2007 at 07:27 PM. Reason: Corrected the explanation



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.