private void NewBarPressureMeasurement(BarPressureMeasurement newMeasurement) { var newValue = newMeasurement.Value; if (_currentBarometricPressureUnit == BarometricPressureUnit.InHg) { newValue = UnitConverter.IntoInHg(newValue); } BarometricPressure = newValue.ToString("F"); }
public void ReadMeasurement() { var randomNumber = Random.NextDouble() * 70 + 980; var newMeasurement = new BarPressureMeasurement { Value = randomNumber, TimeStamp = DateTime.Now }; _eventAggregator.GetEvent <NewBarPressure>().Publish(newMeasurement); }
private void CalculateBarometricPressureTrend(BarPressureMeasurement newBarPressure) { var barometricPressureTrend = newBarPressure.Value - _lastBarometricPressure; _lastBarometricPressure = newBarPressure.Value; _nextTrend = BarometricPressureTrend.Stable; if (barometricPressureTrend >= 4 || barometricPressureTrend <= -4) { var barPerMinute = barometricPressureTrend / (newBarPressure.TimeStamp.Millisecond - _lastMeasurementTime.Millisecond) * 60; _nextTrend = ConvertBarPerMinuteIntoTrend(barPerMinute); _lastMeasurementTime = newBarPressure.TimeStamp; } _eventAggregator.GetEvent <NewBarometricPressureTrend>().Publish(_nextTrend); }