-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from aldas/sentences
Add a lot of new sentences. * [AAM](./aam.go) - Waypoint Arrival Alarm * [ALA](./ala.go) - System Faults and alarms * [APB](./apb.go) - Autopilot Sentence "B" * [BEC](./bec.go) - Bearing and distance to waypoint (dead reckoning) * [BOD](./bod.go) - Bearing waypoint to waypoint (origin to destination). * [BWC](./bwc.go) - Bearing and distance to waypoint, great circle * [BWR](./bwr.go) - Bearing and distance to waypoint (Rhumb Line) * [BWW](./bww.go) - bearing (from destination) destination waypoint to origin waypoint * [DBK](./dbk.go) - Depth Below Keel (obsolete, use DPT instead) * [DOR](./dor.go) - Door Status Detection * [DSC](./dsc.go) - Digital Selective Calling Information * [DSE](./dse.go) - Expanded digital selective calling * [EVE](./eve.go) - General Event Message * [FIR](./fir.go) - Fire Detection event with time and location * [HSC](./hsc.go) - Heading steering command * [MTA](./mta.go) - Air Temperature (obsolete, use XDR instead) * [RMB](./rmb.go) - Recommended Minimum Navigation Information * [RPM](./rpm.go) - Engine or Shaft revolutions and pitch * [RSA](./rsa.go) - Rudder Sensor Angle * [VDR](./vdr.go) - Set and Drift * [VLW](./vlw.go) - Distance Traveled through Water * [VPW](./vpw.go) - Speed Measured Parallel to Wind * [VWR](./vwr.go) - Relative Wind Speed and Angle * [VWT](./vwt.go) - True Wind Speed and Angle * [XDR](./xdr.go) - Transducer Measurement * [XTE](./xte.go) - Cross-track error, measured
- Loading branch information
Showing
65 changed files
with
3,783 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package nmea | ||
|
||
const ( | ||
// TypeAAM type of AAM sentence for Waypoint Arrival Alarm | ||
TypeAAM = "AAM" | ||
) | ||
|
||
// AAM - Waypoint Arrival Alarm | ||
// This sentence is generated by some units to indicate the status of arrival (entering the arrival circle, or passing | ||
// the perpendicular of the course line) at the destination waypoint (source: GPSD). | ||
// https://gpsd.gitlab.io/gpsd/NMEA.html#_aam_waypoint_arrival_alarm | ||
// | ||
// Format: $--AAM,A,A,x.x,N,c--c*hh<CR><LF> | ||
// Example: $GPAAM,A,A,0.10,N,WPTNME*43 | ||
type AAM struct { | ||
BaseSentence | ||
// 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 | ||
|
||
// ArrivalCircleRadius is radius for arrival circle | ||
ArrivalCircleRadius float64 | ||
|
||
// ArrivalCircleRadiusUnit is unit for arrival circle radius | ||
ArrivalCircleRadiusUnit string | ||
|
||
// DestinationWaypointID is destination waypoint ID | ||
DestinationWaypointID string | ||
} | ||
|
||
// newAAM constructor | ||
func newAAM(s BaseSentence) (AAM, error) { | ||
p := NewParser(s) | ||
p.AssertType(TypeAAM) | ||
return AAM{ | ||
BaseSentence: s, | ||
StatusArrivalCircleEntered: p.EnumString(0, "arrival circle entered status", WPStatusArrivalCircleEnteredA, WPStatusArrivalCircleEnteredV), | ||
StatusPerpendicularPassed: p.EnumString(1, "perpendicularly passed status", WPStatusPerpendicularPassedA, WPStatusPerpendicularPassedV), | ||
ArrivalCircleRadius: p.Float64(2, "arrival circle radius"), | ||
ArrivalCircleRadiusUnit: p.EnumString(3, "arrival circle radius units", DistanceUnitKilometre, DistanceUnitNauticalMile, DistanceUnitStatuteMile, DistanceUnitMetre), | ||
DestinationWaypointID: p.String(4, "destination waypoint ID"), | ||
}, p.Err() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package nmea | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestAAM(t *testing.T) { | ||
var tests = []struct { | ||
name string | ||
raw string | ||
err string | ||
msg AAM | ||
}{ | ||
{ | ||
name: "good sentence", | ||
raw: "$GPAAM,A,A,0.10,N,WPTNME*32", | ||
msg: AAM{ | ||
StatusArrivalCircleEntered: WPStatusArrivalCircleEnteredA, | ||
StatusPerpendicularPassed: WPStatusPerpendicularPassedA, | ||
ArrivalCircleRadius: 0.1, | ||
ArrivalCircleRadiusUnit: DistanceUnitNauticalMile, | ||
DestinationWaypointID: "WPTNME", | ||
}, | ||
}, | ||
{ | ||
name: "invalid nmea: StatusArrivalCircleEntered", | ||
raw: "$GPAAM,x,A,0.10,N,WPTNME*0B", | ||
err: "nmea: GPAAM invalid arrival circle entered status: x", | ||
}, | ||
{ | ||
name: "invalid nmea: StatusPerpendicularPassed", | ||
raw: "$GPAAM,A,x,0.10,N,WPTNME*0B", | ||
err: "nmea: GPAAM invalid perpendicularly passed status: x", | ||
}, | ||
{ | ||
name: "invalid nmea: DistanceUnitNauticalMile", | ||
raw: "$GPAAM,A,A,0.10,x,WPTNME*04", | ||
err: "nmea: GPAAM invalid arrival circle radius units: x", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
m, err := Parse(tt.raw) | ||
if tt.err != "" { | ||
assert.Error(t, err) | ||
assert.EqualError(t, err, tt.err) | ||
} else { | ||
assert.NoError(t, err) | ||
aam := m.(AAM) | ||
aam.BaseSentence = BaseSentence{} | ||
assert.Equal(t, tt.msg, aam) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package nmea | ||
|
||
const ( | ||
// TypeALA type of ALA sentence for System Faults and alarms | ||
TypeALA = "ALA" | ||
) | ||
|
||
// ALA - System Faults and alarms | ||
// Source: "Interfacing Voyage Data Recorder Systems, AutroSafe Interactive Fire-Alarm System, 116-P-BSL336/EE, RevA 2007-01-25, | ||
// Autronica Fire and Security AS " (page 31 | p.8.1.3) | ||
// https://product.autronicafire.com/fileshare/fileupload/14251/bsl336_ee.pdf | ||
// | ||
// Format: $FRALA,hhmmss,aa,aa,xx,xxx,a,a,c-cc*hh<CR><LF> | ||
// Example: $FRALA,143955,FR,OT,00,901,N,V,Syst Fault : AutroSafe comm. OK*4F | ||
type ALA struct { | ||
BaseSentence | ||
|
||
// Time is Event Time | ||
Time Time | ||
|
||
// SystemIndicator is system indicator of original alarm source. Detector system type with 2 char identifier. | ||
// Values not known | ||
// https://www.nmea.org/Assets/20190303%20nmea%200183%20talker%20identifier%20mnemonics.pdf | ||
SystemIndicator string | ||
|
||
// SubSystemIndicator is sub system equipment indicator of original alarm source | ||
SubSystemIndicator string | ||
|
||
// InstanceNumber is instance number of equipment/unit/item (00-99) | ||
InstanceNumber int64 | ||
|
||
// Type is alarm type (000-999) | ||
Type int64 | ||
|
||
// Condition describes the condition triggering current message | ||
// * N – Normal state (OK) | ||
// * H - Alarm state (fault); | ||
// could be more | ||
Condition string | ||
|
||
// AlarmAckState is Alarm's acknowledge state | ||
// * A – Acknowledged | ||
// * H - Harbour mode | ||
// * V – Not acknowledged | ||
// * O - Override | ||
// could be more | ||
AlarmAckState string | ||
|
||
// Message's description text (could be cut to fit max packet length) | ||
Message string | ||
} | ||
|
||
// newALA constructor | ||
func newALA(s BaseSentence) (ALA, error) { | ||
p := NewParser(s) | ||
p.AssertType(TypeALA) | ||
return ALA{ | ||
BaseSentence: s, | ||
Time: p.Time(0, "time"), | ||
SystemIndicator: p.String(1, "system indicator"), | ||
SubSystemIndicator: p.String(2, "subsystem indicator"), | ||
InstanceNumber: p.Int64(3, "instance number"), | ||
Type: p.Int64(4, "type"), | ||
Condition: p.String(5, "condition"), // string as there could be more | ||
AlarmAckState: p.String(6, "alarm acknowledgement state"), // string as there could be more | ||
Message: p.String(7, "message"), | ||
}, p.Err() | ||
} |
Oops, something went wrong.