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 > Flexsim Student Forum
Downloads

Flexsim Student Forum Forum for discussion for Flexsim Students using the Flexsim Textbook.

  #1  
Old 05-05-2015
hendry teo
Guest
 
Posts: n/a
Downloads: 41
Uploads: 0
Default Send message from a queue when it is empty

Hi all,

When a batch of 25 comes into a queue, an operator will carry the items one by one to a sink. What I would like to do is when the queue has reached 0 content, it will send a message to the other object in the model. But how?

I know that OnExit trigger cannot be used because when every time an item is moved out of the queue, it will trigger the function.

So, can someone please help?

Thank you

Hendry
  #2  
Old 05-05-2015
RalfGruber's Avatar
RalfGruber RalfGruber is offline
FlexSim Software Products
 
Join Date: Jul 2007
Location: Orem, UT, USA
Posts: 195
Downloads: 37
Uploads: 0
Thanks: 518
Thanked 294 Times in 124 Posts
Rep Power: 345
RalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to behold
Default

Hendry,

you will have to check the content of the Queue in a condition for sending the message:

if (content(current) == 1)
senddelayedmessage(receiving object, delay, current, 1);

Notice, that you will have to check the content against "1" instead of "0", because that will fire when the last item exits the Queue.

Good Luck

Ralf
FlexSim
The Following 2 Users Say Thank You to RalfGruber For This Useful Post:
sravan kumar (05-06-2015)
  #3  
Old 05-05-2015
hendry teo
Guest
 
Posts: n/a
Downloads: 41
Uploads: 0
Default senddelayedmessage?

Hi Ralf,

Thank for your reply!

Your coding is pretty easy to understand and it works!!!!!

For my knowledge, but may I know why we use senddelayedmessage instead of sendmessage. If I put the delay time is 0, would these two terms become the same?

Thank you!!

Hendry
  #4  
Old 05-05-2015
RalfGruber's Avatar
RalfGruber RalfGruber is offline
FlexSim Software Products
 
Join Date: Jul 2007
Location: Orem, UT, USA
Posts: 195
Downloads: 37
Uploads: 0
Thanks: 518
Thanked 294 Times in 124 Posts
Rep Power: 345
RalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to behold
Default

Hendry,

there is a very extensive examination of the differences in the user manual.
Please look it up in there for further explanation. The short answer is:

Sendmessage() is executed immediately when called and jumps back into the code of the calling function after execution, while senddelayedmessage() with a delay of zero time adds an event to the event list in zero time.
This means code following the senddelayedmessage() command will be executed before the message is sent.

Good Luck

Ralf
FlexSim
The Following 4 Users Say Thank You to RalfGruber For This Useful Post:
syseo (05-10-2015)
  #5  
Old 05-09-2015
hendry teo
Guest
 
Posts: n/a
Downloads: 41
Uploads: 0
Default how do I send delay message to multiple receiving object?

Hi Ralf

Can you please teach me on how to send a message to multiple objects at the same time when the content of my queue reaches 0? I tried using "&&" to send message to two objects. e.g.

if (content(current) == 1)
senddelayedmessage(object1&&object2, delay, current, 1);

Well, it is not working..
Really many thanks to you if you can guide me again!

Hendry
  #6  
Old 05-09-2015
RalfGruber's Avatar
RalfGruber RalfGruber is offline
FlexSim Software Products
 
Join Date: Jul 2007
Location: Orem, UT, USA
Posts: 195
Downloads: 37
Uploads: 0
Thanks: 518
Thanked 294 Times in 124 Posts
Rep Power: 345
RalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to behold
Default

if (content(current) == 1)
{
senddelayedmessage(object1, delay, current, 1);
senddelayedmessage(object2, delay, current, 1);
}

There is a help section "Writing Logic in FlexSim" in the User Manual under "Help" which I strongly recommend for you to read.

Good Luck

Ralf
FlexSim
The Following User Says Thank You to RalfGruber For This Useful Post:
hendry teo (05-09-2015)
  #7  
Old 05-09-2015
sagar bolisetti's Avatar
sagar bolisetti sagar bolisetti is offline
Flexsim User
 
Join Date: Aug 2013
Location: Hyderabad,India
Posts: 160
Downloads: 145
Uploads: 0
Thanks: 124
Thanked 99 Times in 63 Posts
Rep Power: 150
sagar bolisetti is a jewel in the roughsagar bolisetti is a jewel in the roughsagar bolisetti is a jewel in the roughsagar bolisetti is a jewel in the rough
Default

Hi Hendry,

Another way to send messages to multiple objects is by looping through all the queue's connected to object's outputs(Source).In this example source feeds two queues and i close input on reset on each queue .If the content of any queue reaches empty i fill up the queue by opening its input port and again closing input on message.I put this code on creation trigger.
Code:
 /**Custom Code*/
  treenodeitem = parnode(1);
  treenodecurrent = ownerobject(c);
  int rownumber = parval(2);  //row number of the schedule/sequence table
//loop through all the queue's connected to object's outputs
  for (int i=1; i<=nrop(current); i++) {
         treenode queue = outobject(current, i);
  //if the queue is empty...
         if (!content(queue)) {
  //open the queue's inputs
  openinput(queue);
  //and send a delayed message that will close the queue's inputs again
  senddelayedmessage(queue,1,current);
         }
  }

Last edited by sagar bolisetti; 05-09-2015 at 12:13 PM.
The Following User Says Thank You to sagar bolisetti For This Useful Post:
hendry teo (05-09-2015)
  #8  
Old 05-09-2015
hendry teo
Guest
 
Posts: n/a
Downloads: 41
Uploads: 0
Default

Hi Ralf and Sagar,

Really many thanks to both of you for the detailed steps and useful information. It does help improving my model. Thank you so much!

Hendry


Thread Thread Starter Forum Replies Last Post
How to send transporter to queue Shahin Gelareh Q&A 1 04-25-2012 02:10 AM
Script windows empty if MTBR tablename contains only digits Jens Mühlheimer Gripes and Goodies 2 03-27-2012 11:31 PM
Empty level in rack Manoj Kumar Q&A 3 02-01-2012 05:27 AM
Empty & Idle Warehouse at the end of the day Labro Eleni Q&A 3 08-08-2011 04:08 AM
IDLE and EMPTY Lydia Franck Q&A 2 08-05-2010 03:03 AM


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.