Fix engine speed signal type 76/30176/2
authorScott Murray <scott.murray@konsulko.com>
Thu, 15 Aug 2024 19:54:01 +0000 (15:54 -0400)
committerLisandro Perez Meyer <lpmeyer@ics.com>
Thu, 15 Aug 2024 20:10:34 +0000 (20:10 +0000)
Update use of the VSS engine speed (RPM) signal to match the fix
done to the AGL VSS overlays to restore the upstream integer data
type.

Bug-AGL: SPEC-5204

Change-Id: I1993cf291cdc2ca056f4fb2b389ef4eee5558473
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
lib/data/data_providers/hybrid_notifier.dart
lib/data/data_providers/vehicle_notifier.dart
lib/data/models/vehicle.dart
lib/presentation/screens/dashboard/widgets/circle_indicator.dart

index 51a65fe..f5431f8 100644 (file)
@@ -47,7 +47,7 @@ class HybridNotifier extends StateNotifier<Hybrid> {
     }
   }
 
-  void updateHybridState(double speed, double engineSpeed, bool brake) {
+  void updateHybridState(double speed, int engineSpeed, bool brake) {
     // Variable to store the current state
     HybridState currentState = state.hybridState;
 
@@ -58,7 +58,7 @@ class HybridNotifier extends StateNotifier<Hybrid> {
     double avgSpeed = 0.0;
 
     // Variable for storing the average value of RPM
-    double avgRpm = 0.0;
+    double avgRpm = 0;
 
     if (speed == 0 && engineSpeed <= 600) {
       // Set idle state.
index fb2de19..6583f9a 100644 (file)
@@ -54,8 +54,8 @@ class VehicleNotifier extends Notifier<Vehicle> {
         }
         break;
       case VSSPath.vehicleEngineSpeed:
-        if (entry.value.hasFloat()) {
-          state = state.copyWith(engineSpeed: entry.value.float);
+        if (entry.value.hasUint32()) {
+          state = state.copyWith(engineSpeed: entry.value.uint32);
         }
         break;
       case VSSPath.vehicleFrontLeftTire:
@@ -274,7 +274,7 @@ class VehicleNotifier extends Notifier<Vehicle> {
     var range = state.range;
     var psi = state.frontLeftTire;
     var actualSpeed = 0.0;
-    var actualRpm = 0.0;
+    var actualRpm = 0;
     var actualFuelLevel = 0.0;
     var actualInsideTemp = 0.0;
     var actualOutsideTemp = 0.0;
index dfeae05..0f1031b 100644 (file)
@@ -5,7 +5,7 @@ import '../../export.dart';
 @immutable
 class Vehicle {
   final double speed;
-  final double engineSpeed;
+  final int engineSpeed;
   final double insideTemperature;
   final double outsideTemperature;
   final int range;
@@ -94,7 +94,7 @@ class Vehicle {
 
   Vehicle copyWith({
     double? speed,
-    double? engineSpeed,
+    int? engineSpeed,
     double? insideTemperature,
     double? outsideTemperature,
     int? range,
@@ -166,7 +166,7 @@ class Vehicle {
   factory Vehicle.fromMap(Map<String, dynamic> map) {
     return Vehicle(
       map['speed']?.toDouble() ?? 0.0,
-      map['engineSpeed']?.toDouble() ?? 0.0,
+      map['engineSpeed']?.toInt() ?? 0,
       map['insideTemperature']?.toDouble() ?? 0.0,
       map['outsideTemperature']?.toDouble() ?? 0.0,
       map['range']?.toInt() ?? 0,
@@ -204,13 +204,13 @@ class Vehicle {
 
     return other is Vehicle &&
         other.speed == speed &&
+        other.engineSpeed == engineSpeed &&
         other.insideTemperature == insideTemperature &&
         other.outsideTemperature == outsideTemperature &&
         other.range == range &&
         other.fuelLevel == fuelLevel &&
         other.isChildLockActiveLeft == isChildLockActiveLeft &&
         other.isChildLockActiveRight == isChildLockActiveRight &&
-        other.engineSpeed == engineSpeed &&
         other.frontLeftTire == frontLeftTire &&
         other.frontRightTire == frontRightTire &&
         other.rearLeftTire == rearLeftTire &&
@@ -228,13 +228,13 @@ class Vehicle {
   @override
   int get hashCode {
     return speed.hashCode ^
+        engineSpeed.hashCode ^
         insideTemperature.hashCode ^
         outsideTemperature.hashCode ^
         range.hashCode ^
         fuelLevel.hashCode ^
         isChildLockActiveLeft.hashCode ^
         isChildLockActiveRight.hashCode ^
-        engineSpeed.hashCode ^
         frontLeftTire.hashCode ^
         frontRightTire.hashCode ^
         rearLeftTire.hashCode ^
index e4be5e7..97c32f2 100644 (file)
@@ -91,7 +91,7 @@ class RPMProgressIndicatorState extends ConsumerState<RPMProgressIndicator>
                     width: 220,
                     child: CustomPaint(
                       foregroundPainter: CirclePainter(
-                        value: rpm,
+                        value: rpm.toDouble(),
                         maxValue: maxRpm.toDouble(),
                         isRPM: true,
                       ),