question

guoyi avatar image
0 Likes"
guoyi asked guoyi commented

Relational expression about the state of the crane

Hicollision.fsm

I get the current state of the crane in the model.

1685522254869.png

Then I want to add a label to the crane according to the current state of the crane

1685522423076.png

But it shows an error, how should this expression be written?

FlexSim 23.1.2
labelexpression
1685522254869.png (17.0 KiB)
1685522423076.png (31.2 KiB)
collision.fsm (47.2 KiB)
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

Arun Kr avatar image
0 Likes"
Arun Kr answered guoyi commented

The state string value "offset travel empty" or any string has to be in double quotes.

if(Model.find("Crane3").as(Object).stats.state().valueString=="offset travel empty")
· 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.

Felix Möhlmann avatar image Felix Möhlmann commented ·

To add to this:

A slightly cleaner approach might be to use the numerical state value and compare it to the respective define. This might prevent typos and probably runs slightly faster.

if(Model.find("Crane3").as(Object).stats.state().value == STATE_OFFSET_TRAVEL_EMPTY)
0 Likes 0 ·
guoyi avatar image guoyi Felix Möhlmann commented ·

Thank you very much for your guidance, but the label on the crane still does not change, what is the reason?

1685535342022.png碰撞1.FSM

1685535356210.png

0 Likes 0 ·
1685535342022.png (17.7 KiB)
1685535356210.png (7.4 KiB)
collision1.fsm (47.4 KiB)
Felix Möhlmann avatar image Felix Möhlmann guoyi commented ·
Use ".value" when comparing to the state number, not ".valueString".
0 Likes 0 ·
Show more comments