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

52 lines
2.0 KiB
Go

package memory
import (
"fmt"
"joylink.club/bj-rtsts-server/dto/request_proto"
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
"joylink.club/rtsssimulation/component/component_proto"
"joylink.club/rtsssimulation/fi"
)
// 处理道岔操作
func HandlePsdOperation(simulation *VerifySimulation, req *request_proto.PsdOperationReq) error {
uid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &graphicData.ScreenDoor{})
switch req.Operation {
case request_proto.Psd_Km4:
return fi.SetInterlockKm4(simulation.World, uid)
case request_proto.Psd_CancelKm4:
return fi.CancelInterlockKm4(simulation.World, uid)
case request_proto.Psd_Km8:
return fi.SetInterlockKm8(simulation.World, uid)
case request_proto.Psd_CancelKm8:
return fi.CancelInterlockKm8(simulation.World, uid)
case request_proto.Psd_Gm:
return fi.SetInterlockGm(simulation.World, uid)
case request_proto.Psd_CancelGm:
return fi.CancelInterlockGm(simulation.World, uid)
case request_proto.Psd_ForceKm4:
case request_proto.Psd_ForceKm8:
case request_proto.Psd_ForceGm:
case request_proto.Psd_CancelForce:
case request_proto.Psd_AsdCannotClose:
return fi.SetPsdFault(simulation.World, uid, component_proto.Psd_AsdCannotClose, req.AsdCodes)
case request_proto.Psd_CancelAsdCannotClose:
return fi.CancelPsdFault(simulation.World, uid, component_proto.Psd_AsdCannotClose, req.AsdCodes)
case request_proto.Psd_AsdCannotOpen:
return fi.SetPsdFault(simulation.World, uid, component_proto.Psd_AsdCannotOpen, req.AsdCodes)
case request_proto.Psd_CancelAsdCannotOpen:
return fi.CancelPsdFault(simulation.World, uid, component_proto.Psd_AsdCannotOpen, req.AsdCodes)
case request_proto.Psd_QDTC:
return fi.SetQDTC(simulation.World, uid)
case request_proto.Psd_CancelQDTC:
return fi.CancelQDTC(simulation.World, uid)
case request_proto.Psd_TZTC:
return fi.SetTZTC(simulation.World, uid)
case request_proto.Psd_CancelTZTC:
return fi.CancelTZTC(simulation.World, uid)
default:
panic(fmt.Sprintf("未知的道岔操作:%s", req.Operation))
}
return nil
}