Control the queue openoutput order, and openoutput one by one

Control the queue openoutput order, and openoutput one by one

joe_l6
Not applicable
315 Views
20 Replies
Message 1 of 21

Control the queue openoutput order, and openoutput one by one

joe_l6
Not applicable

[ FlexSim 16.1.2 ]

Now I have a globaltable called 'Order' and a model as the following picture, I focus on Queue1, Queue2, Queue3.

machine-order.pngmodel.png

I hope that when the model starts simulating, Queue1, Queue2, Queue3 were 'Closeoutput'. And I can determine the order of 'Openoutput' of Queue1, Queue2, and Queue3 based on the values in the Order table. And only one queue is allowed to openoutput at a time.

For example, the values in the order table are as shown in the upper picture, left to right were 1, 2, 3. So the order of 'Openoutput' of Queue1, Queue2, and Queue3 were:

Queue1 Openoutput

\/

Queue1 Closeoutput

\/

Queue2 Openoutput

\/

Queue2 Closeoutput

\/

Queue3 Openoutput

\/

Queue3 Closeoutput

After Queue3 Closeoutput, it goes back to Queue1 Openoutput again, and this process repeats until the simulation ends.

In addition, I also hope that when a Queue is Openoutput, it can remain open until all the items in the Queue are shipped before Closeoutput.

The scenario I described above is that I hope to simulate the operation of one machine at a time, and be able to control the order of machine operations based on the table.

May I know if it is possible to achieve the scenario described above? Thank you!Queue Openoutput Order.fsm

0 Likes
Accepted solutions (1)
316 Views
20 Replies
Replies (20)
Message 2 of 21

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

Trigger Tab of queue: On Exit: Picklist option close output > condition current subnodes.length == 1: involved object current

Same object picklist option open input > same condition: involved object next to open input by source code snippet or sampler tool.

Message 3 of 21

moehlmann_fe
Advocate
Advocate

You could also do this with a simple Process Flow that opens a queue's output, waits until it is empty, closes the output and then moves on to the next queue based on the table.

1677484243714.png

queue-openoutput-order-fm.fsm

Message 4 of 21

joe_l6
Not applicable

Hi @Felix Möhlmann ,

Thank you for your solution. It seems that I encountered an error while downloading the model file. I'm not sure if it's because the file upload failed on your end. Could you please upload the model file again? Thank you!error.png

0 Likes
Message 5 of 21

moehlmann_fe
Advocate
Advocate

Sorry, the forum sometimes loses attachments when editing a post.

queue-openoutput-order-fm.fsm

Message 6 of 21

joe_l6
Not applicable

Thank you @Felix Möhlmann.

order.pngpf.png

I'm trying to change the numerical order of the Order table to 3, 2, 1. And when setting the queue label for Token, it will read the values inside the table. Finally, make the Source generate the second round of items at 260 seconds.

I found that the first round runs smoothly.(items are sent out from Queue3 to Queue1 in order.) But when it comes to the second round, items will be sent out starting from Queue2 instead. Is it caused by my incomplete settings as mentioned above? Thank you!queue-openoutput-order-v2.fsm

0 Likes
Message 7 of 21

moehlmann_fe
Advocate
Advocate

What happens is that the first item that enters Queue3 exits immediately before other items get created, triggering the token to continue and switch the output.

You can place an extra activity in the process flow that checks whether the queue is actually empty after a 0s delay to fix this case.

1677569872851.png

Message 8 of 21

joe_l6
Not applicable
Thanks @Felix Möhlmann ,

I'll give it a try. Thank you!

0 Likes
Message 9 of 21

joe_l6
Not applicable

Hi @Felix Möhlmann ,

Now I have the following scenario. model.pngtable.png

Use the "Order" table to determine the order of the machine, and use the 'BoxType_Process_Stage' table to determine the route of the Box.

[Determine the order of the machine]

Using the "Order" table.

[Determine the route of the Box]

'BoxType_Process_Stage' table will record the Stage of BoxType at each Process. Wherein, the numerical values 1~4 of the Stage correspond to Queue1~Queue4, respectively.

When a Box is produced from the Source, it will have two types of labels: BoxType and Process.

"Queue" will use the two types of labels, BoxType and Process, on the Box, combined with the table "BoxType_Process_Stage" to generate the Stage value.

When the operation of the three Processors is completed, the value of the label "Process" on the Box will be incremented by 1, and then the Box will be sent back to the Queue.

Therefore, when the Source or Processor sends the Box back to the Queue, the Queue calculates a new value for the label "Stage", and each Queue pulls the Box according to the corresponding Stage value.

[Discovered a problem]

The Box is stuck in Queue2 after the Processor completes its operation, but Queue2 is not enabled for output.

How should I set it up to execute the above scenario smoothly? Thank you!box route and machine order.fsm

0 Likes
Message 10 of 21

