question

Karthikeyan B avatar image
0 Likes"
Karthikeyan B asked Matthew Gillespie edited

Set Item color and process items based on labels and item type

Hello I am trying to create some logic for a bigger simulation i am trying to do.

Requirements :

1) I need to produce 9 different product types on my line

2) I have 3 major product types , I have 3 sub product types under every major product.

3) I use the Even trigger ( On creation to assign 3 different major product types )

4) I use the assign label on creation to assign my sub products to the major types so 3X3 = 9

5) I want to create the item colors based on both type and label , not successful

6) I know i can just go ahead and create 9 different item types or labels but I want to use labels and item types so i can use labels later in the process to route the items to different locations in the conveyor.

7) I have used the following expression on the set object color

Color.byNumber(item.Type)+Color.byNumber(item.Subtype)

Can some one tell me how to fix this ??

set-object-color-expression.pngcolor-by-label-and-item-type.fsm

source-triggers.jpg

Also I want to know if the expression i am using to process the 9 different items based on the labels on the same processor is right.processor-based-on-label-value.png

1) I use the getlabelnum(item,"labelname") and I use the value by case for the processing time on the processors

Is this the best way to do this or is there some other way where i can do it based on item type too ??

I have attached my model for the set object color and i have attached screen shots for the other questions.

Thanks

Karthik

FlexSim 19.0.2
process timeitem typecolor
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

·
Joshua S avatar image
2 Likes"
Joshua S answered Karthikeyan B commented

I changed up your creation trigger so that it would assign Type and Subtype based off of operations done on a value "type" that allows you to set the color as well. so now your Types will be 1-3 and your Subtypes will be 1-3, I also changed up the flow so they would check for 1-3 rather than 4-6. You can change it back to checking for 4-6 if you want, just change the code

item.Subtype=type%3+1;

to

item.Subtype=type%3+4;

it was just easier for me to think of it using a 3X3 matrix

18352-color-by-label-and-item-type.fsm

What you are doing for the processor should work, just change the "variant" to "Type".


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

Karthikeyan B avatar image Karthikeyan B commented ·

box-types.jpgsource-trigger-code.jpgHello Joshua Thank you for your response.

I am still relatively a new user when it comes to custom coding but would love to understand the basics so I can take that and change it in my model as I go.

I had some more questions.

What does the % signify in this expression ?

" item.Subtype=type%3+1 "

I understand you have used a custom code to create item types based on D uniform distribution to assign labels 0 ~8 giving me 9 types but when i pull up my item properties I am getting decimal values in my item type , Please correct me if i am wrong but shouldn't these be real numbers ??

item.Type=type/3+1 - So am I assigning the item type to be 0/4,1/4,2/4,3/4,4/4,5/4....8/4 = 0,0.25,0.5,0.75,1....2 ?

Can you also clarify the significance of the code on what its doing so i can modify it based on my application ?

Thanks and regards

Karthik

0 Likes 0 ·
box-types.jpg (34.3 KiB)
Karthikeyan B avatar image Karthikeyan B Karthikeyan B commented ·

Hello Joshua I think after looking at the logic and some searching i understand it.

% - is the mod operator in C is that correct ?

I see what you did here to define the types and sub types.

Really smart way to do it. Thank you.

But is there still a way to get only whole numbers instead of decimals and still achieve this ?

Thanks and regards

Karthik

0 Likes 0 ·

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.