aboutsummaryrefslogtreecommitdiffstats
path: root/lib/data
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2023-12-08 10:28:48 +0900
committerScott Murray <scott.murray@konsulko.com>2023-12-08 10:54:30 +0900
commit71d46d03850653c0229c678de197c6f94fceb477 (patch)
treeb91915e70c9092d304d3172b93eb61ffb0c287c5 /lib/data
parentdca5f5bc58fc3b25972bedc82827b71300d66adc (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')
-rw-r--r--lib/data/data_providers/vehicle_notifier.dart10
-rw-r--r--lib/data/models/vehicle.dart52
2 files changed, 38 insertions, 24 deletions
diff --git a/lib/data/data_providers/vehicle_notifier.dart b/lib/data/data_providers/vehicle_notifier.dart
index 1b2a31a..3a385a3 100644
--- a/lib/data/data_providers/vehicle_notifier.dart
+++ b/lib/data/data_providers/vehicle_notifier.dart
@@ -352,7 +352,7 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
isChildLockActiveRight: !state.isChildLockActiveRight);
break;
default:
- debugPrint("ERROR: Unexpected side value $side}");
+ debugPrint("ERROR: Unexpected side value ${side}");
break;
}
} catch (e) {
@@ -391,7 +391,7 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
state = state.copyWith(passengerTemperature: value);
break;
default:
- debugPrint("ERROR: Unexpected side value $side}");
+ debugPrint("ERROR: Unexpected side value ${side}");
break;
}
} catch (e) {
@@ -399,6 +399,10 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
}
}
+ void setTemperatureSynced(bool newValue) {
+ state = state.copyWith(temperatureSynced: newValue);
+ }
+
void updateFanSpeed(int newValue) {
// Convert local 0-3 setting to the 0-100 the VSS signal expects
var targetFanSpeed = 0;
@@ -465,7 +469,7 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
isRecirculationActive: !state.isRecirculationActive);
break;
default:
- debugPrint("ERROR: Unexpected mode value $mode}");
+ debugPrint("ERROR: Unexpected mode value ${mode}");
break;
}
} catch (e) {
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> {