rts-sim-testing-service/ts/simulation/wayside/memory/wayside_memory_section.go

37 lines
1.3 KiB
Go

package memory
import (
"log/slog"
"joylink.club/bj-rtsts-server/dto"
"joylink.club/bj-rtsts-server/dto/data_proto"
"joylink.club/bj-rtsts-server/dto/request_proto"
"joylink.club/rtsssimulation/fi"
)
func ChangeAxleSectionState(simulation *VerifySimulation, req *dto.AxleSectionOperationReqDto) error {
sectionUid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &data_proto.Section{})
slog.Debug("操作计轴区段", "axleSectionUid", sectionUid)
if req.TrainIn {
return fi.AxleSectionTrainDrive(simulation.World, sectionUid, true)
}
if req.TrainOut {
return fi.AxleSectionTrainDrive(simulation.World, sectionUid, false)
}
switch req.Operation {
case request_proto.Section_CancelDrst:
return fi.AxleSectionDrstDrive(simulation.World, sectionUid, false)
case request_proto.Section_SetDrst:
return fi.AxleSectionDrstDrive(simulation.World, sectionUid, true)
case request_proto.Section_CancelPdrst:
return fi.AxleSectionPdrstDrive(simulation.World, sectionUid, false)
case request_proto.Section_SetPdrst:
return fi.AxleSectionPdrstDrive(simulation.World, sectionUid, true)
case request_proto.Section_CancelFaultOcc:
return fi.AxleSectionFaultOccDrive(simulation.World, sectionUid, false)
case request_proto.Section_SetFaultOcc:
return fi.AxleSectionFaultOccDrive(simulation.World, sectionUid, true)
}
return nil
}