// This works around an issue in the Anniversary Update (1607) in which
        // Altimeter.GetDefault() returns a nonfunctional altimeter if the
        // system has no altimeter. This issue does not exist in other versions
        // of Windows 10, but the workaround is harmless to use even on versions
        // which do not have this problem. The workaround returns the default
        // altimeter only after we confirm that the system has a working altimeter.

        private static async Task <Altimeter> GetDefaultAltimeterWorkerAsync()
        {
            // This workaround is needed only on the Anniversary Update (universal contract 3).
            if (!ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3) ||
                ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4))
            {
                // The current system does not require the workaround.
                return(Altimeter.GetDefault());
            }

            var tcs = new TaskCompletionSource <Altimeter>();

            string deviceSelector =
                // Find all interface classes for altimeter sensors
                "System.Devices.InterfaceClassGuid:=\"{0E903829-FF8A-4A93-97DF-3DCBDE402288}\"" +
                // ... that are present on the system
                " AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True";

            var watcher = Windows.Devices.Enumeration.DeviceInformation.CreateWatcher(deviceSelector);

            watcher.Added += (s, e) => tcs.TrySetResult(Altimeter.GetDefault());
            watcher.EnumerationCompleted += (s, e) => tcs.TrySetResult(null);
            watcher.Start();
            Altimeter altimeter = await tcs.Task;

            watcher.Stop();
            return(altimeter);
        }
Example #2
0
 public void LoadAltimeterData(UDP ethernet)
 {
     ethernet.AltimeterActions.Add((Altimeter) =>
     {
         this.Altimeter        = Altimeter;
         this.NewAltimeterData = true;
     });
 }
Example #3
0
 private void Open_Button_Click(object sender, RoutedEventArgs e)
 {
     alti = Altimeter.GetDefault();
     if (null != alti)
     {
         _deviceUseTrigger = new DeviceUseTrigger();
     }
     openBackgroup();
 }
 public DensityAltitudeApplicationTester(String browser, String application, Elevation elevation, Temperature temperature, Altimeter altimeter, DewPoint dewPoint)
 {
     this.browser     = browser;
     this.application = application;
     this.elevation   = elevation;
     this.temperature = temperature;
     this.altimeter   = altimeter;
     this.dewPoint    = dewPoint;
 }
        public Scenario2_Polling()
        {
            this.InitializeComponent();

            sensor = Altimeter.GetDefault();
            if (null == sensor)
            {
                rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage);
            }
        }
Example #6
0
        public Scenario2_Polling()
        {
            this.InitializeComponent();

            sensor = Altimeter.GetDefault();
            if (null == sensor)
            {
                rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage);
            }
        }
 public BoeingPFD()
 {
     bmp = new Bitmap(DisplaySize.Width,DisplaySize.Height);
     this.g = Graphics.FromImage(bmp);
     g.SmoothingMode = SmoothingMode.AntiAlias;
     compass = new Compass(CompassSize);
     alt = new Altimeter(AltimeterSize);
     ah = new ArtificialHorizon(ArtificialHorizonSize);
     ai = new AirspeedIndicator(AirspeedIndicatorSize);
     vsi = new VerticalSpeedIndicator(VerticalSpeedIndicatorSize);
 }
 public void setAltimeter(Altimeter altimeter)
 {
     webDriver.FindElement(By.Name("altset")).SendKeys(altimeter.getAltimeter());
     if (altimeter.isUsingStandardUnits())
     {
         webDriver.FindElements(By.Name("in_alt_set"))[0].Click();
     }
     else
     {
         webDriver.FindElements(By.Name("in_alt_set"))[1].Click();
     }
 }
Example #9
0
 public void CleanUp()
 {
     foreach (ISensor s in sensors)
     {
         s.CleanUp();
     }
     sensors.Clear();
     sensors       = null;
     altimeter     = null;
     gps           = null;
     battery       = null;
     accelerometer = null;
 }
Example #10
0
 // Use this for initialization
 public SensorModule(Agent agent)
 {
     sensors = new ArrayList();
     //TODO: This relies on the fact that this.transform is the same as agent's transform.
     //		If this is not the case (i.e. the script isn't attached correctly, this will cause problems
     altimeter = new Altimeter(agent.gameObject.transform);
     sensors.Add(altimeter);
     rotationSensor = new RotationSensor(agent.gameObject.transform);
     sensors.Add(rotationSensor);
     gps = new FeauxGPS(agent.gameObject.transform);
     sensors.Add(gps);
     battery = new BatteryLifeSensor();
     sensors.Add(battery);
     accelerometer = new Accelerometer(agent);
     sensors.Add(accelerometer);
 }
