雷达发送功能调整

This commit is contained in:
tiger_zhou 2024-01-25 09:57:17 +08:00
parent b89f4e4b3f
commit 51d8716d4f

View File

@ -16,7 +16,6 @@ import (
type RadarVobc interface { type RadarVobc interface {
Start(radar RadarVobcManager) Start(radar RadarVobcManager)
Stop() Stop()
SendRadarInfo(ctx context.Context)
} }
type RadarVobcManager interface { type RadarVobcManager interface {
@ -60,10 +59,11 @@ func (rv *radarVobc) Start(radar RadarVobcManager) {
ctx, cancleFunc := context.WithCancel(context.Background()) ctx, cancleFunc := context.WithCancel(context.Background())
rv.radarVobcTaskContext = cancleFunc rv.radarVobcTaskContext = cancleFunc
rv.radarVobcManager = radar rv.radarVobcManager = radar
go rv.SendRadarInfo(ctx) go rv.sendRadarInfo(ctx)
} }
func (rv *radarVobc) SendRadarInfo(ctx context.Context) { // sendRadarInfo 发送速度,位移计数 给vobc
func (rv *radarVobc) sendRadarInfo(ctx context.Context) {
/*defer func() { /*defer func() {
slog.Error("") slog.Error("")
}()*/ }()*/
@ -72,7 +72,6 @@ func (rv *radarVobc) SendRadarInfo(ctx context.Context) {
case <-ctx.Done(): case <-ctx.Done():
return return
default: default:
} }
trainStatus := rv.radarVobcManager.FindRadarTrain() trainStatus := rv.radarVobcManager.FindRadarTrain()
if trainStatus != nil { if trainStatus != nil {
@ -85,13 +84,13 @@ func (rv *radarVobc) SendRadarInfo(ctx context.Context) {
} }
func (rv *radarVobc) Stop() { func (rv *radarVobc) Stop() {
if rv.vobcClient != nil {
rv.vobcClient.Close()
rv.vobcClient = nil
}
if rv.radarVobcTaskContext != nil { if rv.radarVobcTaskContext != nil {
rv.radarVobcTaskContext() rv.radarVobcTaskContext()
rv.radarVobcTaskContext = nil rv.radarVobcTaskContext = nil
} }
if rv.vobcClient != nil {
rv.vobcClient.Close()
rv.vobcClient = nil
}
} }