Merge branch 'master' of https://git.code.tencent.com/beijing-rtss-test/bj-rtsts-server-go
This commit is contained in:
commit
bfa8deb77c
@ -1,6 +1,8 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/face"
|
||||
)
|
||||
@ -23,6 +25,19 @@ type VerifyStructure struct {
|
||||
SignalDeviceModelMap map[string]face.SignalDeviceModeller
|
||||
}
|
||||
|
||||
func (me *VerifyStructure) create() *VerifyStructure {
|
||||
me.AxlePointDeviceModelMap = make(map[string]face.AxlePointDeviceModeller)
|
||||
me.SwitchDeviceModelMap = make(map[string]face.SwitchDeviceModeller)
|
||||
me.LinkSectionModelMap = make(map[string]face.LinkSectionModeller)
|
||||
me.AxleSectionModelMap = make(map[string]face.AxleSectionModeller)
|
||||
me.PhysicalSectionModelMap = make(map[string]face.PhysicalSectionModeller)
|
||||
me.LogicalSectionModelMap = make(map[string]face.LogicalSectionModeller)
|
||||
me.SignalDeviceModelMap = make(map[string]face.SignalDeviceModeller)
|
||||
return me
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 轨旁仿真模型状态
|
||||
type VerifyStatus struct {
|
||||
//道岔状态,key为道岔id即索引
|
||||
@ -41,12 +56,27 @@ type VerifyStatus struct {
|
||||
SignalStateMap map[string]*state.SignalState
|
||||
}
|
||||
|
||||
func (me *VerifyStatus) create() *VerifyStatus {
|
||||
me.SwitchStateMap = make(map[string]*state.SwitchState)
|
||||
me.LinkStateMap = make(map[string]*state.LinkState)
|
||||
me.TrainStateMap = make(map[string]*state.TrainState)
|
||||
me.AxleSectionStateMap = make(map[string]*state.SectionState)
|
||||
me.PhysicalSectionStateMap = make(map[string]*state.SectionState)
|
||||
me.LogicSectionStateMap = make(map[string]*state.SectionState)
|
||||
me.SignalStateMap = make(map[string]*state.SignalState)
|
||||
return me
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 轨旁仿真内存模型
|
||||
type WaysideMemory struct {
|
||||
//固定关系数据:轨旁仿真模型结构
|
||||
Structure *VerifyStructure
|
||||
//可变状态数据:轨旁仿真模型状态
|
||||
Status *VerifyStatus
|
||||
//状态保护锁
|
||||
rwLock *sync.RWMutex
|
||||
//对数据的操作管理实现:对内存模型初始化的初始化器
|
||||
Initializer *WaysideMemoryInitializer
|
||||
//对数据的操作管理实现:对内存模型的列车运行时数据操作的更新器
|
||||
@ -62,12 +92,32 @@ type WaysideMemory struct {
|
||||
}
|
||||
|
||||
// 初始化轨旁仿真内存模型
|
||||
func (memory *WaysideMemory) Init() *WaysideMemory {
|
||||
memory.Initializer = new(WaysideMemoryInitializer).Init(memory)
|
||||
memory.TrainRuntime = new(WaysideMemoryTrainRuntime).Init(memory)
|
||||
memory.Helper = new(WaysideMemoryHelper).Init(memory)
|
||||
memory.Variation = new(WaysideMemoryVariation).Init(memory)
|
||||
memory.SectionMapper = new(WaysideMemorySectionMapper).Init(memory)
|
||||
memory.PathLayer = new(WaysidePathLayer).Init(memory)
|
||||
func (memory *WaysideMemory) Create() *WaysideMemory {
|
||||
memory.Structure = new(VerifyStructure).create()
|
||||
memory.Status = new(VerifyStatus).create()
|
||||
memory.rwLock = new(sync.RWMutex)
|
||||
//初始化数据操作管理器
|
||||
memory.Initializer = new(WaysideMemoryInitializer).Create(memory)
|
||||
memory.TrainRuntime = new(WaysideMemoryTrainRuntime).Create(memory)
|
||||
memory.Helper = new(WaysideMemoryHelper).Create(memory)
|
||||
memory.Variation = new(WaysideMemoryVariation).Create(memory)
|
||||
memory.SectionMapper = new(WaysideMemorySectionMapper).Create(memory)
|
||||
memory.PathLayer = new(WaysidePathLayer).Create(memory)
|
||||
return memory
|
||||
}
|
||||
|
||||
// 状态读保护操作
|
||||
func (me *WaysideMemory) SafeOptRead(opt func(memory *WaysideMemory) any) any {
|
||||
me.rwLock.RLock()
|
||||
defer me.rwLock.RUnlock()
|
||||
var rt any = opt(me)
|
||||
return rt
|
||||
}
|
||||
|
||||
// 状态写保护操作
|
||||
func (me *WaysideMemory) SafeOptWrite(opt func(memory *WaysideMemory) any) any {
|
||||
me.rwLock.Lock()
|
||||
defer me.rwLock.Unlock()
|
||||
var rt any = opt(me)
|
||||
return rt
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ type WaysideMemoryHelper struct {
|
||||
memory *WaysideMemory
|
||||
}
|
||||
|
||||
func (me *WaysideMemoryHelper) Init(memory *WaysideMemory) *WaysideMemoryHelper {
|
||||
func (me *WaysideMemoryHelper) Create(memory *WaysideMemory) *WaysideMemoryHelper {
|
||||
me.memory = memory
|
||||
return me
|
||||
}
|
||||
|
@ -1,12 +1,35 @@
|
||||
package memory
|
||||
|
||||
//根据地图数据来初始VerifyMemoryModel,包括对地图数据的校验,构建设备间固定关系,
|
||||
//初始化设备状态。
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||
)
|
||||
|
||||
// 根据地图数据来初始VerifyMemoryModel,包括对地图数据的校验,构建设备间固定关系,
|
||||
// 初始化设备状态。
|
||||
type WaysideMemoryInitializer struct {
|
||||
memory *WaysideMemory
|
||||
}
|
||||
|
||||
func (initializer *WaysideMemoryInitializer) Init(memory *WaysideMemory) *WaysideMemoryInitializer {
|
||||
initializer.memory = memory
|
||||
return initializer
|
||||
func (me *WaysideMemoryInitializer) Create(memory *WaysideMemory) *WaysideMemoryInitializer {
|
||||
me.memory = memory
|
||||
return me
|
||||
}
|
||||
|
||||
// 从地图数据构建仿真内存模型
|
||||
func (me *WaysideMemoryInitializer) InitFromMap(proto *graphicData.RtssGraphicStorage) {
|
||||
me.initFromMapForTest(proto)
|
||||
}
|
||||
|
||||
// 暂时测试用
|
||||
func (me *WaysideMemoryInitializer) initFromMapForTest(proto *graphicData.RtssGraphicStorage) {
|
||||
for _, turnout := range proto.Turnouts {
|
||||
var swtichState *state.SwitchState = new(state.SwitchState)
|
||||
swtichState.Id = fmt.Sprintf("%d", turnout.Index)
|
||||
swtichState.Normal = true
|
||||
swtichState.Reverse = false
|
||||
me.memory.Status.SwitchStateMap[swtichState.Id] = swtichState
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ type WaysideMemorySectionMapper struct {
|
||||
memory *WaysideMemory
|
||||
}
|
||||
|
||||
func (me *WaysideMemorySectionMapper) Init(memory *WaysideMemory) *WaysideMemorySectionMapper {
|
||||
func (me *WaysideMemorySectionMapper) Create(memory *WaysideMemory) *WaysideMemorySectionMapper {
|
||||
me.memory = memory
|
||||
return me
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ type WaysideMemoryTrainRuntime struct {
|
||||
memory *WaysideMemory
|
||||
}
|
||||
|
||||
func (tr *WaysideMemoryTrainRuntime) Init(memory *WaysideMemory) *WaysideMemoryTrainRuntime {
|
||||
func (tr *WaysideMemoryTrainRuntime) Create(memory *WaysideMemory) *WaysideMemoryTrainRuntime {
|
||||
tr.memory = memory
|
||||
return tr
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ type WaysideMemoryVariation struct {
|
||||
memory *WaysideMemory
|
||||
}
|
||||
|
||||
func (me *WaysideMemoryVariation) Init(memory *WaysideMemory) *WaysideMemoryVariation {
|
||||
func (me *WaysideMemoryVariation) Create(memory *WaysideMemory) *WaysideMemoryVariation {
|
||||
me.memory = memory
|
||||
return me
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ type WaysidePathLayer struct {
|
||||
memory *WaysideMemory
|
||||
}
|
||||
|
||||
func (me *WaysidePathLayer) Init(memory *WaysideMemory) *WaysidePathLayer {
|
||||
func (me *WaysidePathLayer) Create(memory *WaysideMemory) *WaysidePathLayer {
|
||||
me.memory = memory
|
||||
return me
|
||||
}
|
||||
|
34
ats/verify/simulation/wayside/runtime/wayside_runtime.go
Normal file
34
ats/verify/simulation/wayside/runtime/wayside_runtime.go
Normal file
@ -0,0 +1,34 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/memory"
|
||||
)
|
||||
|
||||
// 轨旁仿真定义
|
||||
type VerifySimulation struct {
|
||||
//地图id
|
||||
MapId int32
|
||||
//仿真id
|
||||
SimulationId string
|
||||
//仿真内存数据
|
||||
Memory *memory.WaysideMemory
|
||||
}
|
||||
|
||||
// 创建仿真
|
||||
func CreateSimulation(mapId int32, simulationId string) *VerifySimulation {
|
||||
sim := new(VerifySimulation)
|
||||
sim.MapId = mapId
|
||||
sim.SimulationId = simulationId
|
||||
return sim
|
||||
}
|
||||
|
||||
// 启动仿真
|
||||
func (me *VerifySimulation) Start(proto *graphicData.RtssGraphicStorage) {
|
||||
me.Memory.Initializer.InitFromMap(proto)
|
||||
}
|
||||
|
||||
// 关闭仿真
|
||||
func (me *VerifySimulation) Shutdown() {
|
||||
|
||||
}
|
@ -1 +0,0 @@
|
||||
package wayside
|
Loading…
Reference in New Issue
Block a user