question

Mischa Spelt avatar image
0 Likes"
Mischa Spelt asked Mischa Spelt edited

Overriding standard statistics type

Is it correct that bindStandardStatistics is always called, even when I am not explicitly invoking FlexSimEventHandler's bindStatistics from my own class?

I overrode bindStatistics without calling the base class's version, re-initializing e.g. stat_input to a different type of tracked variable, but once the reset completes I still end up with a cumulative variable.

My bindStatistics looks as follows:

void MyClass::bindStatistics()
{
  if( objectexists( node_b_stats_input ) && getdatatype( node_b_stats_input ) == DATATYPE_SIMPLE )
  {
    bindStatisticByName( "stats_input", node_b_stats_input, "Input", STAT_TYPE_KINETIC_LEVEL );
  }
}

and I checked that the line with bindStatisticByName is reached.

statisticsmodulesbind
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

·
Jordan Johnson avatar image
1 Like"
Jordan Johnson answered Mischa Spelt edited

The flag parameter is only used if the node doesn't exist. Since the node exists, no change occurs. Maybe you could delete the node_b_stats_input and set it to 0 in onCreate, and then just call bindStatisticByName as you are now, but without the surrounding if statement. Then, since the node doesn't exist, it should make the right type of node. You may also need to rebind attributes, since stats_input is an attribute.

@anthony.johnson might have corrections or additional info.

· 8
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Thanks for the answer. I ended up calling TrackedVariable::reset in the object's On Reset. That works well for stats_input and stats_output, but for some reason not for FlexSimObject's stats_content. Even when I give it an initial value in the on reset, it gets reset to 0 somewhere I cannot reach. Looking at the history of the TV, I can see it getting set to my initial value, then back to 0. Any idea why this works for input / output but not for content?

0 Likes 0 ·

It is hard to guess at what is going on without your source code. Can you make a demo module that shows the issue? My guess is that you cannot just "rename" one of the statistics that exists on an object. I know you are not calling the super class bind, but you are trying to use nodes provided by the super class, and I don't know if that is possible.

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.