ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
how to get number of itemtype
if one queue has two different itemtypes:1 & 2.
and I want to get the total number of itemtype 1 to write my logic. I want to know how to write this . thx~ |
#2
|
||||
|
||||
Why don't you collect these information by yourself?
Just use a global table or a label table and increment OnEntry the value and decrement (is this English?) in OnExit. Then you have the information and the advantage is that you do not need a search (for loop) to find the number of each item type.
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions." |
#3
|
||||
|
||||
Vic,
If nothing changes while the items are in the queue, use the onentry trigger on the queue to keep track of the number of items. If you want to do it on a label the following code will work. I assume that a label call "Item1" is present on the queue. if( getitemtype(item) == 1) { inc( label(current, "Item1"), 1); } Steven |
#4
|
||||
|
||||
In short:
- First, you have to get the item type on entry of your queue. getitemtype(obj object)Description: Returns the itemtype of an object.Example:getitemtype(so()) Your object is item. - Now you have to count your itemtype. For example: [OnEntry - Queue:] /**CS: count up labels*/ treenode item = parnode(1); treenode current = ownerobject(c); int port = parval(2); double itemtype = getitemtype(item); double counter = 0; switch(itemtype) { case 1: counter = getlabelnum(current, "NumberOfItemtypeOne"); counter++; setlabelnum(current, "NumberOfItemtypeOne", counter); break; case 2: counter = getlabelnum(current, "NumberOfItemtypeTwo"); counter++; setlabelnum(current, "NumberOfItemtypeTwo", counter); break; } - OnExit you have to use counter-- to count down. - And last you should reset your labels on reset. A complete example is attached. |
#5
|
|||
|
|||
thanks David, Hamoen and Seehafer
I got so many idea from you. and I want to ask Seehafer one more question , If I wanna record this by using globaltable, where to write the "settablenum". It seems not put in OnEntry nor OnExit. could you help me to record this in "mytable". thanks ~ |
#6
|
||||
|
||||
You have to write the variable counter of each itemtype in OnEntry and OnExit into the same row and column of your global table (see attachment).
Attention: This model saves only the actual number of each itemtype in labels and in your global table. |
#7
|
||||
|
||||
Sample_RackContentGraph_TD
Guys,
I am pretty sure that you will find the model Sample_RackContentGraph_TD I just posted in the download section useful. It is doing the above thing and shows a bar graph of the content. I used a Rack but as everybody knows is a Rack just a Queue with another visualization and some more functionality. Anyway, here is the link to the model in the download section. http://www.flexsim.com/community/for...do=file&id=165
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions." |
The Following User Says Thank You to Tom David For This Useful Post: | ||
Carsten Seehafer (11-18-2008) |
#8
|
|||
|
|||
Im trying to do something similar in CT. I basically want to count all truck types (bobtail, container, chassis) that come out of a queue. Can anyone help with this? Thank you.
|
#9
|
||||
|
||||
Jamie,
If you have a table of the truck types then you can place some code on the Exit trigger of the queue to increment the table values. The following code will get the itemtype of the item and increment a table cell by one. int trucktype = getitemtype(item); // or getlabelnum(item, "TruckType"); inc(gettablecell("Truck Table", trucktype, 1), 1); Hope this helps, Brandon
__________________
thats not normal. |
The Following User Says Thank You to Brandon Peterson For This Useful Post: | ||
Jamie Santa Ana (08-19-2009) |
#10
|
||||
|
||||
Trucks in CT don't use their itemtype to distinguish whether they are a bobtail, have an empty chassis, or are carrying a container.
Rather, you can just use the content() command to see how many objects are in the truck. A bobtail doesn't have anything in it so its content is 0, a truck with an empty chassis has a chassis in the truck so its content is 1, and a truck with a container on its chassis has a content of 2. Attached is a CT model that shows how you can use the content() command, combined with Brandon's code in GateQueue9's OnExit trigger, to count how many of each type of truck go through a gate queue. |
The Following User Says Thank You to Phil BoBo For This Useful Post: | ||
Jamie Santa Ana (08-19-2009) |
#12
|
||||
|
||||
Hi,
if you don't want to program a code, use a queue and for each itemtype also a queue. Then you select at the first queue send to port by itemtype. The counting does flexsim at the other queues. Jörg |
The Following User Says Thank You to Jörg Vogel For This Useful Post: | ||
Brandon Peterson (08-20-2009) |
Thread | Thread Starter | Forum | Replies | Last Post |
Statistics: Random Number Streams | Tom David | Q&A | 19 | 08-12-2014 02:02 AM |
Collect the total flow time of two itemtype and many replications | Vic Li | Q&A | 5 | 11-04-2010 10:55 AM |
How to unload all the same itemtype flowitem into the matching queue altogether? | karl huang | Q&A | 12 | 02-21-2009 12:45 AM |
Can not catch the number of label | Vic Li | Q&A | 2 | 11-10-2008 12:40 PM |
Setting the number of operators | Sung Kim | Q&A | 4 | 02-05-2008 12:31 PM |