应答器增加[固定报文]和[固定用户报文]状态及修改功能
This commit is contained in:
parent
ba95c8bdef
commit
d94a8335dc
@ -2,15 +2,16 @@ package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
type BaliseState struct {
|
||||
ValidTelegram []byte //当前一条有效报文
|
||||
}
|
||||
|
||||
var (
|
||||
BaliseFB = ecs.NewTag() // 固定应答器
|
||||
BaliseWB = ecs.NewTag() // 轮径校正应答器
|
||||
BaliseDB = ecs.NewTag() // 休眠唤醒应答器
|
||||
BaliseVB = ecs.NewTag() // 主信号应答器
|
||||
BaliseIB = ecs.NewTag() // 预告应答器
|
||||
BaliseStateType = ecs.NewComponentType[BaliseState]()
|
||||
BaliseFB = ecs.NewTag() // 固定应答器
|
||||
BaliseWB = ecs.NewTag() // 轮径校正应答器
|
||||
BaliseDB = ecs.NewTag() // 休眠唤醒应答器
|
||||
BaliseVB = ecs.NewTag() // 主信号应答器
|
||||
BaliseIB = ecs.NewTag() // 预告应答器
|
||||
)
|
||||
var BaliseFixedTelegramType = ecs.NewComponentType[BaliseState]() //应答器固定报文
|
||||
var BaliseVariableTelegramType = ecs.NewComponentType[BaliseState]() //应答器可变报文
|
||||
type BaliseState struct {
|
||||
Telegram []byte //报文
|
||||
UserTelegram []byte //用户报文
|
||||
}
|
||||
|
@ -33,9 +33,12 @@ func newBaliseEntity(w ecs.World, td *repository.Transponder, worldData *compone
|
||||
uid := td.Id()
|
||||
entry, ok := worldData.EntityMap[uid]
|
||||
if !ok {
|
||||
entry = w.Entry(w.Create(component.UidType, component.BaliseStateType, component.LinkPositionType, component.KmType))
|
||||
entry = w.Entry(w.Create(component.UidType, component.BaliseFixedTelegramType, component.LinkPositionType, component.KmType))
|
||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||
component.BaliseStateType.Set(entry, &component.BaliseState{})
|
||||
component.BaliseFixedTelegramType.Set(entry, &component.BaliseState{
|
||||
Telegram: td.FixedTelegram(),
|
||||
UserTelegram: td.FixedUserTelegram(),
|
||||
})
|
||||
component.LinkPositionType.SetValue(entry, component_data.LinkPosition{
|
||||
LinkId: td.LinkPosition().Link().Id(),
|
||||
Offset: td.LinkPosition().Offset(),
|
||||
|
@ -159,6 +159,7 @@ message Transponder {
|
||||
DevicePort turnoutPort = 4; //关联的区段端口
|
||||
bytes fixedTelegram = 5;//无源应答器固定报文
|
||||
Type type = 6;//应答器类型
|
||||
bytes fixedUserTelegram = 7; //无源应答器固定用户报文
|
||||
enum Type {
|
||||
FB = 0; // 固定应答器
|
||||
WB = 1; // 轮径校正应答器
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -84,7 +84,7 @@ func buildModels(source *proto.Repository, repository *Repository) error {
|
||||
repository.signalMap[m.Id()] = m
|
||||
}
|
||||
for _, protoData := range source.Transponders {
|
||||
m := NewTransponder(protoData.Id, protoData.Km, protoData.FixedTelegram, protoData.Type)
|
||||
m := NewTransponder(protoData.Id, protoData.Km, protoData.FixedTelegram, protoData.FixedUserTelegram, protoData.Type)
|
||||
repository.responderMap[m.Id()] = m
|
||||
}
|
||||
for _, protoData := range source.Slopes {
|
||||
|
@ -8,17 +8,19 @@ type Transponder struct {
|
||||
km *proto.Kilometer
|
||||
//section *PhysicalSection
|
||||
//turnoutPort TurnoutPort
|
||||
linkPosition *LinkPosition //此位置是应答器初始位置,当前位置需从应答器实体中获取
|
||||
fixedTelegram []byte //无源应答器固定报文
|
||||
baliseType proto.Transponder_Type //应答器类型
|
||||
linkPosition *LinkPosition //此位置是应答器初始位置,当前位置需从应答器实体中获取
|
||||
fixedTelegram []byte //应答器固定报文
|
||||
fixedUserTelegram []byte //应答器固定用户报文
|
||||
baliseType proto.Transponder_Type //应答器类型
|
||||
}
|
||||
|
||||
func NewTransponder(id string, km *proto.Kilometer, fixedTelegram []byte, baliseType proto.Transponder_Type) *Transponder {
|
||||
func NewTransponder(id string, km *proto.Kilometer, fixedTelegram []byte, fixedUserTelegram []byte, baliseType proto.Transponder_Type) *Transponder {
|
||||
return &Transponder{
|
||||
Identity: identity{id, proto.DeviceType_DeviceType_Transponder},
|
||||
km: km,
|
||||
fixedTelegram: fixedTelegram,
|
||||
baliseType: baliseType,
|
||||
Identity: identity{id, proto.DeviceType_DeviceType_Transponder},
|
||||
km: km,
|
||||
fixedTelegram: fixedTelegram,
|
||||
fixedUserTelegram: fixedUserTelegram,
|
||||
baliseType: baliseType,
|
||||
}
|
||||
}
|
||||
func (t *Transponder) TransponderType() proto.Transponder_Type {
|
||||
@ -27,6 +29,9 @@ func (t *Transponder) TransponderType() proto.Transponder_Type {
|
||||
func (t *Transponder) FixedTelegram() []byte {
|
||||
return t.fixedTelegram
|
||||
}
|
||||
func (t *Transponder) FixedUserTelegram() []byte {
|
||||
return t.fixedUserTelegram
|
||||
}
|
||||
func (t *Transponder) bindLinkPosition(position *LinkPosition) {
|
||||
t.linkPosition = position
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
)
|
||||
|
||||
type BaliseSystem struct {
|
||||
@ -12,7 +11,7 @@ type BaliseSystem struct {
|
||||
}
|
||||
|
||||
func NewBaliseSystem() *BaliseSystem {
|
||||
return &BaliseSystem{baliseQuery: ecs.NewQuery(filter.Contains(component.UidType, component.BaliseStateType))}
|
||||
return &BaliseSystem{baliseQuery: ecs.NewQuery(filter.Contains(component.UidType, component.BaliseFixedTelegramType))}
|
||||
}
|
||||
func (s *BaliseSystem) Update(w ecs.World) {
|
||||
s.baliseQuery.Each(w, func(entry *ecs.Entry) {
|
||||
@ -22,25 +21,25 @@ func (s *BaliseSystem) Update(w ecs.World) {
|
||||
|
||||
// 更新应答器有效报文
|
||||
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) { //固定应答器
|
||||
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) { //休眠唤醒应答器
|
||||
|
||||
} else if entry.HasComponent(component.BaliseIB) { //预告应答器
|
||||
|
||||
} else if entry.HasComponent(component.BaliseVB) { //主信号应答器
|
||||
|
||||
} else if entry.HasComponent(component.BaliseWB) { //轮径校正应答器
|
||||
|
||||
}
|
||||
//wd := entity.GetWorldData(w)
|
||||
//id := component.UidType.Get(entry).Id
|
||||
//baliseState := component.BaliseFixedTelegramType.Get(entry)
|
||||
//if entry.HasComponent(component.BaliseFB) { //固定应答器
|
||||
// if len(baliseState.FixedTelegram) == 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.FixedTelegram = telegram
|
||||
// }
|
||||
//} else if entry.HasComponent(component.BaliseDB) { //休眠唤醒应答器
|
||||
//
|
||||
//} else if entry.HasComponent(component.BaliseIB) { //预告应答器
|
||||
//
|
||||
//} else if entry.HasComponent(component.BaliseVB) { //主信号应答器
|
||||
//
|
||||
//} else if entry.HasComponent(component.BaliseWB) { //轮径校正应答器
|
||||
//
|
||||
//}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user