[修改]北京12号线连锁rsd、sse、ssr编解码算法及交互流程
This commit is contained in:
parent
ef7e469175
commit
8c6bfb2aee
@ -9,6 +9,9 @@ var (
|
|||||||
BaliseVB = ecs.NewTag() // 主信号应答器
|
BaliseVB = ecs.NewTag() // 主信号应答器
|
||||||
BaliseIB = ecs.NewTag() // 预告应答器
|
BaliseIB = ecs.NewTag() // 预告应答器
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ForceVariableTelegram = ecs.NewTag() //表示可变报文为强制设置并锁定
|
||||||
|
|
||||||
var BaliseFixedTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器固定报文
|
var BaliseFixedTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器固定报文
|
||||||
var BaliseVariableTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器可变报文
|
var BaliseVariableTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器可变报文
|
||||||
type BaliseTelegram struct {
|
type BaliseTelegram struct {
|
||||||
|
@ -12,7 +12,7 @@ func GetBitOfBytes(bs []byte, bitIndex int) bool {
|
|||||||
panic(fmt.Errorf("从字节数组获取位值错误,位索引超出字节数组范围: 数组len=%d,位索引=%d", len(bs), bitIndex))
|
panic(fmt.Errorf("从字节数组获取位值错误,位索引超出字节数组范围: 数组len=%d,位索引=%d", len(bs), bitIndex))
|
||||||
}
|
}
|
||||||
by := bs[bi]
|
by := bs[bi]
|
||||||
v := byte(1 << (7 - i))
|
v := byte(1 << i)
|
||||||
return (by & v) == v
|
return (by & v) == v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
65
fi/balise.go
Normal file
65
fi/balise.go
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package fi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"joylink.club/ecs"
|
||||||
|
"joylink.club/rtsssimulation/component"
|
||||||
|
"joylink.club/rtsssimulation/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BaliseUpdateFixedTelegram 更新固定报文
|
||||||
|
func BaliseUpdateFixedTelegram(w ecs.World, id string, telegram []byte, userTelegram []byte) error {
|
||||||
|
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||||
|
wd := entity.GetWorldData(w)
|
||||||
|
entry, ok := wd.EntityMap[id]
|
||||||
|
if ok {
|
||||||
|
baliseFixedTelegram := component.BaliseFixedTelegramType.Get(entry)
|
||||||
|
baliseFixedTelegram.Telegram = telegram
|
||||||
|
baliseFixedTelegram.UserTelegram = userTelegram
|
||||||
|
} else {
|
||||||
|
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的应答器", id))
|
||||||
|
}
|
||||||
|
return ecs.NewOkEmptyResult()
|
||||||
|
})
|
||||||
|
return result.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaliseUpdateVariableTelegram 更新可变报文
|
||||||
|
func BaliseUpdateVariableTelegram(w ecs.World, id string, telegram []byte, force bool) error {
|
||||||
|
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||||
|
wd := entity.GetWorldData(w)
|
||||||
|
entry, ok := wd.EntityMap[id]
|
||||||
|
if ok {
|
||||||
|
if entry.HasComponent(component.BaliseVariableTelegramType) {
|
||||||
|
if force {
|
||||||
|
entry.AddComponent(component.ForceVariableTelegram)
|
||||||
|
} else if entry.HasComponent(component.ForceVariableTelegram) {
|
||||||
|
return ecs.NewOkEmptyResult()
|
||||||
|
}
|
||||||
|
baliseVariableTelegram := component.BaliseVariableTelegramType.Get(entry)
|
||||||
|
baliseVariableTelegram.Telegram = telegram
|
||||||
|
} else {
|
||||||
|
ecs.NewErrResult(fmt.Errorf("应答器[%s]无可变报文组件", id))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ecs.NewErrResult(fmt.Errorf("未找到应答器[%s]", id))
|
||||||
|
}
|
||||||
|
return ecs.NewOkEmptyResult()
|
||||||
|
})
|
||||||
|
return result.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaliseCancelForceVariableTelegram 取消强制可变报文
|
||||||
|
func BaliseCancelForceVariableTelegram(w ecs.World, id string) error {
|
||||||
|
request := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||||
|
wd := entity.GetWorldData(w)
|
||||||
|
entry, ok := wd.EntityMap[id]
|
||||||
|
if ok {
|
||||||
|
if entry.HasComponent(component.ForceVariableTelegram) {
|
||||||
|
entry.RemoveComponent(component.ForceVariableTelegram)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ecs.NewOkEmptyResult()
|
||||||
|
})
|
||||||
|
return request.Err
|
||||||
|
}
|
@ -164,6 +164,8 @@ message Transponder {
|
|||||||
bytes fixedTelegram = 5;//无源应答器固定报文
|
bytes fixedTelegram = 5;//无源应答器固定报文
|
||||||
Type type = 6;//应答器类型
|
Type type = 6;//应答器类型
|
||||||
bytes fixedUserTelegram = 7; //无源应答器固定用户报文
|
bytes fixedUserTelegram = 7; //无源应答器固定用户报文
|
||||||
|
uint32 leuIndex = 8; //应答器所属LEU的索引
|
||||||
|
uint32 indexInLeu = 9; //应答器在LEU内部的索引
|
||||||
enum Type {
|
enum Type {
|
||||||
FB = 0; // 固定应答器
|
FB = 0; // 固定应答器
|
||||||
WB = 1; // 轮径校正应答器
|
WB = 1; // 轮径校正应答器
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -370,6 +370,14 @@ func (repo *Repository) CentralizedStationRefList() []*proto.CentralizedStationR
|
|||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *Repository) TransponderList() []*Transponder {
|
||||||
|
var list []*Transponder
|
||||||
|
for _, model := range repo.responderMap {
|
||||||
|
list = append(list, model)
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
func (repo *Repository) GetCentralizedStationRef(centralizedStationId string) *proto.CentralizedStationRef {
|
func (repo *Repository) GetCentralizedStationRef(centralizedStationId string) *proto.CentralizedStationRef {
|
||||||
return repo.centralizedMap[centralizedStationId]
|
return repo.centralizedMap[centralizedStationId]
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,8 @@ 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.FixedUserTelegram, protoData.Type)
|
m := NewTransponder(protoData.Id, protoData.Km, protoData.FixedTelegram, protoData.FixedUserTelegram,
|
||||||
|
protoData.Type, protoData.LeuIndex, protoData.IndexInLeu)
|
||||||
repository.responderMap[m.Id()] = m
|
repository.responderMap[m.Id()] = m
|
||||||
}
|
}
|
||||||
for _, protoData := range source.Slopes {
|
for _, protoData := range source.Slopes {
|
||||||
|
@ -12,17 +12,23 @@ type Transponder struct {
|
|||||||
fixedTelegram []byte //应答器固定报文
|
fixedTelegram []byte //应答器固定报文
|
||||||
fixedUserTelegram []byte //应答器固定用户报文
|
fixedUserTelegram []byte //应答器固定用户报文
|
||||||
baliseType proto.Transponder_Type //应答器类型
|
baliseType proto.Transponder_Type //应答器类型
|
||||||
|
leuIndex uint32 //应答器所属LEU的索引
|
||||||
|
indexInLeu uint32 //应答器在LEU内的索引
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTransponder(id string, km *proto.Kilometer, fixedTelegram []byte, fixedUserTelegram []byte, baliseType proto.Transponder_Type) *Transponder {
|
func NewTransponder(id string, km *proto.Kilometer, fixedTelegram []byte, fixedUserTelegram []byte,
|
||||||
|
baliseType proto.Transponder_Type, leuIndex uint32, indexInLeu uint32) *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,
|
||||||
fixedUserTelegram: fixedUserTelegram,
|
fixedUserTelegram: fixedUserTelegram,
|
||||||
baliseType: baliseType,
|
baliseType: baliseType,
|
||||||
|
leuIndex: leuIndex,
|
||||||
|
indexInLeu: indexInLeu,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transponder) TransponderType() proto.Transponder_Type {
|
func (t *Transponder) TransponderType() proto.Transponder_Type {
|
||||||
return t.baliseType
|
return t.baliseType
|
||||||
}
|
}
|
||||||
@ -35,7 +41,6 @@ func (t *Transponder) FixedUserTelegram() []byte {
|
|||||||
func (t *Transponder) bindLinkPosition(position *LinkPosition) {
|
func (t *Transponder) bindLinkPosition(position *LinkPosition) {
|
||||||
t.linkPosition = position
|
t.linkPosition = position
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transponder) LinkPosition() *LinkPosition {
|
func (t *Transponder) LinkPosition() *LinkPosition {
|
||||||
return t.linkPosition
|
return t.linkPosition
|
||||||
}
|
}
|
||||||
@ -47,3 +52,11 @@ func (t *Transponder) Km() *proto.Kilometer {
|
|||||||
func (t *Transponder) BaliseType() proto.Transponder_Type {
|
func (t *Transponder) BaliseType() proto.Transponder_Type {
|
||||||
return t.baliseType
|
return t.baliseType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Transponder) LeuIndex() uint32 {
|
||||||
|
return t.leuIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Transponder) IndexInLeu() uint32 {
|
||||||
|
return t.indexInLeu
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user