From 78538690909636a6ba82b56bb3cccae0e064dc61 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Thu, 23 Nov 2023 11:17:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0=E6=BA=90=E5=BA=94=E7=AD=94=E5=99=A8?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E6=8A=A5=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/train.go | 12 ++++++++---- entity/balise.go | 9 +++++++++ proto/src/model.proto | 8 ++++++++ sys/device_sys/balise_detection.go | 18 +++++++++++++++--- 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 entity/balise.go diff --git a/component/train.go b/component/train.go index 014fb91..95db636 100644 --- a/component/train.go +++ b/component/train.go @@ -26,6 +26,12 @@ func (t *TrainPositionInfo) ToString() string { return fmt.Sprintf("Up=%t len=%d headLink=%s headOff=%d tailLink=%s tailOff=%d", t.Up, t.Len, t.HeadLink, t.HeadLinkOffset, t.TailLink, t.TailLinkOffset) } +// TrainBaliseTelegram 应答器报文 +type TrainBaliseTelegram struct { + BaliseId string //应答器ID + Telegram []byte //一个应答器同一时刻只有一条报文处于激活有效状态 +} + // TrainBtm 列车应答器传输模块 type TrainBtm struct { //应答器计数(每过一个应答器加一,在同一个应答器内不变) @@ -40,10 +46,8 @@ type TrainBtm struct { ScannedBalises []*TrainBaliseTelegram } -// TrainBaliseTelegram 应答器报文 -type TrainBaliseTelegram struct { - BaliseId string //应答器ID - Telegram []byte //一个应答器同一时刻只有一条报文处于激活有效状态 +func (t *TrainBtm) Scanning(aboveBalise bool, tbt *TrainBaliseTelegram) { + t.AboveBalise = aboveBalise } var ( diff --git a/entity/balise.go b/entity/balise.go new file mode 100644 index 0000000..b4bd659 --- /dev/null +++ b/entity/balise.go @@ -0,0 +1,9 @@ +package entity + +import "joylink.club/ecs" + +// LoadBalises 加载应答器实体 +func LoadBalises(w ecs.World) error { + data := GetWorldData(w) + signals := data.Repo.ResponderList() +} diff --git a/proto/src/model.proto b/proto/src/model.proto index b7fa03f..1d9d951 100644 --- a/proto/src/model.proto +++ b/proto/src/model.proto @@ -114,6 +114,14 @@ message Transponder { string sectionId = 3; //关联的区段 DevicePort turnoutPort = 4; //关联的区段端口 bytes fixedTelegram = 5;//无源应答器固定报文 + Type type = 6;//应答器类型 + enum Type { + FB = 0; // 固定应答器 + WB = 1; // 轮径校正应答器 + DB = 2; // 休眠唤醒应答器 + VB = 3; // 主信号应答器 + IB = 4; // 预告应答器 + } } //坡度 diff --git a/sys/device_sys/balise_detection.go b/sys/device_sys/balise_detection.go index 71f9c31..39bacbd 100644 --- a/sys/device_sys/balise_detection.go +++ b/sys/device_sys/balise_detection.go @@ -27,12 +27,24 @@ func (s *BaliseDetectSystem) Update(w ecs.World) { //列车速度80KM/H时,222mm/10ms s.trainQuery.Each(w, func(entry *ecs.Entry) { tp := component.TrainPositionInfoType.Get(entry) + btm := component.TrainBtmType.Get(entry) detectedBalise := s.detect(wd, tp, balises) - if detectedBalise != nil { //列车应答器天线扫描到应答器,获取应答器报文发送给BTM - - } + //列车应答器天线扫描到应答器,获取应答器报文发送给BTM + tbt := s.findBaliseTelegram(wd, detectedBalise) + btm.Scanning(detectedBalise != nil, tbt) }) } + +// 获取应答器激活的有效报文 +func (s *BaliseDetectSystem) findBaliseTelegram(wd *component.WorldData, detectedBalise *repository.Transponder) *component.TrainBaliseTelegram { + if detectedBalise == nil { + return nil + } + // + + // + return nil +} func (s *BaliseDetectSystem) detect(wd *component.WorldData, tp *component.TrainPositionInfo, balises []*repository.Transponder) *repository.Transponder { scanRange := s.calculateScanRange(wd, tp) for _, balise := range balises {