question

Shoog N avatar image
0 Likes"
Shoog N asked Kavika F commented

How can I build a logic based on item properties (label)?

I am building a code where I have to decide the path of the flowing item ( Pill Bottle in a Tote), after being combined via a combiner. knowing that the criteria is based on the Pill Bottle label!

However when I run the model, the system console states the error "Label does not exist" because, it only sees the tote and not the Pill Bottle!


Notes:

1. The Pill Bottle has 10 labels, the criteria is based on one label only!

2, I added "On creation triggers" in the source that supplies Pill Bottle>> Data << set label table value

SO Is there a specific function I can use so when flowing items arrive the Decision Point, the DP decides the route based on the label of the Pill Bottle that has a string value (non- numerical data), and not based on the tote?

FlexSim 22.1.1
label logicsetlabelcod
· 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.

Jacob W2 avatar image Jacob W2 ♦ commented ·

Hi @Shoog N,

It's hard to know how to help without looking at your model. To receive a more accurate solution, please post your model or a sample model that demonstrates your question.

Proprietary models can be posted as a private question visible only to FlexSim U.S. support staff. You can also contact your local FlexSim distributor for phone or email help.

0 Likes 0 ·
Kavika F avatar image Kavika F ♦ commented ·

Hi @Shoog N, was one of Jason Lightfoot's or Joerg Vogel's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel commented

I assume you have a nested structure of containers.
pill bottle, box of pill bottles, pallet of boxes.

Any trigger is firing on an event triggered by top most item. In this case the pallet.

If you want to get a reference to a nested item you have to go down subnodes of your item reference.

item.subnodes[2] is a reference to second box on your pallet.

item.subnodes[2].subnodes[3] is third pill bottle in second box on your pallet.

If I assume further on you want to read a label on a pill bottle called “myData”, you get a stored string value “ABC” by

string readData =  item.subnodes[2].subnodes[3].myData;

You can compare logically string data in “if structures”

if (readData == “ABC”) { do something in a block structure}

If you want to convert string data into numbers, you can do it for example by evaluating an array of possible strings

Array convertInNumber = [ “xyz”, “txt”, “ABC”, “def”];
int newData = convertInNumber.indexOf(readData);

The integer local variable newData keeps now a value of 3.

with a number it gets easier to evaluate more cases in a switch by case structure.

Following here are some links into the manual to read about code structures

Coding in FlexSim

https://docs.flexsim.com/en/22.1/Reference/CodingInFlexSim/WritingLogic/WritingLogic.html

https://docs.flexsim.com/en/22.1/Reference/CodingInFlexSim/BasicModelingFunctions/BasicModelingFunctions.html

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

Shoog N avatar image Shoog N commented ·
it is not a nested if, the condition is regarding one of the labels of the Pill Bottle only, if the pill bottle (item.FillingStation = = "Manual") then senditem to DP5 for example...etc


0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Shoog N commented ·

You have a nested structure, if your 10 pill bottles are inside of a tote and you want to read a label at a pill bottle, because item on your conveyor is your tote and then is your code above a label at your tote!

There are triggers at your decision point to divert items to another decision point on a branch of your conveyor system as it is well described in first tutorial for conveyors in manual:

https://docs.flexsim.com/en/22.1/Tutorials/AdditionalTools/Tutorial1Conveyors/1-1Sorting/1-1Sorting.html

There is a condition similar to my example above

readData == “ABC”

you find in this tutorial a statistical distribution which returns values in a range of 0 and > 0. A value of 0 is logical false any other value is true.

0 Likes 0 ·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered

Instead of referring to the label on just the item - use 'item.first' - or if you need to refer to the nth pill bottle, use item.subnodes[n]

5 |100000

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

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.