question

Adam J avatar image
0 Likes"
Adam J asked Jordan Johnson commented

Queue content

I have a queue which receives two type of items. I'd like to get access to the quantity of a specific type of items that's been recieved by the queue. Any help ?

FlexSim 19.0.0
FlexSim 18.0.8
queue 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.

Jordan Johnson avatar image
2 Likes"
Jordan Johnson answered Jordan Johnson commented

You can use the Statistics Collector to make the table you need. From there, you can access the values with the Table API, or make a dashboard chart:

Table("StatisticsCollector1")[1][2] // would give back 58 in this case

inputbytype.fsm

inputbytype18.fsm

Here are the steps I used to make the stats collector:

  1. Create a Statistics Collector. In the Toolbox, click the add button, and choose the Statistics Menu, then choose the Statistics Collector option.
  2. In the Statistics Collector Properties, use the sampler button to listen to the Queue's OnEntry
  3. Add a a label called Type with the value data.item.Type
  4. On the Data Recording tab, set the Row Mode to Unique Row Values. Set the Row Value to Type. Sort the rows by data.rowValue.
  5. Add a Type column that updates when the row is added, and has the value data.rowValue
  6. Add a Count column that increments the value. It should update by event dependency. Be sure to link it to the event.

Those are pretty brief steps, but hopefully, you can follow along using the attached model. I made the model in 19.0, because Statistics Collectors can sort values in 19.0. I have attached the equivalent model in 18.0 as well.


inputbytype.png (3.1 KiB)
inputbytype.fsm (22.0 KiB)
inputbytype18.fsm (25.2 KiB)
· 11
5 |100000

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

Adam J avatar image Adam J commented ·

Thanks a lot ! I think I couldn't explain well what I'm looking for. I have a queue connected to a processor as in your example I want to close the input of the processor once a quantity of a specific type of items has been processed. I want to get access to this quantity so I can put it as a conditipn to close the port of the processor as we do when we write current.subnodes.length to get the current content of an object.

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Adam J commented ·

Are you writing code in one of the Queue's triggers?

0 Likes 0 ·
Adam J avatar image Adam J Jordan Johnson ♦♦ commented ·

Yah on OnEntry trigger but couldn't find a way to get the current content of one type item in order to use it as a condition to close the input

0 Likes 0 ·
Show more comments
Jeff Nordgren avatar image
2 Likes"
Jeff Nordgren answered Adam J commented

@Adam J,

The way I would do it is to add labels to the Queue to keep track of those numbers (see below).

Of course the easiest way would be to just look at the Statistics in the Quick Properties window for the Queue information that you are wanting.

Attached is the model file so that you can see what was done. If you have any questions or problems, please let us know.

Thanks.

adam-sample1-jn.fsm


adam-sample1.gif (1.4 MiB)
adam-sample1.png (40.0 KiB)
adam-sample1-jn.fsm (19.7 KiB)
· 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.

Adam J avatar image Adam J commented ·

Thank you so much but the file aint open I got a message saying that tree file is not compatible with the version I have (I'm working with flexsim 2018)

0 Likes 0 ·
Mohamed El-akabawy avatar image Mohamed El-akabawy Adam J commented ·

Yes same; the file cannot open completely

0 Likes 0 ·
Adam J avatar image Adam J commented ·

Is there a way to compare the Type1Tot to a number ? For example if it's greater than 100 the output of the queue will be closed ?

0 Likes 0 ·
Mohamed El-akabawy avatar image
0 Likes"
Mohamed El-akabawy answered Joerg Vogel edited

@Adam J could you please verify the complete answer for the problem in screenshots as the file cannot be opened

· 2
5 |100000

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

Adam J avatar image Adam J commented ·

Well, I'm looking for an expression ( like current.subnodes.length ...) that allows me to get access not to the current content of items in object but to the current content of a specific type of items already been defined ( setlabel/value..)

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Adam J commented ·

@Adam J, There isn’t any method, that does what you want to achieve, like count or add up a label in the content of an object.

Jeff shows the classic approach:

  • setting up labels, one label for each type.
  • OnEntry trigger increment the right label by 1
  • OnExit trigger increment the right label by -1

Jordan has presented a similar approach in the statistic collector looping through all values of the collectors table.

You can replace the for-loop in his answer by a query.

Alternatives are:

  • You can build a table query over the content of the queue which counts only items of one type.
  • You can push the items OnEntry to a partitioned global list by type. OnExit you pull the items from the list. Then the length of the partition is the current content of the queue by type content-by-type-by-list.fsm.
1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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