From 90c803f71d9dd1b46bf8d3d74fb7dc9a1e9d8ee3 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Tue, 5 Dec 2023 13:49:21 +0800 Subject: [PATCH] =?UTF-8?q?balise=20detect=20=E9=A2=84=E6=B5=8B=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sys/device_sys/balise.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/device_sys/balise.go b/sys/device_sys/balise.go index b5d389b..5560463 100644 --- a/sys/device_sys/balise.go +++ b/sys/device_sys/balise.go @@ -16,22 +16,23 @@ func NewBaliseSystem() *BaliseSystem { } func (s *BaliseSystem) Update(w ecs.World) { s.baliseQuery.Each(w, func(entry *ecs.Entry) { - baliseState := component.BaliseStateType.Get(entry) - baliseState.ValidTelegram = s.findValidTelegram(w, entry) + s.updateValidTelegram(w, entry) }) } -// 获取应答器有效报文 -func (s *BaliseSystem) findValidTelegram(w ecs.World, entry *ecs.Entry) []byte { +// 更新应答器有效报文 +func (s *BaliseSystem) updateValidTelegram(w ecs.World, entry *ecs.Entry) { wd := entity.GetWorldData(w) id := component.UidType.Get(entry).Id + baliseState := component.BaliseStateType.Get(entry) if entry.HasComponent(component.BaliseFB) { //固定应答器 - baliseModel := wd.Repo.FindTransponder(id) - telegram := baliseModel.FixedTelegram() - if telegram != nil { - return telegram - } else { //测试用 - return []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + if len(baliseState.ValidTelegram) == 0 { + baliseModel := wd.Repo.FindTransponder(id) + telegram := baliseModel.FixedTelegram() + if len(telegram) == 0 { //测试用 + telegram = []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + } + baliseState.ValidTelegram = telegram } } else if entry.HasComponent(component.BaliseDB) { //休眠唤醒应答器 @@ -42,5 +43,4 @@ func (s *BaliseSystem) findValidTelegram(w ecs.World, entry *ecs.Entry) []byte { } else if entry.HasComponent(component.BaliseWB) { //轮径校正应答器 } - return nil }