-
Notifications
You must be signed in to change notification settings - Fork 78
/
apb.go
131 lines (109 loc) · 5.06 KB
/
apb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package nmea
const (
// TypeAPB type of APB sentence for Autopilot Sentence "B"
TypeAPB = "APB"
// StatusWarningASetAPB indicates LORAN-C Blink or SNR warning
StatusWarningASetAPB = "V"
// StatusWarningAClearORNotUsedAPB general warning flag or other navigation systems when a reliable fix is not available
StatusWarningAClearORNotUsedAPB = "A"
// StatusWarningBSetAPB means Loran-C Cycle Lock warning OK or not used
StatusWarningBSetAPB = "A"
// StatusWarningBClearAPB means Loran-C Cycle Lock warning flag
StatusWarningBClearAPB = "V"
)
// Autopilot related constants (used in APB, APA, AAM)
const (
// WPStatusPerpendicularPassedA is warning for passing the perpendicular of the course line of waypoint
WPStatusPerpendicularPassedA = "A"
// WPStatusPerpendicularPassedV indicates for not passing of the perpendicular of the course line of waypoint
WPStatusPerpendicularPassedV = "V"
// WPStatusArrivalCircleEnteredA is warning of entering to waypoint circle
WPStatusArrivalCircleEnteredA = "A"
// WPStatusArrivalCircleEnteredV indicates of not yet entered into waypoint circle
WPStatusArrivalCircleEnteredV = "V"
)
// APB - Autopilot Sentence "B" for heading/tracking
// https://gpsd.gitlab.io/gpsd/NMEA.html#_apb_autopilot_sentence_b
// https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf (page 5)
//
// Format: $--APB,A,A,x.x,a,N,A,A,x.x,a,c--c,x.x,a,x.x,a*hh<CR><LF>
// Format NMEA 2.3+: $--APB,A,A,x.x,a,N,A,A,x.x,a,c--c,x.x,a,x.x,a,a*hh<CR><LF>
// Example: $GPAPB,A,A,0.10,R,N,V,V,011,M,DEST,011,M,011,M*82
// $ECAPB,A,A,0.0,L,M,V,V,175.2,T,Antechamber_Bay,175.2,T,175.2,T*48
type APB struct {
BaseSentence
// StatusGeneralWarning is used for warnings
// * V = LORAN-C Blink or SNR warning
// * A = general warning flag or other navigation systems when a reliable fix is not available
StatusGeneralWarning string
// StatusLockWarning is used for lock warning
// * V = Loran-C Cycle Lock warning flag
// * A = OK or not used
StatusLockWarning string
// CrossTrackErrorMagnitude is Cross Track Error Magnitude
CrossTrackErrorMagnitude float64
// DirectionToSteer is Direction to steer,
// * L = left
// * R = right
DirectionToSteer string
// CrossTrackUnits is cross track units
// * N = nautical miles
// * K = for kilometers
CrossTrackUnits string
// StatusArrivalCircleEntered is warning of arrival to waypoint circle
// * A = Arrival Circle Entered
// * V = not entered
StatusArrivalCircleEntered string
// StatusPerpendicularPassed is warning for perpendicular passing of waypoint
// * A = Perpendicular passed at waypoint
// * V = not passed
StatusPerpendicularPassed string
// BearingOriginToDest is Bearing origin to destination
BearingOriginToDest float64
// BearingOriginToDestType is Bearing origin to dest type
// * M = Magnetic
// * T = True
BearingOriginToDestType string
// DestinationWaypointID is Destination waypoint ID
DestinationWaypointID string
// BearingPresentToDest is Bearing, present position to Destination
BearingPresentToDest float64
// BearingPresentToDestType is Bearing present to dest type
// * M = Magnetic
// * T = True
BearingPresentToDestType string
// Heading is heading to steer to destination waypoint
Heading float64
// HeadingType is Heading type
// * M = Magnetic
// * T = True
HeadingType string
// FAA mode indicator (filled in NMEA 2.3 and later)
FFAMode string
}
// newAPB constructor
func newAPB(s BaseSentence) (Sentence, error) {
p := NewParser(s)
p.AssertType(TypeAPB)
apb := APB{
BaseSentence: s,
StatusGeneralWarning: p.EnumString(0, "general warning", StatusWarningAClearORNotUsedAPB, StatusWarningASetAPB),
StatusLockWarning: p.EnumString(1, "lock warning", StatusWarningBSetAPB, StatusWarningBClearAPB),
CrossTrackErrorMagnitude: p.Float64(2, "cross track error magnitude"),
DirectionToSteer: p.EnumString(3, "direction to steer", Left, Right),
CrossTrackUnits: p.EnumString(4, "cross track units", DistanceUnitKilometre, DistanceUnitNauticalMile, DistanceUnitStatuteMile, DistanceUnitMetre),
StatusArrivalCircleEntered: p.EnumString(5, "arrival circle entered status", WPStatusArrivalCircleEnteredA, WPStatusArrivalCircleEnteredV),
StatusPerpendicularPassed: p.EnumString(6, "perpendicularly passed status", WPStatusPerpendicularPassedA, WPStatusPerpendicularPassedV),
BearingOriginToDest: p.Float64(7, "origin bearing to destination"),
BearingOriginToDestType: p.EnumString(8, "origin bearing to destination type", HeadingMagnetic, HeadingTrue),
DestinationWaypointID: p.String(9, "destination waypoint ID"),
BearingPresentToDest: p.Float64(10, "present bearing to destination"),
BearingPresentToDestType: p.EnumString(11, "present bearing to destination type", HeadingMagnetic, HeadingTrue),
Heading: p.Float64(12, "heading"),
HeadingType: p.EnumString(13, "heading type", HeadingMagnetic, HeadingTrue),
}
if len(p.Fields) > 14 {
apb.FFAMode = p.String(14, "FAA mode") // not enum because some devices have proprietary "non-nmea" values
}
return apb, p.Err()
}