예제 #1
0
        public void AddTask(ITask task)
        {
            Task t       = null;
            var  mission = Mission as Mission;

            foreach (Task task1 in mission.Tasks)
            {
                if (task1.TaskID == task.TaskID)
                {
                    t = task1;
                    break;
                }
            }
            if (t == null)
            {
                Mission.AddTask(task);
            }
            else
            {
                mission.Tasks.Remove(t);
                mission.Tasks.Add(task as Task);
            }
        }
예제 #2
0
        private void MapWaypointMessengerAction(MapWaypointMessenger obj)
        {
            //NavTask.NavPath.Clear();
            //ServiceLocator.Current.GetInstance<IMap>().RemoveAllShape();
            byte  index   = 1;
            var   mission = (MissionPackage.Mission)Mission;
            ITask first   = null;

            foreach (Task task in mission.Tasks)
            {
                if (task.TaskID == obj.TaskId)
                {
                    first = task;
                    break;
                }
            }
            var taskNav = first as MavlinkTaskNav;

            if (taskNav != null)
            {
                taskNav.NavPath.Clear();

                foreach (var waypoint in obj.Points)
                {
                    double x = waypoint.X, y = waypoint.Y;
                    //Utils.Utils.ConvertGeoToMercator(ref x, ref y);
                    taskNav.NavPath.Add(new MavlinkWaypoint
                    {
                        Id        = index,
                        Command   = (ushort)MissionMavCmd.WAYPOINT,
                        Latitude  = y,
                        Longitude = x,
                        Altitude  = DefaultAltitude,
                        Param1    = 0,
                        Param2    = 0,
                        Param3    = 0,
                        Param4    = 0
                    });
                    index++;
                }
            }
            else
            {
                var mavlinkTaskNav = new MavlinkTaskNav("Task_" + (ushort)obj.TaskId, (ushort)obj.TaskId);
                foreach (var waypoint in obj.Points)
                {
                    double x = waypoint.X, y = waypoint.Y;
                    //Utils.Utils.ConvertGeoToMercator(ref x, ref y);
                    mavlinkTaskNav.NavPath.Add(new MavlinkWaypoint
                    {
                        Id        = index,
                        Command   = (ushort)MissionMavCmd.WAYPOINT,
                        Latitude  = y,
                        Longitude = x,
                        Altitude  = DefaultAltitude,
                        Param1    = 0,
                        Param2    = 0,
                        Param3    = 0,
                        Param4    = 0
                    });
                    index++;
                }
                Mission.AddTask(mavlinkTaskNav);
            }

            Messenger.Default.Send(new UpdataMissionMessenger {
                MissionId = Mission.MissionID
            });
        }