App 2.31.1: log the cruise control while driving, with every assist value
The 2.27.3 log wrote a line only when the target speed changed, so the car showed one line at the start. Now a line is written on any change of a mode or the target and every 2 s while driving, with the raw driver-assistance properties (target speed, assist and speed-assist modes, the followed object) and the reason for any unread value. The last 600 lines are kept in an appended file; the Logs tab shows 150. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
@@ -1,18 +1,54 @@
|
||||
package com.evsuite.abrp;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/** The cruise control log's value format — pure JVM. */
|
||||
/** The cruise control debug log's lines and when it writes one — pure JVM. */
|
||||
public class CruiseLogTest {
|
||||
|
||||
private static List<String[]> readings(String cc, String ica, String dist) {
|
||||
return Arrays.asList(new String[] { "cc", cc }, new String[] { "ica", ica },
|
||||
new String[] { "dist", dist });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneDecimalOrUnread() {
|
||||
assertEquals("120.0", CruiseLog.format(120f));
|
||||
assertEquals("33.3", CruiseLog.format(33.33f));
|
||||
assertEquals("0.0", CruiseLog.format(0f));
|
||||
assertEquals("unread", CruiseLog.format(null));
|
||||
assertEquals("unread", CruiseLog.format(Float.NaN));
|
||||
public void lineHasEveryValue() {
|
||||
assertEquals("cc 120.00 ica 1 dist 35.20", CruiseLog.values(readings("120.00", "1", "35.20")));
|
||||
assertEquals("cc unread (not available) ica 0 dist unread",
|
||||
CruiseLog.values(readings("unread (not available)", "0", "unread")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void followedObjectAloneIsNoChange() {
|
||||
assertEquals(CruiseLog.steady(readings("120.00", "1", "35.20")),
|
||||
CruiseLog.steady(readings("120.00", "1", "12.00")));
|
||||
assertFalse(CruiseLog.steady(readings("120.00", "1", "1")).contains("dist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writesOnChangeAndEveryTwoSecondsWhileDriving() {
|
||||
String a = CruiseLog.steady(readings("120.00", "1", "35"));
|
||||
String b = CruiseLog.steady(readings("110.00", "1", "35"));
|
||||
assertTrue(CruiseLog.due(a, null, 0, 0, false));
|
||||
assertTrue(CruiseLog.due(b, a, 1000, 500, false));
|
||||
assertFalse(CruiseLog.due(a, a, 1000, 500, true));
|
||||
assertTrue(CruiseLog.due(a, a, 2500, 500, true));
|
||||
// Parked: nothing new, nothing written.
|
||||
assertFalse(CruiseLog.due(a, a, 60_000, 500, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drivingIsDOrROrMoving() {
|
||||
assertTrue(CruiseLog.driving(null, 4));
|
||||
assertTrue(CruiseLog.driving(0f, 2));
|
||||
assertTrue(CruiseLog.driving(30f, 3));
|
||||
assertFalse(CruiseLog.driving(0f, 1));
|
||||
assertFalse(CruiseLog.driving(null, null));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user