From 778a991b75a0e6d71cfda7bc599e8cc5621dcca3 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Tue, 6 Feb 2024 09:30:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=94=E7=AD=94=E5=99=A8?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E5=8F=91=E9=80=81=E6=8A=A5=E6=96=87=E6=95=85?= =?UTF-8?q?=E9=9A=9C=EF=BC=9B=E5=A2=9E=E5=8A=A0=E5=BA=94=E7=AD=94=E5=99=A8?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=8A=B6=E6=80=81=E7=8A=B6=E6=80=81=EF=BC=9B?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=97=E8=BD=A6=E8=BD=A6=E5=B0=BE=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=88=E4=BB=85=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E8=B5=8B=E5=80=BC=E9=80=BB=E8=BE=91=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/balise.go | 11 ++++++++--- entity/balise.go | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/component/balise.go b/component/balise.go index 81b7e8e..f6350d7 100644 --- a/component/balise.go +++ b/component/balise.go @@ -9,9 +9,14 @@ var ( BaliseVB = ecs.NewTag() // 主信号应答器 BaliseIB = ecs.NewTag() // 预告应答器 ) -var BaliseFixedTelegramType = ecs.NewComponentType[BaliseState]() //应答器固定报文 -var BaliseVariableTelegramType = ecs.NewComponentType[BaliseState]() //应答器可变报文 -type BaliseState struct { +var BaliseFixedTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器固定报文 +var BaliseVariableTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器可变报文 +type BaliseTelegram struct { Telegram []byte //报文 UserTelegram []byte //用户报文 } + +var BaliseWorkStateType = ecs.NewComponentType[BaliseWorkState]() // 工作状态 +type BaliseWorkState struct { + Work bool //应答器是否正常工作中(目前仅应答器停止发送报文故障会导致为false) +} diff --git a/entity/balise.go b/entity/balise.go index 993d356..7c753aa 100644 --- a/entity/balise.go +++ b/entity/balise.go @@ -8,6 +8,9 @@ import ( "joylink.club/rtsssimulation/repository/model/proto" ) +var BaliseBaseComponentTypeArr = []ecs.IComponentType{component.UidType, component.BaliseFixedTelegramType, + component.LinkPositionType, component.KmType, component.BaliseWorkStateType} + // LoadBalises 加载应答器实体 func LoadBalises(w ecs.World) error { data := GetWorldData(w) @@ -29,13 +32,15 @@ func LoadBalises(w ecs.World) error { } return nil } + func newBaliseEntity(w ecs.World, td *repository.Transponder, worldData *component.WorldData) *ecs.Entry { uid := td.Id() entry, ok := worldData.EntityMap[uid] if !ok { - entry = w.Entry(w.Create(component.UidType, component.BaliseFixedTelegramType, component.LinkPositionType, component.KmType)) + entry = w.Entry(w.Create(BaliseBaseComponentTypeArr...)) component.UidType.SetValue(entry, component.Uid{Id: uid}) - component.BaliseFixedTelegramType.Set(entry, &component.BaliseState{ + component.BaliseWorkStateType.SetValue(entry, component.BaliseWorkState{Work: true}) + component.BaliseFixedTelegramType.Set(entry, &component.BaliseTelegram{ Telegram: td.FixedTelegram(), UserTelegram: td.FixedUserTelegram(), })