question

Marc R5 avatar image
0 Likes"
Marc R5 asked Felix Möhlmann edited

get accumulated time in a specific state - time table

Hello,

If I want to get the total production time of a simulation, I cannot use directly "Model.time" function, because it takes the whole time between start and end.

I need to accumulate the time in a specific state that I have defined in my time table, to substract to the total time.

What functions are there to get this info?

Thanks.

FlexSim 22.1.1
time tablefunctions
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
0 Likes"
Felix Möhlmann answered Felix Möhlmann edited

To get the time an object spent in a given state you can use the following command:

Object.stats.state().getTotalTimeAt(stateName/stateNum);

You could theoretically also read the time directly from the node that stores the timetable information.

// Get the timetable table node
Table timetable = Model.find("/Tools/TimeTables/TimeTable1>variables/table");
int stateNum = 12;
// Query to sum up the duration of a given state up to the current model time (completed blocks only)
Table queryResult = Table.query("SELECT SUM(Duration) FROM $1 WHERE State == $2 AND Time + Duration < $3", timetable, stateNum, Model.time);
// If the query found something, return it
if(queryResult.numRows)
return queryResult[1][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.