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