Warning thresholds added in drone profile. traffic light indication in drone satus menue added. layout and content optimized
This commit is contained in:
@@ -65,6 +65,52 @@ class _DroneProfileEditorState extends ConsumerState<DroneProfileEditor> {
|
||||
(key: 'maxAltitudeM', label: 'Ceiling', min: 50.0, max: 10000.0, stepBig: 100.0, stepSmall: 10.0, decimals: 0, unit: 'm'),
|
||||
],
|
||||
),
|
||||
// Ampel-Schwellwerte fuer die farbcodierten Telemetriefelder im
|
||||
// Drohnen-Status-Menue (Doku: "Schwellwerte fuer die Ampel-Kodierung im
|
||||
// Drohnenprofil anlegen", siehe domain/telemetry/telemetry_field_status.dart) -
|
||||
// je Feld Gruen-/Rot-Schwelle als eigene Gruppe, analog Climb/Descent oben.
|
||||
(
|
||||
title: 'GPS satellites alarm',
|
||||
fields: [
|
||||
(key: 'gpsSatGreenMin', label: 'Green from', min: 0.0, max: 20.0, stepBig: 2.0, stepSmall: 1.0, decimals: 0, unit: 'sat'),
|
||||
(key: 'gpsSatRedMin', label: 'Red below', min: 0.0, max: 20.0, stepBig: 2.0, stepSmall: 1.0, decimals: 0, unit: 'sat'),
|
||||
],
|
||||
),
|
||||
(
|
||||
title: 'GPS precision (HDOP) alarm',
|
||||
fields: [
|
||||
(key: 'hdopGreenMax', label: 'Green up to', min: 0.5, max: 10.0, stepBig: 1.0, stepSmall: 0.1, decimals: 1, unit: ''),
|
||||
(key: 'hdopRedMax', label: 'Red above', min: 0.5, max: 20.0, stepBig: 1.0, stepSmall: 0.1, decimals: 1, unit: ''),
|
||||
],
|
||||
),
|
||||
(
|
||||
title: 'Current draw alarm (A)',
|
||||
fields: [
|
||||
(key: 'currentGreenMaxA', label: 'Green up to', min: 1.0, max: 200.0, stepBig: 10.0, stepSmall: 1.0, decimals: 0, unit: 'A'),
|
||||
(key: 'currentRedMaxA', label: 'Red above', min: 1.0, max: 300.0, stepBig: 10.0, stepSmall: 1.0, decimals: 0, unit: 'A'),
|
||||
],
|
||||
),
|
||||
(
|
||||
title: 'Battery voltage alarm (V)',
|
||||
fields: [
|
||||
(key: 'batteryVoltageGreenMinV', label: 'Green from', min: 5.0, max: 60.0, stepBig: 1.0, stepSmall: 0.1, decimals: 1, unit: 'V'),
|
||||
(key: 'batteryVoltageRedMinV', label: 'Red below', min: 5.0, max: 60.0, stepBig: 1.0, stepSmall: 0.1, decimals: 1, unit: 'V'),
|
||||
],
|
||||
),
|
||||
(
|
||||
title: 'RX link quality alarm (%)',
|
||||
fields: [
|
||||
(key: 'rxQualityGreenMin', label: 'Green from', min: 0.0, max: 100.0, stepBig: 10.0, stepSmall: 1.0, decimals: 0, unit: '%'),
|
||||
(key: 'rxQualityRedMin', label: 'Red below', min: 0.0, max: 100.0, stepBig: 10.0, stepSmall: 1.0, decimals: 0, unit: '%'),
|
||||
],
|
||||
),
|
||||
(
|
||||
title: 'RX SNR alarm (dB)',
|
||||
fields: [
|
||||
(key: 'rxSnrGreenMinDb', label: 'Green from', min: -30.0, max: 30.0, stepBig: 5.0, stepSmall: 1.0, decimals: 0, unit: 'dB'),
|
||||
(key: 'rxSnrRedMinDb', label: 'Red below', min: -30.0, max: 30.0, stepBig: 5.0, stepSmall: 1.0, decimals: 0, unit: 'dB'),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
double _fieldValue(DroneProfile p, String key) => switch (key) {
|
||||
@@ -79,6 +125,18 @@ class _DroneProfileEditorState extends ConsumerState<DroneProfileEditor> {
|
||||
'maxRangeM' => p.maxRangeM,
|
||||
'maxEnduranceMin' => p.maxEnduranceMin,
|
||||
'maxAltitudeM' => p.maxAltitudeM,
|
||||
'gpsSatGreenMin' => p.gpsSatGreenMin,
|
||||
'gpsSatRedMin' => p.gpsSatRedMin,
|
||||
'hdopGreenMax' => p.hdopGreenMax,
|
||||
'hdopRedMax' => p.hdopRedMax,
|
||||
'currentGreenMaxA' => p.currentGreenMaxA,
|
||||
'currentRedMaxA' => p.currentRedMaxA,
|
||||
'batteryVoltageGreenMinV' => p.batteryVoltageGreenMinV,
|
||||
'batteryVoltageRedMinV' => p.batteryVoltageRedMinV,
|
||||
'rxQualityGreenMin' => p.rxQualityGreenMin,
|
||||
'rxQualityRedMin' => p.rxQualityRedMin,
|
||||
'rxSnrGreenMinDb' => p.rxSnrGreenMinDb,
|
||||
'rxSnrRedMinDb' => p.rxSnrRedMinDb,
|
||||
_ => throw ArgumentError(key),
|
||||
};
|
||||
|
||||
@@ -120,6 +178,18 @@ class _DroneProfileEditorState extends ConsumerState<DroneProfileEditor> {
|
||||
maxRangeM: v('maxRangeM'),
|
||||
maxEnduranceMin: v('maxEnduranceMin'),
|
||||
maxAltitudeM: v('maxAltitudeM'),
|
||||
gpsSatGreenMin: v('gpsSatGreenMin'),
|
||||
gpsSatRedMin: v('gpsSatRedMin'),
|
||||
hdopGreenMax: v('hdopGreenMax'),
|
||||
hdopRedMax: v('hdopRedMax'),
|
||||
currentGreenMaxA: v('currentGreenMaxA'),
|
||||
currentRedMaxA: v('currentRedMaxA'),
|
||||
batteryVoltageGreenMinV: v('batteryVoltageGreenMinV'),
|
||||
batteryVoltageRedMinV: v('batteryVoltageRedMinV'),
|
||||
rxQualityGreenMin: v('rxQualityGreenMin'),
|
||||
rxQualityRedMin: v('rxQualityRedMin'),
|
||||
rxSnrGreenMinDb: v('rxSnrGreenMinDb'),
|
||||
rxSnrRedMinDb: v('rxSnrRedMinDb'),
|
||||
);
|
||||
|
||||
final repo = ref.read(droneProfileRepositoryProvider);
|
||||
|
||||
@@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../domain/telemetry/drone_event.dart';
|
||||
import '../../domain/telemetry/drone_status.dart';
|
||||
import '../../domain/telemetry/telemetry_field_status.dart';
|
||||
import '../dmc_colors.dart';
|
||||
import '../providers/active_drone_profile_provider.dart';
|
||||
import '../providers/drone_event_log_provider.dart';
|
||||
import '../providers/telemetry_provider.dart';
|
||||
|
||||
@@ -109,36 +112,56 @@ class _DroneStatusWarningsPanelState extends ConsumerState<DroneStatusWarningsPa
|
||||
|
||||
Widget _statusTab() {
|
||||
final telemetry = ref.watch(telemetryProvider);
|
||||
final droneProfile = ref.watch(activeDroneProfileProvider);
|
||||
return telemetry.when(
|
||||
data: (frame) => ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_statusRow('GPS satellites', '${frame.numSat}'),
|
||||
_statusRow(
|
||||
'GPS precision (HDOP)',
|
||||
frame.hasFix ? frame.hdop.toStringAsFixed(2) : '—',
|
||||
),
|
||||
_statusRow(
|
||||
'GPS coordinates',
|
||||
frame.hasFix
|
||||
? '${frame.lat.toStringAsFixed(6)}, ${frame.lon.toStringAsFixed(6)}'
|
||||
: '—',
|
||||
),
|
||||
_statusRow('Current draw', '${frame.currentA.toStringAsFixed(1)} A'),
|
||||
_statusRow('Battery voltage', '${frame.batteryVoltage.toStringAsFixed(2)} V'),
|
||||
_statusRow('Heading', '${frame.headingDeg.round()}°'),
|
||||
_statusRow('RX quality / SNR', '${frame.linkQuality}% / ${frame.snrDb} dB'),
|
||||
// Downlink-Qualitaet/-SNR und die Akku-SoC des Sendemoduls selbst
|
||||
// (nicht der Drohne) sind ueber keinen MSP-GET-Befehl abrufbar -
|
||||
// rxLinkStatistics_t (iNAV 9.1, rx.h) hat zwar ein downlinkLQ-Feld,
|
||||
// das wird aber nur per MSP2_COMMON_SET_MSP_RC_LINK_STATS von
|
||||
// aussen HINEINgeschrieben, nie per GET zurueckgelesen; eine
|
||||
// Downlink-SNR oder eine Sender-Akkugroesse existiert im Struct
|
||||
// ueberhaupt nicht (verifiziert im lokalen iNAV-Checkout,
|
||||
// release/9.1).
|
||||
_statusRow('TX battery SoC / quality / SNR', 'Not available (not exposed via MSP)'),
|
||||
],
|
||||
),
|
||||
data: (frame) {
|
||||
final fieldStatus = computeTelemetryFieldStatus(
|
||||
numSat: frame.numSat,
|
||||
hasFix: frame.hasFix,
|
||||
hdop: frame.hdop,
|
||||
currentA: frame.currentA,
|
||||
batteryVoltage: frame.batteryVoltage,
|
||||
linkQuality: frame.linkQuality,
|
||||
snrDb: frame.snrDb,
|
||||
profile: droneProfile,
|
||||
);
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// Farbcodierte Felder zuerst (Doku: "drone status felder im
|
||||
// menue auch farblich kodieren", Schwellwerte je Drohnenprofil -
|
||||
// siehe computeTelemetryFieldStatus), informelle Felder ohne
|
||||
// Ampel-Bewertung (Koordinaten/Heading/Alt/Speed) danach.
|
||||
_statusRow('GPS satellites', '${frame.numSat}', level: fieldStatus.numSat),
|
||||
_statusRow(
|
||||
'GPS precision (HDOP)',
|
||||
frame.hasFix ? frame.hdop.toStringAsFixed(2) : '—',
|
||||
level: fieldStatus.hdop,
|
||||
),
|
||||
_statusRow(
|
||||
'Current draw',
|
||||
'${frame.currentA.toStringAsFixed(1)} A',
|
||||
level: fieldStatus.currentA,
|
||||
),
|
||||
_statusRow(
|
||||
'Battery voltage',
|
||||
'${frame.batteryVoltage.toStringAsFixed(2)} V',
|
||||
level: fieldStatus.batteryVoltage,
|
||||
),
|
||||
_statusRow('RX quality', '${frame.linkQuality}%', level: fieldStatus.rxQuality),
|
||||
_statusRow('RX SNR', '${frame.snrDb} dB', level: fieldStatus.rxSnr),
|
||||
_statusRow(
|
||||
'GPS coordinates',
|
||||
frame.hasFix
|
||||
? '${frame.lat.toStringAsFixed(6)}, ${frame.lon.toStringAsFixed(6)}'
|
||||
: '—',
|
||||
),
|
||||
_statusRow('Heading', '${frame.headingDeg.round()}°'),
|
||||
_statusRow('Altitude', '${frame.altitudeM.toStringAsFixed(0)} m'),
|
||||
_statusRow('Speed', '${frame.speedMs.toStringAsFixed(1)} m/s'),
|
||||
],
|
||||
);
|
||||
},
|
||||
loading: () => const Center(
|
||||
child: CircularProgressIndicator(color: Color(0xFF4D9DFF)),
|
||||
),
|
||||
@@ -148,7 +171,14 @@ class _DroneStatusWarningsPanelState extends ConsumerState<DroneStatusWarningsPa
|
||||
);
|
||||
}
|
||||
|
||||
Widget _statusRow(String label, String value) {
|
||||
static const _signalColors = {
|
||||
SignalLevel.green: DmcColors.flyModeColor,
|
||||
SignalLevel.yellow: DmcColors.pafAmber,
|
||||
SignalLevel.red: DmcColors.warnRed,
|
||||
};
|
||||
|
||||
Widget _statusRow(String label, String value, {SignalLevel? level}) {
|
||||
final valueColor = level != null ? _signalColors[level]! : Colors.white;
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
@@ -159,7 +189,15 @@ class _DroneStatusWarningsPanelState extends ConsumerState<DroneStatusWarningsPa
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(label, style: const TextStyle(color: Colors.white70))),
|
||||
Text(value, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w600)),
|
||||
if (level != null) ...[
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
margin: const EdgeInsets.only(right: 8),
|
||||
decoration: BoxDecoration(color: valueColor, shape: BoxShape.circle),
|
||||
),
|
||||
],
|
||||
Text(value, style: TextStyle(color: valueColor, fontWeight: FontWeight.w600)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user