From 7a75716196c8933e014ad0e08745f344472d1d7a Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Wed, 29 Nov 2023 14:10:18 +0800 Subject: [PATCH] btm --- component/train.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/component/train.go b/component/train.go index 1388eb3..4b2f4cb 100644 --- a/component/train.go +++ b/component/train.go @@ -58,8 +58,10 @@ type TrainBtm struct { lastTelegram *TrainBaliseTelegram } +const SB_LEN = 16 + func NewTrainBtm() *TrainBtm { - return &TrainBtm{scannedBalises: make(chan *TrainBaliseTelegram, 16)} + return &TrainBtm{scannedBalises: make(chan *TrainBaliseTelegram, SB_LEN)} } // 应答器计数器加1,[0,255] @@ -95,7 +97,9 @@ func (t *TrainBtm) Scanning(aboveBalise bool, telegram *TrainBaliseTelegram) { } // if isNewTbt { - t.scannedBalises <- telegram + if len(t.scannedBalises) < SB_LEN { + t.scannedBalises <- telegram + } t.baliseMessageCounterAdd1() } //