Merge branch 'master' of https://git.code.tencent.com/beijing-rtss-test/bj-rtsts-server-go
This commit is contained in:
commit
e102a28bb2
@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/third_party/axle_device"
|
||||
"log/slog"
|
||||
"net"
|
||||
"os"
|
||||
@ -56,6 +57,7 @@ type ThridPartyConfig struct {
|
||||
Dynamics DynamicsConfig `json:"dynamics" description:"动力学配置"`
|
||||
Vobc VobcConfig `json:"vobc" description:"半实物配置"`
|
||||
Interlocks []InterlockConfig `json:"interlock" description:"联锁配置"`
|
||||
RsspAxle RsspAxleConfig `json:"rsspAxle" description:"计轴RSSP-I配置"`
|
||||
}
|
||||
type DynamicsConfig struct {
|
||||
Ip string `json:"ip" description:"IP配置"`
|
||||
@ -78,6 +80,10 @@ type InterlockConfig struct {
|
||||
Open bool `json:"open" description:"是否开启"`
|
||||
Code string `json:"code" description:"所属集中站"`
|
||||
}
|
||||
type RsspAxleConfig struct {
|
||||
MasterRssp axle_device.RsspConfig `json:"masterRssp" description:"主安全通道配置"`
|
||||
SlaveRssp axle_device.RsspConfig `json:"slaveRssp" description:"备安全通道配置"`
|
||||
}
|
||||
|
||||
var Config AppConfig
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 45b4f4f0fe4eaf1eae6f31cca8d0b14237596bf1
|
||||
Subproject commit 3c08644dde7d13da7de400afa68a9fd4f1712a1e
|
34
third_party/axle_device/config.go
vendored
34
third_party/axle_device/config.go
vendored
@ -5,25 +5,25 @@ import "joylink.club/bj-rtsts-server/third_party/message"
|
||||
// RsspConfig CI系统与计轴设备的安全通信协议配置参数
|
||||
// 计轴设备(管理一个集中站的所有计轴器)配置
|
||||
type RsspConfig struct {
|
||||
SrcAddr uint16 //16位源地址,本地地址
|
||||
DstAddr uint16 //16位目的地址,远程地址
|
||||
DataVer1 uint32 //通道1数据版本
|
||||
DataVer2 uint32 //通道2数据版本
|
||||
SID1 uint32 //通道1源标识
|
||||
SID2 uint32 //通道2源标识
|
||||
SINIT1 uint32 //通道1序列初始
|
||||
SINIT2 uint32 //通道2序列初始
|
||||
SendingPeriod uint32 //接收方每个安全通信会话对应的发送周期值,单位ms
|
||||
SsrRsspTimeout uint32 //等待SSR回应的定时器超时值,为RsspTimer时间,1=SendingPeriod
|
||||
Mtv uint32 //每个安全通信会话可容忍的最大时序偏差,即当前接收的RSD的序列号与上一次RSD的序列号最大允许差值
|
||||
Udl uint32 //每个安全通信会话RSD应用数据长度发送和接收的配置值(支持固定长度和可变长度);0-可变长度,大于0即固定长度
|
||||
SrcAddr uint16 `json:"SrcAddr" description:"16位源地址,本地地址"` //16位源地址,本地地址
|
||||
DstAddr uint16 `json:"DstAddr" description:"16位目的地址,远程地址"` //16位目的地址,远程地址
|
||||
DataVer1 uint32 `json:"DataVer1" description:"通道1数据版本"` //通道1数据版本
|
||||
DataVer2 uint32 `json:"DataVer2" description:"通道2数据版本"` //通道2数据版本
|
||||
SID1 uint32 `json:"SID1" description:"通道1源标识"` //通道1源标识
|
||||
SID2 uint32 `json:"SID2" description:"通道2源标识"` //通道2源标识
|
||||
SINIT1 uint32 `json:"SINIT1" description:"通道1序列初始"` //通道1序列初始
|
||||
SINIT2 uint32 `json:"SINIT2" description:"通道2序列初始"` //通道2序列初始
|
||||
SendingPeriod uint32 `json:"SendingPeriod" description:"发送周期值"` //接收方每个安全通信会话对应的发送周期值,单位ms
|
||||
SsrRsspTimeout uint32 `json:"SsrRsspTimeout" description:"等待SSR回应的定时器超时值"` //等待SSR回应的定时器超时值,为RsspTimer时间,1=SendingPeriod
|
||||
Mtv uint32 `json:"Mtv" description:"最大时序偏差"` //每个安全通信会话可容忍的最大时序偏差,即当前接收的RSD的序列号与上一次RSD的序列号最大允许差值
|
||||
Udl uint32 `json:"Udl" description:"RSD应用数据长度配置值"` //每个安全通信会话RSD应用数据长度发送和接收的配置值(支持固定长度和可变长度);0-可变长度,大于0即固定长度
|
||||
|
||||
PicType message.PicType //协议交互类别
|
||||
DeviceA bool //true-A机;false-B机
|
||||
PicType message.PicType `json:"PicType" description:"协议交互类别"` //协议交互类别
|
||||
DeviceA bool `json:"DeviceA" description:"true-A机;false-B机"` //true-A机;false-B机
|
||||
|
||||
RemoteIp string //远程服务器ip
|
||||
RemoteUdpPort int //远程服务器端口
|
||||
LocalUdpPort int //本地服务器端口
|
||||
RemoteIp string `json:"RemoteIp" description:"远程服务器ip"` //远程服务器ip
|
||||
RemoteUdpPort int `json:"RemoteUdpPort" description:"远程服务器端口"` //远程服务器端口
|
||||
LocalUdpPort int `json:"LocalUdpPort" description:"本地服务器端口"` //本地服务器端口
|
||||
}
|
||||
|
||||
// CheckAddress 检测目标源地址目的地址是否在配置中
|
||||
|
57
third_party/axle_device/rssp_axle.go
vendored
57
third_party/axle_device/rssp_axle.go
vendored
@ -1,6 +1,11 @@
|
||||
package axle_device
|
||||
|
||||
import "joylink.club/bj-rtsts-server/third_party/message"
|
||||
import (
|
||||
"context"
|
||||
"joylink.club/bj-rtsts-server/third_party/message"
|
||||
"log/slog"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
//计轴设备与联锁系统安全通信应用层实现
|
||||
|
||||
@ -31,10 +36,16 @@ type rsspAxle struct {
|
||||
slaveRssp *RsspChannel
|
||||
//收到应用层消息回调
|
||||
messageManager AxleMessageManager
|
||||
//发送区段状态任务
|
||||
cancelSendStatus context.CancelFunc
|
||||
}
|
||||
|
||||
func NewRsspAxle(masterRssp *RsspChannel, slaveRssp *RsspChannel) RsspAxle {
|
||||
return &rsspAxle{masterRssp: masterRssp, slaveRssp: slaveRssp}
|
||||
func NewRsspAxle(masterConfig *RsspConfig, slaveConfig *RsspConfig) RsspAxle {
|
||||
mr := &RsspChannel{}
|
||||
mr.Init(masterConfig)
|
||||
lr := &RsspChannel{}
|
||||
lr.Init(slaveConfig)
|
||||
return &rsspAxle{masterRssp: mr, slaveRssp: lr}
|
||||
}
|
||||
|
||||
// rssp 安全层执行
|
||||
@ -55,6 +66,10 @@ func (s *rsspAxle) Start(amm AxleMessageManager) error {
|
||||
s.slaveRssp.Start()
|
||||
}
|
||||
//
|
||||
sendContext, sendCancel := context.WithCancel(context.Background())
|
||||
go s.doTaskSendStatus(sendContext)
|
||||
s.cancelSendStatus = sendCancel
|
||||
//
|
||||
return nil
|
||||
}
|
||||
func (s *rsspAxle) Stop() {
|
||||
@ -64,6 +79,42 @@ func (s *rsspAxle) Stop() {
|
||||
if s.slaveRssp != nil {
|
||||
s.slaveRssp.Stop()
|
||||
}
|
||||
//
|
||||
if s.cancelSendStatus != nil {
|
||||
s.cancelSendStatus()
|
||||
}
|
||||
s.messageManager = nil
|
||||
}
|
||||
func (s *rsspAxle) doTaskSendStatus(sendContext context.Context) {
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
slog.Error("定时发送计轴区段状态任务异常", "error", e, "stack", string(debug.Stack()))
|
||||
debug.PrintStack()
|
||||
}
|
||||
}()
|
||||
for {
|
||||
select {
|
||||
case <-sendContext.Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
if s.messageManager == nil {
|
||||
slog.Warn("定时发送计轴区段状态任务因messageManager不存在退出")
|
||||
return
|
||||
}
|
||||
//收集区段状态
|
||||
sectionStatusMsg, e := s.messageManager.CollectSectionStatus(s.city, s.lineId, s.centralizedStation)
|
||||
if e == nil {
|
||||
if sectionStatusMsg != nil {
|
||||
msgPack := &message.SectionStatusMsgPack{}
|
||||
msgPack.Ck = 0 //暂时无用
|
||||
msgPack.Sms = sectionStatusMsg
|
||||
s.sendStatusMsg(msgPack)
|
||||
}
|
||||
} else {
|
||||
slog.Debug(e.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 发送计轴区段状态给联锁
|
||||
|
Loading…
Reference in New Issue
Block a user