get accumulated time in a specific state - time table

get accumulated time in a specific state - time table

marc_r5
Not applicable
134 Views
1 Reply
Message 1 of 2

get accumulated time in a specific state - time table

marc_r5
Not applicable

[ FlexSim 22.1.1 ]

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.

0 Likes
Accepted solutions (1)
135 Views
1 Reply
Reply (1)
Message 2 of 2

moehlmann_fe
Advocate
Advocate
Accepted solution

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];
0 Likes