private void UpdateStatus() { if (!arDroneControl.IsConnected) { labelCamera.Content = "No picture"; labelStatusCamera.Content = "None"; labelStatusBattery.Content = "N/A"; labelStatusAltitude.Content = "N/A"; labelStatusFrameRate.Content = "No video"; } else { ARDroneControl.DroneData data = new ARDroneControl.DroneData(); data = arDroneControl.GetCurrentDroneData(); int frameRate = GetCurrentFrameRate(); if (arDroneControl.CurrentCameraType == ARDroneControl.CameraType.FrontCamera) { labelCamera.Content = "Front camera"; labelStatusCamera.Content = "Front"; } else { labelCamera.Content = "Bottom camera"; labelStatusCamera.Content = "Bottom"; } labelStatusBattery.Content = data.BatteryLevel.ToString() + "%"; labelStatusAltitude.Content = data.Altitude.ToString(); labelStatusFrameRate.Content = frameRate.ToString(); } labelStatusConnected.Content = arDroneControl.IsConnected.ToString(); labelStatusFlying.Content = arDroneControl.IsFlying.ToString(); labelStatusHovering.Content = arDroneControl.IsHovering.ToString(); }
private void updateInstruments() { if (this.arDroneControl.IsConnected) { ARDrone.Control.ARDroneControl.DroneData droneData = arDroneControl.GetCurrentDroneData(); foreach (InstrumentControl instrumentControl in instrumentList) { try { switch (instrumentControl.GetType().Name) { case "AttitudeIndicatorInstrumentControl": updateInstrument((AttitudeIndicatorInstrumentControl)instrumentControl, droneData); break; case "AltimeterInstrumentControl": updateInstrument((AltimeterInstrumentControl)instrumentControl, droneData); break; case "HeadingIndicatorInstrumentControl": updateInstrument((HeadingIndicatorInstrumentControl)instrumentControl, droneData); break; case "VerticalSpeedIndicatorInstrumentControl": updateInstrument((VerticalSpeedIndicatorInstrumentControl)instrumentControl, droneData); break; } } catch (Exception e) { Console.WriteLine(e.Message); this.stopManage(); } } } }