question

Sven E2 avatar image
0 Likes"
Sven E2 asked Joshua S commented

How to identify a flow items label in a tote

assemblypull.fsm

Hello,

I'm trying to build an assembly line with several processes. First I give you an overview about my model:

First of all, orders are generated with individual order numbers and individual types of items/products (this is not part of the example model below).

Each order has two components which should be assembled. Different types of ComponentTwo are delivered in a tote to the assembly station (every ComponentTwo has an individual OrderNo and Type according to the generated orders). As soon as they arrive at the assembly station, they should trigger the process to produce the corresponding ComponentOne. If ComponentOne is finished it should get labels with the type and orderNo. After this, ComponentOne has to be transported to the assembly station. Now an Operator must search for the ComponentTwo in the tote matching the ComponentOne which has just arrived in that moment. The last step is to join them together and send them to the next process.

Now my Question(s):

How can I get the values from the labels of ComponentTwo in the tote? I don´t know how to reference ComponentTwo both for triggering the production of ComponentOne and for finding it once ComponentOne is finished.

How can I manipulate the Combiner (assembly station) that it is looking for matches of the OrderNo and Types from both Components?

assemblypull.fsm

FlexSim 18.0.3
labelscustom combinerflowitem in flowitemmatch flowitems
assemblypull.fsm (53.6 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.

tannerp avatar image tannerp commented ·

I've attached a model that incorporates Process Flow to trigger the creation of ComponentOne objects according to ComponentTwo product types. Let us know if this works. If so, we can find a way to combine both components.

assemblypull-with-new-logic.fsm

0 Likes 0 ·
Sven E2 avatar image Sven E2 tannerp commented ·

Thanks, your model works well. Before we will do the next step, I want to get a deeper understanding how the model works. Can you give me a few explanations how the custom code works? Following I try to explain it with my own words.

First the default part:

/**Custom Code*/
Object current = param(1);		
//The current Object is the tote, right?
treenode activity = param(2);
//The treenode activity is the Custom Code? 
Token token = param(3);
//token is the entering token?
treenode processFlow = ownerobject(activity);
// owenerobject(activity) means to get the object which is entering the custom code(activity). In this case the tote?
Array Types= makearray(3);
// This define an array with 3 variables in it?

I hope this is right so far.

Now the for loop. I guess I understand the basically function of the loop. At each loop the expression "I<=token.Crate.as(Object).subnodes.length" is executed which controls if the variable "I" is higher than the content in the tote.

But I don´t understand how you reference "subnodes.length" and "ComponentTwo" in the if statement.

"token.Crate": Crate is the label which was added to the entering item

"as(Object)": as access a label from object, which is the tote? The called label is "subnodes[I]"?

"subnodes[I]": subnodes reference the lower ranked object from the tote, which is ComponentTwo with index "I"?

"as(Object)": as access a label from object, which should be ComponentTwo. But variable Object is set to current? At this point I am confused!

label["Type"]: is the called label from the as() statement?

for (int I=1;I<=token.Crate.as(Object).subnodes.length;I++)
{
	if (token.Crate.as(Object).subnodes[I].as(Object).labels["Type"].value==1)
	{
		Types[1]++;
	}
	if (token.Crate.as(Object).subnodes[I].as(Object).labels["Type"].value==2)
	{
		Types[2]++;
	}
	if (token.Crate.as(Object).subnodes[I].as(Object).labels["Type"].value==3)
	{
		Types[3]++;
	}
}
token.Types=Types;

One finally question, so far :)

When the code can gets the label "Type". Is it possible to extend the code that it get also the label "OrderNo"?

 if (token.Crate.as(Object).subnodes[I].as(Object).labels["Type"].value==1)	
	{
		Types[1]++;
	object involved = token;
	string labelname = OrderNo;
	Variant value = token.Crate.as(Object).subnodes[I].as(Object).la	bels["orderNo"];
	involved.labels.asser(labelname).value = value;
	}

I´m sorry for being so confused. Thanks for your support.

0 Likes 0 ·
Sven E2 avatar image Sven E2 tannerp commented ·

