rts-sim-testing-service/ts/simulation/wayside/memory/wayside_memory_section.go
2023-11-01 11:08:26 +08:00

38 lines
1.3 KiB
Go

package memory
import (
"joylink.club/bj-rtsts-server/dto"
"joylink.club/bj-rtsts-server/dto/request_proto"
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
"joylink.club/rtsssimulation/fi"
"log/slog"
)
func ChangeAxleSectionState(simulation *VerifySimulation, req *dto.AxleSectionOperationReqDto) error {
sectionUid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &graphicData.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
}