计轴rssp 集成
This commit is contained in:
parent
3347dece7c
commit
4dc9f06d27
@ -3,7 +3,6 @@ package config
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/third_party/axle_device"
|
||||
"log/slog"
|
||||
"net"
|
||||
"os"
|
||||
@ -53,11 +52,11 @@ type centrifugo struct {
|
||||
|
||||
// 第三方配置结构
|
||||
type ThridPartyConfig struct {
|
||||
Id int32 `json:"id"`
|
||||
Dynamics DynamicsConfig `json:"dynamics" description:"动力学配置"`
|
||||
Vobc VobcConfig `json:"vobc" description:"半实物配置"`
|
||||
Interlocks []InterlockConfig `json:"interlock" description:"联锁配置"`
|
||||
RsspAxle RsspAxleConfig `json:"rsspAxle" description:"计轴RSSP-I配置"`
|
||||
Id int32 `json:"id"`
|
||||
Dynamics DynamicsConfig `json:"dynamics" description:"动力学配置"`
|
||||
Vobc VobcConfig `json:"vobc" description:"半实物配置"`
|
||||
Interlocks []InterlockConfig `json:"interlock" description:"联锁配置"`
|
||||
RsspAxleCfgs []RsspAxleConfig `json:"rsspAxleCfgs" description:"所有联锁集中站计轴RSSP-I配置"`
|
||||
}
|
||||
type DynamicsConfig struct {
|
||||
Ip string `json:"ip" description:"IP配置"`
|
||||
@ -80,11 +79,44 @@ type InterlockConfig struct {
|
||||
Open bool `json:"open" description:"是否开启"`
|
||||
Code string `json:"code" description:"所属集中站"`
|
||||
}
|
||||
|
||||
// RsspAxleConfig 计轴区段与联锁安全通信配置
|
||||
type RsspAxleConfig struct {
|
||||
MasterRssp axle_device.RsspConfig `json:"masterRssp" description:"主安全通道配置"`
|
||||
SlaveRssp axle_device.RsspConfig `json:"slaveRssp" description:"备安全通道配置"`
|
||||
City string `json:"City" description:"所属城市"`
|
||||
LineId string `json:"LineId" description:"所属线路"`
|
||||
CentralizedStation string `json:"centralizedStation" description:"所属集中站"`
|
||||
RsspCfgs []RsspConfig `json:"rsspCfgs" description:"主备安全通道配置"`
|
||||
}
|
||||
|
||||
// RsspConfig CI系统与计轴设备的安全通信协议配置参数
|
||||
// 计轴设备(管理一个集中站的所有计轴器)配置
|
||||
type RsspConfig struct {
|
||||
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 byte `json:"picType" description:"协议交互类别"` //协议交互类别,message.PicType
|
||||
DeviceA bool `json:"deviceA" description:"true-A机;false-B机"` //true-A机;false-B机
|
||||
RemoteIp string `json:"remoteIp" description:"远程服务器ip"` //远程服务器ip
|
||||
RemoteUdpPort int `json:"remoteUdpPort" description:"远程服务器端口"` //远程服务器端口
|
||||
LocalUdpPort int `json:"localUdpPort" description:"本地服务器端口"` //本地服务器端口
|
||||
}
|
||||
|
||||
// CheckAddress 检测目标源地址目的地址是否在配置中
|
||||
func (c *RsspConfig) CheckAddress(srcAddr uint16, dstAddr uint16) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var Config AppConfig
|
||||
|
||||
var SimulationId_prefix = (func() string {
|
||||
|
30
third_party/axle_device/config.go
vendored
30
third_party/axle_device/config.go
vendored
@ -1,30 +0,0 @@
|
||||
package axle_device
|
||||
|
||||
import "joylink.club/bj-rtsts-server/third_party/message"
|
||||
|
||||
// RsspConfig CI系统与计轴设备的安全通信协议配置参数
|
||||
// 计轴设备(管理一个集中站的所有计轴器)配置
|
||||
type RsspConfig struct {
|
||||
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 `json:"picType" description:"协议交互类别"` //协议交互类别
|
||||
DeviceA bool `json:"deviceA" description:"true-A机;false-B机"` //true-A机;false-B机
|
||||
RemoteIp string `json:"remoteIp" description:"远程服务器ip"` //远程服务器ip
|
||||
RemoteUdpPort int `json:"remoteUdpPort" description:"远程服务器端口"` //远程服务器端口
|
||||
LocalUdpPort int `json:"localUdpPort" description:"本地服务器端口"` //本地服务器端口
|
||||
}
|
||||
|
||||
// CheckAddress 检测目标源地址目的地址是否在配置中
|
||||
func (c *RsspConfig) CheckAddress(srcAddr uint16, dstAddr uint16) bool {
|
||||
return true
|
||||
}
|
42
third_party/axle_device/rssp_axle.go
vendored
42
third_party/axle_device/rssp_axle.go
vendored
@ -2,6 +2,7 @@ package axle_device
|
||||
|
||||
import (
|
||||
"context"
|
||||
"joylink.club/bj-rtsts-server/config"
|
||||
"joylink.club/bj-rtsts-server/third_party/message"
|
||||
"log/slog"
|
||||
"runtime/debug"
|
||||
@ -16,13 +17,6 @@ type RsspAxle interface {
|
||||
Stop()
|
||||
}
|
||||
|
||||
type AxleMessageManager interface {
|
||||
//HandleSectionCmdMsg 计轴设备接收到联锁发送来的控制命令
|
||||
HandleSectionCmdMsg(city string, lineId string, centralizedStation string, msg *message.SectionCmdMsgPack)
|
||||
//CollectSectionStatus 收集仿真中计轴区段状态
|
||||
CollectSectionStatus(city string, lineId string, centralizedStation string) ([]*message.SectionStatusMsg, error)
|
||||
}
|
||||
|
||||
type rsspAxle struct {
|
||||
//所属城市
|
||||
city string
|
||||
@ -40,12 +34,31 @@ type rsspAxle struct {
|
||||
cancelSendStatus context.CancelFunc
|
||||
}
|
||||
|
||||
func NewRsspAxle(masterConfig *RsspConfig, slaveConfig *RsspConfig) RsspAxle {
|
||||
mr := &RsspChannel{}
|
||||
mr.Init(masterConfig)
|
||||
lr := &RsspChannel{}
|
||||
lr.Init(slaveConfig)
|
||||
return &rsspAxle{masterRssp: mr, slaveRssp: lr}
|
||||
func InitRsspAxle(cfg *config.RsspAxleConfig) RsspAxle {
|
||||
ra := &rsspAxle{}
|
||||
//
|
||||
ra.city = cfg.City
|
||||
ra.lineId = cfg.LineId
|
||||
ra.centralizedStation = cfg.CentralizedStation
|
||||
//
|
||||
cfgLen := len(cfg.RsspCfgs)
|
||||
var masterConfig, slaveConfig *config.RsspConfig
|
||||
if cfgLen >= 1 {
|
||||
masterConfig = &cfg.RsspCfgs[0]
|
||||
}
|
||||
if cfgLen >= 2 {
|
||||
slaveConfig = &cfg.RsspCfgs[1]
|
||||
}
|
||||
if masterConfig != nil {
|
||||
mrc := &RsspChannel{}
|
||||
ra.masterRssp = mrc.Init(masterConfig)
|
||||
}
|
||||
if slaveConfig != nil {
|
||||
src := &RsspChannel{}
|
||||
ra.slaveRssp = src.Init(slaveConfig)
|
||||
}
|
||||
//
|
||||
return ra
|
||||
}
|
||||
|
||||
// rssp 安全层执行
|
||||
@ -83,6 +96,9 @@ func (s *rsspAxle) Stop() {
|
||||
if s.cancelSendStatus != nil {
|
||||
s.cancelSendStatus()
|
||||
}
|
||||
if s.cancelSendStatus != nil {
|
||||
s.cancelSendStatus()
|
||||
}
|
||||
s.messageManager = nil
|
||||
}
|
||||
func (s *rsspAxle) doTaskSendStatus(sendContext context.Context) {
|
||||
|
29
third_party/axle_device/rssp_axle_manage.go
vendored
Normal file
29
third_party/axle_device/rssp_axle_manage.go
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
package axle_device
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/config"
|
||||
"joylink.club/bj-rtsts-server/third_party/message"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
//联锁集中站计轴与联锁通信管理
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func StartLineAllRsspAxleServices(ram AxleMessageManager) {
|
||||
cfgs := ram.GetLineAllRsspAxleCfgs()
|
||||
for _, cfg := range cfgs {
|
||||
if len(cfg.RsspCfgs) > 0 {
|
||||
InitRsspAxle(&cfg).Start(ram)
|
||||
} else {
|
||||
slog.Debug(fmt.Sprintf(""))
|
||||
}
|
||||
}
|
||||
}
|
6
third_party/axle_device/rssp_channel.go
vendored
6
third_party/axle_device/rssp_channel.go
vendored
@ -2,6 +2,7 @@ package axle_device
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/config"
|
||||
"joylink.club/bj-rtsts-server/third_party/message"
|
||||
"joylink.club/bj-rtsts-server/third_party/udp"
|
||||
"log/slog"
|
||||
@ -21,7 +22,7 @@ type RsspChannel struct {
|
||||
//回调应用层
|
||||
handleUserData HandleUserData
|
||||
//rssp安全通信配置
|
||||
config *RsspConfig
|
||||
config *config.RsspConfig
|
||||
//rssp时钟
|
||||
rsspTimer *RsspTimer
|
||||
//批次编号,发送序列号
|
||||
@ -40,12 +41,13 @@ type RsspChannel struct {
|
||||
sendSseRecord *SseFireRecord
|
||||
}
|
||||
|
||||
func (s *RsspChannel) Init(config *RsspConfig) {
|
||||
func (s *RsspChannel) Init(config *config.RsspConfig) *RsspChannel {
|
||||
s.config = config
|
||||
s.rsspTimer = &RsspTimer{t: 0}
|
||||
s.sn = message.NewRsspSn(1)
|
||||
s.ch1Ts = message.NewRsspLFSR(message.RsspTsC1, 32, s.config.SID1, false)
|
||||
s.ch2Ts = message.NewRsspLFSR(message.RsspTsC2, 32, s.config.SID2, false)
|
||||
return s
|
||||
}
|
||||
|
||||
// Start 启动安全通道
|
||||
|
4
third_party/third_party.go
vendored
4
third_party/third_party.go
vendored
@ -1,5 +1,7 @@
|
||||
package third_party
|
||||
|
||||
func Init() {
|
||||
import "joylink.club/bj-rtsts-server/third_party/message"
|
||||
|
||||
func Init() {
|
||||
message.InitRsspCrcTable()
|
||||
}
|
||||
|
@ -147,6 +147,9 @@ func (s *VerifySimulation) GetComIdByUid(uid string) string {
|
||||
}
|
||||
return es[uid].CommonId
|
||||
}
|
||||
func (s *VerifySimulation) GetLineAllRsspAxleCfgs() []config.RsspAxleConfig {
|
||||
return s.runConfig.RsspAxleCfgs
|
||||
}
|
||||
|
||||
// CollectSectionStatus 收集仿真中计轴区段状态
|
||||
func (s *VerifySimulation) CollectSectionStatus(city string, lineId string, centralizedStation string) ([]*message.SectionStatusMsg, error) {
|
||||
|
@ -2,6 +2,7 @@ package ts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/third_party/axle_device"
|
||||
"log/slog"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@ -110,6 +111,8 @@ func runThirdParty(s *memory.VerifySimulation) error {
|
||||
for _, c := range s.GetInterlockCodes() {
|
||||
interlock.Default(c).Start(s)
|
||||
}
|
||||
// 计轴RSSP启动
|
||||
axle_device.StartLineAllRsspAxleServices(s)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user