gnssview_old/plugins/gnss/lib/nmea/gsa.dart
tanlinxing 553bde932c getx
2024-07-31 19:04:11 +08:00

63 lines
1.3 KiB
Dart

// ignore_for_file: constant_identifier_names
import 'parser.dart';
import 'sentence.dart';
const TypeGSA = "GSA";
// Auto - Field 1, auto or manual fix.
const Auto = "A";
// Manual - Field 1, auto or manual fix.
const Manual = "M";
// FixNone - Field 2, fix type.
const FixNone = "1";
// Fix2D - Field 2, fix type.
const Fix2D = "2";
// Fix3D - Field 2, fix type.
const Fix3D = "3";
class GSA {
String mode;
String fixType;
List<String> sv;
double pdop;
double hdop;
double vdop;
int systemID;
GSA(
{required this.mode,
required this.fixType,
required this.sv,
required this.pdop,
required this.hdop,
required this.vdop,
required this.systemID});
static GSA newGSA(BaseSentence s) {
var p = Parser(s);
var m = GSA(
mode: p.enumString(0, "selection mode", [Auto, Manual]),
fixType: p.enumString(1, "fix type", [FixNone, Fix2D, Fix3D]),
sv: [],
pdop: 0,
hdop: 0,
vdop: 0,
systemID: 0,
);
for (int i = 2; i < 14; i++) {
var v = p.string(i, "satellite in view");
if (v != "") {
m.sv.add(v);
}
}
m.pdop = p.float64(14, "pdop");
m.hdop = p.float64(15, "hdop");
m.vdop = p.float64(16, "vdop");
if (s.fields.length > 17) {
m.systemID = p.int64(17, "system ID");
}
return m;
}
}