计轴rssp 集成
This commit is contained in:
parent
4cd8ada0ff
commit
0887ac8d68
@ -1 +1 @@
|
|||||||
Subproject commit a6dfa6fffb7ecfe6630280a838092d208c0e3c1a
|
Subproject commit 45b4f4f0fe4eaf1eae6f31cca8d0b14237596bf1
|
10
third_party/axle_device/rssp_axle.go
vendored
10
third_party/axle_device/rssp_axle.go
vendored
@ -13,12 +13,16 @@ type RsspAxle interface {
|
|||||||
|
|
||||||
type AxleMessageManager interface {
|
type AxleMessageManager interface {
|
||||||
//HandleSectionCmdMsg 计轴设备接收到联锁发送来的控制命令
|
//HandleSectionCmdMsg 计轴设备接收到联锁发送来的控制命令
|
||||||
HandleSectionCmdMsg(centralizedStation string, msg *message.SectionCmdMsgPack)
|
HandleSectionCmdMsg(city string, lineId string, centralizedStation string, msg *message.SectionCmdMsgPack)
|
||||||
//CollectSectionStatus 收集仿真中计轴区段状态
|
//CollectSectionStatus 收集仿真中计轴区段状态
|
||||||
CollectSectionStatus() []*message.SectionStatusMsg
|
CollectSectionStatus(city string, lineId string, centralizedStation string) ([]*message.SectionStatusMsg, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type rsspAxle struct {
|
type rsspAxle struct {
|
||||||
|
//所属城市
|
||||||
|
city string
|
||||||
|
//所属线路
|
||||||
|
lineId string
|
||||||
//所属集中站
|
//所属集中站
|
||||||
centralizedStation string
|
centralizedStation string
|
||||||
//主安全通道
|
//主安全通道
|
||||||
@ -37,7 +41,7 @@ func NewRsspAxle(masterRssp *RsspChannel, slaveRssp *RsspChannel) RsspAxle {
|
|||||||
func (s *rsspAxle) rcvCmdMsg(data []byte) {
|
func (s *rsspAxle) rcvCmdMsg(data []byte) {
|
||||||
msg := &message.SectionCmdMsgPack{}
|
msg := &message.SectionCmdMsgPack{}
|
||||||
msg.Decode(data)
|
msg.Decode(data)
|
||||||
s.messageManager.HandleSectionCmdMsg(s.centralizedStation, msg)
|
s.messageManager.HandleSectionCmdMsg(s.city, s.lineId, s.centralizedStation, msg)
|
||||||
}
|
}
|
||||||
func (s *rsspAxle) Start(amm AxleMessageManager) error {
|
func (s *rsspAxle) Start(amm AxleMessageManager) error {
|
||||||
s.messageManager = amm
|
s.messageManager = amm
|
||||||
|
@ -148,6 +148,57 @@ func (s *VerifySimulation) GetComIdByUid(uid string) string {
|
|||||||
return es[uid].CommonId
|
return es[uid].CommonId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CollectSectionStatus 收集仿真中计轴区段状态
|
||||||
|
func (s *VerifySimulation) CollectSectionStatus(city string, lineId string, centralizedStation string) ([]*message.SectionStatusMsg, error) {
|
||||||
|
stationUid := GenerateElementUid(city, lineId, nil, centralizedStation)
|
||||||
|
ref := s.Repo.GetCentralizedStationRef(stationUid)
|
||||||
|
if ref == nil {
|
||||||
|
return nil, fmt.Errorf("没有找到GetCentralizedStationRef [%s]", stationUid)
|
||||||
|
}
|
||||||
|
//
|
||||||
|
codePoints := ref.SectionCodePoints
|
||||||
|
if len(codePoints) <= 0 {
|
||||||
|
return nil, fmt.Errorf("没有找到GetCentralizedStationRef[%s]的区段码表为空", stationUid)
|
||||||
|
}
|
||||||
|
//
|
||||||
|
var msg []*message.SectionStatusMsg
|
||||||
|
var axleSectionIds []string
|
||||||
|
for _, section := range codePoints {
|
||||||
|
axleSectionIds = append(axleSectionIds, section.SectionId)
|
||||||
|
}
|
||||||
|
//
|
||||||
|
as, e := fi.FindAxleSectionsStatus(s.World, axleSectionIds)
|
||||||
|
if e != nil { //从仿真中收集计轴区段状态的失败列表
|
||||||
|
return nil, e
|
||||||
|
}
|
||||||
|
//
|
||||||
|
stateMap := make(map[string]*fi.AxleSectionState)
|
||||||
|
for _, a := range as {
|
||||||
|
stateMap[a.Id] = a
|
||||||
|
}
|
||||||
|
//
|
||||||
|
sort.SliceStable(codePoints, func(i, j int) bool {
|
||||||
|
return codePoints[i].Row < codePoints[j].Row
|
||||||
|
})
|
||||||
|
//
|
||||||
|
for _, codePoint := range codePoints {
|
||||||
|
sectionState, find := stateMap[codePoint.SectionId]
|
||||||
|
if find {
|
||||||
|
state := &message.SectionStatusMsg{}
|
||||||
|
state.Rac = sectionState.Rac
|
||||||
|
state.Rjt = sectionState.Rjt
|
||||||
|
state.Rjo = sectionState.Rjo
|
||||||
|
state.Occ = sectionState.Occ
|
||||||
|
state.Clr = sectionState.Clr
|
||||||
|
msg = append(msg, state)
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("仿真中没有对应区段[%s]的状态", codePoint.SectionId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return msg, nil
|
||||||
|
}
|
||||||
|
|
||||||
// 采集动力学道岔状态
|
// 采集动力学道岔状态
|
||||||
func (s *VerifySimulation) CollectDynamicsTurnoutInfo() []*message.DynamicsTurnoutInfo {
|
func (s *VerifySimulation) CollectDynamicsTurnoutInfo() []*message.DynamicsTurnoutInfo {
|
||||||
var turnoutStates []*message.DynamicsTurnoutInfo
|
var turnoutStates []*message.DynamicsTurnoutInfo
|
||||||
@ -171,38 +222,37 @@ func (s *VerifySimulation) CollectDynamicsTurnoutInfo() []*message.DynamicsTurno
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HandleSectionCmdMsg 计轴设备接收到联锁发送来的控制命令
|
// HandleSectionCmdMsg 计轴设备接收到联锁发送来的控制命令
|
||||||
func (s *VerifySimulation) HandleSectionCmdMsg(centralizedStation string, msg *message.SectionCmdMsgPack) {
|
func (s *VerifySimulation) HandleSectionCmdMsg(city string, lineId string, centralizedStation string, msg *message.SectionCmdMsgPack) {
|
||||||
|
stationUid := GenerateElementUid(city, lineId, nil, centralizedStation)
|
||||||
|
ref := s.Repo.GetCentralizedStationRef(stationUid)
|
||||||
|
if ref == nil {
|
||||||
|
slog.Warn(fmt.Sprintf("没有找到GetCentralizedStationRef [%s]", stationUid))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//
|
||||||
|
codePoints := ref.SectionCodePoints
|
||||||
|
if len(codePoints) != len(msg.Scs) {
|
||||||
|
slog.Warn(fmt.Sprintf("本地配置区段码表个数[%d] != 联锁发送集中站[%s]的区段命令个数[%d]", len(codePoints), stationUid, len(msg.Scs)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//
|
||||||
|
var cpSectionMap = make(map[int]*proto.CiSectionCodePoint)
|
||||||
|
for _, cp := range codePoints {
|
||||||
|
cpSectionMap[int(cp.Row)] = cp
|
||||||
|
}
|
||||||
|
//
|
||||||
|
var cmds []*fi.AxleSectionCmd
|
||||||
|
for index, cmdMsg := range msg.Scs {
|
||||||
|
cp := cpSectionMap[index]
|
||||||
|
cmd := &fi.AxleSectionCmd{}
|
||||||
|
cmd.SectionId = cp.SectionId
|
||||||
|
cmd.Drst = cmdMsg.Drst
|
||||||
|
cmd.Pdrst = cmdMsg.Pdrst
|
||||||
|
cmds = append(cmds, cmd)
|
||||||
|
}
|
||||||
|
fi.AxleSectionRstDrive(s.World, cmds)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CollectSectionStatus 收集仿真中计轴区段状态
|
|
||||||
func (s *VerifySimulation) CollectSectionStatus() []*message.SectionStatusMsg {
|
|
||||||
var msg []*message.SectionStatusMsg
|
|
||||||
var axleSectionIds []string
|
|
||||||
for _, section := range s.Repo.PhysicalSectionList() {
|
|
||||||
if is, _ := section.IsAxleSection(); is {
|
|
||||||
axleSectionIds = append(axleSectionIds, section.Id())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(axleSectionIds) <= 0 {
|
|
||||||
return []*message.SectionStatusMsg{}
|
|
||||||
} else {
|
|
||||||
as, e := fi.FindAxleSectionsStatus(s.World, axleSectionIds)
|
|
||||||
if e != nil { //从仿真中收集计轴区段状态的失败列表
|
|
||||||
slog.Warn(e.Error())
|
|
||||||
}
|
|
||||||
for _, a := range as {
|
|
||||||
state := &message.SectionStatusMsg{}
|
|
||||||
state.Rac = a.Rac
|
|
||||||
state.Rjt = a.Rjt
|
|
||||||
state.Rjo = a.Rjo
|
|
||||||
state.Occ = a.Occ
|
|
||||||
state.Clr = a.Clr
|
|
||||||
msg = append(msg, state)
|
|
||||||
}
|
|
||||||
return msg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func handlerDynamicsTurnoutState(w ecs.World, uid string) *message.DynamicsTurnoutInfo {
|
func handlerDynamicsTurnoutState(w ecs.World, uid string) *message.DynamicsTurnoutInfo {
|
||||||
entry, ok := entity.GetEntityByUid(w, uid)
|
entry, ok := entity.GetEntityByUid(w, uid)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -99,6 +99,10 @@ func initWorld(s *memory.VerifySimulation) error {
|
|||||||
|
|
||||||
// 运行仿真第三方模块
|
// 运行仿真第三方模块
|
||||||
func runThirdParty(s *memory.VerifySimulation) error {
|
func runThirdParty(s *memory.VerifySimulation) error {
|
||||||
|
//测试
|
||||||
|
if s != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
// 动力学启动
|
// 动力学启动
|
||||||
err := dynamics.Default().Start(s)
|
err := dynamics.Default().Start(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user