72 lines
1.9 KiB
Dart
72 lines
1.9 KiB
Dart
|
|
import 'parser.dart';
|
|
import 'sentence.dart';
|
|
import 'types.dart';
|
|
|
|
// ignore_for_file: constant_identifier_names
|
|
|
|
const TypeRMC = "RMC";
|
|
// ValidRMC character
|
|
const ValidRMC = "A";
|
|
// InvalidRMC character
|
|
const InvalidRMC = "V";
|
|
|
|
class RMC {
|
|
BaseSentence sentence; // sentence
|
|
Time time; // Time Stamp
|
|
String validity; // validity - A-ok, V-invalid
|
|
double latitude; // Latitude
|
|
double longitude; // Longitude
|
|
double speed; // Speed in knots
|
|
double course; // True course
|
|
Date date; // Date
|
|
double variation; // Magnetic variation
|
|
String? ffaMode; // FAA mode indicator (filled in NMEA 2.3 and later)
|
|
String? navStatus; // Nav Status (NMEA 4.1 and later)
|
|
|
|
RMC({
|
|
required this.sentence,
|
|
required this.time,
|
|
required this.validity,
|
|
required this.latitude,
|
|
required this.longitude,
|
|
required this.speed,
|
|
required this.course,
|
|
required this.date,
|
|
required this.variation,
|
|
this.ffaMode,
|
|
this.navStatus,
|
|
}) ;
|
|
|
|
static RMC newRMC(BaseSentence s) {
|
|
var p = Parser(s);
|
|
var m = RMC(
|
|
sentence: s,
|
|
time: p.time(0, "time"),
|
|
validity: p.enumString(1, "validity", [ValidRMC, InvalidRMC]),
|
|
latitude: p.latLong(2, 3, "latitude"),
|
|
longitude: p.latLong(4, 5, "longitude"),
|
|
speed: p.float64(6, "speed"),
|
|
course: p.float64(7, "course"),
|
|
date: p.date(8, "date"),
|
|
variation: p.float64(9, "variation"),//是否有效
|
|
);
|
|
if (p.enumString(10, "direction", [West, East]) == West) {
|
|
m.variation = 0 - m.variation;
|
|
}
|
|
if (s.fields.length > 11) {
|
|
m.ffaMode = p.string(11,
|
|
"FAA mode"); // not enum because some devices have proprietary "non-nmea" values
|
|
}
|
|
if (s.fields.length > 12) {
|
|
m.navStatus = p.enumString(12, "navigation status", [
|
|
NavStatusSafe,
|
|
NavStatusCaution,
|
|
NavStatusUnsafe,
|
|
NavStatusNotValid,
|
|
]);
|
|
}
|
|
return m;
|
|
}
|
|
}
|