question

Shinya O avatar image
0 Likes"
Shinya O asked Jason Lightfoot commented

On Label Value Change does not work

Hi,

I would like to listen the change of the label value, but OnLabelValueChange does not work well. I attach the model. Do I need to configure anything?

Is there no other option but to sample the tracking variable labels directly from the tree?

1706682848875.png

Thanks in advance.OnLabelValueChange.fsm

FlexSim 23.0.12
on label value change
1706682848875.png (540.1 KiB)
· 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.

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Shinya O, was Regan Blackett's answer helpful? If so, please click the "Accept" button at the bottom of their answer. 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 comment back to reopen your question.

0 Likes 0 ·

1 Answer

Regan Blackett avatar image
0 Likes"
Regan Blackett answered Shinya O commented

To use wait for event with the change in a label value, the label has to have a Tracked Variable datatype. In my example, I use a token to create an item with a Label whose value is a tracked variable:

1706727745080.png

In my example I chose a "Level" tracked variable type. In the wait for event you use the label as the object reference:

1706727826151.png

To Get access to the on Change event, you have to sample a different tracked variable, I usually just create one in the Toolbox so I can sample the OnChange event.

The change rules give you a lot of options for how the value should change in order to release the token from the wait for event. In my example, I have it set so that every 5 times a flowitem goes around a conveyor loop, it randomly changes its color.

listen to label tracked variable.fsm


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

Shinya O avatar image Shinya O commented ·

What I want to know is about the On Label Value Change event, not the On Change event.

In my model, the operator has the label which has a Tracked Variable datatype. Therefore, when sampling with the WaitFor Event sampler, the On Label Value Change option becomes selectable. Is there something wrong with this approach?


0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

You can also sample the label in the tree as a pointer type which will then continue to listen to the label even if you rename it which might be better that using labels["Type"]

1707138664669.png

Here's the model of that working for the operator with an event at 10s to change the label value.

onlabelvaluechange_jl.fsm

It does look like OnLabelValueChange doesn't work - even for the case described in the documentation. It gives exceptions when reaching the activiy. I'll send a report into the developers - thanks for drawing this to our attention.

0 Likes 0 ·
Shinya O avatar image Shinya O Jason Lightfoot ♦♦ commented ·

Thank you both. Thank you for the alternative, On Change event.

0 Likes 0 ·