aboutsummaryrefslogtreecommitdiffstats
path: root/lib/data
diff options
context:
space:
mode:
authorLisandro Pérez Meyer <lpmeyer@ics.com>2023-11-17 09:17:29 -0300
committerLisandro Perez Meyer <lpmeyer@ics.com>2023-11-17 14:11:43 +0000
commit0016d533a9fc601aa65f69a050c60c8d6158ed36 (patch)
tree6fd0765f9d1006a2bddd142caf1d7c0a9d5482cf /lib/data
parent4d77bab5a0f698943d1abf74482eecef7cc95f08 (diff)
Disable value animation at start up % update FuelLevel path.
Also: - Remove some warnings. - Improvements of hvac temp buttons. Original from: Dominik Wawrzonek <dwawrzonek@ics.com> Bug-AGL: SPEC-4971 Change-Id: Ic10e9ec5ec79f79f63d951469924325f29ea3fa7 Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
Diffstat (limited to 'lib/data')
-rw-r--r--lib/data/data_providers/vehicle_notifier.dart42
-rw-r--r--lib/data/models/vehicle.dart41
2 files changed, 72 insertions, 11 deletions
diff --git a/lib/data/data_providers/vehicle_notifier.dart b/lib/data/data_providers/vehicle_notifier.dart
index fb69595..b9a543c 100644
--- a/lib/data/data_providers/vehicle_notifier.dart
+++ b/lib/data/data_providers/vehicle_notifier.dart
@@ -136,7 +136,17 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
state = state.copyWith(fanSpeed: update.entry.value.uint32);
}
break;
-
+ case VSSPath.vehicleDriverTemperature:
+ if (update.entry.value.hasInt32()) {
+ state = state.copyWith(driverTemperature: update.entry.value.int32);
+ }
+ break;
+ case VSSPath.vehiclePassengerTemperature:
+ if (update.entry.value.hasInt32()) {
+ state =
+ state.copyWith(passengerTemperature: update.entry.value.int32);
+ }
+ break;
// default:
// debugPrint("ERROR: Unexpected path ${update.entry.path}");
// break;
@@ -302,7 +312,6 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
}, onError: (stacktrace, errorDescriptor) {
debugPrint(stacktrace.toString());
state = const Vehicle.initialForDebug();
-
});
} catch (e) {
debugPrint(e.toString());
@@ -340,6 +349,35 @@ class VehicleNotifier extends StateNotifier<Vehicle> {
}
}
+ void setTemperature({required Side side, required int value}) {
+ var helper = ValClientHelper(channel: channel, stub: stub);
+ try {
+ switch (side) {
+ case Side.left:
+ helper.setInt32(
+ VSSPath.vehicleDriverTemperature,
+ value,
+ false,
+ );
+ state = state.copyWith(driverTemperature: value);
+ break;
+ case Side.right:
+ helper.setInt32(
+ VSSPath.vehiclePassengerTemperature,
+ value,
+ false,
+ );
+ state = state.copyWith(passengerTemperature: value);
+ break;
+ default:
+ debugPrint("ERROR: Unexpected side value $side}");
+ break;
+ }
+ } catch (e) {
+ debugPrint(e.toString());
+ }
+ }
+
void updateFanSpeed(int newValue) {
state = state.copyWith(fanSpeed: newValue);
}
diff --git a/lib/data/models/vehicle.dart b/lib/data/models/vehicle.dart
index adc6fc2..16752d3 100644
--- a/lib/data/models/vehicle.dart
+++ b/lib/data/models/vehicle.dart
@@ -22,6 +22,8 @@ class Vehicle {
final bool isRearDefrosterActive;
final bool isRecirculationActive;
final int fanSpeed;
+ final int driverTemperature;
+ final int passengerTemperature;
const Vehicle(
this.speed,
@@ -41,7 +43,10 @@ class Vehicle {
this.isFrontDefrosterActive,
this.isRearDefrosterActive,
this.isRecirculationActive,
- this.fanSpeed);
+ this.fanSpeed,
+ this.driverTemperature,
+ this.passengerTemperature,
+ );
const Vehicle.initial()
: speed = 0,
@@ -61,7 +66,9 @@ class Vehicle {
isFrontDefrosterActive = false,
isRearDefrosterActive = false,
isRecirculationActive = false,
- fanSpeed = 0;
+ fanSpeed = 0,
+ driverTemperature = 26,
+ passengerTemperature = 26;
const Vehicle.initialForDebug()
: speed = 60,
@@ -81,7 +88,9 @@ class Vehicle {
isFrontDefrosterActive = false,
isRearDefrosterActive = false,
isRecirculationActive = false,
- fanSpeed = 0;
+ fanSpeed = 0,
+ driverTemperature = 26,
+ passengerTemperature = 26;
Vehicle copyWith(
{double? speed,
@@ -101,7 +110,10 @@ class Vehicle {
bool? isFrontDefrosterActive,
bool? isRearDefrosterActive,
bool? isRecirculationActive,
- int? fanSpeed}) {
+ int? fanSpeed,
+ int? driverTemperature,
+ int? passengerTemperature,
+ }) {
return Vehicle(
speed ?? this.speed,
insideTemperature ?? this.insideTemperature,
@@ -120,7 +132,10 @@ class Vehicle {
isFrontDefrosterActive ?? this.isFrontDefrosterActive,
isRearDefrosterActive ?? this.isRearDefrosterActive,
isRecirculationActive ?? this.isRecirculationActive,
- fanSpeed ?? this.fanSpeed);
+ fanSpeed ?? this.fanSpeed,
+ driverTemperature ?? this.driverTemperature,
+ passengerTemperature ?? this.passengerTemperature,
+ );
}
Map<String, dynamic> toMap() {
@@ -142,7 +157,9 @@ class Vehicle {
'isFrontDefrosterActive': isFrontDefrosterActive,
'isRearDefrosterActive': isRearDefrosterActive,
'isRecirculationActive': isRecirculationActive,
- 'fanSpeed': fanSpeed
+ 'fanSpeed': fanSpeed,
+ 'driverTemperature': driverTemperature,
+ 'passengerTemperature': passengerTemperature,
};
}
@@ -166,6 +183,8 @@ class Vehicle {
map['isRearDefrosterActive'] ?? false,
map['isRecirculationActive'] ?? false,
map['fanSpeed'] ?? 0,
+ map['driverTemperature'] ?? 0,
+ map['passengerTemperature'] ?? 0,
);
}
@@ -176,7 +195,7 @@ class Vehicle {
@override
String toString() {
- return 'Vehicle(speed: $speed, insideTemperature: $insideTemperature, outsideTemperature: $outsideTemperature, range: $range, fuelLevel: $fuelLevel, mediaVolume: $mediaVolume, isChildLockActiveLeft: $isChildLockActiveLeft, isChildLockActiveRight: $isChildLockActiveRight, engineSpeed: $engineSpeed, frontLeftTire: $frontLeftTire, frontRightTire: $frontRightTire, rearLeftTire: $rearLeftTire, rearRightTire: $rearRightTire, isAirConditioningActive: $isAirConditioningActive, isFrontDefrosterActive: $isFrontDefrosterActive, isRearDefrosterActive: $isRearDefrosterActive, isRecirculationActive: $isRecirculationActive,fanSpeed:$fanSpeed)';
+ return 'Vehicle(speed: $speed, insideTemperature: $insideTemperature, outsideTemperature: $outsideTemperature, range: $range, fuelLevel: $fuelLevel, mediaVolume: $mediaVolume, isChildLockActiveLeft: $isChildLockActiveLeft, isChildLockActiveRight: $isChildLockActiveRight, engineSpeed: $engineSpeed, frontLeftTire: $frontLeftTire, frontRightTire: $frontRightTire, rearLeftTire: $rearLeftTire, rearRightTire: $rearRightTire, isAirConditioningActive: $isAirConditioningActive, isFrontDefrosterActive: $isFrontDefrosterActive, isRearDefrosterActive: $isRearDefrosterActive, isRecirculationActive: $isRecirculationActive,fanSpeed:$fanSpeed,driverTemperature:$driverTemperature, passengerTemperature:$passengerTemperature)';
}
@override
@@ -201,7 +220,9 @@ class Vehicle {
other.isFrontDefrosterActive == isFrontDefrosterActive &&
other.isRearDefrosterActive == isRearDefrosterActive &&
other.isRecirculationActive == isRecirculationActive &&
- other.fanSpeed == fanSpeed;
+ other.fanSpeed == fanSpeed &&
+ other.driverTemperature == driverTemperature &&
+ other.passengerTemperature == passengerTemperature;
}
@override
@@ -223,7 +244,9 @@ class Vehicle {
isFrontDefrosterActive.hashCode ^
isRearDefrosterActive.hashCode ^
isRecirculationActive.hashCode ^
- fanSpeed.hashCode;
+ fanSpeed.hashCode ^
+ driverTemperature.hashCode ^
+ passengerTemperature.hashCode;
}
// }
// / class VehicleNotifier extends StateNotifier<Vehicle> {