Jelajahi Sumber

radio > radar

terry 8 bulan lalu
induk
melakukan
95ed2069d4
6 mengubah file dengan 27 tambahan dan 27 penghapusan
  1. 1 1
      build.bat
  2. 3 3
      config.yaml
  3. 1 1
      lc/model/radio.go
  4. 13 13
      lc/radio_event.go
  5. 7 7
      lc/server.go
  6. 2 2
      util/config.go

+ 1 - 1
build.bat

@@ -2,4 +2,4 @@ set GOARCH=arm
 set GOARM=6
 set GOOS=linux
 set CGO_ENABLED=0
-go build -o smartX_radio ./
+go build -o smartX_radar ./

+ 3 - 3
config.yaml

@@ -1,5 +1,5 @@
 service:
-  support_radio: false
+  support_radar: false
   support_camera: true
   support_speaker: true
   support_led: false
@@ -10,7 +10,7 @@ cameras:
   - name: "主路1"
     ip: "192.168.1.64"
     branch: 1
-radios:
+radars:
   - port: "/dev/ttymxc4"
     name: "对向"
     branch: 1
@@ -26,6 +26,6 @@ speakers:
   - name: "主路1 IP音柱"
     ip: "192.168.1.160"
     speed: 50
-    volume: 50
+    volume: 40
     branch: 0
     audio: "支路来车"

+ 1 - 1
lc/model/radio.go

@@ -1,6 +1,6 @@
 package model
 
-type RadioInfo struct {
+type RadarInfo struct {
 	Port   string `yaml:"port"` //对应哪个485口
 	Name   string `yaml:"name"`
 	Branch byte   `yaml:"branch"`

+ 13 - 13
lc/radio_event.go

@@ -7,32 +7,32 @@ import (
 	"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
 }
 
-type RadioServer struct {
-	Radios    []model.RadioInfo
+type RadarServer struct {
+	Radars    []model.RadarInfo
 	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屏和主路雷达
-		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]
 	if !ok {
 		logrus.Errorf("回调函数注册表没有该ip:%s", port)
@@ -41,7 +41,7 @@ func (s *RadioServer) Callback(port string) {
 	notifier.Notify()
 }
 
-func (s *RadioServer) OpenSerial(portName string) {
+func (s *RadarServer) OpenSerial(portName string) {
 	// 配置串口参数
 	options := serial.OpenOptions{
 		PortName:        portName, // /dev/ttymxc4 6 3

+ 7 - 7
lc/server.go

@@ -12,7 +12,7 @@ type SmartXServer interface {
 }
 
 type IntersectionServer struct {
-	RadioEventServer  *RadioServer
+	RadarEventServer  *RadarServer
 	CameraEventServer *CameraServer
 	MainState         byte
 	SubState          byte
@@ -33,9 +33,9 @@ func StartIntersectionServer() {
 		is.CameraEventServer = NewCameraEventServer()
 		gopool.Go(is.CameraEventServer.Start)
 	}
-	if util.Config.Server.SupportRadio {
-		is.RadioEventServer = NewRadioEventServer()
-		gopool.Go(is.RadioEventServer.Start)
+	if util.Config.Server.SupportRadar {
+		is.RadarEventServer = NewRadarEventServer()
+		gopool.Go(is.RadarEventServer.Start)
 	}
 	//等事件服务先启动
 	time.Sleep(1 * time.Second)
@@ -74,9 +74,9 @@ func (is *IntersectionServer) Serve() {
 		is.CameraEventServer.RegisterCallback(1, &SubNotifier{is})
 		is.CameraEventServer.RegisterCallback(0, &MainNotifier{is})
 	}
-	if util.Config.Server.SupportRadio {
-		is.RadioEventServer.RegisterCallback(1, &SubNotifier{is})
-		is.RadioEventServer.RegisterCallback(0, &MainNotifier{is})
+	if util.Config.Server.SupportRadar {
+		is.RadarEventServer.RegisterCallback(1, &SubNotifier{is})
+		is.RadarEventServer.RegisterCallback(0, &MainNotifier{is})
 	}
 
 	//先创建响应设备

+ 2 - 2
util/config.go

@@ -23,14 +23,14 @@ var Config = func() config {
 type config struct {
 	HikServer hikServer           `yaml:"hikServer"`
 	Cameras   []model.CameraInfo  `yaml:"cameras"`
-	Radios    []model.RadioInfo   `yaml:"radios"`
+	Radars    []model.RadarInfo   `yaml:"radars"`
 	Screens   []model.ScreenInfo  `yaml:"screens"`
 	Speakers  []model.SpeakerInfo `yaml:"speakers"`
 	Server    service             `yaml:"service"`
 }
 
 type service struct {
-	SupportRadio   bool `yaml:"support_radio"`
+	SupportRadar   bool `yaml:"support_radar"`
 	SupportCamera  bool `yaml:"support_camera"`
 	SupportSpeaker bool `yaml:"support_speaker"`
 	SupportLed     bool `yaml:"support_led"`