bool OnTimer() { bool result = false; if (stopwatch.IsRunning) { DemoSample s = mode.GetSample(stopwatch.ElapsedMilliseconds); Update(s); result = true; // restart timer } return(result); }
public DemoModeBrake() { Debug.LogToFileMethod(); sample = new DemoSample(0, 0, 0, 0, 0, 0); /* * Profil Brake: (nur Zeitangabe, keine Streckenangabe) * Anzeige geht auf 175kmh und wieder zurück auf 0kmh * - 100-0: 3,6s */ // BRAKE // accelerate to 175 km/h and then back to 0 km/h double[] pointsX = { 0, 2, 4, 6, 8, 10, 12, 13, 14, 15, TIME_MAX }; // time [s] double[] pointsY = { 0, 33, 66, 100, 140, 175, 100, 75, 50, 25, 0 }; // speed [km/h] spline = CubicSpline.InterpolateAkimaSorted(pointsX, pointsY); }
void Update(DemoSample s) { sensorX = s.x; sensorY = s.y; sensorZ = s.z; sensorTimestamp = s.t; // e.Timestamp = nanoseconds since 01. januar 1970 // e.Timestamp / 1 000 000 000 = seconds if (isFirstRun) { isFirstRun = false; sensorTimestampFirst = sensorTimestamp; sensorAcceleration = 0; sensorSpeed = 0; } else { sensorXDelta = sensorX - sensorXLast; sensorYDelta = sensorY - sensorYLast; sensorZDelta = sensorZ - sensorZLast; sensorSpeed = s.s; // acceleration magnitude of all components sensorAcceleration = (float)Math.Sqrt(sensorX * sensorX + sensorY * sensorY + sensorZ * sensorZ); } sensorXLast = sensorX; sensorYLast = sensorY; sensorZLast = sensorZ; sensorTimestampLast = sensorTimestamp; if (listener != null) { listener.OnAcceleromterUpdate(); } }
public DemoModeAcceleration() { Debug.LogToFileMethod(); sample = new DemoSample(0, 0, 0, 0, 0, 0); /* * Profil Acceleration: * Anzeige geht auf 250kmh und wieder zurück auf 0kmh * 0-100: 3,8s * 0-200: 10,3s */ // ACCELERATION // accelerate to 250 km/h and then back to 0 km/h double[] pointsX = { 0, 1, 4.6, 13.5, 15, TIME_MAX }; // time [s] double[] pointsY = { 0, 30, 100, 250, 100, 0 }; // speed [km/h] spline = CubicSpline.InterpolateAkimaSorted(pointsX, pointsY); }
public DemoModeZeroToZero() { Debug.LogToFileMethod(); sample = new DemoSample(0, 0, 0, 0, 0, 0); /* * Profil Zero to Zero: (nur Zeitangabe, keine Streckenangabe) * Geschwindigkeitsanzeige geht auf 126kmh und wieder zurück auf 0kmh * - 0-100: 4,85s * - 0-126 (Vmax): 6,2s * - 100-0: 3,75s * - 0 - 0: 10,85s */ // ZERO TO ZERO // accelerate to 126 km/h and then back to 0 km/h double[] pointsX = { 0, 7, 8, 9, TIME_MAX }; // time [s] double[] pointsY = { 0, 110, 126, 110, 0 }; // speed [km/h] spline = CubicSpline.InterpolateAkimaSorted(pointsX, pointsY); }