rts-sim-testing-service/third_party/axle_device/rssp_axle_manage.go

66 lines
1.9 KiB
Go
Raw Normal View History

2023-11-09 13:05:29 +08:00
package axle_device
import (
"joylink.club/bj-rtsts-server/config"
"joylink.club/bj-rtsts-server/third_party/message"
2023-11-14 17:57:54 +08:00
"log/slog"
2023-11-09 13:05:29 +08:00
)
//联锁集中站计轴与联锁通信管理
type AxleMessageManager interface {
GetLineAllRsspAxleCfgs() []config.RsspAxleConfig
//HandleSectionCmdMsg 计轴设备接收到联锁发送来的控制命令
HandleSectionCmdMsg(city string, lineId string, centralizedStation string, msg *message.SectionCmdMsgPack)
//CollectSectionStatus 收集仿真中计轴区段状态
CollectSectionStatus(city string, lineId string, centralizedStation string) ([]*message.SectionStatusMsg, error)
}
2023-11-10 10:54:44 +08:00
var allRsspAxleServices []RsspAxle
2023-11-09 13:05:29 +08:00
func StartLineAllRsspAxleServices(ram AxleMessageManager) {
2023-11-10 10:54:44 +08:00
allRsspAxleServices = nil
2023-11-09 13:05:29 +08:00
cfgs := ram.GetLineAllRsspAxleCfgs()
2023-11-14 17:58:38 +08:00
//cfgs = getTestConfig() //测试用
2023-11-09 13:05:29 +08:00
for _, cfg := range cfgs {
2023-11-09 17:38:17 +08:00
if cfg.Open {
2023-11-10 10:54:44 +08:00
as := InitRsspAxle(&cfg)
allRsspAxleServices = append(allRsspAxleServices, as)
as.Start(ram)
2023-11-14 17:57:54 +08:00
slog.Debug("启动计轴设备", "city", cfg.City, "lineId", cfg.LineId, "CentralizedStation", cfg.CentralizedStation)
2023-11-09 13:05:29 +08:00
}
}
}
2023-11-10 10:54:44 +08:00
func StopLineAllRsspAxleServices() {
for _, as := range allRsspAxleServices {
as.Stop()
}
}
2023-11-14 17:57:54 +08:00
// 测试用
func getTestConfig() []config.RsspAxleConfig {
cfg := &config.RsspAxleConfig{}
cfg.Open = true
cfg.City = "北京"
cfg.LineId = "12"
cfg.CentralizedStation = "酒仙桥"
cfg.RsspCfg.SrcAddr = 0x02
cfg.RsspCfg.DstAddr = 0x01
cfg.RsspCfg.DataVer1 = 0x0011
cfg.RsspCfg.DataVer2 = 0x0012
cfg.RsspCfg.SID1 = 0x10000000
cfg.RsspCfg.SID2 = 0x00000001
cfg.RsspCfg.SINIT1 = 0x01
cfg.RsspCfg.SINIT2 = 0x02
cfg.RsspCfg.SendingPeriod = 500
cfg.RsspCfg.SsrRsspTimeout = 3
cfg.RsspCfg.Mtv = 3
cfg.RsspCfg.DeviceA = false
cfg.RsspCfg.PicType = message.PIC_MASTER
cfg.RsspCfg.RemoteIp = "192.168.3.5"
cfg.RsspCfg.RemoteUdpPort = 7777
cfg.RsspCfg.LocalUdpPort = 6666
//
return []config.RsspAxleConfig{*cfg}
}