Example #11
0
        public Scenario1_DataEvents()
        {
            this.InitializeComponent();

            sensor = Altimeter.GetDefault();
            if (null != sensor)
            {
                // Select a report interval that is both suitable for the purposes of the app and supported by the sensor.
                // This value will be used later to activate the sensor.
                uint minReportIntervalMs = sensor.MinimumReportInterval;
                desiredReportIntervalMs = minReportIntervalMs > 1000 ? minReportIntervalMs : 1000;
            }
            else
            {
                rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage);
            }
        }
Example #12
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape | DisplayOrientations.LandscapeFlipped | DisplayOrientations.Portrait | DisplayOrientations.PortraitFlipped;
     acc = Accelerometer.GetDefault();
     //act = ActivitySensor.GetDefaultAsync().GetResults();
     alt  = Altimeter.GetDefault();
     baro = Barometer.GetDefault();
     comp = Compass.GetDefault();
     gyro = Gyrometer.GetDefault();
     //has = HingeAngleSensor.GetDefaultAsync().GetResults();
     inc = Inclinometer.GetDefault();
     mm  = Magnetometer.GetDefault();
     os  = OrientationSensor.GetDefault();
     //pm = Pedometer.GetDefaultAsync().GetResults();
     //ps = ProximitySensor.FromId(ProximitySensor.GetDeviceSelector());
     sos = SimpleOrientationSensor.GetDefault();
 }
Example #13
0
        /// <summary>
        /// This is the click handler for the 'GetData' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ScenarioGetData(object sender, RoutedEventArgs e)
        {
            sensor = await MainPage.GetDefaultAltimeterAsync();

            if (null != sensor)
            {
                AltimeterReading reading = sensor.GetCurrentReading();
                if (null != reading)
                {
                    ScenarioOutput_M.Text = String.Format("{0,5:0.00}", reading.AltitudeChangeInMeters);
                }
            }
            else
            {
                rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage);
            }
        }
        public Scenario1_DataEvents()
        {
            this.InitializeComponent();

            sensor = Altimeter.GetDefault();
            if (null != sensor)
            {
                // Select a report interval that is both suitable for the purposes of the app and supported by the sensor.
                // This value will be used later to activate the sensor.
                uint minReportIntervalMs = sensor.MinimumReportInterval;
                desiredReportIntervalMs = minReportIntervalMs > 1000 ? minReportIntervalMs : 1000;
            }
            else
            {
                rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage);
            }
        }
Example #15
0
        public UDP()
        {
            this.Client           = new UdpClient(PORT);
            this.RemoteEndPoint   = new IPEndPoint(IPAddress.Any, PORT);
            this.ImuActions       = new List <Action <InertialMeasurementUnit> >();
            this.CustomerActions  = new List <Action <IMUCustomer> >();
            this.ProximityActions = new List <Action <ProximitySensor> >();
            this.AltimeterActions = new List <Action <Altimeter> >();
            this.FFTActions       = new List <Action <FFT> >();
            this.GNSSActions      = new List <Action <GNSS> >();

            this.t = 0;
            this.messageReceived = false;
            this.DebugImu        = new InertialMeasurementUnit();
            this.Customer        = new IMUCustomer();
            this.ProximitySensor = new ProximitySensor();
            this.AltimeterSensor = new Altimeter();
            this.fft             = new FFT();
            this.Gnss            = new GNSS();
        }
Example #16
0
        // <summary>
        // Background task entry point.
        // </summary>
        // <param name="taskInstance"></param>
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            //alti = Altimeter.GetDefault();
            high = Altimeter.GetDefault();
            if (null != high)
            {
                TimerCallback timerc = new TimerCallback(timerTask);
                timer = new Timer(timerc, null, 1000 * 60 * 10, 1000 * 60 * 10);

                dm = DataManager.getInstance();
                //dm.setHeightTable();
                //IAsyncOperation<Pedometer> iasyncP = Pedometer.GetDefaultAsync();
                pressure = Barometer.GetDefault();

                // Select a report interval that is both suitable for the purposes of the app and supported by the sensor.
                //uint minReportIntervalMsecs = alti.MinimumReportInterval;
                //alti.ReportInterval = 50000;

                // Subscribe to accelerometer ReadingChanged events.
                //initAlti = alti.GetCurrentReading().AltitudeChangeInMeters;
                //barometer = Barometer.GetDefault();
                //barometer.ReportInterval = 2000;
                //initBarometer = barometer.GetCurrentReading().StationPressureInHectopascals;
                //barometer.ReadingChanged += new TypedEventHandler<Barometer, BarometerReadingChangedEventArgs>(Barometer_Readingchanged);

                // Take a deferral that is released when the task is completed.
                _deferral = taskInstance.GetDeferral();
                // Get notified when the task is canceled.
                taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(OnCanceled);
                //Task.Delay(500).Wait();
                // Store a setting so that the app knows that the task is running.
                //ApplicationData.Current.LocalSettings.Values["IsBackgroundTaskActive"] = true;
                //pedometer = iasyncP.GetResults();
                pedometer = await Pedometer.GetDefaultAsync();

                start();
                high.ReadingChanged      += new TypedEventHandler <Altimeter, AltimeterReadingChangedEventArgs>(ReadingChanged);
                pedometer.ReadingChanged += new TypedEventHandler <Pedometer, PedometerReadingChangedEventArgs>(Pedometer_ReadingChanged);
            }
        }
