-
Notifications
You must be signed in to change notification settings - Fork 79
/
mwv.go
75 lines (68 loc) · 2.3 KB
/
mwv.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
package nmea
/**
$WIMWV
NMEA 0183 standard Wind Speed and Angle, in relation to the vessel’s bow/centerline.
Syntax
$WIMWV,<1>,<2>,<3>,<4>,<5>*hh<CR><LF>
Fields
<1> Wind angle, 0.0 to 359.9 degrees, in relation to the vessel’s bow/centerline, to the nearest 0.1
degree. If the data for this field is not valid, the field will be blank.
<2> Reference:
R = Relative (apparent wind, as felt when standing on the moving ship)
T = Theoretical (calculated actual wind, as though the vessel were stationary)
<3> Wind speed, to the nearest tenth of a unit. If the data for this field is not valid, the field will be
blank.
<4> Wind speed units:
K = km/hr
M = m/s
N = knots
S = statute miles/hr
(Most WeatherStations will commonly use "N" (knots))
<5> Status:
A = data valid; V = data invalid
*/
const (
// TypeMWV type for MWV sentences
TypeMWV = "MWV"
// RelativeMWV for Valid Relative angle data
RelativeMWV = "R"
// TheoreticalMWV for valid Theoretical angle data
TheoreticalMWV = "T"
// UnitKMHMWV unit for Kilometer per hour (KM/H)
UnitKMHMWV = "K" // KM/H
// UnitMSMWV unit for Meters per second (M/S)
UnitMSMWV = "M" // M/S
// UnitKnotsMWV unit for knots
UnitKnotsMWV = "N" // knots
// UnitSMilesHMWV unit for Miles per hour (M/H)
UnitSMilesHMWV = "S"
// ValidMWV data is valid
ValidMWV = "A"
// InvalidMWV data is invalid
InvalidMWV = "V"
)
// MWV is the Wind Speed and Angle, in relation to the vessel’s bow/centerline.
// https://gpsd.gitlab.io/gpsd/NMEA.html#_mwv_wind_speed_and_angle
//
// Format: $--MWV,x.x,a,x.x,a*hh<CR><LF>
// Example: $WIMWV,12.1,T,10.1,N,A*27
type MWV struct {
BaseSentence
WindAngle float64
Reference string
WindSpeed float64
WindSpeedUnit string
StatusValid bool
}
func newMWV(s BaseSentence) (Sentence, error) {
p := NewParser(s)
p.AssertType(TypeMWV)
return MWV{
BaseSentence: s,
WindAngle: p.Float64(0, "wind angle"),
Reference: p.EnumString(1, "reference", RelativeMWV, TheoreticalMWV),
WindSpeed: p.Float64(2, "wind speed"),
WindSpeedUnit: p.EnumString(3, "wind speed unit", UnitKMHMWV, UnitMSMWV, UnitKnotsMWV, UnitSMilesHMWV),
StatusValid: p.EnumString(4, "status", ValidMWV, InvalidMWV) == ValidMWV,
}, p.Err()
}