/// <summary> /// Example hpw to upload processed route to vehicle /// </summary> /// <param name="route">calculated route</param> /// <param name="vehicle">Vehicle where to upload route</param> /// <returns></returns> public bool UploadRoute(ProcessedRoute route, Vehicle vehicle) { if (route == null) { throw new Exception("Route not specified"); } if (vehicle == null) { throw new Exception("Vehicle not specified"); } UploadRouteRequest request = new UploadRouteRequest { ClientId = _connect.AuthorizeHciResponse.ClientId, ProcessedRoute = route, Vehicle = vehicle, }; MessageFuture <UploadRouteResponse> task = _connect.Executor.Submit <UploadRouteResponse>(request); task.Wait(); if (task.Exception != null || task.Value == null) { logger.LogException(task.Exception); throw new Exception("Upload error: " + task.Exception.Message); } return(true); }
/// <summary> /// Example how to calculate route by id /// </summary> /// <param name="routeId">route ID</param> /// <returns>Processed route</returns> public ProcessedRoute CalculateRouteById(int routeId) { var updatedRoute = GetUpdatedRouteById(routeId); ProcessRouteRequest request = new ProcessRouteRequest { ClientId = _connect.AuthorizeHciResponse.ClientId, Route = updatedRoute, }; MessageFuture <ProcessRouteResponse> task = _connect.Executor.Submit <ProcessRouteResponse>(request); task.Wait(); if (task.Exception != null || task.Value == null) { logger.LogException(task.Exception); throw new Exception("Calculate error: " + task.Exception.Message); } return(task.Value.ProcessedRoute); }
/// <summary> /// Example how to create route on server with route parameters /// Minimum parameters is specified /// </summary> /// <param name="mission">Mission where create route</param> /// <param name="vehicleProfile">Profile for route</param> /// <param name="name">Route name</param> /// <returns></returns> public Route CreateNewRoute(Mission mission, VehicleProfile vehicleProfile, String name = "TestRoute") { var routeName = string.Format("{0} {1}", name, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); Route route = new Route { CreationTime = ServiceHelpers.CreationTime(), Name = routeName, Mission = mission }; ChangeRouteVehicleProfileRequest request = new ChangeRouteVehicleProfileRequest { ClientId = _connect.AuthorizeHciResponse.ClientId, Route = route, NewProfile = new VehicleProfile { Id = vehicleProfile.Id } }; MessageFuture <ChangeRouteVehicleProfileResponse> future = _connect.Executor.Submit <ChangeRouteVehicleProfileResponse>(request); future.Wait(); route = future.Value.Route; route.Mission = mission; route.TrajectoryType = TrajectoryType.TT_STAIR; route.MaxAltitude = 50.0; route.SafeAltitude = 3.0; route.CheckAerodromeNfz = false; route.CheckAerodromeNfzSpecified = true; route.InitialSpeed = 0.0; route.MaxSpeed = 0.0; route.CheckCustomNfz = false; route.CheckCustomNfzSpecified = true; route.Failsafes.Add(new Failsafe() { Action = FailsafeAction.FA_GO_HOME, ActionSpecified = true, Reason = FailsafeReason.FR_RC_LOST, ReasonSpecified = true, }); route.Failsafes.Add(new Failsafe() { Action = FailsafeAction.FA_LAND, ActionSpecified = true, Reason = FailsafeReason.FR_LOW_BATTERY, ReasonSpecified = true }); route.Failsafes.Add(new Failsafe() { Action = FailsafeAction.FA_WAIT, ActionSpecified = true, Reason = FailsafeReason.FR_GPS_LOST, ReasonSpecified = true }); route.Failsafes.Add(new Failsafe() { Action = FailsafeAction.FA_GO_HOME, ActionSpecified = true, Reason = FailsafeReason.FR_DATALINK_LOST, ReasonSpecified = true }); return(SaveUpdatedRoute(route)); }