From be4da312ad1f33cea62ba7c8768bb4060ee6a178 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Mon, 2 Jan 2023 15:35:50 -0500 Subject: VSS signal fixes Changes: - Update some signals for VSS 3.0 changes that were missed on the initial pass. - Improve error handling in VSS parsing to display error message from the VIS server. - Add explicit knob to disable navigation display with a default value of disabled, so that mode switches triggered by the steering wheel "Info" signal do not unexpectedly activate it. Bug-AGL: SPEC-4664 Signed-off-by: Scott Murray Change-Id: Ib5fba613053f2860a0a5ff7331c78d6ab9590848 (cherry picked from commit c605ab037edcb35a7aa365fa6abe7fd6289d8a19) --- lib/cluster_config.dart | 13 +++++++++++-- lib/screen/home.dart | 6 +++++- lib/vehicle_signal/vehicle_signal_methods.dart | 8 ++++---- lib/vehicle_signal/vehicle_signal_path.dart | 20 +++++++++----------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/lib/cluster_config.dart b/lib/cluster_config.dart index 10e152d..7a81360 100644 --- a/lib/cluster_config.dart +++ b/lib/cluster_config.dart @@ -23,7 +23,7 @@ class _GetConfigState extends ConsumerState { String configFilePath = '/etc/xdg/AGL/flutter-cluster-dashboard.yaml'; String orsKeyFilePath = '/etc/default/openroutekey'; - + String keyContent = ""; final configFile = File(configFilePath); @@ -34,6 +34,7 @@ class _GetConfigState extends ConsumerState { configStateProvider.update( hostname: yamlMap['hostname'], port: yamlMap['port'], + enableNavigation: yamlMap['enableNavigation'], homeLat: yamlMap['homeLat'], homeLng: yamlMap['homeLng'], orsPathParam: yamlMap['orsPathParam'], @@ -43,7 +44,8 @@ class _GetConfigState extends ConsumerState { orsKeyFile.readAsString().then((content) { keyContent = content.split(':')[1].trim(); - if (keyContent.isNotEmpty && keyContent != 'YOU_NEED_TO_SET_IT_IN_LOCAL_CONF') { + if (keyContent.isNotEmpty && + keyContent != 'YOU_NEED_TO_SET_IT_IN_LOCAL_CONF') { configStateProvider.update(orsApiKey: keyContent); } else { print("WARNING: openrouteservice API Key not found !"); @@ -84,6 +86,7 @@ class ClusterConfig { required this.hostname, required this.port, required this.kuksaAuthToken, + required this.enableNavigation, required this.orsApiKey, required this.orsPathParam, required this.homeLat, @@ -92,6 +95,7 @@ class ClusterConfig { final String hostname; final int port; final String kuksaAuthToken; + final bool enableNavigation; final double homeLat; final double homeLng; final String orsApiKey; @@ -101,6 +105,7 @@ class ClusterConfig { String? hostname, int? port, String? kuksaAuthToken, + bool? enableNavigation, double? homeLat, double? homeLng, String? orsApiKey, @@ -110,6 +115,7 @@ class ClusterConfig { hostname: hostname ?? this.hostname, port: port ?? this.port, kuksaAuthToken: kuksaAuthToken ?? this.kuksaAuthToken, + enableNavigation: enableNavigation ?? this.enableNavigation, orsApiKey: orsApiKey ?? this.orsApiKey, orsPathParam: orsPathParam ?? this.orsPathParam, homeLat: homeLat ?? this.homeLat, @@ -123,6 +129,7 @@ class ClusterConfigStateNotifier extends StateNotifier { hostname: "", port: 0, kuksaAuthToken: "", + enableNavigation: false, orsApiKey: "", orsPathParam: "", homeLat: 0, @@ -132,6 +139,7 @@ class ClusterConfigStateNotifier extends StateNotifier { String? hostname, int? port, String? kuksaAuthToken, + bool? enableNavigation, double? homeLat, double? homeLng, String? orsApiKey, @@ -141,6 +149,7 @@ class ClusterConfigStateNotifier extends StateNotifier { hostname: hostname, port: port, kuksaAuthToken: kuksaAuthToken, + enableNavigation: enableNavigation, homeLat: homeLat, homeLng: homeLng, orsApiKey: orsApiKey, diff --git a/lib/screen/home.dart b/lib/screen/home.dart index 4cfa770..3bd47a8 100644 --- a/lib/screen/home.dart +++ b/lib/screen/home.dart @@ -15,6 +15,7 @@ import 'package:flutter_cluster_dashboard/screen/widgets/guages/speed_guage_anim import 'package:flutter_cluster_dashboard/screen/widgets/signals.dart'; import 'package:flutter_cluster_dashboard/screen/widgets/turn_signal.dart'; import 'package:flutter_cluster_dashboard/vehicle_signal/vehicle_signal_provider.dart'; +import 'package:flutter_cluster_dashboard/cluster_config.dart'; import 'package:intl/intl.dart'; class Home extends ConsumerWidget { @@ -46,6 +47,7 @@ class Home extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final clusterConfig = ref.read(clusterConfigStateprovider); final vehicle = ref.watch(vehicleSignalProvider); final clock = ref.watch(clockProvider); final windowHeight = MediaQuery.of(context).size.height; @@ -222,7 +224,9 @@ class Home extends ConsumerWidget { fit: FlexFit.tight, child: SizedBox( width: (330 * screenHeight) / 720, - child: (vehicle.isSteeringInfo) + child: (clusterConfig + .enableNavigation && + vehicle.isSteeringInfo) ? const NavigationHome() : Padding( padding: EdgeInsets.symmetric( diff --git a/lib/vehicle_signal/vehicle_signal_methods.dart b/lib/vehicle_signal/vehicle_signal_methods.dart index 04c740c..7f3d8e0 100644 --- a/lib/vehicle_signal/vehicle_signal_methods.dart +++ b/lib/vehicle_signal/vehicle_signal_methods.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:io'; +import 'package:flutter/rendering.dart'; import 'package:flutter_cluster_dashboard/cluster_config.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_cluster_dashboard/map/networkPolyline.dart'; @@ -221,8 +222,7 @@ class VISS { vehicleSignal.update(isCruiseControlError: dp['value']); break; case VSPath.vehicleCruiseControlSpeedSet: - vehicleSignal.update( - cruiseControlSpeed: dp['value']); + vehicleSignal.update(cruiseControlSpeed: dp['value']); break; case VSPath.vehicleCruiseControlSpeedisActive: vehicleSignal.update(isCruiseControlActive: dp['value']); @@ -306,8 +306,8 @@ class VISS { .containsKey("dp")) { print("ERROR:'dp':key not found !"); } - } else { - print("ERROR:'data':key not found!"); + } else if (dataMap.containsKey("error")) { + print("ERROR: ${dataMap['error']['message']}"); } } } diff --git a/lib/vehicle_signal/vehicle_signal_path.dart b/lib/vehicle_signal/vehicle_signal_path.dart index 25cc27a..4902811 100644 --- a/lib/vehicle_signal/vehicle_signal_path.dart +++ b/lib/vehicle_signal/vehicle_signal_path.dart @@ -6,7 +6,7 @@ class VSPath { "Vehicle.Powertrain.CombustionEngine.Speed"; static const String vehicleFuelLevel = "Vehicle.Powertrain.FuelSystem.Level"; static const String vehicleCoolantTemp = - "Vehicle.Powertrain.CombustionEngine.Engine.ECT"; + "Vehicle.Powertrain.CombustionEngine.ECT"; static const String vehicleLeftIndicator = "Vehicle.Body.Lights.IsLeftIndicatorOn"; static const String vehicleRightIndicator = @@ -19,22 +19,22 @@ class VSPath { static const String vehicleParkingLightOn = "Vehicle.Body.Lights.IsParkingOn"; static const String vehicleHazardLightOn = "Vehicle.Body.Lights.IsHazardOn"; static const String vehicleTravelledDistance = "Vehicle.TravelledDistance"; - static const String vehicleTrunkLocked = "Vehicle.Body.Trunk.IsLocked"; - static const String vehicleTrunkOpen = "Vehicle.Body.Trunk.IsOpen"; + 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"; static const String vehicleAmbientAirTemperature = - "Vehicle.AmbientAirTemperature"; - static const String vehicleMIL = "Vehicle.OBD.Status.MIL"; + "Vehicle.Exterior.AirTemperature"; + static const String vehicleMIL = "Vehicle.OBD.Status.IsMILOn"; static const String vehicleCruiseControlError = - "Vehicle.ADAS.CruiseControl.Error"; + "Vehicle.ADAS.CruiseControl.IsError"; static const String vehicleCruiseControlSpeedSet = "Vehicle.ADAS.CruiseControl.SpeedSet"; static const String vehicleCruiseControlSpeedisActive = "Vehicle.ADAS.CruiseControl.IsActive"; static const String vehicleBatteryChargingStatus = - "Vehicle.Powertrain.Battery.Charging.Status"; + "Vehicle.Powertrain.TractionBattery.Charging.IsCharging"; static const String steeringCruiseEnable = "Vehicle.Cabin.SteeringWheel.Switches.CruiseEnable"; @@ -51,10 +51,8 @@ class VSPath { static const String vehicleDistanceUnit = "Vehicle.Cabin.Infotainment.HMI.DistanceUnit"; - static const String vehicleCurrLat = - "Vehicle.Cabin.Infotainment.Navigation.CurrentLocation.Latitude"; - static const String vehicleCurrLng = - "Vehicle.Cabin.Infotainment.Navigation.CurrentLocation.Longitude"; + static const String vehicleCurrLat = "Vehicle.CurrentLocation.Latitude"; + static const String vehicleCurrLng = "Vehicle.CurrentLocation.Longitude"; static const String vehicleDesLat = "Vehicle.Cabin.Infotainment.Navigation.DestinationSet.Latitude"; static const String vehicleDesLng = -- cgit 1.2.3-korg