rts-sim-testing-service/ats/verify/simulation/simulation_manage.go

49 lines
1.2 KiB
Go
Raw Normal View History

2023-07-31 08:41:42 +08:00
package simulation
import (
"strconv"
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside"
)
// 仿真存储集合
var SimulationMap = make(map[string]*wayside.VerifyMemory)
// 仿真子id生成器
var SimulationSubId = 0
// 创建仿真对象
func CreateSimulation(mapId int, mapData *graphicData.RtssGraphicStorage) string {
simulationId := createSimulationId(mapId)
verifyMemory := &wayside.VerifyMemory{
Status: &wayside.VerifyStatus{
SwitchStateMap: make(map[string]*state.SwitchState),
},
}
SimulationMap[simulationId] = verifyMemory
return simulationId
}
// 删除仿真对象
func DestroySimulation(simulationId string) {
delete(SimulationMap, simulationId)
}
// 创建时生成仿真Id
func createSimulationId(mapId int) string {
SimulationSubId++
return strconv.Itoa(mapId) + "_" + strconv.Itoa(SimulationSubId)
2023-07-31 08:41:42 +08:00
}
// 获取仿真列表
func ListAllSimulations() []*wayside.VerifyMemory {
return nil
}
// 根据仿真id查找仿真实例
func FindSimulation(simulationId string) *wayside.VerifyMemory {
return SimulationMap[simulationId]
}