/
lmschannel.go
142 lines (118 loc) · 4.13 KB
/
lmschannel.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package limedrv
import (
"fmt"
"github.com/racerxdl/limedrv/limewrap"
)
// LMSChannel is the struct that represents a Channel from a LMSDevice.
// It can be either a RX or TX Channel, defined by the field IsRX.
// It also contains the list of available antenna ports.
type LMSChannel struct {
Antennas []LMSAntenna
IsRX bool
parent *LMSDevice
parentIndex int
stream limewrap.Lms_stream_t
currentDigitalBandwidth float64
digitalFilterEnabled bool
advancedFiltering bool
}
// Enable enables this channel from the read / write callback
func (c *LMSChannel) Enable() *LMSChannel {
c.parent.EnableChannel(c.parentIndex, c.IsRX)
return c
}
// Disable disables this channel from the read / write callback
func (c *LMSChannel) Disable() *LMSChannel {
c.parent.DisableChannel(c.parentIndex, c.IsRX)
return c
}
// SetGainDB sets this channel gain in decibels
func (c *LMSChannel) SetGainDB(gain uint) *LMSChannel {
c.parent.SetGainDB(c.parentIndex, c.IsRX, gain)
return c
}
// SetGainNormalized sets the channel normalized gain. [0-1]
func (c *LMSChannel) SetGainNormalized(gain float64) *LMSChannel {
c.parent.SetGainNormalized(c.parentIndex, c.IsRX, gain)
return c
}
// GetGainDB returns the channel current gain in decibels
func (c *LMSChannel) GetGainDB() uint {
return c.parent.GetGainDB(c.parentIndex, c.IsRX)
}
// GetGainNormalized returns the channel current normalized gain. [0-1]
func (c *LMSChannel) GetGainNormalized() float64 {
return c.parent.GetGainNormalized(c.parentIndex, c.IsRX)
}
// SetLPF sets the Analog Low Pass filter bandwidth for the current channel.
func (c *LMSChannel) SetLPF(bandwidth float64) *LMSChannel {
c.parent.SetLPF(c.parentIndex, c.IsRX, bandwidth)
return c
}
// GetLPF gets the current Analog Low Pass filter bandwidth for the current channel.
func (c *LMSChannel) GetLPF() float64 {
return c.parent.GetLPF(c.parentIndex, c.IsRX)
}
// EnableLPF enables the Analog Low Pass filter for the current channel.
func (c *LMSChannel) EnableLPF() *LMSChannel {
c.parent.EnableLPF(c.parentIndex, c.IsRX)
return c
}
// DisableLPF disables the Analog Low Pass filter for the current channel.
func (c *LMSChannel) DisableLPF() *LMSChannel {
c.parent.EnableLPF(c.parentIndex, c.IsRX)
return c
}
// SetDigitalLPF sets the current channel digital filter (GFIR) to low pass with specified bandwidth.
func (c *LMSChannel) SetDigitalLPF(bandwidth float64) *LMSChannel {
c.parent.SetDigitalFilter(c.parentIndex, c.IsRX, bandwidth)
return c
}
// EnableDigitalLPF enables current channel digital filter (GFIR)
func (c *LMSChannel) EnableDigitalLPF() *LMSChannel {
c.parent.EnableDigitalFilter(c.parentIndex, c.IsRX)
return c
}
// DisableDigitalLPF disables current channel digital filter (GFIR)
func (c *LMSChannel) DisableDigitalLPF() *LMSChannel {
c.parent.DisableDigitalFilter(c.parentIndex, c.IsRX)
return c
}
// SetAntenna sets the current channel antenna port
func (c *LMSChannel) SetAntenna(idx int) *LMSChannel {
c.parent.SetAntenna(idx, c.parentIndex, c.IsRX)
return c
}
// SetAntennaByName sets the current channel antenna port by name.
// Example: LNAW
func (c *LMSChannel) SetAntennaByName(name string) *LMSChannel {
c.parent.SetAntennaByName(name, c.parentIndex, c.IsRX)
return c
}
// SetCenterFrequency sets the current channel center frequency in hertz.
func (c *LMSChannel) SetCenterFrequency(centerFrequency float64) *LMSChannel {
c.parent.SetCenterFrequency(c.parentIndex, c.IsRX, centerFrequency)
return c
}
// GetCenterFrequency returns the current channel center frequency in hertz.
func (c *LMSChannel) GetCenterFrequency() float64 {
return c.parent.GetCenterFrequency(c.parentIndex, c.IsRX)
}
// String returns a representation of the channel
func (c *LMSChannel) String() string {
var str = fmt.Sprintf("\nIs RX: %t\nAntennas: %d", c.IsRX, len(c.Antennas))
for i := 0; i < len(c.Antennas); i++ {
str = fmt.Sprintf("%s\n\t%s", str, c.Antennas[i].String())
}
return str
}
func (c *LMSChannel) start() {
if c.stream != nil {
limewrap.LMS_StartStream(c.stream)
}
}
//func (c *LMSChannel) stop() {
// if c.stream != nil {
// limewrap.LMS_StopStream(c.stream)
// }
//}