Example #17
0
        private void Altimeter_ReadingChanged(Altimeter sender, AltimeterReadingChangedEventArgs args)
        {
            if (SensorValueChanged == null)
            {
                return;
            }

            var reading = args.Reading;

#if DEBUG
            Debug.WriteLine($"Altimeter Raised Event  Altitude = {reading.AltitudeChangeInMeters}");
#endif
            SensorValueChanged((object)this, new SensorReadingValueChangedEventArgs()
            {
                SensorType = SensorType.Altimeter,
                ValueType  = ValueType.SingleValue,
                Value      = new SingleSensorValue()
                {
                    Value = reading.AltitudeChangeInMeters,
                },
            });
        }
Example #18
0
        public void Start(SensorType sensorType, int interval)
        {
            switch (sensorType)
            {
            case SensorType.Accelerometer:
                accelerometer = Accelerometer.GetDefault();
                if (accelerometer != null)
                {
                    accelerometer.ReadingChanged += Accelerometer_ReadingChanged;
                }
                break;

            case SensorType.Gyroscope:
                gyrometer = Gyrometer.GetDefault();
                if (gyrometer != null)
                {
                    gyrometer.ReadingChanged += Gyrometer_ReadingChanged;
                }
                break;

            case SensorType.Magntometer:
                magnetometer = Magnetometer.GetDefault();
                if (magnetometer != null)
                {
                    magnetometer.ReadingChanged += Magnetometer_ReadingChanged;
                }
                break;

            case SensorType.Altimeter:
                altimeter = Altimeter.GetDefault();
                if (altimeter != null)
                {
                    altimeter.ReadingChanged += Altimeter_ReadingChanged;
                }
                break;
            }

            sensorTypeStatus[sensorType] = true;
        }
Example #19
0
        public MainView()
        {
            InitializeComponent();
            this.ImuDebugData           = new InertialMeasurementUnit();
            this.CustomerIMU            = new IMUCustomer();
            this.Altimeter              = new Altimeter();
            this.Ethernet               = new UDP();
            this.FFTData                = new FFT();
            this.GNSSData               = new GNSS();
            this.NewDebugImuData        = false;
            this.NewCustomerData        = false;
            this.NewProximitySensorData = false;
            this.NewAltimeterData       = false;
            this.NewFFTData             = false;
            counter = 0;

            loadDebugIMU(this.Ethernet);
            loadCustomerData(this.Ethernet);
            LoadProximitySensor(this.Ethernet);
            LoadAltimeterData(this.Ethernet);
            LoadFFTData(this.Ethernet);
            LoadGNSSData(this.Ethernet);
            this.EthernetRecvThread = new Thread(this.Ethernet.Start);
            this.EthernetRecvThread.IsBackground = true;
            this.EthernetRecvThread.Start();

            DataFpsTimer.Interval   = 500;
            DataFpsTimer.Tick      += new EventHandler(dataFpsTick);
            GraphsFpsTimer.Interval = 1;
            GraphsFpsTimer.Tick    += new EventHandler(graphFpsTick);
            GraphsFpsTimer.Start();
            DataFpsTimer.Start();



            this.fftChart.ChartAreas["ChartArea1"].AxisX.Maximum = this.FFTData.N;
            CreateMap();
        }
        /// <summary>
        /// This is the click handler for the 'Enable' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ScenarioEnable(object sender, RoutedEventArgs e)
        {
            ScenarioEnableButton.IsEnabled = false;
            sensor = await MainPage.GetDefaultAltimeterAsync();

            if (null != sensor)
            {
                // Set a report interval that is both suitable for the purposes of the app and supported by the sensor.
                uint minReportIntervalMs = sensor.MinimumReportInterval;
                desiredReportIntervalMs = minReportIntervalMs > 1000 ? minReportIntervalMs : 1000;
                sensor.ReportInterval   = desiredReportIntervalMs;

                Window.Current.VisibilityChanged += new WindowVisibilityChangedEventHandler(VisibilityChanged);
                sensor.ReadingChanged            += new TypedEventHandler <Altimeter, AltimeterReadingChangedEventArgs>(ReadingChanged);

                ScenarioEnableButton.IsEnabled  = false;
                ScenarioDisableButton.IsEnabled = true;
            }
            else
            {
                ScenarioEnableButton.IsEnabled = true;
                rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage);
            }
        }
 public AltimeterEvents(Altimeter This)
 {
     this.This = This;
 }
Example #22
0
 public void WhenTheAltimeterIs(String altimeter, String altimeterUnits)
 {
     this.altimeter = new Altimeter(altimeter, altimeterUnits);
 }