-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
112 lines (104 loc) · 1.85 KB
/
types.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
package rigctld
import "errors"
// Frequency is a frequency in hertz.
type Frequency int64
// Mode is a radio modulation mode.
type Mode int
const (
// USB is Upper Sideband.
USB Mode = iota
// LSB is Lower Sideband.
LSB
// CW is Continuous Wave.
CW
// CWR is Continuous Wave Reverse.
CWR
// RTTY is Radio Teletype.
RTTY
// RTTYR is Radio Teletype Reverse.
RTTYR
// AM is Amplitude Modulation.
AM
// FM is Frequency Modulation.
FM
// WFM is Wideband FM.
WFM
// AMS is Amplitude Modulation Synchronous.
AMS
// PKTLSB is Packet Lower Sideband.
PKTLSB
// PKTUSB is Packet Upper Sideband.
PKTUSB
// PKTFM is Packet FM.
PKTFM
// ECSSUSB is Exalted Carrier Single Sideband Upper Sideband.
ECSSUSB
// ECSSLSB is Exalted Carrier Single Sideband Lower Sideband.
ECSSLSB
// FA is Frequency Agile.
FA
// SAM is Synchronous AM.
SAM
// SAL is Synchronous AM Lower.
SAL
// SAH is Synchronous AM Upper.
SAH
// DSB is Double Sideband.
DSB
)
func (m Mode) String() string {
return [...]string{
"USB",
"LSB",
"CW",
"CWR",
"RTTY",
"RTTYR",
"AM",
"FM",
"WFM",
"AMS",
"PKTLSB",
"PKTUSB",
"PKTFM",
"ECSSUSB",
"ECSSLSB",
"FA",
"SAM",
"SAL",
"SAH",
"DSB"}[m]
}
func (m Mode) EnumIndex() int {
return int(m)
}
// ModeFromString converts a string to a Mode.
func ModeFromString(modeStr string) (Mode, error) {
modes := map[string]Mode{
"USB": USB,
"LSB": LSB,
"CW": CW,
"CWR": CWR,
"RTTY": RTTY,
"RTTYR": RTTYR,
"AM": AM,
"FM": FM,
"WFM": WFM,
"AMS": AMS,
"PKTLSB": PKTLSB,
"PKTUSB": PKTUSB,
"PKTFM": PKTFM,
"ECSSUSB": ECSSUSB,
"ECSSLSB": ECSSLSB,
"FA": FA,
"SAM": SAM,
"SAL": SAL,
"SAH": SAH,
"DSB": DSB,
}
mode, exists := modes[modeStr]
if !exists {
return 0, errors.New("invalid mode string")
}
return mode, nil
}