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