question

tchunn avatar image
0 Likes"
tchunn asked Felix Möhlmann commented

Flexsim 2022 calculating in queue trigger using global variable

I am using on entry and on exit trigger in queue to calculate the real time volume and area in queue. I have set up the global variable and make them show in dashboard. However, the number is always higher than it should be. (For example, there's only 5 cubic feet in queue, but the calculation shows 11 or something else.) There might be some repeated calculation but I do not know how to avoid them.

The reason I am using this way is because the volume and the area of each item going into queue is different. Or if there are any other ways that I could use please let me know.


Thank you!


*I have queue1 and queue2, and my code is trying to calculate queue1 and queue2 separately, and also the total(sum) of queue1 and queue2.

*The code in queue1 and queue2 is basically the same. The difference is only the variable's name's different. (For example, name Queue1_Volume will become Queue2_Volume in queue2.)

*I have set the item label of Volume, Width and Length.


Here's my entry code for queue1:

Object current = ownerobject(c);

Object item = param(1);

int port = param(2);

double itemVolume = item.Volume ;


// update the accumulate volumes in queue

Queue1_Volume += itemVolume;

// updata queue's current volume

Current_Queue1_Volume += itemVolume;

// Update total queues' volumes

TotalQueueVolume += itemVolume;


// area counting

double itemarea = item.Length * item.Width ;

// update the accumulate area in queue

Queue1_area += itemarea;

// updata queue's current area

Current_Queue1_area += itemarea;

// Update total queues' area

TotalQueuearea += itemarea;


And the exit code for queue1:

Object item = param(1);

// get the leaving item's volume label

double itemVolume = item.Volume;

// update this queue's volume

Current_Queue1_Volume -= itemVolume;

// update total queues' volumes

TotalQueueVolume -= itemVolume;


// get the leaving item's area label

double itemarea = item.Length * item.Width;

// update this queue's area

Current_Queue1_area -= itemarea;

// update total queues' area

TotalQueuearea -= itemarea;

FlexSim 22.0.16
queueglobal variablecalculationtrigger codevolume
· 1
5 |100000

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

Felix Möhlmann avatar image Felix Möhlmann commented ·

I don't see any issues in the code. It might be caused by how the items enter/exit the queue. Can you attach your model?

0 Likes 0 ·

0 Answers