Beispiel #1
0
 public BarometerTests()
 {
     this.InitializeComponent();
     _barometer = Barometer.GetDefault();
     if (_barometer == null)
     {
         ResultsTextBlock.Text = "Barometer not available on this device";
     }
 }
Beispiel #2
0
        public Scenario2_Polling()
        {
            this.InitializeComponent();

            sensor = Barometer.GetDefault();
            if (null == sensor)
            {
                rootPage.NotifyUser("No barometer found", NotifyType.ErrorMessage);
            }
        }
        public Scenario1_DataEvents()
        {
            this.InitializeComponent();

            sensor = Barometer.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 barometer found", NotifyType.ErrorMessage);
            }
        }
Beispiel #4
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();
 }
Beispiel #5
0
 public BarometerTestsViewModel(CoreDispatcher dispatcher) : base(dispatcher)
 {
     _barometer = Barometer.GetDefault();
     if (_barometer != null)
     {
         _barometer.ReportInterval = 250;
         SensorStatus = "Barometer created";
     }
     else
     {
         SensorStatus = "Barometer not available on this device";
     }
     Disposables.Add(Disposable.Create(() =>
     {
         if (_barometer != null)
         {
             _barometer.ReadingChanged -= Barometer_ReadingChanged;
         }
     }));
 }
Beispiel #6
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);
            }
        }
Beispiel #7
0
        private async void end(string name)
        {
            DataManager dm       = DataManager.getInstance();
            var         settings = ApplicationData.Current.LocalSettings;
            double      nowH     = (double)settings.Values["nowH"];
            int         startRS  = (int)settings.Values["startRS"];
            int         startWS  = (int)settings.Values["startWS"];
            var         aaa      = await Pedometer.GetDefaultAsync();

            var    aa = aaa.GetCurrentReadings();
            int    rs = aa[PedometerStepKind.Running].CumulativeSteps;
            int    ws = aa[PedometerStepKind.Walking].CumulativeSteps;
            double p  = Barometer.GetDefault().GetCurrentReading().StationPressureInHectopascals;
            double h  = Math.Round(nowH, 1);
            double la = 200;
            double lo = 200;

            try
            {
                Geolocator geolocator = new Geolocator();
                // 获取当前的位置
                Geoposition pos = await geolocator.GetGeopositionAsync();

                //纬度
                la = pos.Coordinate.Point.Position.Latitude;
                //经度
                lo = pos.Coordinate.Point.Position.Longitude;
            }
            catch (UnauthorizedAccessException)
            {
                //未授权的访问异常
            }
            catch (Exception ex)
            {
                //超时 time out
            }
            dm.end(la, lo, h, p, ws, rs, (ws - startWS) + (rs - startRS), name);
            dm.closeDB();
        }
 public BarometerDeviceSensor()
 {
     _barometer = Barometer.GetDefault();
 }
Beispiel #9
0
 public BarometerImpl()
 {
     this.barometer = Barometer.GetDefault();
 }