FlexSim Community Forum

FlexSim Community Forum (https://archive.flexsim.com/index.php)
-   Q&A (https://archive.flexsim.com/forumdisplay.php?f=66)
-   -   How to open/close processor when there is a long queue (https://archive.flexsim.com/showthread.php?t=796)

Lilian_wulp 12-03-2008 01:57 AM

How to open/close processor when there is a long queue
How to open/close processor when there is a long queue.

Two processor available.

Currently, there is one working processor.

When the queue has more than 20 items, the second processor will start operation.

After the queue has been shorten.The second processor will stop its operation.

Jörg Vogel 12-03-2008 02:19 AM

Hi Lilian,

use a if-statement in the Send To function of the Queue.
If the content of the queue is greater than x send to first available. Otherwise send to a specific port. That is not the explicit solution but it gives you a hint.


Lilian_wulp 12-03-2008 02:39 AM

okay, what should i do in the if-statement part. To be more exact what do i have to input in ?

tobias.biemueller 12-03-2008 02:54 AM

You can also find a description of if - statements in the user commands and in the manual ;)

I think he mean something ie.:


int i_returnport = 1;

if ( content(current) > 20)
    i_returnport = 2;

return i_returnport;

Best regards

Steven Hamoen 12-03-2008 07:53 AM

With this solution all the products go to the 2nd machine if the content is larger than 20 and the first machine doesn't get anything anymore. In my opinion it is better to close the input of the 2nd processor and open it when the content is > 20. You could also use the pull rule on the 2nd processor but that slows down your model if your queue gets large.

To close the input of the 2nd machine select on reset to close and open ports. (the standard option already closes input so is fine)

then on entry of the queue if content > 20 openinput of the machine 2:
if( content(current) > 20 ) openinput( outobject( current, 2));

onexit of the queue if content < 20 closeinput again:
if( content(current) < 20 ) closeinput( outobject( current, 2));

the sendto port should simply be first available.


Brandon Peterson 12-03-2008 08:51 AM

Just a little hint: In the on exit of the Queue you would want to check for the content of the Queue being == 21 or <= 21 instead of < 20. The reason for this is that on exit the item is still considered to be in the Queue. So in order to close the input of the Processor at 20 items in the queue (2nd processor only used if content > 20) you would want to close the input if the content of the queue was 21 or lower (as the 21st if the one leaving).

Also, I haven't tested your method yet and I would definitely try this first but I am interested to see what the result will be if the closing item is going to the 2nd processor. This would result in a situation where the item exiting the queue would be closing the input port of the object it was going into. There is a big potential for problems there. So, if problems do come up I would suggest closing the output of the queue and sending a delayed message of 0 time to the queue in the on exit trigger of the queue (only if content(queue) == 21). The message could then open the output ports back up after running the check to see if it needed to close the input port of the 2nd pocessor. This way you don't have any possibility of object code undoing our code. The reason for closing the output here would be to insure that the 20th item doesn't sneak off to the 2nd processor. This would happen if you had the 21st item going to the 1st processor at the same moment in time that the next item (20) would want to exit to go to the 2nd processor.

Good Luck,

All times are GMT -6. The time now is 11:36 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.