question

Rajiv C avatar image
0 Likes"
Rajiv C asked Rajiv C commented

Count Item Type on a Pallet

ProcessTimeBy ItemTypeCount.fsm

I want to count item types on a pallet & then dynamically change the processing time of pallet in the processor by multiplying one of the item type count on that pallet with a fixed time value for example if item type 1 have a quantity of 6 on the pallet then I want the processing time in the processor to be 3second x 6 count = 12 seconds.


FlexSim 20.0.0
flexsim 20.0.0w
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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Rajiv C commented

You could use a loop to count each type in the processtime trigger:

int numType1=0;    //we'll increment this
for (int n=item.subnodes.length;n>0;n--)    //loop for all the items.
    numType1+=item.subnodes[n].Type==1;    //increment by  true (1) or false(0)
return numType1*3;    //assume model time units are second; 


A more flexible and generic way is to set up a processing time array on the processor for the types - shown here with 3 seconds for type1 and then 1 second for type2 (could also be zero):

Then in the processtime trigger use SQL to get a table of types and their quantities:

/**Pallet of Type Based Process Times from label array */

Table result =Table.query("SELECT Type,count(*) FROM $1 GROUP BY Type",item);     // create the table with type and quantity
double ptime=0;
for (int n=result.numRows;n>0;n--) {
    ptime+=result[n][2]*current.typeProcTimes[result[n][1]];   //increment the process time by the quantity and the time for the type
}
return ptime;


This way you can edit the array with times for each type.

Model attached.

processtimeby-itemtypecount_jl.fsm





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

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Here's the version with just a simple loop.

processtimeby-itemtypecount_jl_simpleLoop.fsm

0 Likes 0 ·
Rajiv C avatar image Rajiv C commented ·

Thanks Jason, this works

0 Likes 0 ·