[修改]北京12号线计轴通信配置

This commit is contained in:
thesai 2024-07-08 16:14:26 +08:00
parent 4bdd91c18b
commit 8a6de531c8
3 changed files with 35 additions and 34 deletions

View File

@ -178,9 +178,10 @@ type RsspAxleConfig struct {
type RsspNetConfig struct {
RemoteIp string `json:"remoteIp" description:"远端IP"`
RemotePort int `json:"remotePort" description:"远端端口"`
LocalIp string `json:"localIp" description:"本地IP"`
LocalPort int `json:"localPort" description:"本地端口"`
SourceAddr string `json:"sourceAddr" description:"源地址16进制2字节"`
TargetAddr string `json:"targetAddr" description:"目的地址16进制2字节"`
RemoteAddr string `json:"sourceAddr" description:"联锁地址16进制2字节"`
LocalAddr string `json:"targetAddr" description:"计轴地址16进制2字节"`
Sid1 string `json:"sid1" description:"联锁SID_116进制4字节"`
Sid2 string `json:"sid2" description:"联锁SID_216进制4字节"`
LocalSid1 string `json:"remoteSid" description:"计轴SID_116进制4字节"`

View File

@ -38,8 +38,8 @@ type serviceContext struct {
cancelFunc context.CancelFunc
ciSectionIndexConfigs []*proto.CiSectionCodePoint
sourceAddr uint16 //源地址 从配置中的16进制字符串转来的
targetAddr uint16 //目的地址 从配置中的16进制字符串转来的
remoteAddr uint16 //联锁地址 从配置中的16进制字符串转来的
localAddr uint16 //计轴地址 从配置中的16进制字符串转来的
sid1 uint32 //联锁SID1 从配置中的16进制字符串转来的
sid2 uint32 //联锁SID2 从配置中的16进制字符串转来的
localSid1 uint32 //计轴SID1 从配置中的16进制字符串转来的
@ -78,13 +78,13 @@ func Start(simulation *memory.VerifySimulation) {
logger().Warn(fmt.Sprintf("集中站[%s]无区段编码数据,服务不启动", rsspConfig.StationCode))
return
}
sourceAddr, err := strconv.ParseUint(rsspConfig.NetAConfig.SourceAddr, 16, 16)
sourceAddr, err := strconv.ParseUint(rsspConfig.NetAConfig.RemoteAddr, 16, 16)
if err != nil {
panic(sys_error.New(fmt.Sprintf("%s集中站[%s]解析源地址[%s]出错", logTag, rsspConfig.StationCode, rsspConfig.NetAConfig.SourceAddr)))
panic(sys_error.New(fmt.Sprintf("%s集中站[%s]解析源地址[%s]出错", logTag, rsspConfig.StationCode, rsspConfig.NetAConfig.RemoteAddr)))
}
targetAddr, err := strconv.ParseUint(rsspConfig.NetAConfig.TargetAddr, 16, 16)
targetAddr, err := strconv.ParseUint(rsspConfig.NetAConfig.LocalAddr, 16, 16)
if err != nil {
panic(sys_error.New(fmt.Sprintf("%s集中站[%s]解析目的地址[%s]出错", logTag, rsspConfig.StationCode, rsspConfig.NetAConfig.TargetAddr)))
panic(sys_error.New(fmt.Sprintf("%s集中站[%s]解析目的地址[%s]出错", logTag, rsspConfig.StationCode, rsspConfig.NetAConfig.LocalAddr)))
}
sid1, err := strconv.ParseUint(rsspConfig.NetAConfig.Sid1, 16, 32)
if err != nil {
@ -116,8 +116,8 @@ func Start(simulation *memory.VerifySimulation) {
sim: simulation,
config: rsspConfig,
ciSectionIndexConfigs: ref.SectionCodePoints,
sourceAddr: uint16(sourceAddr),
targetAddr: uint16(targetAddr),
remoteAddr: uint16(sourceAddr),
localAddr: uint16(targetAddr),
sid1: uint32(sid1),
sid2: uint32(sid2),
localSid1: uint32(localSid1),
@ -130,7 +130,7 @@ func Start(simulation *memory.VerifySimulation) {
lfsr2: lfsr{value: uint32(localSid2)},
}
netAConfig := rsspConfig.NetAConfig
server := udp.NewServer(fmt.Sprintf(":%d", netAConfig.LocalPort), func(b []byte) {
server := udp.NewServer(fmt.Sprintf("%s:%d", netAConfig.LocalIp, netAConfig.LocalPort), func(b []byte) {
msgChan <- b
})
client := udp.NewClient(fmt.Sprintf("%s:%d", netAConfig.RemoteIp, netAConfig.RemotePort))
@ -179,7 +179,7 @@ func (s *serviceContext) runCollectTask(ctx context.Context) {
s.runCollectTask(ctx)
}
}()
for range time.Tick(time.Millisecond * time.Duration(s.config.NetAConfig.Period)) {
for range time.Tick(time.Millisecond * time.Duration(s.config.NetAConfig.Period) * time.Millisecond) {
select {
case <-ctx.Done():
return
@ -250,8 +250,8 @@ func (s *serviceContext) collect() *msg.RsdMsgBuilder {
MsgHeader: msg.MsgHeader{
ProtocolType: msg.ProtocolType_Sync,
MessageType: msg.MessageType_A,
SourceAddr: s.sourceAddr,
TargetAddr: s.targetAddr,
SourceAddr: s.localAddr,
TargetAddr: s.remoteAddr,
},
SeqNum: s.seqNum,
Svc1: s.calculateSvc1(userData),
@ -292,6 +292,8 @@ func (s *serviceContext) handleRsdMsg(data []byte) {
return
} else if validateResult == 2 {
//开启时序校正流程
logger().Error("时序校验失败,开始时序校正")
return
}
//流程处理
cmdInfos := msg.CmdInfos{}
@ -331,8 +333,8 @@ func (s *serviceContext) handleSseMsg(data []byte) {
MsgHeader: msg.MsgHeader{
ProtocolType: msg.ProtocolType_Sync,
MessageType: msg.MessageType_SSR,
SourceAddr: s.sourceAddr,
TargetAddr: s.targetAddr,
SourceAddr: s.remoteAddr,
TargetAddr: s.localAddr,
},
SeqNumSsr: s.seqNum,
SeqNumSse: sseMsg.SeqNum,
@ -371,8 +373,8 @@ func (s *serviceContext) startSeeProgress() {
MsgHeader: msg.MsgHeader{
ProtocolType: msg.ProtocolType_Sync,
MessageType: msg.MessageType_SSE,
SourceAddr: s.sourceAddr,
TargetAddr: s.targetAddr,
SourceAddr: s.remoteAddr,
TargetAddr: s.localAddr,
},
SeqNum: s.seqNum,
SeqEnq1: s.calculateSeqEnq1(),
@ -390,14 +392,12 @@ func (s *serviceContext) startSeeProgress() {
// 校验RSD消息
// return 0-时序校验之外的失败 1-成功 2-时序异常
func (s *serviceContext) validateRsdMsg(rsdMsg *msg.RsdMsg) int {
sourceAddr, _ := strconv.ParseUint(s.config.NetAConfig.SourceAddr, 16, 16)
if rsdMsg.SourceAddr != uint16(sourceAddr) {
logger().Error(fmt.Sprintf("源地址[%x]不正确[%s]", rsdMsg.SourceAddr, s.config.NetAConfig.SourceAddr))
if rsdMsg.SourceAddr != s.remoteAddr {
logger().Error(fmt.Sprintf("源地址[%x]不正确[%s]", rsdMsg.SourceAddr, s.config.NetAConfig.RemoteAddr))
return 0
}
targetAddr, _ := strconv.ParseUint(s.config.NetAConfig.TargetAddr, 16, 16)
if rsdMsg.TargetAddr != uint16(targetAddr) {
logger().Error(fmt.Sprintf("目的地址[%x]不正确[%s]", rsdMsg.TargetAddr, s.config.NetAConfig.TargetAddr))
if rsdMsg.TargetAddr != s.localAddr {
logger().Error(fmt.Sprintf("目的地址[%x]不正确[%s]", rsdMsg.TargetAddr, s.config.NetAConfig.LocalAddr))
return 0
}
if len(rsdMsg.UserData) != len(s.ciSectionIndexConfigs) {

View File

@ -146,16 +146,16 @@ func filterOtherLineDevice(data *data_proto.RtssGraphicStorage) {
for _, d := range data.Section {
did := GetMapElementId(d.Common)
if otherDeviceIdMap[did] {
slog.Warn("区段[id:%v][code:%s]设备是其他线路设备已过滤", did, d.Code)
slog.Warn(fmt.Sprintf("区段[id:%v][code:%s]设备是其他线路设备已过滤", did, d.Code))
continue
}
if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] {
d.PaRef = nil
slog.Warn("区段[id:%v][code:%s]设备A端是其他线路设备已置空", did, d.Code)
slog.Warn(fmt.Sprintf("区段[id:%v][code:%s]设备A端是其他线路设备已置空", did, d.Code))
}
if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] {
d.PbRef = nil
slog.Warn("区段[id:%v][code:%s]设备B端是其他线路设备已置空", did, d.Code)
slog.Warn(fmt.Sprintf("区段[id:%v][code:%s]设备B端是其他线路设备已置空", did, d.Code))
}
var acs []uint32
for _, id := range d.AxleCountings {
@ -176,7 +176,7 @@ func filterOtherLineDevice(data *data_proto.RtssGraphicStorage) {
for _, d := range data.AxleCountings {
did := GetMapElementId(d.Common)
if otherDeviceIdMap[did] {
slog.Warn("计轴[id:%v][code:%s]设备其他线路设备已过滤", did, d.Code)
slog.Warn(fmt.Sprintf("计轴[id:%v][code:%s]设备其他线路设备已过滤", did, d.Code))
continue
}
var refs []*data_proto.RelatedRef
@ -195,20 +195,20 @@ func filterOtherLineDevice(data *data_proto.RtssGraphicStorage) {
for _, d := range data.Turnouts {
did := GetMapElementId(d.Common)
if otherDeviceIdMap[did] {
slog.Warn("道岔[id:%v][code:%s]设备其他线路设备已过滤", did, d.Code)
slog.Warn(fmt.Sprintf("道岔[id:%v][code:%s]设备其他线路设备已过滤", did, d.Code))
continue
}
if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] {
d.PaRef = nil
slog.Warn("道岔[id:%v][code:%s]设备A端是其他线路设备已置空", did, d.Code)
slog.Warn(fmt.Sprintf("道岔[id:%v][code:%s]设备A端是其他线路设备已置空", did, d.Code))
}
if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] {
d.PbRef = nil
slog.Warn("道岔[id:%v][code:%s]设备B端是其他线路设备已置空", did, d.Code)
slog.Warn(fmt.Sprintf("道岔[id:%v][code:%s]设备B端是其他线路设备已置空", did, d.Code))
}
if d.PcRef != nil && otherDeviceIdMap[d.PcRef.Id] {
d.PcRef = nil
slog.Warn("道岔[id:%v][code:%s]设备C端是其他线路设备已置空", did, d.Code)
slog.Warn(fmt.Sprintf("道岔[id:%v][code:%s]设备C端是其他线路设备已置空", did, d.Code))
}
if d.PaTrackSectionId != 0 && otherDeviceIdMap[d.PaTrackSectionId] {
d.PaTrackSectionId = 0
@ -227,7 +227,7 @@ func filterOtherLineDevice(data *data_proto.RtssGraphicStorage) {
for _, d := range data.Signals {
did := GetMapElementId(d.Common)
if otherDeviceIdMap[did] {
slog.Warn("信号机[id:%v][code:%s]设备其他线路设备已过滤", did, d.Code)
slog.Warn(fmt.Sprintf("信号机[id:%v][code:%s]设备其他线路设备已过滤", did, d.Code))
continue
}
signals = append(signals, d)
@ -238,7 +238,7 @@ func filterOtherLineDevice(data *data_proto.RtssGraphicStorage) {
for _, d := range data.Transponders {
did := GetMapElementId(d.Common)
if otherDeviceIdMap[did] {
slog.Warn("应答器[id:%v][code:%s]设备其他线路设备已过滤", did, d.Code)
slog.Warn(fmt.Sprintf("应答器[id:%v][code:%s]设备其他线路设备已过滤", did, d.Code))
continue
}
transponders = append(transponders, d)