question

Enrique Elizaga avatar image
0 Likes"
Enrique Elizaga asked Jeanette F commented

query state time from objects

Hi, I am getting the time in particular states in this way:

  1. double FLHRS = 0;
  2. Object FL = Group("name")[INDEX];
  3. FLHRS += FL.as(Object).stats.state().getTotalTimeAt("travel empty");
  4. FLHRS += FL.as(Object).stats.state().getTotalTimeAt("travel loaded");

Is there a way to do this using a query?

FlexSim 22.0.0
querysql queriesobject states
· 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.

1 Answer

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered

You can clone the state profile node into a global table and then use an SQL query on that.

  1. Object FL = Group("name")[INDEX];
  2. treenode states = FL.find(">stats/state_current/profile").as(Table).cloneTo(Table("GlobalTable1"));
  3. Table result = Table.query("SELECT SUM(time) FROM GlobalTable1 WHERE state == 'travel empty' OR state == 'travel loaded'");
  4. double FLHRS = result[1][1];

Though that is just an extra step to arrive at the same result. Might I ask why you want to use a query instead of the command?

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