This commit is contained in:
weizhihong 2023-07-31 17:27:13 +08:00
commit 811baed6ce
7 changed files with 140 additions and 0 deletions

View File

@ -0,0 +1,73 @@
package memory
import (
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/face"
)
// 轨旁仿真模型结构
type VerifyStructure struct {
//计轴检测点设备模型集合,key为索引编号
AxlePointDeviceModelMap map[string]face.AxlePointDeviceModeller
//道岔设备模型集合,key为索引编号
SwitchDeviceModelMap map[string]face.SwitchDeviceModeller
//由端点确定的link模型集合,key为索引编号
LinkSectionModelMap map[string]face.LinkSectionModeller
//计轴区段模型集合,key为索引编号
AxleSectionModelMap map[string]face.AxleSectionModeller
//物理区段模型集合,key为索引编号
PhysicalSectionModelMap map[string]face.PhysicalSectionModeller
//逻辑区段模型集合,key为索引编号
LogicalSectionModelMap map[string]face.LogicalSectionModeller
//信号机模型集合,key为索引编号
SignalDeviceModelMap map[string]face.SignalDeviceModeller
}
// 轨旁仿真模型状态
type VerifyStatus struct {
//道岔状态key为道岔id即索引
SwitchStateMap map[string]*state.SwitchState
//轨道状态key为轨道id即索引
LinkStateMap map[string]*state.LinkState
//列车状态key为列车id即索引
TrainStateMap map[string]*state.TrainState
//计轴区段状态key为计轴区段的id即索引
AxleSectionStateMap map[string]*state.SectionState
//物理区段状态key为物理区段id即索引
PhysicalSectionStateMap map[string]*state.SectionState
//逻辑区段状态key为逻辑区段id即索引
LogicSectionStateMap map[string]*state.SectionState
//信号机状态key为信号机id,即索引
SignalStateMap map[string]*state.SignalState
}
// 轨旁仿真内存模型
type WaysideMemory struct {
//固定关系数据:轨旁仿真模型结构
Structure *VerifyStructure
//可变状态数据:轨旁仿真模型状态
Status *VerifyStatus
//对数据的操作管理实现:对内存模型初始化的初始化器
Initializer *WaysideMemoryInitializer
//对数据的操作管理实现:对内存模型的列车运行时数据操作的更新器
TrainRuntime *WaysideMemoryTrainRuntime
//对数据的操作管理实现:工具
Helper *WaysideMemoryHelper
//对数据的操作管理实现:计算当前时刻与上一时刻状态的变化量,用于前端页面增量更新
Variation *WaysideMemoryVariation
//对数据的操作管理实现:实现设备到区段的映射
SectionMapper *WaysideMemorySectionMapper
//端点和轨道构成的路径层
PathLayer *WaysidePathLayer
}
// 初始化轨旁仿真内存模型
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)
return memory
}

View File

@ -0,0 +1,11 @@
package memory
//工具
type WaysideMemoryHelper struct {
memory *WaysideMemory
}
func (me *WaysideMemoryHelper) Init(memory *WaysideMemory) *WaysideMemoryHelper {
me.memory = memory
return me
}

View File

@ -0,0 +1,12 @@
package memory
//根据地图数据来初始VerifyMemoryModel包括对地图数据的校验构建设备间固定关系
//初始化设备状态。
type WaysideMemoryInitializer struct {
memory *WaysideMemory
}
func (initializer *WaysideMemoryInitializer) Init(memory *WaysideMemory) *WaysideMemoryInitializer {
initializer.memory = memory
return initializer
}

View File

@ -0,0 +1,11 @@
package memory
//实现设备到区段的映射
type WaysideMemorySectionMapper struct {
memory *WaysideMemory
}
func (me *WaysideMemorySectionMapper) Init(memory *WaysideMemory) *WaysideMemorySectionMapper {
me.memory = memory
return me
}

View File

@ -0,0 +1,11 @@
package memory
//对内存模型的列车运行时数据操作的更新器
type WaysideMemoryTrainRuntime struct {
memory *WaysideMemory
}
func (tr *WaysideMemoryTrainRuntime) Init(memory *WaysideMemory) *WaysideMemoryTrainRuntime {
tr.memory = memory
return tr
}

View File

@ -0,0 +1,11 @@
package memory
//计算当前时刻与上一时刻状态的变化量,用于前端页面增量更新
type WaysideMemoryVariation struct {
memory *WaysideMemory
}
func (me *WaysideMemoryVariation) Init(memory *WaysideMemory) *WaysideMemoryVariation {
me.memory = memory
return me
}

View File

@ -0,0 +1,11 @@
package memory
//端点和轨道构成的路径层
type WaysidePathLayer struct {
memory *WaysideMemory
}
func (me *WaysidePathLayer) Init(memory *WaysideMemory) *WaysidePathLayer {
me.memory = memory
return me
}