forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathths.go
51 lines (47 loc) · 1.16 KB
/
ths.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
package nmea
const (
// TypeTHS type for THS sentences
TypeTHS = "THS"
// AutonomousTHS autonomous ths heading
AutonomousTHS = "A"
// EstimatedTHS estimated (dead reckoning) THS heading
EstimatedTHS = "E"
// ManualTHS manual input THS heading
ManualTHS = "M"
// SimulatorTHS simulated THS heading
SimulatorTHS = "S"
// InvalidTHS not valid THS heading (or standby)
InvalidTHS = "V"
)
// THS is the Actual vessel heading in degrees True with status.
// http://www.nuovamarea.net/pytheas_9.html
type THS struct {
BaseSentence
Heading float64 // Heading in degrees
Status string // Heading status
}
func (s THS) ToMap() (map[string]interface{}, error) {
m := map[string]interface{}{
"heading": s.Heading,
"status": s.Status,
}
bm, err := s.BaseSentence.toMap()
if err != nil {
return m, err
}
for k, v := range bm {
m[k] = v
}
return m, nil
}
// newTHS constructor
func newTHS(s BaseSentence) (THS, error) {
p := NewParser(s)
p.AssertType(TypeTHS)
m := THS{
BaseSentence: s,
Heading: p.Float64(0, "heading"),
Status: p.EnumString(1, "status", AutonomousTHS, EstimatedTHS, ManualTHS, SimulatorTHS, InvalidTHS),
}
return m, p.Err()
}