question

ighiri-mehdi avatar image
0 Likes"
ighiri-mehdi asked ighiri-mehdi commented

Event Trigger and Global Table " Tracked Variables"

Recently, I asked a question about finding a solution to monitor a set of data using a triggered source and a global table. You can find the topic here: Using an Event Triggered Source with a Global Table in FlexSim - FlexSim Community .

My current problem is that I'm using this method with some code in the process flow, and I've noticed that the event trigger doesn't work when I'm running my custom code. Is it because I'm using a "For" loop, which prevents the source from detecting changes while the code is running? Please find attached the custom code, the table, and the triggered source.

1743684550694.png

1743684570130.png

1743684656614.png

FlexSim 25.0.2
global tabletracked variablescustomcodeevent-triggered sourcefor
1743684550694.png (126.3 KiB)
1743684570130.png (30.1 KiB)
1743684656614.png (60.4 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.

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

Works correctly when I test it in an example model.

tr-table-event.fsm

Can you upload a model with the issue? Maybe try stepping through the code one by one and monitor the table at the same time. Could be a timing issue.

1 Like 1 ·
tr-table-event.fsm (28.8 KiB)

1 Answer

ighiri-mehdi avatar image
0 Likes"
ighiri-mehdi answered ighiri-mehdi commented

Thank you for your response. Indeed, it was due to a script I placed in the initialization that updates the various events to be integrated into the object. I imagine that if we change a parameter in the event triggered source, it is absolutely necessary to reset the model and restart it. When I removed this initialization, it worked.

Maybe I need to launch my script before the reset. Is there a method to run custom code before the model resets?

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

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

I assume you update the change thresholds on each reset? Putting that code into the model reset trigger (Toolbox -> Modeling Logic -> Model Triggers) should work.

1 Like 1 ·
ighiri-mehdi avatar image ighiri-mehdi Felix Möhlmann commented ·

I just tried, and it works, thank you so much!

0 Likes 0 ·