moehlmann_fe
Advocate
Advocate

As the item exits immediately upon opening the output, the Wait for Event activitiy is never triggered, because the queue is already empty when the token reaches it.

You could implement a second case. If the queue is not empty when the output is about to be opened you skip the Wait for Event and only go back to if the queue is not yet empty.

1678086590253.png

Message 11 of 21

jason_lightfoot_adsk
Autodesk
Autodesk
You could also consider moving the open output to the On Listener Initialized trigger of the wait for event.
Message 12 of 21

joe_l6
Not applicable

Hi @Felix Möhlmann ,

Now I try to add the second box and it starts with Process2.2boxs.png

When simulating, the Process1 and Process2 will operate at the same time. In the end, only the second box will finish the route, first box will stuck at Queue2.

And I notice that when the model starts, token value is as below.token.png

My ideal scenario is when I set the table as below:table.png

Processor1 will operate the first box. At the same time, second box will wait in Queue2.

When processor1 finish operated the first box, the macine order moves to Processor2. And Processor2 operates the first and second box, until Processor3.

How should I set it up to execute the above scenario smoothly? Thank you!box route and machine order.fsm

0 Likes
Message 13 of 21

moehlmann_fe
Advocate
Advocate

You could have the Wait for Event listen to items exiting the processor. Then, if both the queue and processor are empty, shift the open port to the next queue.

To pull the newer item first, you can use the "Pull Best Item" option the processor's Pull Strategy. In the attached model it almost pulls the newest item (LIFO), but you could also use labels to give certain items priorty over others.

box-route-and-machine-order_1.fsm

Message 14 of 21

joe_l6
Not applicable

Thanks @Felix Möhlmann ,

I'll keep give it a try. Thanks!

0 Likes
Message 15 of 21

joe_l6
Not applicable

Hi @Felix Möhlmann ,

sorry I got another question about the same model.

Now I make the 2nd box arrives at time 50s.2-boxes.png

In the ideal scenario, 2nd box will arrives at time 50s and goes to queue2 and be operated by processor2. But it seems like 2nd box will stuck at queue2 at time 50s.time50-box2-stuck.png

I think it's because the logic in 'Wait for Event' is 'OnExit'. Queue1 can't trigger the OnExit so it won't go to Queue2.

token-stuck.png

How can I set up the model to keep the queues continuously rotating open? For example, when there are no boxes in the current queue and processor after a period of time, the next queue will be opened instead? The queues will continuously rotating open until the simulation ends. Thanks!

box-route-and-machine-order-1.fsm

0 Likes
Message 16 of 21

moehlmann_fe
Advocate
Advocate

If it is Ok that the item has to wait some time, you can simply add a maximum wait time to the "Wait for Event" activity.

(The wait time can be smaller than this, though very small values will have an impact on how fast the model can run, due to the frequent checks).

capture.png

Message 17 of 21

joe_l6
Not applicable
Thanks @Felix Möhlmann ,

it solves my problem perfectly, thank you!

0 Likes
Message 18 of 21

joe_l6
Not applicable

Hi @Felix Möhlmann ,

I would like to ask if it is possible to set up the ProcessFlow to only work from 0-12 hours and then stop, and have another ProcessFlow start working from 12-24 hours.

Currently, I am using one ProcessFlow along with the 'Order' table to control the opening and closing sequence of three queues. However, in future models, I hope to have a new logic for the opening and closing sequence of three queues after 12 hours.

I hope to have two different ProcessFlows to control the queues for the 0-12 hour period and the 12-24 hour period separately.

For example, the opening and closing sequence for the queues during the 0-12 hour period is 1, 2, 3, while the opening and closing sequence for the queues during the 12-24 hour period is 3, 2, 1.

I will add a second column (12-24hr) in the Order table, and I hope the second ProcessFlow will only read the values in that column.

2shifts.png

Is it possible to set up the ProcessFlow to only work from 0-12 hours and then stop, and have another ProcessFlow start working from 12-24 hours? Thank you!machine order_2shifts.fsm

0 Likes
Message 19 of 21

moehlmann_fe
Advocate
Advocate

I wouldn't build a separate second process flow but instead change the logic in the existing one. This eliminates the possibility that the two flows might clash at the crossover time.

You can use "getmodelunit(CURRENT_HOUR_OF_DAY)" to use different logic depending on the time of day. (Minutes etc. can also be read, you can look up the command details in the command helper.)

In the case you describe above you could define a "row" label on the token, which you update every time the token restarts the loop.

machine-order-2shifts-fm.fsm

For more complex differences, you can send the token to a different section of the process flow in a decide activity.

Message 20 of 21

joe_l6
Not applicable

Thanks @Felix Möhlmann ,

"getmodelunit(CURRENT_HOUR_OF_DAY)" is a very helpful command for my problem. Thank you so much!

0 Likes