According to your Code I fund a solution to get access to the label "OrderNo". I created a activity "assign label" with the following code.

/**Custom Code*/
Object current = param(1);
treenode activity = param(2);
Token token = param(3);
Variant assignTo = param(4);
string labelName = param(5);
treenode processFlow = ownerobject(activity);
Variant OrderNo = 0;
for (int I=1;I<=token.Crate.as(Object).subnodes.length;I++)
OrderNo = token.Crate.as(Object).subnodes[I].as(Object).labels["OrderNo"].value;
return OrderNo;

But now every token has the same OrderNo.

0 Likes 0 ·

1 Answer

Joshua S avatar image
0 Likes"
Joshua S answered Joshua S commented
@Sven E2

You have the first part of the code figured out. You have most of the other parts figured out to.

This code is a rather long reference.

token.Crate.as(Object).subnodes[I].as(Object).labels["Type"].value

token.Crate= grab the Crate that is referenced by the label on the token.

as(Object)= this is used so the code recognizes that the object I want to reference is referenced as an "Object" class and allows me to access "Object" values such as location, size, subnodes, and other values.

subnodes[I]= references the Ith Product inside the Tote.

as(Object)= does as mentioned above

label["Type"].value= is referencing the value of the label "Type" on the Product.

You can definitely get the label "OrderNo", my question is what do you want to do with that label?

If you want to assign it to a token ,you just have to use this line.

token.OderNo=token.Crate.as(Object).subnodes[I].as(Object).labels["OrderNo"].value

But there are 3 OrderNo's for 1 token, do you want them assigned to the objects created at the processors?

· 7
5 |100000

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

Matthew Gillespie avatar image Matthew Gillespie ♦♦ commented ·

@Joshua S, You don't actually need the casts to Object in this example. The subnodes and labels properties are on the treenode class.

1 Like 1 ·
Joshua S avatar image Joshua S Matthew Gillespie ♦♦ commented ·

@Sven E2

With @Matthew Gillespie's advice, you can shorten a lot of your references to

token.Crate.subnodes[I].labels["Type"].value

rather then the much longer reference.

0 Likes 0 ·
Sven E2 avatar image Sven E2 commented ·

@Joshua S and @Matthew Gillespie

Thanks for the explanations.

Yes, I want to assign the label "OrderNo" to the object created at the processor. I tried to solve the Problem with the multiple OrderNo´s for 1 token with the following code. But I failed.

Array OrderNo= makearray(4);
for (int I=1;I<=token.Crate.subnodes.length;I++)
{
OrderNo[I] = token.Crate.subnodes[I].labels["OrderNo"].value;
}
token.OrderNo=OrderNo;

It´s necessary for the original model to assign the label OrderNo to the created objects (ComponentOne). The first reason is, that not every "ComponentOne Type 1" has the same properties. But I don´t want to build this complexity in my model. The second reason is, that there are several assembly stations in my model, as you can see I the extended version I attached. It´s quite enough that the right ComponentOne Type 1 finds the right ComponentTwo Type1, which I want to mange with the OrderNo.

Do you have an idea how to solve this?

assemblypullextended.fsm

0 Likes 0 ·
Joshua S avatar image Joshua S Sven E2 commented ·

@Sven E2 Made some changes to the code so now all the token have the OrderNo assigned to them and the created items have the right OrderNo assigned to the them as well12340-assemblypullextended.fsm

So for the Combiner logic, you want the 2 objects to find each other, one from the Buffer assembly Queue, and one from the Component Queues?

0 Likes 0 ·
Sven E2 avatar image Sven E2 Joshua S commented ·

@Joshua S

Thanks for the code. What does this part of the code do?

Array Types= Array(3);
for (int I=1;I<=3;I++)
{
	Types[I]=Array(0);
}

Does this Code means to return the first, second and third value of the Array(3) in the Array Types [1]?

return token.Types[1][creationRank];

Yes, this is exactly what I want to do. When the 2 object find each other both should move to the combiner. After this the combiner joint them to one object. When one tote is empty, it should be delete so that a new and full tote can arrive.

0 Likes 0 ·
Show more comments