Merge remote-tracking branch 'origin/master'

This commit is contained in:
tiger_zhou 2024-02-06 10:50:43 +08:00
commit 814f68154d
2 changed files with 15 additions and 5 deletions

View File

@ -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
}

View File

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