Exemplo n.º 1
0
 private void WindowMenuOpenQuadPropertyCommandAction()
 {
     if (QuadPropertyWindow != null)
     {
         QuadPropertyWindow.Close();
     }
     QuadPropertyWindow = new QuadPropertyWindow();
     QuadPropertyWindow.Show();
 }
Exemplo n.º 2
0
        private void CommandStateClick(object obj)
        {
            if (VehicleComponent == null)
            {
                VehicleComponent = ServiceLocator.Current.GetInstance <IVehicleComponent>();
            }
            if (VehicleComponent == null)
            {
                return;
            }

            if (MissionComponent == null)
            {
                MissionComponent = ServiceLocator.Current.GetInstance <IMissionComponent>();
            }
            if (MissionComponent == null)
            {
                return;
            }

            VisibilityView = Visibility.Hidden;
            var state = obj as string;

            switch (state)
            {
            case "CameHome":
                if (VehicleSelected != null)
                {
                    VehicleComponent.SendModeCommand(VehicleSelected.ID, (uint)VehicleModeEnum.RTL);
                }
                break;

            case "Land":
                if (VehicleSelected != null)
                {
                    VehicleComponent.SendModeCommand(VehicleSelected.ID, (uint)VehicleModeEnum.Land);
                }
                break;

            case "Pause":
                if (VehicleSelected != null)
                {
                    VehicleComponent.SendModeCommand(VehicleSelected.ID, (uint)VehicleModeEnum.Loiter);
                }
                break;

            case "Start":
                if (VehicleSelected != null)
                {
                    //VehicleComponent.SendModeCommand(VehicleSelected.ID, (uint) VehicleModeEnum.Auto);
                    //MissionComponent.StartMission(VehicleSelected.ID, 0);
                    MissionComponent.StartMissionAuto(VehicleSelected.ID, 0);
                }
                break;

            case "LoadMission":
                if (VehicleSelected.Tasks.Count > 0)
                {
                    VehicleSelected.IsActivateMission = false;
                    MissionComponent.UploadTask(VehicleSelected.ID,
                                                VehicleSelected.HomePosition,
                                                new MavlinkWaypoint
                    {
                        Latitude  = VehicleSelected.Latitude,
                        Longitude = VehicleSelected.Longitude,
                        Altitude  = DefaultAltitude,
                        Param4    = (float)VehicleSelected.Heading
                    },
                                                VehicleSelected.Tasks[0]);
                    VehicleSelected.MissionID = VehicleSelected.Tasks[0].TaskID;
                }
                break;

            case "TakeOff":
                if (VehicleSelected != null)
                {
                    VehicleComponent.TakeOffCommand(VehicleSelected.ID, 100, (float)VehicleSelected.Latitude,
                                                    (float)VehicleSelected.Longitude, (float)VehicleSelected.Heading);
                }
                break;

            case "ControlRequest":
                //if (value)
                //    ServiceLocator.Current.GetInstance<IJoystick>(idx).Start();
                //else
                //    ServiceLocator.Current.GetInstance<IJoystick>().Stop();
                break;

            case "OpenCamera":

                if (QuadPropertyWindow != null)
                {
                    QuadPropertyWindow.Close();
                    QuadPropertyWindow = null;
                }

                QuadPropertyWindow = new QuadPropertyWindow();
                QuadPropertyWindow.Show();
                break;
            }
        }