Calculate total driving time from a stint

Posts: 61
Hia there!

I was wondering, is it possible to calculate the amount of time a driver sits in a current driving session?
For example, during the iracing 24h of le mans, i did 4 consecutive stints. Is there a way to display that driving time as a total using a script?

Note: I haven't played yet with the script editor as of yet. Just asking around at first to see if this idea is possible.
Posts: 785
We do track the start and end time for each pitstop I believe so from that we could give you the total elapsed time. But this info is not exposed to you so you can't get to it. I can see if I can update the SDK to include it.

Another way would be to keep track yourself with a script that is constantly running and tracks when a driver change happened. If you just store the local time when a swap happens you can calculate the elapsed time every update.
Posts: 61
Nick Thissen wrote:
We do track the start and end time for each pitstop I believe so from that we could give you the total elapsed time. But this info is not exposed to you so you can't get to it. I can see if I can update the SDK to include it.
Hmm interesting

Nick Thissen wrote:
Another way would be to keep track yourself with a script that is constantly running and tracks when a driver change happened. If you just store the local time when a swap happens you can calculate the elapsed time every update.
I am sadly not that experienced with coding tho haha. Do know what you mean!
Posts: 61
Is it possible to code a timer with the script funcitonality?
Posts: 785
What do you mean with "code a timer"?

You can manipulate a Timer item in your theme (start it, stop it, etc).

Or you can make your script use timing functions by what I said previously: store the current date/time on a certain event and then read it back when appropriate and calculate the delta.
Posts: 785
Nick Thissen wrote:
We do track the start and end time for each pitstop I believe so from that we could give you the total elapsed time. But this info is not exposed to you so you can't get to it.
I was wrong - we do give it to you, I was just not looking in the right place.

The result object (IEntitySessionResult) has four properties regarding pit lane and box entry and exit times:
PitLaneEntryTime, PitLaneExitTime, PitStopStartTime, PitStopEndTime

PitLane means entry and exit of the pit lane, while PitStop means the actual stopping in the box. The values indicate the session time at which each event happened in seconds, so if you somehow track these and take a delta you get the time in seconds since the last pitstop.

It is still a bit tricky to calculate total stint time from this. I'll see if I can make that easier.
Posts: 785
I added new properties for total stint duration for each driver. This should make it into a future update relatively soon (pending some other changes). It will give you the start and end sessiontime of the current (or last) stint of each driver, as well as the duration. This is a property on the driver, not on the result level (since a result is valid for an entry/car and not specific to a driver). It still needs some work for handling session changes (it should count the start of the race session, not the start of the practice for example) but I think I can fix that.
Posts: 61
Nick Thissen wrote:
I added new properties for total stint duration for each driver. This should make it into a future update relatively soon (pending some other changes). It will give you the start and end sessiontime of the current (or last) stint of each driver, as well as the duration. This is a property on the driver, not on the result level (since a result is valid for an entry/car and not specific to a driver). It still needs some work for handling session changes (it should count the start of the race session, not the start of the practice for example) but I think I can fix that.

Thank you so much! :D
Posts: 287
Very interesting ;)
Edited (1 time)