File tree Expand file tree Collapse file tree
main/java/com/evsuite/hardware/telemetry
test/java/com/evsuite/hardware/telemetry Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ All notable changes to this project are documented here. Format follows
2323- ** Trip history can be pruned without bypassing its atomic persistence boundary.**
2424 ` EnergyTripHistoryStore ` can remove one start-time-identified trip or replace the history with
2525 a valid empty v2 envelope; both operations preserve the same unique-temp-file rewrite used by
26- appends, so a UI never deletes the only valid file before its replacement exists.
26+ appends, so a UI never deletes the only valid file before its replacement exists. The default
27+ summary bound is 200 trips; the existing byte ceiling still drops old sample tracks first.
2728
2829- ** A public post-AAOS 9 capacity signal can be tested without becoming product data.**
2930 ` EV_CURRENT_BATTERY_CAPACITY ` describes real-time usable capacity rather than the pack's nominal
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ data class TripHistoryFile(
4242 */
4343class EnergyTripHistoryStore (
4444 private val target : File ,
45- private val maxTrips : Int = 50 ,
45+ private val maxTrips : Int = 200 ,
4646 private val maxBytes : Int = 512 * 1024 ,
4747 private val gson : Gson = Gson (),
4848) {
Original file line number Diff line number Diff line change @@ -141,6 +141,18 @@ class TripHistoryStoreTest {
141141 assertEquals(30 , store.read().size)
142142 }
143143
144+ @Test fun `the default history retains two hundred summaries newest first` () {
145+ val directory = tempDirectory()
146+ val store = EnergyTripHistoryStore (File (directory, " trips.json" ))
147+
148+ repeat(201 ) { trip -> assertTrue(store.append(summary(trip.toLong()))) }
149+
150+ val starts = store.readSummaries().map { it.startedAtMs }
151+ assertEquals(200 , starts.size)
152+ assertEquals(200L , starts.first())
153+ assertEquals(1L , starts.last())
154+ }
155+
144156 @Test fun `a four hour trip is decimated rather than truncated` () {
145157 val track = TripSampleTrack (startIntervalMs = 5_000L , maxSamples = 64 )
146158 // Four hours at 1 Hz: 14 400 reads, of which the track would keep 2 880 at 5 s.
You can’t perform that action at this time.
0 commit comments