question

Laurenz Peleman avatar image
0 Likes"
Laurenz Peleman asked Laurenz Peleman commented

Delay when changing the rank of items in Object

Hello everyone

I encountered a problem when I was trying to change the order of items in a queue based on a label value. Any time an item with label "label" = 5 enters, it should be processed before any other item in the queue. I wrote the code below for the OnEntry trigger.

Now, the code results in the outputport being opened before the items are shuffled. Hence, the item initially at rank 1, so before the entry trigger, is passed to the processor, not the one I want. Only after the wrong item was passed, the remaining items are ordered correctly.

Is there an easy way to overcome the apparent delay on the item sorting step, or am I doing something wrong?

Many thanks in advance

  1. Object item = param(1);
  2. Object current = ownerobject(c);
  3. int port = param(2);
  4. { // ************* PickOption Start ************* //
  5. if (item.label == 5) {
  6. treenode itemConsidered = current.subnodes[current.subnodes.length];
  7. itemConsidered.rank = 1;
  8. openoutput(current);
  9. }
  10. } // ******* PickOption End ******* //
FlexSim 17.0.0
rank in queue
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

Steven Hamoen avatar image
0 Likes"
Steven Hamoen answered Laurenz Peleman commented

@Laurenz Peleman Have you tried using a senddelayedmessage with delay 0 and in that onmessage trigger open the output? This usually solves these types of problems.

· 3
5 |100000

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