diff options
author | Scott Murray <scott.murray@konsulko.com> | 2023-12-08 10:28:48 +0900 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2023-12-08 10:54:30 +0900 |
commit | 71d46d03850653c0229c678de197c6f94fceb477 (patch) | |
tree | b91915e70c9092d304d3172b93eb61ffb0c287c5 /lib/data/models/vehicle.dart | |
parent | dca5f5bc58fc3b25972bedc82827b71300d66adc (diff) |
More signaling fixes
Changes:
- Fixed parsing of engine speed from databroker response to use
uint32 again to match VSS type.
- Shifted engine speed definitions in Vehicle class next to
vehicle speed since that seems a bit saner than having it down at
the bottom with the temperature values.
- Removed duplicate temperature state from temperature control
widget, and pushed the use of the providers from the HVAC widget.
The existing scheme was somewhat broken with respect to having the
values managed with RiverPod, e.g. new values from external updates
would not show up until switching away and back to the HVAC tab.
- Moved HVAC "SYNC" button state into the Vehicle state class to
manage it with RiverPod, and allow use from both the HVAC and
temperature widgets so that the expected behavior can actually be
implemented.
- Fixed brace usage in a couple of debugPrint statements.
Bug-AGL: SPEC-4999
Change-Id: I07ea49d20fedca47e6f9e54f45ad34296e0a873c
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Diffstat (limited to 'lib/data/models/vehicle.dart')
-rw-r--r-- | lib/data/models/vehicle.dart | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/lib/data/models/vehicle.dart b/lib/data/models/vehicle.dart index 67ef693..2dea928 100644 --- a/lib/data/models/vehicle.dart +++ b/lib/data/models/vehicle.dart @@ -5,6 +5,7 @@ import '../../export.dart'; @immutable class Vehicle { final double speed; + final double engineSpeed; final double insideTemperature; final double outsideTemperature; final int range; @@ -12,7 +13,6 @@ class Vehicle { final int mediaVolume; final bool isChildLockActiveLeft; final bool isChildLockActiveRight; - final double engineSpeed; final int frontLeftTire; final int frontRightTire; final int rearLeftTire; @@ -24,9 +24,11 @@ class Vehicle { final int fanSpeed; final int driverTemperature; final int passengerTemperature; + final bool temperatureSynced; const Vehicle( this.speed, + this.engineSpeed, this.insideTemperature, this.outsideTemperature, this.range, @@ -34,7 +36,6 @@ class Vehicle { this.mediaVolume, this.isChildLockActiveLeft, this.isChildLockActiveRight, - this.engineSpeed, this.frontLeftTire, this.frontRightTire, this.rearLeftTire, @@ -43,13 +44,15 @@ class Vehicle { this.isFrontDefrosterActive, this.isRearDefrosterActive, this.isRecirculationActive, - this.fanSpeed, - this.driverTemperature, - this.passengerTemperature, + this.fanSpeed, + this.driverTemperature, + this.passengerTemperature, + this.temperatureSynced, ); const Vehicle.initial() : speed = 0, + engineSpeed = 0, insideTemperature = 0, outsideTemperature = 0, range = 0, @@ -57,7 +60,6 @@ class Vehicle { mediaVolume = 50, isChildLockActiveLeft = false, isChildLockActiveRight = true, - engineSpeed = 0, frontLeftTire = 33, frontRightTire = 31, rearLeftTire = 31, @@ -68,10 +70,12 @@ class Vehicle { isRecirculationActive = false, fanSpeed = 0, driverTemperature = 26, - passengerTemperature = 26; + passengerTemperature = 26, + temperatureSynced = true; const Vehicle.initialForDebug() : speed = 60, + engineSpeed = 6500, insideTemperature = 25, outsideTemperature = 32.0, range = 21, @@ -79,7 +83,6 @@ class Vehicle { mediaVolume = 50, isChildLockActiveLeft = false, isChildLockActiveRight = true, - engineSpeed = 6500, frontLeftTire = 33, frontRightTire = 31, rearLeftTire = 31, @@ -90,10 +93,12 @@ class Vehicle { isRecirculationActive = false, fanSpeed = 0, driverTemperature = 26, - passengerTemperature = 26; + passengerTemperature = 26, + temperatureSynced = true; Vehicle copyWith( {double? speed, + double? engineSpeed, double? insideTemperature, double? outsideTemperature, int? range, @@ -101,7 +106,6 @@ class Vehicle { int? mediaVolume, bool? isChildLockActiveLeft, bool? isChildLockActiveRight, - double? engineSpeed, int? frontLeftTire, int? frontRightTire, int? rearLeftTire, @@ -110,12 +114,14 @@ class Vehicle { bool? isFrontDefrosterActive, bool? isRearDefrosterActive, bool? isRecirculationActive, - int? fanSpeed, - int? driverTemperature, - int? passengerTemperature, + int? fanSpeed, + int? driverTemperature, + int? passengerTemperature, + bool? temperatureSynced, }) { return Vehicle( speed ?? this.speed, + engineSpeed ?? this.engineSpeed, insideTemperature ?? this.insideTemperature, outsideTemperature ?? this.outsideTemperature, range ?? this.range, @@ -123,7 +129,6 @@ class Vehicle { mediaVolume ?? this.mediaVolume, isChildLockActiveLeft ?? this.isChildLockActiveLeft, isChildLockActiveRight ?? this.isChildLockActiveRight, - engineSpeed ?? this.engineSpeed, frontLeftTire ?? this.frontLeftTire, frontRightTire ?? this.frontRightTire, rearLeftTire ?? this.rearLeftTire, @@ -132,15 +137,17 @@ class Vehicle { isFrontDefrosterActive ?? this.isFrontDefrosterActive, isRearDefrosterActive ?? this.isRearDefrosterActive, isRecirculationActive ?? this.isRecirculationActive, - fanSpeed ?? this.fanSpeed, - driverTemperature ?? this.driverTemperature, - passengerTemperature ?? this.passengerTemperature, + fanSpeed ?? this.fanSpeed, + driverTemperature ?? this.driverTemperature, + passengerTemperature ?? this.passengerTemperature, + temperatureSynced ?? this.temperatureSynced, ); } Map<String, dynamic> toMap() { return { 'speed': speed, + 'engineSpeed': engineSpeed, 'insideTemperature': insideTemperature, 'outsideTemperature': outsideTemperature, 'range': range, @@ -148,7 +155,6 @@ class Vehicle { 'mediaVolume': mediaVolume, 'isChildLockActiveLeft': isChildLockActiveLeft, 'isChildLockActiveRight': isChildLockActiveRight, - 'engineSpeed': engineSpeed, 'frontLeftTire': frontLeftTire, 'frontRightTire': frontRightTire, 'rearLeftTire': rearLeftTire, @@ -160,12 +166,14 @@ class Vehicle { 'fanSpeed': fanSpeed, 'driverTemperature': driverTemperature, 'passengerTemperature': passengerTemperature, + 'temperatureSynced': temperatureSynced, }; } factory Vehicle.fromMap(Map<String, dynamic> map) { return Vehicle( map['speed']?.toDouble() ?? 0.0, + map['engineSpeed']?.toDouble() ?? 0.0, map['insideTemperature']?.toDouble() ?? 0.0, map['outsideTemperature']?.toDouble() ?? 0.0, map['range']?.toInt() ?? 0, @@ -173,7 +181,6 @@ class Vehicle { map['mediaVolume']?.toInt() ?? 0, map['isChildLockActiveLeft'] ?? false, map['isChildLockActiveRight'] ?? false, - map['engineSpeed']?.toInt() ?? 0, map['frontLeftTire']?.toInt() ?? 0, map['frontRightTire']?.toInt() ?? 0, map['rearLeftTire']?.toInt() ?? 0, @@ -185,6 +192,7 @@ class Vehicle { map['fanSpeed'] ?? 0, map['driverTemperature'] ?? 0, map['passengerTemperature'] ?? 0, + map['temperatureSynced'] ?? false, ); } @@ -222,7 +230,8 @@ class Vehicle { other.isRecirculationActive == isRecirculationActive && other.fanSpeed == fanSpeed && other.driverTemperature == driverTemperature && - other.passengerTemperature == passengerTemperature; + other.passengerTemperature == passengerTemperature && + other.temperatureSynced == temperatureSynced; } @override @@ -246,7 +255,8 @@ class Vehicle { isRecirculationActive.hashCode ^ fanSpeed.hashCode ^ driverTemperature.hashCode ^ - passengerTemperature.hashCode; + passengerTemperature.hashCode ^ + temperatureSynced.hashCode; } // } // / class VehicleNotifier extends StateNotifier<Vehicle> { |