public async Task Stop_Monitor() { // TODO: the test runner app (UI version) should do this, until then... if (!HardwareSupport.HasBarometer) { return; } var tcs = new TaskCompletionSource <BarometerData>(); Barometer.ReadingChanged += Barometer_ReadingChanged; void Barometer_ReadingChanged(object sender, BarometerChangedEventArgs e) { tcs.TrySetResult(e.Reading); } Barometer.Start(SensorSpeed.UI); var d = await tcs.Task; Barometer.Stop(); Barometer.ReadingChanged -= Barometer_ReadingChanged; Assert.False(Barometer.IsMonitoring); }
public void Stop() { if (Barometer.IsMonitoring) { Barometer.Stop(); } }
public void ToggleBarometer() { try { if (Barometer.IsMonitoring) { Barometer.Stop(); } else { Barometer.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device Console.WriteLine(fnsEx); exception.Text = "Feature not supported on device"; } catch (Exception ex) { // Other error has occurred. Console.WriteLine(ex); exception.Text = "Other error has occurred"; } }
private async void _barometer_ReadingChanged(Barometer sender, BarometerReadingChangedEventArgs args) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ResultsTextBlock.Text = $"StationPressureInHectopascals: {args.Reading.StationPressureInHectopascals}\r\nat {args.Reading.Timestamp}"; }); }
static void Main(string[] agrs) { IAlatUkur ialatukur; Console.WriteLine("\n\tPenggunaan Interface\n"); ialatukur = new Speedometer(); ialatukur.Menghitung(); ialatukur = new Barometer(); ialatukur.Menghitung(); ialatukur = new Dinamometer(); ialatukur.Menghitung(); AlatUkur alatukur; Console.WriteLine("\n\n\tPenggunaan AbstractClass\n"); alatukur = new Termometer(); alatukur.Menghitung(); alatukur = new Meteran(); alatukur.Menghitung(); alatukur = new Timbangan(); alatukur.Menghitung(); alatukur.Lain(); Console.ReadKey(); }
public BarometerTests() { this.InitializeComponent(); _barometer = Barometer.GetDefault(); if (_barometer == null) { ResultsTextBlock.Text = "Barometer not available on this device"; } }
public override void OnDisappearing() { Barometer.ReadingChanged -= OnReadingChanged; if (Barometer.IsMonitoring) { Barometer.Stop(); } }
public Scenario2_Polling() { this.InitializeComponent(); sensor = Barometer.GetDefault(); if (null == sensor) { rootPage.NotifyUser("No barometer found", NotifyType.ErrorMessage); } }
public override int GetHashCode() { unchecked { var hashCode = Altitude.GetHashCode(); hashCode = (hashCode * 397) ^ Barometer.GetHashCode(); hashCode = (hashCode * 397) ^ Temperature.GetHashCode(); hashCode = (hashCode * 397) ^ RelativeHumidity.GetHashCode(); return(hashCode); } }
void Start() { rb = GetComponent <Rigidbody>(); operations = new ConcurrentQueue <Action>(); orientation = new Orientation(this); accelerometer = new Accelerometer(this); gyroscpe = new Gyroscope(this); barometer = new Barometer(this); allSensors = new AllSensors(this); motorFLH = new Motor(this) { position = new Vector3(-0.193f, 0.0937f, 0.2389f), rotation = Quaternion.Euler(new Vector3(0f, 30f, 0f)), isClockwise = false }; motorBLH = new Motor(this) { position = new Vector3(-0.193f, 0.0937f, -0.2151f), rotation = Quaternion.Euler(new Vector3(0f, 150f, 0f)), isClockwise = false }; motorFRH = new Motor(this) { position = new Vector3(0.193f, 0.0937f, 0.2389f), rotation = Quaternion.Euler(new Vector3(0f, -30f, 0f)), isClockwise = true }; motorBRH = new Motor(this) { position = new Vector3(0.193f, 0.0937f, -0.2151f), rotation = Quaternion.Euler(new Vector3(0f, -150f, 0f)), isClockwise = true }; motorFLV = new Motor(this) { position = new Vector3(-0.1709f, 0f, 0.1195f), rotation = Quaternion.Euler(new Vector3(-90f, 0f, 0f)), isClockwise = true }; motorBLV = new Motor(this) { position = new Vector3(-0.1709f, 0f, -0.0963f), rotation = Quaternion.Euler(new Vector3(-90f, 0f, 0f)), isClockwise = true }; motorFRV = new Motor(this) { position = new Vector3(0.1709f, 0f, 0.1195f), rotation = Quaternion.Euler(new Vector3(-90f, 0f, 0f)), isClockwise = false }; motorBRV = new Motor(this) { position = new Vector3(0.1709f, 0f, -0.0963f), rotation = Quaternion.Euler(new Vector3(-90f, 0f, 0f)), isClockwise = false }; rollPID = new PID(.4f, .0f, 0.03f, 1f, 1, .5f); pitchPID = new PID(.7f, .0f, 0.1f, 1f, 1, .5f); yawPID = new PID(.3f, .0f, 0.04f, 1f, 1, .5f); depthPID = new PID(10f, .0f, 4f, 1f, 1, .5f); rollSpeedPID = new PID(1f, 0.1f, 0.05f, 1f, 1, .5f); pitchSpeedPID = new PID(1f, 0.1f, 0.05f, 1f, 1, .5f); yawSpeedPID = new PID(1f, 0.1f, 0.05f, 1f, 1, .5f); JsonSerializer.ToJsonString <JSON.PIDs>(new JSON.PIDs()); //No idea why first first call takes 1 second, leave it for performance }
// Displays WeatherLink data formatted public string Pretty() { var outputString = new StringBuilder(); outputString.Append("Barometer: ").Append(Barometer.ToString("f2")).Append("in. ").Append(GetBarTrendText()) .Append(Environment.NewLine); outputString.Append("Internal Temperature: ").Append(InternalTemperature).Append(Environment.NewLine); outputString.Append("Internal Humidity: ").Append(InternalHumidity).Append("%").Append(Environment.NewLine); outputString.Append("External Temperature: ").Append(ExternalTemperature).Append(Environment.NewLine); outputString.Append("External Humidity: ").Append(ExternalHumidity).Append("%").Append(Environment.NewLine); outputString.Append("Wind Direction: ").Append(GetWindDirectionText()).Append(" @ ").Append(WindDirection).Append(" degrees").Append(Environment.NewLine); outputString.Append("Current Wind Speed: ").Append(CurrentWindSpeed).Append("MPH").Append(Environment.NewLine); outputString.Append("10 Minute Average Wind Speed: ").Append(AvgWindSpeed).Append("MPH"); .Append(Environment.NewLine);
public override async void OnAppearing() { Barometer.ReadingChanged += OnReadingChanged; if (!Barometer.IsMonitoring) { Barometer.Start(SensorSpeed.UI); } var location = await Geolocation.GetLocationAsync(); GPSAltitude = location.Altitude.GetValueOrDefault(); }
public bool Equals(WeatherCondition other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Altitude.Equals(other.Altitude) && Barometer.Equals(other.Barometer) && Temperature.Equals(other.Temperature) && RelativeHumidity.Equals(other.RelativeHumidity)); }
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(); }
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); } }
private void BarometerBtn_Click(object sender, EventArgs e) { try { if (Barometer.IsMonitoring) { Barometer.Stop(); FindViewById <TextView>(Resource.Id.barometer).Text = "Pressure: off"; } else { Barometer.Start(speed); } } catch (Exception ex) { Toast.MakeText(ApplicationContext, ex.Message, ToastLength.Long).Show(); } }
public Task Stop() { try { Barometer.Stop(); } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device Console.WriteLine(fnsEx.Message); } catch (Exception ex) { // Other error has occurred. Console.WriteLine(ex.Message); } return(Task.CompletedTask); }
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; } })); }
// <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); } }
private void BarometerCheckButtom_Clicked(object sender, EventArgs e) { try { if (Barometer.IsMonitoring) { Barometer.Stop(); } else { Barometer.Start(SensorSpeed.Default); } } catch (FeatureNotSupportedException fnsEx) { DisplayAlert("Not Supported", "Error: " + fnsEx.Message, "Aceptar"); } catch (Exception ex) { DisplayAlert("Exception", "Error: " + ex.Message, "Aceptar"); } }
public void ToggleBarometer() { try { if (Barometer.IsMonitoring) { Barometer.Stop(); } else { Barometer.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device } catch (Exception ex) { // Other error has occurred. } }
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(); }
void barometer_MeasurementComplete(Barometer sender, Barometer.SensorData sensorData) { _pressure = sensorData.Pressure; _temperature = sensorData.Temperature; _temperatureF = _temperature * 1.8 + 32.0; }
void barometer_MeasurementComplete(Barometer sender, Barometer.SensorData sensorData) { barometerMeas = sensorData.Pressure; }
public void Barometer_Start() => Assert.Throws <NotImplementedInReferenceAssemblyException>(() => Barometer.Stop());
public BarometerEvents(Barometer This) { this.This = This; }
public InchOfMercuryToPascalConverter(Barometer barometer, PressureVisualizer visualizer) : base(barometer, visualizer) { }
protected override void OnAppearing() { base.OnAppearing(); Barometer.Start(SensorSpeed.Default); }
protected override void OnDisappearing() { base.OnDisappearing(); Barometer.Stop(); }
public async Task GetAndStoreBarometer() { var currentValue = Barometer.GetBarometerValue(); await Storage.StoreBarometerValue(currentValue); }
private void BarometerReadingChanged(Barometer sender, BarometerReadingChangedEventArgs args) { OnReadingChanged?.Invoke(this, new DeviceSensorReadingEventArgs <double>(args.Reading.StationPressureInHectopascals)); }
public BarometerDeviceSensor() { _barometer = Barometer.GetDefault(); }