62 lines
2.2 KiB
Dart
62 lines
2.2 KiB
Dart
|
// ignore_for_file: constant_identifier_names
|
||
|
|
||
|
import 'sentence.dart';
|
||
|
|
||
|
import 'parser.dart';
|
||
|
import 'types.dart';
|
||
|
|
||
|
const TypeBWR = "BWR";
|
||
|
|
||
|
class BWR {
|
||
|
Time time; // UTC Time
|
||
|
double latitude; // latitude of waypoint
|
||
|
double longitude; // longitude of waypoint
|
||
|
double bearingTrue; // true bearing in degrees
|
||
|
String bearingTrueType; // is type of true bearing
|
||
|
double bearingMagnetic; // magnetic bearing in degrees
|
||
|
String bearingMagneticType; // is type of magnetic bearing
|
||
|
double distanceNauticalMiles; // distance to waypoint in nautical miles
|
||
|
String
|
||
|
distanceNauticalMilesUnit; // is unit of distance to waypoint nautical miles
|
||
|
String destinationWaypointID; // destination waypoint ID
|
||
|
String ffaMode; // FAA mode indicator (filled in NMEA 2.3 and later)
|
||
|
BWR({
|
||
|
required this.time,
|
||
|
required this.latitude,
|
||
|
required this.longitude,
|
||
|
required this.bearingTrue,
|
||
|
required this.bearingTrueType,
|
||
|
required this.bearingMagnetic,
|
||
|
required this.bearingMagneticType,
|
||
|
required this.distanceNauticalMiles,
|
||
|
required this.distanceNauticalMilesUnit,
|
||
|
required this.destinationWaypointID,
|
||
|
required this.ffaMode,
|
||
|
});
|
||
|
static BWR newBWR(BaseSentence s) {
|
||
|
var p = Parser(s);
|
||
|
var bwr = BWR(
|
||
|
time: p.time(0, "time"),
|
||
|
latitude: p.latLong(1, 2, "latitude"),
|
||
|
longitude: p.latLong(3, 4, "longitude"),
|
||
|
bearingTrue: p.float64(5, "true bearing"),
|
||
|
bearingTrueType: p.enumString(6, "true bearing type", [BearingTrue]),
|
||
|
bearingMagnetic: p.float64(7, "magnetic bearing"),
|
||
|
bearingMagneticType:
|
||
|
p.enumString(8, "magnetic bearing type", [BearingMagnetic]),
|
||
|
distanceNauticalMiles:
|
||
|
p.float64(9, "distance to waypoint is nautical miles"),
|
||
|
distanceNauticalMilesUnit: p.enumString(
|
||
|
10,
|
||
|
"is distance to waypoint nautical miles unit",
|
||
|
[DistanceUnitNauticalMile]),
|
||
|
destinationWaypointID: p.string(11, "destination waypoint ID"),
|
||
|
ffaMode: "");
|
||
|
if (s.fields.length > 12) {
|
||
|
bwr.ffaMode = p.string(12,
|
||
|
"FAA mode"); // not enum because some devices have proprietary "non-nmea" values
|
||
|
}
|
||
|
return bwr;
|
||
|
}
|
||
|
}
|