question

Jimmy jang avatar image
0 Likes"
Jimmy jang asked Logan Gold commented

Groups' subnodes

Good Day


Currently i have several groups which are groups of racks and queues.


i am trying to create a token when subnodes ==0.

ex)

Group("Racks").subnodes.length

Group("Queues").subnodes.length


However i assume Group("Queues").subnodes.length applys to number of the queues.


May i know how to count the items inside all queues and racks ?


Best regards


FlexSim 24.2.1
groupsubnodes
· 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.

Hi @Jimmy jang, was one of Matthew Gillespie's or Joerg Vogel's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·
Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Matthew Gillespie edited

To get the number of objects in a group use:

Group("Queues").length

If you want to count the items inside each object in the group you'd have to use a for loop:

Group queues = Group("Queues");
int numItems = 0;
for (int i = 1; i <= queues.length; i++) {
    Object q = queues[i];
    numItems += q.subnodes.length;
}
return numItems;

An easy way to trigger an event if all the queues are empty would be to use an Event-triggered Source that listens to the OnContentChange of the group.

1735846897657.png

Heres's an example model:

EmptyQueues.fsm


1735846897657.png (20.1 KiB)
emptyqueues.fsm (31.5 KiB)
5 |100000

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

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel commented

https://docs.flexsim.com/en/24.2/Reference/CodingInFlexSim/CommandReference/Commands.html#forobjecttreeunder

please check, that you node container is casted correctly and it is the right node in tools of your model tree,

· 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.

Joerg Vogel avatar image Joerg Vogel commented ·
This command has got a major impact on performance, if you run experiments. Perhaps you think of a different approach where you update labels at objects while you run your model to keep a correct inventory balance.
0 Likes 0 ·