question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Kavika F commented

Calculated table not updating everytime?

Hi team,

I writing data in global table while simulation is progressing and extracted some data in calculated table using SQL queries. But I am facing some issues for updating data in calculated tables.

I am aware of update mode options always or by interval. I tried both of them based on their purpose. But I am able to see that it is not updating data every time based on both option defined. Sometime it works sometime it requires manual update.

Does anybody know why it is happening?

Thank you!

FlexSim 21.0.10
calculated tableupdate mode
· 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.

Kavika F avatar image Kavika F ♦ commented ·

Hi @Ankur A3, was Jordan Johnson'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 unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered

This sounds like a bug, but it's very difficult to say without a model. In Always mode, the Calculated Table updates any time any of the following occurs:

  • The Table view for the Calculated Table is open, and it tries to repaint
  • A chart is pointed at the Calculated Table, and it tries to repaint
  • You query the Calculated Table in Table.query(), including from another Calculated Table
  • You call the Table() constructor.

When any of the above happen, the Calculated Table is designed to run the query, to make sure it's up-to-date. Then, it caches off the current time and a pointer to the current event node. If any of the above events happen again (repainting happens many times per second), then the Calculated Table checks; if the time hasn't changed, and the top event hasn't been executed, then it won't update.

So if you stop the model, view the Calculated Table, and then change the global table (using the interface, or from a script), then the Calculated Table won't update, as you say, until you use the "Update" button. But if you run the model for some tiny non-zero time, then it will update.

Note: perhaps a better name for "Always" is "When accessed". If you look at the actual data in the tree, you'll see that the bundle that stores the data doesn't change, unless one of the above happens.

You also see the issue in Interval mode. The way Interval mode works is by scheduling an event that updates the table, and schedules the next event. If you set a stop time at the exact time when the event is supposed to occur, the table will not have updated when the model stops. At the stop time, none of the events scheduled as that exact time have happened yet. Again, the answer is to run the model for a tiny bit of time; in this case, that will cause the event to be executed, which should cause the table to update.

Those are the only two cases I can think of where you might see an out-of-date table. Otherwise, it sounds like a bug. If you can post a model, we can figure out exactly what's happening.

5 |100000

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