ats 测试模型定义
This commit is contained in:
parent
53d0ecfa3f
commit
5eeddab55c
@ -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
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ type WaysideMemoryInitializer struct {
|
||||
memory *WaysideMemory
|
||||
}
|
||||
|
||||
func (initializer *WaysideMemoryInitializer) Init(memory *WaysideMemory) *WaysideMemoryInitializer {
|
||||
func (initializer *WaysideMemoryInitializer) Create(memory *WaysideMemory) *WaysideMemoryInitializer {
|
||||
initializer.memory = memory
|
||||
return initializer
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user