question

Patrick Zweekhorst avatar image
0 Likes"
Patrick Zweekhorst asked Jordan Johnson answered

Stats collector exception with Model parameter

Hi,

I have a stats collector that looks at a Model parameter at the change value for the event. The parameters are in the drop down option so I would expect it to work:
1723711614364.png

When pressing reset I get the following exception:

exception: FlexScript exception: Cannot access collected data values outside of statistics collector events at MODEL:/Tools/StatisticsCollectors/Content Vs Time_2 Collector>variables/eventReferences/Group1 - On Content Change/changeValue at line 4

Is this a bug? Or maybe just something that is not allowed?

As a work around we tried to set a label on the stats collector at the OnModelReset trigger and use this label in the stats collector instead of the model parameter. However this resulted in the same exception.

Thank you for your time,

Patrick

StatsCollector.fsm

FlexSim 24.1.1
model parameters tablestats collector
1723711614364.png (28.7 KiB)
statscollector.fsm (632.3 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.

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered

This is a bug, but it seems you can work around it. The issue is the header that is applied when you add code directly. Change the code to this:

StatisticsCollector collector = ownerobject(c);
// var data = collector.collectedData;
// treenode current = data.eventNode;
// Object instance = data.processFlowInstance;

return /**/Model.parameters.Parameter1/**direct*/;

I'll add it to the dev list. It is true that collectedData is not yet available, because the event hasn't actually fired yet. This code is testing whether the event should fire. The bug (at least in my opinion) is that the header adds invalid stuff like that.

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
0 Likes"
Jason Lightfoot answered Jason Lightfoot commented

Have tried using the OnSet of the Parameter to set the value?

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

Patrick Zweekhorst avatar image Patrick Zweekhorst commented ·
Thank you for the idea Jason. However when I tried it I still get the exception.
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Patrick Zweekhorst commented ·

I can't see an issue.

statscollector_jl.fsm

0 Likes 0 ·
Patrick Zweekhorst avatar image Patrick Zweekhorst Jason Lightfoot ♦♦ commented ·
Hi Jason,

Now that I see your model I noticed that I mis understood your suggestion. I thought the idea was to set a label on the stats collector from the OnSet of the Model parameter. Setting the value of the node itself indeed works.
Thanks!

Would you still classify the original error as a bug, or just something that is not allowed?

0 Likes 0 ·
Show more comments