question

Zach B avatar image
0 Likes"
Zach B asked tannerp commented

How to keep track of height in Queue?

Hello,

I am trying to limit the height of boxes stacked in a queue by keeping track of the height of boxes in the queue. See below for the custom code I am currently using. I am adding the height of the box to a label on the queue itself. I also want to take away height from the queue when the box leaves. The problem is if I use the same thought process for reducing the height of the queue it doesn't work. I am looking at the z-location of the box plus the box height to check if the height label needs to be changed. Since I am using Process Flow to create the boxes it unloads the boxes in the queue from the bottom up. Can anyone come up with a method to decrease the height of the queue as well as increase it when it needs to? My goal is allow the queue to reduce to zero then repopulate the queue with process flow. Queue batching may be useful but the box entering can be a different size so I don't know the exact content of the queue. I would like the box to fill the entire queue just up to a certain number of stacked boxes high.

Thanks,

Zach Bell

Queue OnEntry

/**Custom Code*/
Object current = ownerobject(c);
Object item = param(1);
int port = param(2);
updatelocations(item);
if(item.location.z + item.size.z > current.CurrentHeight)
(
(current.CurrentHeight = item.location.z + item.size.z)
);

Incorrect Queue OnExit

/**Custom Code*/
Object current = ownerobject(c);
Object item = param(1);
int port = param(2);
updatelocations(item);
if(current.CurrentHeight/item.size.z < )
(
(current.CurrentHeight = current.CurrentHeight - item.size.z)
);

FlexSim 18.1.2
custom codequeue content
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joshua S avatar image
1 Like"
Joshua S answered Joshua S commented

Replace both of your trigger codes with this, it adds the height of all your objects in youre queue every time an item leaves or enter.

Object current = ownerobject(c);
Object item = param(1);
int port = param(2);
current.CurrentHeight=0;
for (int I =1;I<=current.subnodes.length;I++)
{
	current.CurrentHeight+=current.subnodes[I].as(Object).size.z;
}
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Zach B avatar image Zach B commented ·

Now the issue is it will only place 1 row of 7 boxes long and 1 box tall. I need it to fill the queue length wise and only increase CurrentHeight if the row is taller than it was before. I could do an if statement with a modulo of the length to make sure it is filled. Unfortunately, I have many different sized boxes so I don't want to set the length. I just want it to fill the queue with as many boxes wide as the queue will fit.

Can I dynamically refer to the queue stacking strategy when it decides to start stacking vertically?

Thanks

0 Likes 0 ·
Joshua S avatar image Joshua S Zach B commented ·

Here's a previous problem I worked on, let me know if it is similar to what you are doing in any way

Question

0 Likes 0 ·
Zach B avatar image Zach B commented ·

stacking-question.fsm

Here is my model of what I am trying to do. I want to fill the queues but only stack them 6 boxes high. Then let them totally deplete and at that point refill them. Let me know if you come up with a better solution.

Thanks,

Zach Bell

0 Likes 0 ·
Joshua S avatar image Joshua S Zach B commented ·

Since you have specific dimensions for both your queues and your items, you can calculate how many items it will take to reach a height of 6 and set the amount of boxes created in that queue to that specific number. Then you can have an event trigger that is fired when the content reaches 0 adding the amonut of boxes you calculated previously.

0 Likes 0 ·