【列车状态结构处理】
This commit is contained in:
parent
52cdb57d47
commit
bd9542fd8d
@ -46,10 +46,6 @@ func (ms *SfpMs) OnTick() ([]*ms_api.TopicMsg, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
trainStates, err := ms.collectTrainStates()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
signalStates, err := ms.collectSignalStates()
|
signalStates, err := ms.collectSignalStates()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -70,11 +66,15 @@ func (ms *SfpMs) OnTick() ([]*ms_api.TopicMsg, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
trainState, err := ms.collectTrainStates()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
ststes := &state.PushedDevicesStatus{
|
ststes := &state.PushedDevicesStatus{
|
||||||
All: true,
|
All: true,
|
||||||
AllStatus: &state.AllDevicesStatus{
|
AllStatus: &state.AllDevicesStatus{
|
||||||
|
TrainState: trainState,
|
||||||
SwitchState: turnoutStates,
|
SwitchState: turnoutStates,
|
||||||
TrainState: trainStates,
|
|
||||||
SignalState: signalStates,
|
SignalState: signalStates,
|
||||||
ButtonState: buttonStates,
|
ButtonState: buttonStates,
|
||||||
PsdState: psdStates,
|
PsdState: psdStates,
|
||||||
@ -238,16 +238,85 @@ func handlerSignalState(w ecs.World, uid string) (*state.SignalState, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 收集列车状态
|
// 收集列车状态
|
||||||
func (ms *SfpMs) collectTrainStates() ([]*state.TrainState, error) {
|
func (ms *SfpMs) collectTrainStates() ([]*state.TrainMapState, error) {
|
||||||
allTrainMap := &ms.vs.Memory.Status.TrainStateMap
|
allTrainMap := &ms.vs.Memory.Status.TrainStateMap
|
||||||
var trainArr []*state.TrainState
|
var trainArr []*state.TrainMapState
|
||||||
allTrainMap.Range(func(_, v any) bool {
|
allTrainMap.Range(func(_, v any) bool {
|
||||||
trainArr = append(trainArr, v.(*state.TrainState))
|
trainArr = append(trainArr, convertTrainState(v.(*state.TrainState)))
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
return trainArr, nil
|
return trainArr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convertTrainState(v *state.TrainState) *state.TrainMapState {
|
||||||
|
t := &state.TrainMapState{
|
||||||
|
Id: v.Id,
|
||||||
|
Up: v.Up,
|
||||||
|
InitialSpeed: v.Speed,
|
||||||
|
TrainLength: v.TrainLength,
|
||||||
|
Show: v.Show,
|
||||||
|
HeadDeviceId: v.HeadDeviceId,
|
||||||
|
HeadOffset: v.HeadOffset,
|
||||||
|
DevicePort: v.DevicePort,
|
||||||
|
PointTo: v.PointTo,
|
||||||
|
RunDirection: v.RunDirection,
|
||||||
|
HeadDirection: v.HeadDirection,
|
||||||
|
TrainKilometer: v.TrainKilometer,
|
||||||
|
ControlDelayTime: v.ControlDelayTime,
|
||||||
|
WheelDiameter: v.WheelDiameter,
|
||||||
|
// 动力学
|
||||||
|
DynamicHeartbeat: v.DynamicState.Heartbeat,
|
||||||
|
HeadLinkId: v.DynamicState.HeadLinkId,
|
||||||
|
HeadLinkOffset: v.DynamicState.HeadLinkOffset,
|
||||||
|
TailLinkId: v.DynamicState.TailLinkId,
|
||||||
|
TailLinkOffset: v.DynamicState.TailLinkOffset,
|
||||||
|
OccupiedLinkIndex: v.DynamicState.OccupiedLinkIndex,
|
||||||
|
Slope: v.DynamicState.Slope,
|
||||||
|
Upslope: v.DynamicState.Upslope,
|
||||||
|
RunningUp: v.DynamicState.RunningUp,
|
||||||
|
RunningResistanceSum: v.DynamicState.RunningResistanceSum,
|
||||||
|
AirResistance: v.DynamicState.AirResistance,
|
||||||
|
RampResistance: v.DynamicState.RampResistance,
|
||||||
|
CurveResistance: v.DynamicState.CurveResistance,
|
||||||
|
Speed: v.DynamicState.Speed,
|
||||||
|
HeadSensorSpeed1: v.DynamicState.HeadSensorSpeed1,
|
||||||
|
HeadSensorSpeed2: v.DynamicState.HeadSensorSpeed2,
|
||||||
|
TailSensorSpeed1: v.DynamicState.TailSensorSpeed1,
|
||||||
|
TailSensorSpeed2: v.DynamicState.TailSensorSpeed2,
|
||||||
|
HeadRadarSpeed: v.DynamicState.HeadRadarSpeed,
|
||||||
|
TailRadarSpeed: v.DynamicState.TailRadarSpeed,
|
||||||
|
DynamicInterruption: v.DynamicState.UdpInterruption,
|
||||||
|
Acceleration: v.DynamicState.Acceleration,
|
||||||
|
// 半实物
|
||||||
|
VobcLifeSignal: v.VobcState.LifeSignal,
|
||||||
|
Tc1Active: v.VobcState.Tc1Active,
|
||||||
|
Tc2Active: v.VobcState.Tc2Active,
|
||||||
|
DirectionForward: v.VobcState.DirectionForward,
|
||||||
|
DirectionBackward: v.VobcState.DirectionBackward,
|
||||||
|
TractionStatus: v.VobcState.TractionStatus,
|
||||||
|
BrakingStatus: v.VobcState.BrakingStatus,
|
||||||
|
EmergencyBrakingStatus: v.VobcState.EmergencyBrakingStatus,
|
||||||
|
TurnbackStatus: v.VobcState.TurnbackStatus,
|
||||||
|
JumpStatus: v.VobcState.JumpStatus,
|
||||||
|
Ato: v.VobcState.Ato,
|
||||||
|
Fam: v.VobcState.Fam,
|
||||||
|
Cam: v.VobcState.Cam,
|
||||||
|
TractionSafetyCircuit: v.VobcState.TractionSafetyCircuit,
|
||||||
|
ParkingBrakeStatus: v.VobcState.ParkingBrakeStatus,
|
||||||
|
MaintainBrakeStatus: v.VobcState.MaintainBrakeStatus,
|
||||||
|
TractionForce: v.VobcState.TractionForce,
|
||||||
|
BrakeForce: v.VobcState.BrakeForce,
|
||||||
|
TrainLoad: v.VobcState.TrainLoad,
|
||||||
|
LeftDoorOpenCommand: v.VobcState.LeftDoorOpenCommand,
|
||||||
|
RightDoorOpenCommand: v.VobcState.RightDoorOpenCommand,
|
||||||
|
LeftDoorCloseCommand: v.VobcState.LeftDoorCloseCommand,
|
||||||
|
RightDoorCloseCommand: v.VobcState.RightDoorCloseCommand,
|
||||||
|
AllDoorClose: v.VobcState.AllDoorClose,
|
||||||
|
VobcInterruption: v.VobcState.UdpInterruption,
|
||||||
|
}
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
// 收集道岔状态
|
// 收集道岔状态
|
||||||
func (ms *SfpMs) collectTurnoutStates() ([]*state.SwitchState, error) {
|
func (ms *SfpMs) collectTurnoutStates() ([]*state.SwitchState, error) {
|
||||||
sim := ms.vs
|
sim := ms.vs
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user