Stats collector exception with Model parameter

Stats collector exception with Model parameter

patrick_zweekhorst
Advocate Advocate
150 Views
6 Replies
Message 1 of 7

Stats collector exception with Model parameter

patrick_zweekhorst
Advocate
Advocate

[ FlexSim 24.1.1 ]

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

0 Likes
Accepted solutions (1)
151 Views
6 Replies
Replies (6)
Message 2 of 7

jason_lightfootVL7B4
Autodesk
Autodesk

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

0 Likes
Message 3 of 7

patrick_zweekhorst
Advocate
Advocate
Thank you for the idea Jason. However when I tried it I still get the exception.
0 Likes
Message 4 of 7

jason_lightfootVL7B4
Autodesk
Autodesk

I can't see an issue.

statscollector_jl.fsm

0 Likes
Message 5 of 7

patrick_zweekhorst
Advocate
Advocate
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
Message 6 of 7

jason_lightfootVL7B4
Autodesk
Autodesk

@Jordan Johnson may have a view on this - the problem could be due to the parameter value being stored on a sdt node and perhaps listeners are not easily applied to them - but I'm guessing.

0 Likes
Message 7 of 7

JordanLJohnson
Autodesk
Autodesk
Accepted solution

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.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes