-
Notifications
You must be signed in to change notification settings - Fork 79
/
mtw.go
30 lines (27 loc) · 803 Bytes
/
mtw.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
package nmea
const (
// TypeMTW type of MWT sentence describing mean temperature of water
TypeMTW = "MTW"
// CelsiusMTW is MTW unit of measurement in celsius
CelsiusMTW = "C"
)
// MTW is sentence for mean temperature of water.
// https://gpsd.gitlab.io/gpsd/NMEA.html#_mtw_mean_temperature_of_water
//
// Format: $--MTW,TT.T,C*hh<CR><LF>
// Example: $INMTW,17.9,C*1B
type MTW struct {
BaseSentence
Temperature float64 // Temperature, degrees
CelsiusValid bool // Is unit of measurement Celsius
}
// newMTW constructor
func newMTW(s BaseSentence) (Sentence, error) {
p := NewParser(s)
p.AssertType(TypeMTW)
return MTW{
BaseSentence: s,
Temperature: p.Float64(0, "temperature"),
CelsiusValid: p.EnumString(1, "unit of measurement celsius", CelsiusMTW) == CelsiusMTW,
}, p.Err()
}