question

Patrick C4 avatar image
0 Likes"
Patrick C4 asked Matthew Gillespie converted comment to answer

Load by Case with string label in Process Flow

I have a crane that needs to load different types of parts; Stiffeners and Plates. How do I use Load by Case so that it doesn't matter whether a stiffener or a plate part comes through, it still gets loaded. The original code called for the crane to load token.Stiffener, but now I need to load small plates as well. There is no guidance that I can find anywhere on the proper syntax.

FlexSim 20.0.2
syntax for pull and push to list
· 4
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 ·

Did you mean to attach your model?

0 Likes 0 ·
Patrick C4 avatar image Patrick C4 Matthew Gillespie ♦♦ commented ·

I was trying to attach a screen shot by pasting. Apparently need to use the attach button. I was able to fix the pull problem with synchronizing list. Newest issue is syntax for load by case. I cannot find any guidance on how this works. I want to load either a token.Stiffener or a token.Plate, depending on what arrives.

0 Likes 0 ·
capture.png (111.1 KiB)
load.png (25.6 KiB)
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Patrick C4 commented ·

How do you know what arrived?

If it's just an either-or situation based off some label value then you could just use the Conditional Object option.

0 Likes 0 ·
Show more comments
Brandon Peterson avatar image
0 Likes"
Brandon Peterson answered Matthew Gillespie converted comment to answer

@Patrick C4

Here is an example where you don't have to use a string value in a case statement. The benefit here is that it would be future proof for you.

You would use a set labels activity in each flow prior to the join and set a universal label ("LoadPart" in this example) to be equal to the token.Stiffener or Token.Plate labels that you currently have in your model.

If you have your heart set on using a case statement then you need to use a number to differentiate between the part types. The reason for this is that case statements are unable to take strings, integer numbers.

I hope this helps,

Brandon


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

Patrick C4 avatar image Patrick C4 commented ·

I'll give the label method a try. Already setting some additional labels to drive other logic. Thanks

1 Like 1 ·
Matthew Gillespie avatar image
2 Likes"
Matthew Gillespie answered

It seems like the easiest thing to do, would be to set a new label on the token, like "ItemToLoad" wherever the DESC label gets set. That way your Load activity could just say token.ItemToLoad.

The By Case option is a good way of having multiple options, but it only works if the Case Function returns a number. In your case, where you're deciding based off the string value of a label you should just write a series of if statements. So click the Edit Code button next to the Item field and type in code like this:

if(token.DESC == "Stiffener")
	return token.Stiffener;
if(token.DESC == "Plate")
	return token.Plate;
if(token.DESC == "SomethingElse")
	return token.SomethingElse;
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.