Exemplo n.º 1
0
 public frmUploadMission(Mission mission)
 {
     this.mission = mission;
     InitializeComponent();
     grdMissionSummary.SelectedObject = mission;
     MissionUploadResult = UploadType.Cancel;
 }
Exemplo n.º 2
0
 public MissionController(Mission mission)
 {
     this.mission = mission;
     PollingInterval = Properties.Settings.Default.missionPointPollingInterval;
 }
Exemplo n.º 3
0
        public void StopMission(bool upload)
        {
            if (MissionRunning)
            {
                if (missionReader != null && missionReader.IsOpen)
                {
                    MissionRunning = false;
                    missionReader.Close();
                    mission.Duration = missionReader.Duration.TotalMinutes;
                }

                if (videoController != null && videoController.ImageStream.IsEnabled)
                {
                    videoController.StopImageStream();
                }

                if (upload)
                {
                    UploadMission();
                }
                mission = null;
            }
        }
Exemplo n.º 4
0
 public void NewMission(Location loc, Airframe plane, User user, Camera camera, IMavLinkListener callback, IVideoController videoController)
 {
     frmCreateMission createMission = new frmCreateMission();
     if (createMission.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         IsLive = createMission.IsLive;
         if (createMission.IsLive)
         {
             missionReader = new MissionPlannerLiveConnector("127.0.0.1", "56781", callback);
             if (missionReader.Open(false, DateTime.Now))
             {
                 mission = new Mission(loc, plane, user, camera, createMission.Description, createMission.VideoFile, createMission.LogFile);
                 this.videoController = videoController;
             }
         }
         else
         {
             if (File.Exists(createMission.LogFile) && File.Exists(createMission.VideoFile))
             {
                 mission = new Mission(loc, plane, user, camera, createMission.Description, createMission.VideoFile, createMission.LogFile);
                 missionReader = new MissionPlannerLogReader(createMission.LogFile, false, callback);
                 this.videoController = videoController;
             }
         }
     }
 }
Exemplo n.º 5
0
 public void LoadMission(Mission mission)
 {
     this.mission = mission;
 }
Exemplo n.º 6
0
        public HttpStatusCode PostMission(Mission mission, ref string responseInfo)
        {
            HttpStatusCode result = HttpStatusCode.OK;

            string url = BaseURL + "/mission/new";
            responseInfo = "";

            //get mission as json string ready for post.
            string jsonEncodedMission = JsonEncode(mission);

            //url encoding is required to make the post work.
            string postDataAsString = "username="******"&password="******"&mission=" + HttpUtility.UrlEncode(jsonEncodedMission);
            byte[] postData = Encoding.UTF8.GetBytes(postDataAsString);

            result = PostWebServiceData(url, postData, ref responseInfo);

            if (result != null && result == HttpStatusCode.OK) //get the mission id
            {

                Mission[] aMissions = null;
                DataContractJsonSerializer deserialiser = new DataContractJsonSerializer(typeof(Mission[]));

                try
                {
                    if (responseInfo != null)
                    {
                        System.Console.Write(responseInfo);
                        MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseInfo));
                        aMissions = deserialiser.ReadObject(ms) as Mission[];
                        ms.Close();
                    }

                }
                catch (Exception e)
                {
                    throw;
                }

                if (aMissions != null && aMissions.Length > 0)
                {
                    if (aMissions[0] != null)
                    {
                        mission.ID = aMissions[0].ID;
                    }
                }

            }

            return result;
        }