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() } //