-
Notifications
You must be signed in to change notification settings - Fork 0
/
rig.go
70 lines (62 loc) · 1.32 KB
/
rig.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
package rig
import (
"fmt"
"strconv"
"strings"
)
type Frequency int64
const (
Hz Frequency = 1
KHz Frequency = 10e2
MHz Frequency = 10e5
GHz Frequency = 10e8
THz Frequency = 10e11
PHz Frequency = 10e14
)
func (f Frequency) String() string {
var v, s string
switch {
case f < KHz:
v = strconv.Itoa(int(f))
s = "Hz"
case f < MHz:
v = fmt.Sprintf("%f", float32(f)/float32(KHz))
s = "kHz"
case f < GHz:
v = strconv.FormatFloat(float64(f)/float64(MHz), 'f', -1, 64)
s = "MHz"
case f < THz:
v = strconv.FormatFloat(float64(f)/float64(GHz), 'f', -1, 64)
s = "MHz"
case f < PHz:
v = strconv.FormatFloat(float64(f)/float64(THz), 'f', -1, 64)
s = "THz"
default:
return "overflow"
}
v = strings.TrimSuffix(v, "0")
return v + " " + s
}
type Rig interface {
String() string
Model() string
Manufacturer() string
Capabilities() map[string]bool
Channel() (int, error)
Frequency() (Frequency, error)
SplitFrequency() (Frequency, error)
RepeaterShift() (Frequency, error)
RepeaterOffset() (Frequency, error)
TuningStep() (Frequency, error)
Mode() (Mode, error)
VFO() (VFO, error)
SplitMode() (SplitMode, error)
RIT() (int, error)
XIT() (int, error)
PTT() (bool, error)
Squelch() (bool, error)
CTCSS() (string, error)
SquelchCTCSS() (string, error)
DCS() (string, error)
SquelchDCS() (string, error)
}