ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 11-11-2008
Vic Li Vic Li is offline
Flexsim User
 
Join Date: Mar 2008
Posts: 39
Downloads: 0
Uploads: 0
Thanks: 6
Thanked 1 Time in 1 Post
Rep Power: 150
Vic Li is on a distinguished road
Default 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  
Old 11-11-2008
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

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  
Old 11-11-2008
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

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  
Old 11-11-2008
Carsten Seehafer's Avatar
Carsten Seehafer Carsten Seehafer is offline
FlexSim Geek
 
Join Date: Oct 2008
Location: Ritterhude, Deutschland
Posts: 230
Downloads: 45
Uploads: 1
Thanks: 474
Thanked 320 Times in 143 Posts
Rep Power: 379
Carsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud of
Smile

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.
Attached Files
File Type: zip SAMPLE-count_itemtypes_CS.zip (45.9 KB, 349 views)
  #5  
Old 11-11-2008
Vic Li Vic Li is offline
Flexsim User
 
Join Date: Mar 2008
Posts: 39
Downloads: 0
Uploads: 0
Thanks: 6
Thanked 1 Time in 1 Post
Rep Power: 150
Vic Li is on a distinguished road
Default

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 ~
Attached Files
File Type: zip using globaltable.zip (43.5 KB, 289 views)
  #6  
Old 11-12-2008
Carsten Seehafer's Avatar
Carsten Seehafer Carsten Seehafer is offline
FlexSim Geek
 
Join Date: Oct 2008
Location: Ritterhude, Deutschland
Posts: 230
Downloads: 45
Uploads: 1
Thanks: 474
Thanked 320 Times in 143 Posts
Rep Power: 379
Carsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud of
Default

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.
Attached Files
File Type: zip using globaltable - modified.zip (46.2 KB, 325 views)
  #7  
Old 11-18-2008
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default 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  
Old 08-19-2009
Jamie Santa Ana Jamie Santa Ana is offline
Flexsim User
 
Join Date: Jul 2009
Location: Southern California
Posts: 44
Downloads: 22
Uploads: 0
Thanks: 25
Thanked 4 Times in 4 Posts
Rep Power: 135
Jamie Santa Ana is on a distinguished road
Default

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  
Old 08-19-2009
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

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  
Old 08-19-2009
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

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.
Attached Files
File Type: zip count_trucks_in_gate.zip (95.5 KB, 230 views)
The Following User Says Thank You to Phil BoBo For This Useful Post:
Jamie Santa Ana (08-19-2009)
  #11  
Old 08-19-2009
Jamie Santa Ana Jamie Santa Ana is offline
Flexsim User
 
Join Date: Jul 2009
Location: Southern California
Posts: 44
Downloads: 22
Uploads: 0
Thanks: 25
Thanked 4 Times in 4 Posts
Rep Power: 135
Jamie Santa Ana is on a distinguished road
Default

Awesome, that's exactly what I need. Thanks.
  #12  
Old 08-19-2009
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Wink

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


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.