rts-sim-testing-service/ats/verify/simulation/wayside/memory/wayside_simulation.go

53 lines
1.3 KiB
Go
Raw Normal View History

2023-08-01 14:54:11 +08:00
package memory
import (
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
)
2023-08-01 14:54:11 +08:00
// 轨旁仿真定义
type VerifySimulation struct {
//地图id
MapId int32
//仿真id
SimulationId string
//仿真内存数据
Memory *WaysideMemory
}
// 创建仿真对象
func CreateSimulation(mapId int32, simulationId string) *VerifySimulation {
m := &WaysideMemory{}
verifySimulation := &VerifySimulation{
MapId: mapId,
SimulationId: simulationId,
Memory: m.Create(),
}
// 初始化构地图设备状态
InitFromMap(verifySimulation.Memory.Status, QueryMapVerifyStructure(mapId))
return verifySimulation
}
// 获取全量状态
func (s *VerifySimulation) GetAllState() *state.PushedDevicesStatus {
return &state.PushedDevicesStatus{
All: true,
AllStatus: &state.AllDevicesStatus{
SwitchState: GetAllTurnoutState(s),
TrainState: GetAllTrainState(s),
SectionState: append(GetAllAxleSectionState(s), GetAllPhysicalSectionState(s)...),
},
}
}
// 获取变量状态
func (s *VerifySimulation) GetChangeState() *state.PushedDevicesStatus {
return &state.PushedDevicesStatus{
All: false,
VarStatus: &state.VariationStatus{
UpdatedSwitch: GetChangeTurnoutState(s),
RemovedTrainId: GetRemovedTrainId(s),
UpdatedTrain: GetUpdatedTrainState(s),
},
}
}