question

Jon Perez avatar image
0 Likes"
Jon Perez asked Joerg Vogel commented

How to create a reference in a combiner using Code Snippet

Hello, I have made a simulation where joining 3 raw materials with a combiner, creates a reference. On the other hand, the combiner joins 2 raw materials and creates again a reference. I have used Snippet Code to define when the combiner needs to take 3 raw materials and when 2 raw materials. The problem is that I would like to create 2 different references when joining the different raw materials (for example, when joining 3 raw materials, the combiner creates a label called RefA. On the other hand, when joining 2 raw materials, the combiner creates a label called RefB), but, I don't know how to code it. How would I need to code it using Snippet Code on the combiner?

Thank you.

Join different references.fsm

FlexSim 23.1.0
code snippet
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
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

When you switch the component list set another label to the current ref value A or B.

current.ref="A";

then for the entering item

item.ref=current.ref;

You said the label should be called "RefA" - this is a common mistake. A label in FlexSim is something you can refer to for a value - like a SKU label on the pallet. The name of the label should describe the information it carries rather than be the information itself. Checking label names is more cumbersome and less generic than checking their values.

5 |100000

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

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Joerg Vogel commented

In join mode you loose a lot of data after an setup finish event. Until then you have all items as subnodes in your combiner, later you have only your item from input port number one, which is your first entered item.

Because you have added code already, then I suggest you do it again. You do it, where you have most of your data present. It is On Entry trigger. You choose there which recipe is going to be processed. There you can add a label to your first entered item to be set to value of "RefA" or "RefB".

· 1
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

here is an example: components list is updated by "Type" label value and a global table.

"ref" Label gets set in source1 and is still present after a join operation.

keep_ref_label_from_port1_item.fsm


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.