|
@@ -7,32 +7,32 @@ import (
|
|
"lc-smartX/util"
|
|
"lc-smartX/util"
|
|
)
|
|
)
|
|
|
|
|
|
-func NewRadioEventServer() *RadioServer {
|
|
|
|
- s := &RadioServer{Radios: util.Config.Radios, Notifiers: make(map[string]Notifier, 4)}
|
|
|
|
|
|
+func NewRadarEventServer() *RadarServer {
|
|
|
|
+ s := &RadarServer{Radars: util.Config.Radars, Notifiers: make(map[string]Notifier, 4)}
|
|
return s
|
|
return s
|
|
}
|
|
}
|
|
|
|
|
|
-type RadioServer struct {
|
|
|
|
- Radios []model.RadioInfo
|
|
|
|
|
|
+type RadarServer struct {
|
|
|
|
+ Radars []model.RadarInfo
|
|
Notifiers map[string]Notifier //485通道名
|
|
Notifiers map[string]Notifier //485通道名
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *RadioServer) Start() {
|
|
|
|
- for _, radio := range s.Radios {
|
|
|
|
- go s.OpenSerial(radio.Port)
|
|
|
|
|
|
+func (s *RadarServer) Start() {
|
|
|
|
+ for _, radar := range s.Radars {
|
|
|
|
+ go s.OpenSerial(radar.Port)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *RadioServer) RegisterCallback(branch byte, notifier Notifier) {
|
|
|
|
- for _, radio := range s.Radios {
|
|
|
|
|
|
+func (s *RadarServer) RegisterCallback(branch byte, notifier Notifier) {
|
|
|
|
+ for _, radar := range s.Radars {
|
|
//关联主路led屏和支路雷达;关联支路led屏和主路雷达
|
|
//关联主路led屏和支路雷达;关联支路led屏和主路雷达
|
|
- if branch == 0 && radio.Branch == 1 || branch == 1 && radio.Branch == 0 {
|
|
|
|
- s.Notifiers[radio.Port] = notifier
|
|
|
|
|
|
+ if branch == 0 && radar.Branch == 1 || branch == 1 && radar.Branch == 0 {
|
|
|
|
+ s.Notifiers[radar.Port] = notifier
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *RadioServer) Callback(port string) {
|
|
|
|
|
|
+func (s *RadarServer) Callback(port string) {
|
|
notifier, ok := s.Notifiers[port]
|
|
notifier, ok := s.Notifiers[port]
|
|
if !ok {
|
|
if !ok {
|
|
logrus.Errorf("回调函数注册表没有该ip:%s", port)
|
|
logrus.Errorf("回调函数注册表没有该ip:%s", port)
|
|
@@ -41,7 +41,7 @@ func (s *RadioServer) Callback(port string) {
|
|
notifier.Notify()
|
|
notifier.Notify()
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *RadioServer) OpenSerial(portName string) {
|
|
|
|
|
|
+func (s *RadarServer) OpenSerial(portName string) {
|
|
// 配置串口参数
|
|
// 配置串口参数
|
|
options := serial.OpenOptions{
|
|
options := serial.OpenOptions{
|
|
PortName: portName, // /dev/ttymxc4 6 3
|
|
PortName: portName, // /dev/ttymxc4 6 3
|