Ejemplo n.º 1
0
        private FlightPoint[] convertToFlightPoint(double heading, float alt, long missionFK)
        {
            FlightPoint[] fps = new FlightPoint[wpArray.Length];
            FlightPoint   fp  = new FlightPoint();

            for (int i = 0; i < wpArray.Length; i++)
            {
                fp            = new FlightPoint();
                fp.MissionFK  = missionFK;
                fp.Latitude   = wpArray[i].lat;
                fp.Longitude  = wpArray[i].lon;
                fp.Altitude   = alt;
                fp.Target_yaw = (short)heading;
                fp.PIAction   = PIAction.TakePicture;

                fp.Damping_distance     = 0;
                fp.Target_gimbal_pitch  = 0;
                fp.Turn_mode            = TurnMode.Clockwise;
                fp.Has_action           = HasAction.No_Action;
                fp.Action_time_limit    = 5;
                fp.ACTION_action_repeat = 1;
                fp.ACTION_Command_list  = new List <int>(1)
                {
                    1
                };
                fp.ACTION_Param_list = new List <int>(1)
                {
                    1
                };

                fps[i] = fp;
            }

            return(fps);
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(long id)
        {
            FlightPoint flightPoint = db.FlightPoints.Find(id);

            db.FlightPoints.Remove(flightPoint);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public FlightPoint[] reverseMission(FlightPoint[] fps)
        {
            FlightPoint[] reverseArray = new FlightPoint[fps.Length];

            for (int i = 0; i < fps.Length; i++)
            {
                reverseArray[i] = fps[fps.Length - 1 - i];
            }

            return(reverseArray);
        }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "FlightPointPK,MissionFK,Latitude,Longitude,Altitude,Damping_distance,Target_yaw,Target_gimbal_pitch,Turn_mode,Has_action,Action_time_limit,ACTION_action_repeat,_ACTION_COMMAND_LIST,_ACTION_COMMAND_PARAMS,PIAction")] FlightPoint flightPoint)
 {
     if (ModelState.IsValid)
     {
         db.Entry(flightPoint).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MissionFK = new SelectList(db.Missions, "MissionPK", "Name", flightPoint.MissionFK);
     return(View(flightPoint));
 }
Ejemplo n.º 5
0
        // GET: FlightPoints/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FlightPoint flightPoint = db.FlightPoints.Find(id);

            if (flightPoint == null)
            {
                return(HttpNotFound());
            }
            return(View(flightPoint));
        }
Ejemplo n.º 6
0
        // GET: FlightPoints/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FlightPoint flightPoint = db.FlightPoints.Find(id);

            if (flightPoint == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MissionFK = new SelectList(db.Missions, "MissionPK", "Name", flightPoint.MissionFK);
            return(View(flightPoint));
        }
Ejemplo n.º 7
0
        // GET: FlightPoints/Create
        public ActionResult Create()
        {
            ViewBag.MissionFK = new SelectList(db.Missions, "MissionPK", "Name");
            var Model = new FlightPoint()
            {
                Altitude               = 30,
                Target_yaw             = 0,
                Damping_distance       = 0,
                Target_gimbal_pitch    = 0,
                Turn_mode              = TurnMode.Clockwise,
                Has_action             = HasAction.No_Action,
                Action_time_limit      = 5,
                ACTION_action_repeat   = 1,
                _ACTION_COMMAND_LIST   = "1",
                _ACTION_COMMAND_PARAMS = "1"
            };

            return(View(Model));
        }
Ejemplo n.º 8
0
        private void SelectDestination(FlightPoint flight, FlightWay way)
        {
            if (flight != null)
            {
                if (_route == null)
                {
                    _route = new Route();
                }
                switch (way)
                {
                case FlightWay.DEPARTURE:
                    _route.Departure = flight.Iata;
                    break;

                case FlightWay.ARRIVAL:
                    _route.Arrival = flight.Iata;
                    break;
                }
                if (_route.FormRoute())
                {
                    APrefListViewModel._viewModel.Routes.Add(_route);
                }
            }
        }
Ejemplo n.º 9
0
        public FlightPoint[] mirrorMission(FlightPoint[] fps)
        {
            FlightPoint[] mirrorArray = new FlightPoint[fps.Length];

            GPSCoordinates v1 = new GPSCoordinates();
            GPSCoordinates v2 = new GPSCoordinates();

            if (fps.Length < 2)
            {
                return(null);
            }

            double heading             = fps[0].Target_yaw;
            double startHeading        = 0;
            double reverseStartHeading = 0;

            v1.lat = fps[0].Latitude;
            v1.lon = fps[0].Longitude;

            v2.lat = fps[1].Latitude;
            v2.lon = fps[1].Longitude;

            startHeading = calcHeading(v1, v2);
            if (startHeading < 0)
            {
                reverseStartHeading = 180 + startHeading;
            }
            else
            {
                reverseStartHeading = -180 + startHeading;
            }

            int  curStripeStartIndex = 0;
            int  numOfWpInStripe     = 1;
            bool endOfMission        = false;

            int i = 0;

            while (!endOfMission)
            {
                numOfWpInStripe = 1;

                for (i = curStripeStartIndex; i < fps.Length; i++)
                {
                    v1.lat = fps[i].Latitude;
                    v1.lon = fps[i].Longitude;

                    if (i + 1 < fps.Length)
                    {
                        v2.lat = fps[i + 1].Latitude;
                        v2.lon = fps[i + 1].Longitude;
                    }
                    else
                    {
                        endOfMission = true;
                        break;
                    }

                    // ako se heading i target_yaw poklapaju, odnosno ako su supotni ali istog pravca
                    // Kada pocne sledeci stripe, heading ce biti pomeren za 90
                    if ((Math.Abs(calcHeading(v1, v2) - heading) < 2) ||
                        ((Math.Abs(calcHeading(v1, v2) - heading) > 178) && (Math.Abs(calcHeading(v1, v2) - heading) < 182)))
                    {
                        numOfWpInStripe++;
                    }
                    else
                    {
                        break;
                    }
                }

                // Okreni ovaj stripe i okreni mu Target_Yaw
                for (int j = 0; j < numOfWpInStripe; j++)
                {
                    mirrorArray[curStripeStartIndex + j]            = fps[curStripeStartIndex + numOfWpInStripe - 1 - j];
                    mirrorArray[curStripeStartIndex + j].Target_yaw = (short)reverseStartHeading;
                }

                // U prvom prolazu treba numOfWpInStripe - 1, ali + 1 da bi presli na prvi u sledecem stripe-u
                if (curStripeStartIndex == 0)
                {
                    curStripeStartIndex = numOfWpInStripe - 1 + 1;
                }
                // Da bi poceo od prvog u sledecem stripe-u dodajemo + 1
                else
                {
                    curStripeStartIndex += numOfWpInStripe;
                }

                if (i >= fps.Length - 1)
                {
                    endOfMission = true;
                }
            }

            return(mirrorArray);
        }