2023-08-01 14:54:11 +08:00
|
|
|
package memory
|
|
|
|
|
2023-08-01 17:08:45 +08:00
|
|
|
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
|
|
|
|
}
|
2023-08-01 17:08:45 +08:00
|
|
|
|
|
|
|
// 获取全量状态
|
|
|
|
func (s *VerifySimulation) GetAllState() *state.PushedDevicesStatus {
|
|
|
|
return &state.PushedDevicesStatus{
|
|
|
|
All: true,
|
|
|
|
AllStatus: &state.AllDevicesStatus{
|
2023-08-03 10:41:43 +08:00
|
|
|
SwitchState: GetAllTurnoutState(s),
|
|
|
|
TrainState: GetAllTrainState(s),
|
|
|
|
SectionState: append(GetAllAxleSectionState(s), GetAllPhysicalSectionState(s)...),
|
2023-08-01 17:08:45 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取变量状态
|
|
|
|
func (s *VerifySimulation) GetChangeState() *state.PushedDevicesStatus {
|
|
|
|
return &state.PushedDevicesStatus{
|
|
|
|
All: false,
|
|
|
|
VarStatus: &state.VariationStatus{
|
|
|
|
UpdatedSwitch: GetChangeTurnoutState(s),
|
|
|
|
RemovedTrainId: GetRemovedTrainId(s),
|
|
|
|
UpdatedTrain: GetUpdatedTrainState(s),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|