package memory import ( "fmt" "joylink.club/rtsssimulation/component/component_proto" "joylink.club/rtsssimulation/fi" "joylink.club/bj-rtsts-server/dto/request_proto" "joylink.club/bj-rtsts-server/ts/protos/graphicData" ) // 处理道岔操作 func HandleTurnoutOperation(simulation *VerifySimulation, req *request_proto.TurnoutOperationReq) error { uid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &graphicData.Turnout{}) var err error switch req.Operation { case request_proto.Turnout_DC: err = fi.DriveTurnoutDCOn(simulation.World, uid) case request_proto.Turnout_CancelDC: err = fi.DriveTurnoutDCOff(simulation.World, uid) case request_proto.Turnout_FC: err = fi.DriveTurnoutFCOn(simulation.World, uid) case request_proto.Turnout_CancelFC: err = fi.DriveTurnoutFCOff(simulation.World, uid) case request_proto.Turnout_SetSB: err = fi.SetTurnoutFault(simulation.World, uid, component_proto.Turnout_SB) case request_proto.Turnout_CancelSB: err = fi.CancelTurnoutFault(simulation.World, uid, component_proto.Turnout_SB) case request_proto.Turnout_SetJC: err = fi.SetTurnoutFault(simulation.World, uid, component_proto.Turnout_JC) case request_proto.Turnout_CancelJC: err = fi.CancelTurnoutFault(simulation.World, uid, component_proto.Turnout_JC) case request_proto.Turnout_ForceDw: err = fi.ForceTurnoutDw(simulation.World, uid) case request_proto.Turnout_ForceFw: err = fi.ForceTurnoutFw(simulation.World, uid) case request_proto.Turnout_CancelForce: err = fi.CancelTurnoutForce(simulation.World, uid) default: panic(fmt.Sprintf("未知的道岔操作:%s", req.Operation)) } return err }