diff options
Diffstat (limited to 'lib/vehicle-signals')
-rw-r--r-- | lib/vehicle-signals/vehicle_status_provider.dart | 1 | ||||
-rw-r--r-- | lib/vehicle-signals/vss_client.dart | 44 | ||||
-rw-r--r-- | lib/vehicle-signals/vss_path.dart | 11 | ||||
-rw-r--r-- | lib/vehicle-signals/vss_provider.dart | 86 |
4 files changed, 71 insertions, 71 deletions
diff --git a/lib/vehicle-signals/vehicle_status_provider.dart b/lib/vehicle-signals/vehicle_status_provider.dart index da593cb..86edaf7 100644 --- a/lib/vehicle-signals/vehicle_status_provider.dart +++ b/lib/vehicle-signals/vehicle_status_provider.dart @@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
enum DistanceUnit { kilometers, miles }
+
enum TemperatureUnit { celsius, fahrenheit }
class VehicleStatus {
diff --git a/lib/vehicle-signals/vss_client.dart b/lib/vehicle-signals/vss_client.dart index e416d87..4a44a81 100644 --- a/lib/vehicle-signals/vss_client.dart +++ b/lib/vehicle-signals/vss_client.dart @@ -1,7 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -import 'dart:io'; -import 'package:meta/meta.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:grpc/grpc.dart'; import 'package:flutter_cluster_dashboard/generated/kuksa/val/v1/val.pbgrpc.dart'; @@ -17,14 +14,17 @@ abstract class VssClient { // Extenders will likely override this final List<String> signals = []; - VssClient({required this.config, required this.channel, required this.stub, required this.ref}); + VssClient( + {required this.config, + required this.channel, + required this.stub, + required this.ref}); // Abstract method extenders must implement void handleSignalUpdates(EntryUpdate update); void run() async { - if (signals.isEmpty) - return; + if (signals.isEmpty) return; var request = SubscribeRequest(); for (var i = 0; i < signals.length; i++) { @@ -38,13 +38,13 @@ abstract class VssClient { try { Map<String, String> metadata = {}; if (config.authorization.isNotEmpty) { - metadata = {'authorization': "Bearer ${config.authorization}" }; + metadata = {'authorization': "Bearer ${config.authorization}"}; } - var responseStream = stub.subscribe(request, options: CallOptions(metadata: metadata)); + var responseStream = + stub.subscribe(request, options: CallOptions(metadata: metadata)); await for (var response in responseStream) { for (var update in response.updates) { - if (!(update.hasEntry() && update.entry.hasPath())) - continue; + if (!(update.hasEntry() && update.entry.hasPath())) continue; handleSignalUpdates(update); } } @@ -54,44 +54,37 @@ abstract class VssClient { } void setUint32(String path, int value, [bool actuator = true]) async { - var dp = Datapoint() - ..uint32 = value; + var dp = Datapoint()..uint32 = value; set(path, dp, actuator); } void setInt32(String path, int value, [bool actuator = true]) async { - var dp = Datapoint() - ..int32 = value; + var dp = Datapoint()..int32 = value; set(path, dp, actuator); } void setBool(String path, bool value, [bool actuator = true]) async { - var dp = Datapoint() - ..bool_12 = value; + var dp = Datapoint()..bool_12 = value; set(path, dp, actuator); } void setString(String path, String value, [bool actuator = true]) async { - var dp = Datapoint() - ..string = value; + var dp = Datapoint()..string = value; set(path, dp, actuator); } void setFloat(String path, double value, [bool actuator = true]) async { - var dp = Datapoint() - ..float = value; + var dp = Datapoint()..float = value; set(path, dp, actuator); } void setDouble(String path, double value, [bool actuator = true]) async { - var dp = Datapoint() - ..double_18 = value; + var dp = Datapoint()..double_18 = value; set(path, dp, actuator); } void set(String path, Datapoint dp, bool actuator) async { - var entry = DataEntry() - ..path = path; + var entry = DataEntry()..path = path; var update = EntryUpdate(); if (actuator) { entry.actuatorTarget = dp; @@ -105,9 +98,8 @@ abstract class VssClient { request.updates.add(update); Map<String, String> metadata = {}; if (config.authorization.isNotEmpty) { - metadata = {'authorization': "Bearer ${config.authorization}" }; + metadata = {'authorization': "Bearer ${config.authorization}"}; } await stub.set(request, options: CallOptions(metadata: metadata)); } - } diff --git a/lib/vehicle-signals/vss_path.dart b/lib/vehicle-signals/vss_path.dart index 047ad18..dd2bff1 100644 --- a/lib/vehicle-signals/vss_path.dart +++ b/lib/vehicle-signals/vss_path.dart @@ -6,7 +6,8 @@ class VSSPath { static const String vehicleEngineRPM =
"Vehicle.Powertrain.CombustionEngine.Speed";
- static const String vehicleFuelLevel = "Vehicle.Powertrain.FuelSystem.RelativeLevel";
+ static const String vehicleFuelLevel =
+ "Vehicle.Powertrain.FuelSystem.RelativeLevel";
static const String vehicleCoolantTemp =
"Vehicle.Powertrain.CombustionEngine.ECT";
@@ -28,16 +29,18 @@ class VSSPath { static const String vehicleHighBeamOn = "Vehicle.Body.Lights.Beam.High.IsOn";
- static const String vehicleParkingLightOn = "Vehicle.Body.Lights.Parking.IsOn";
+ static const String vehicleParkingLightOn =
+ "Vehicle.Body.Lights.Parking.IsOn";
- static const String vehicleHazardLightOn = "Vehicle.Body.Lights.Hazard.IsSignaling";
+ static const String vehicleHazardLightOn =
+ "Vehicle.Body.Lights.Hazard.IsSignaling";
static const String vehicleTraveledDistance = "Vehicle.TraveledDistance";
static const String vehicleTrunkLocked = "Vehicle.Body.Trunk.Rear.IsLocked";
static const String vehicleTrunkOpen = "Vehicle.Body.Trunk.Rear.IsOpen";
-
+
// \"normal\",\"sport\",\"economy\",\"snow\",\"rain\"]
static const String vehiclePerformanceMode =
"Vehicle.Powertrain.Transmission.PerformanceMode";
diff --git a/lib/vehicle-signals/vss_provider.dart b/lib/vehicle-signals/vss_provider.dart index 5c62b96..b6c7036 100644 --- a/lib/vehicle-signals/vss_provider.dart +++ b/lib/vehicle-signals/vss_provider.dart @@ -1,11 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 -import 'dart:io'; -import 'package:meta/meta.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:grpc/grpc.dart'; import 'package:flutter_cluster_dashboard/generated/kuksa/val/v1/val.pbgrpc.dart'; -import 'package:flutter_cluster_dashboard/generated/kuksa/val/v1/types.pb.dart'; import 'package:flutter_cluster_dashboard/config.dart'; import 'package:flutter_cluster_dashboard/vehicle-signals/vss_client.dart'; import 'package:flutter_cluster_dashboard/vehicle-signals/vss_path.dart'; @@ -14,37 +11,41 @@ import 'package:flutter_cluster_dashboard/vehicle-signals/vehicle_status_provide class DashboardVssClient extends VssClient { @override final List<String> signals = [ - VSSPath.vehicleSpeed, - VSSPath.vehicleEngineRPM, - VSSPath.vehicleFuelLevel, - VSSPath.vehicleCoolantTemp, - VSSPath.vehicleAmbientAirTemperature, - VSSPath.vehicleLeftIndicator, - VSSPath.vehicleRightIndicator, - VSSPath.vehicleHazardLightOn, - VSSPath.vehicleHighBeamOn, - VSSPath.vehicleLowBeamOn, - VSSPath.vehicleSelectedGear, - VSSPath.vehiclePerformanceMode, - VSSPath.vehicleParkingLightOn, - VSSPath.vehicleTrunkLocked, - VSSPath.vehicleTrunkOpen, - VSSPath.vehicleMIL, - VSSPath.vehicleCruiseControlError, - VSSPath.vehicleCruiseControlSpeedSet, - VSSPath.vehicleCruiseControlActive, - VSSPath.vehicleBatteryChargingStatus, - VSSPath.vehicleDistanceUnit, - VSSPath.vehicleTemperatureUnit, - VSSPath.steeringCruiseEnable, - VSSPath.steeringCruiseSet, - VSSPath.steeringCruiseResume, - VSSPath.steeringCruiseCancel, - VSSPath.steeringInfo, - VSSPath.steeringLaneDepWarn - ]; + VSSPath.vehicleSpeed, + VSSPath.vehicleEngineRPM, + VSSPath.vehicleFuelLevel, + VSSPath.vehicleCoolantTemp, + VSSPath.vehicleAmbientAirTemperature, + VSSPath.vehicleLeftIndicator, + VSSPath.vehicleRightIndicator, + VSSPath.vehicleHazardLightOn, + VSSPath.vehicleHighBeamOn, + VSSPath.vehicleLowBeamOn, + VSSPath.vehicleSelectedGear, + VSSPath.vehiclePerformanceMode, + VSSPath.vehicleParkingLightOn, + VSSPath.vehicleTrunkLocked, + VSSPath.vehicleTrunkOpen, + VSSPath.vehicleMIL, + VSSPath.vehicleCruiseControlError, + VSSPath.vehicleCruiseControlSpeedSet, + VSSPath.vehicleCruiseControlActive, + VSSPath.vehicleBatteryChargingStatus, + VSSPath.vehicleDistanceUnit, + VSSPath.vehicleTemperatureUnit, + VSSPath.steeringCruiseEnable, + VSSPath.steeringCruiseSet, + VSSPath.steeringCruiseResume, + VSSPath.steeringCruiseCancel, + VSSPath.steeringInfo, + VSSPath.steeringLaneDepWarn + ]; - DashboardVssClient({required super.config, required super.channel, required super.stub, required super.ref}); + DashboardVssClient( + {required super.config, + required super.channel, + required super.stub, + required super.ref}); static String? numToGear(int? number) { switch (number) { @@ -163,7 +164,8 @@ class DashboardVssClient extends VssClient { break; case VSSPath.vehicleCruiseControlError: if (update.entry.value.hasBool_12()) { - vehicleStatus.update(isCruiseControlError: update.entry.value.bool_12); + vehicleStatus.update( + isCruiseControlError: update.entry.value.bool_12); } break; case VSSPath.vehicleCruiseControlSpeedSet: @@ -173,7 +175,8 @@ class DashboardVssClient extends VssClient { break; case VSSPath.vehicleCruiseControlActive: if (update.entry.value.hasBool_12()) { - vehicleStatus.update(isCruiseControlActive: update.entry.value.bool_12); + vehicleStatus.update( + isCruiseControlActive: update.entry.value.bool_12); } break; case VSSPath.vehicleBatteryChargingStatus: @@ -184,8 +187,7 @@ class DashboardVssClient extends VssClient { case VSSPath.vehicleDistanceUnit: if (update.entry.value.hasString()) { DistanceUnit unit = DistanceUnit.kilometers; - if (update.entry.value.string == "MILES") - unit = DistanceUnit.miles; + if (update.entry.value.string == "MILES") unit = DistanceUnit.miles; vehicleStatus.update(distanceUnit: unit); } break; @@ -266,17 +268,19 @@ final vssClientProvider = Provider((ref) { if (config.use_tls && config.ca_certificate.isNotEmpty) { print("Using TLS"); if (config.tls_server_name.isNotEmpty) - creds = ChannelCredentials.secure(certificates: config.ca_certificate, authority: config.tls_server_name); + creds = ChannelCredentials.secure( + certificates: config.ca_certificate, + authority: config.tls_server_name); else creds = ChannelCredentials.secure(certificates: config.ca_certificate); } else { creds = ChannelCredentials.insecure(); } final channel = ClientChannel(config.hostname, - port: config.port, - options: ChannelOptions(credentials: creds)); + port: config.port, options: ChannelOptions(credentials: creds)); final stub = VALClient(channel); - return DashboardVssClient(config: config, channel: channel, stub: stub, ref: ref); + return DashboardVssClient( + config: config, channel: channel, stub: stub, ref: ref); }); |