public override void Invalidate() { base.Invalidate(); if (record == null) { return; } var c = foreground.Context; var sp = record.sp; title.Text = sp.GetLocalizedStringAbreviation(c); icon.Visibility = ViewStates.Invisible; divider.Visibility = ViewStates.Invisible; unit.Text = ""; if (sp.hasSecondarySensor) { title.Text = record.manifold.secondarySensor.type.GetTypeAbreviationString(); measurement.Text = SensorUtils.ToFormattedString(sp.modifiedMeasurement, false); unit.Text = sp.modifiedMeasurement.unit.ToString(); } else { title.Text = c.GetString(Resource.String.link).ToUpper(); measurement.Text = c.GetString(Resource.String.link_none); } }
/// <summary> /// Draws the reports device measurement statistics to the file. /// </summary> /// <returns>A Tuple containing the width and height respectively of the drawn section.</returns> /// <param name="file">The file that is drawn to.</param> /// <param name="dlr">The report being drawn.</param> /// <param name="row">The x coordinate to start drawing the section in cells.</param> /// <param name="col">The y coordinate to start drawing the section in cells.</param> protected Tuple <int, int> DrawDeviceAverages(XlsFile file, DataLogReport dlr, int row, int col) { var l = dlr.localization; // Draw header file.SetCellValue(row, col, l.serialNumber, sectionHeaderFormat); file.SetCellValue(row, col + 1, l.minimum, sectionHeaderFormat); file.SetCellValue(row, col + 2, l.maximum, sectionHeaderFormat); file.SetCellValue(row, col + 3, l.average, sectionHeaderFormat); // Draw the content var offset = 1; foreach (var pair in dlr.dataLogResults) { var ro = row + offset++; var sensorType = pair.Key.type; var u = ion.preferences.units.DefaultUnitFor(sensorType); var min = pair.Value.minimum.ConvertTo(u); var max = pair.Value.maximum.ConvertTo(u); var avg = pair.Value.average.ConvertTo(u); file.SetCellValue(ro, col, pair.Key.device.serialNumber, sectionContentFormat); file.SetCellValue(ro, col + 1, SensorUtils.ToFormattedString(min, true), sectionContentFormat); file.SetCellValue(ro, col + 2, SensorUtils.ToFormattedString(max, true), sectionContentFormat); file.SetCellValue(ro, col + 3, SensorUtils.ToFormattedString(avg, true), sectionContentFormat); } return(new Tuple <int, int>(4, offset)); }
public override void Invalidate() { base.Invalidate(); if (record == null) { return; } var c = foreground.Context; Func <int, string> GetString = c.GetString; var pt = record.manifold.ptChart; var amount = record.sp.modifiedMeasurement.amount; var u = record.sp.modifiedMeasurement.unit; if (pt.fluid.mixture) { switch (pt.state) { case Fluid.EState.Bubble: { title.Text = GetString(Resource.String.fluid_sc_abrv); } break; // Fluid.EState.Bubble case Fluid.EState.Dew: { title.Text = GetString(Resource.String.fluid_sh_abrv); } break; // Fluid.EState.Dew } // measurement.Text = SensorUtils.ToFormattedString(Math.Abs(amount), unit); } else { if (amount < 0) { title.Text = GetString(Resource.String.fluid_sc_abrv); } else if (amount > 0) { title.Text = GetString(Resource.String.fluid_sh_abrv); } else { title.Text = GetString(Resource.String.fluid_sh_sc); } measurement.Text = SensorUtils.ToFormattedString(Math.Abs(amount), u); } fluid.Text = pt.fluid.name; fluid.SetBackgroundColor(new Color(pt.fluid.color)); if (record.manifold.secondarySensor == null) { measurement.Text = c.GetString(Resource.String.fluid_setup); unit.Text = ""; } else { measurement.Text = SensorUtils.ToFormattedString(Math.Abs(amount), u); unit.Text = record.sp.temperatureSensor.unit.ToString(); } }
public Android.App.Dialog Show() { var view = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_manual_sensor_edit, null); var title = view.FindViewById <TextView>(Resource.Id.title); var name = view.FindViewById <EditText>(Resource.Id.name); var measurement = view.FindViewById <EditText>(Resource.Id.measurement); var button = view.FindViewById <Button>(Resource.Id.unit); var unit = sensor.unit; button.Text = unit.ToString(); if (sensor != null) { name.Text = sensor.name; measurement.Text = SensorUtils.ToFormattedString(sensor.measurement); } button.SetOnClickListener(new ViewClickAction((v) => { UnitDialog.Create(context, sensor.supportedUnits, (obj, u) => { unit = u; button.Text = unit.ToString(); }).Show(); })); var adb = new IONAlertDialog(context); adb.SetTitle(Resource.String.edit_manual_entry); adb.SetView(view); adb.SetNegativeButton(Resource.String.cancel, (obj, args) => { var d = obj as Android.App.Dialog; d.Dismiss(); }); adb.SetPositiveButton(Resource.String.ok_done, (obj, args) => { var d = obj as Android.App.Dialog; try { sensor.name = name.Text; var meas = double.Parse(measurement.Text); sensor.measurement = unit.OfScalar(meas); if (action != null) { action(d, sensor); } d.Dismiss(); } catch (Exception e) { Log.E(this, "Failed to edit manual sensor", e); Toast.MakeText(context, Resource.String.please_enter_valid_number, ToastLength.Long).Show(); } }); return(adb.Show()); }
/// <summary> /// Raises the resume event. /// </summary> protected override void OnResume() { base.OnResume(); ion.locationManager.onLocationChanged += OnLocationChanged; var loc = ion.locationManager.lastKnownLocation; if (loc == null) { loc = new SimpleLocation(); } elevation.Text = SensorUtils.ToFormattedString(loc.altitude.ConvertTo(ion.preferences.units.length), true); }
// Implemented for IGraphRenderer public void Render(Canvas canvas, DateIndexLookup dil, SensorDataLogResults results) { var sensor = results.sensor; var serial = sensor.device.serialNumber; var indices = dil.count; var series = results.AsLineSeries(dil); model.Subtitle = serial.ToString() + "(" + sensor.type.GetTypeString() + ")"; xAxis.Minimum = 0; xAxis.Maximum = indices - 1; xAxis.MajorStep = (xAxis.Maximum - xAxis.Minimum) / Math.Min(10, indices); xAxis.LabelFormatter = (arg) => { var date = dil.GetDateTimeFromIndex((int)arg); return(date.ToLongTimeString()); }; yAxis.Minimum = results.minimum.amount; yAxis.Maximum = results.maximum.amount; yAxis.MajorStep = (yAxis.Maximum - yAxis.Minimum) / 5; if (yAxis.MajorStep == 0) { yAxis.MajorStep = 1; } yAxis.LabelFormatter = (arg) => { var su = sensor.unit.standardUnit; return(SensorUtils.ToFormattedString(su.OfScalar(arg).ConvertTo(sensor.unit))); }; yAxis.Title = sensor.unit.ToString(); model.Series.Clear(); foreach (var s in series) { var colors = sensor.GetColorForSensor(context); s.Color = OxyColor.FromUInt32((uint)colors.Item1.ToArgb()); model.Series.Add(s); } model.InvalidatePlot(true); var widthSpec = View.MeasureSpec.MakeMeasureSpec(800, MeasureSpecMode.Exactly); var heightSpec = View.MeasureSpec.MakeMeasureSpec(400, MeasureSpecMode.Exactly); plot.Measure(widthSpec, heightSpec); plot.Layout(0, 0, plot.MeasuredWidth, plot.MeasuredHeight); plot.Draw(canvas); if (plot.Model.GetLastPlotException() != null) { throw plot.Model.GetLastPlotException(); } }
private void HandleSuperheatSubcoolSensorPropertyChanged(TargetSuperheatSubcoolProperty sensorProperty) { labelTarget.Text = record.sensor.targetSHSC.ToString(); switch (sensorProperty.sensor.fluidState) { case Fluid.EState.Bubble: //labelTitle.Text = Strings.Fluid.SUBCOOL_ABRV; labelTitle.Text = "T-SC"; break; case Fluid.EState.Dew: //labelTitle.Text = Strings.Fluid.SUPERHEAT_ABRV; labelTitle.Text = "T-SH"; break; default: labelTitle.Text = Strings.UNKNOWN; break; } if (sensorProperty.pressureSensor == null || sensorProperty.temperatureSensor == null) { labelTitle.Text = Strings.Fluid.SHSC; } else { var meas = sensorProperty.modifiedMeasurement; if (meas > 0) { //labelTitle.Text = Strings.Fluid.SH; labelTitle.Text = "T-SH"; } else if (meas < 0) { //labelTitle.Text = Strings.Fluid.SC; labelTitle.Text = "T-SC"; } } ////set subview for not existing sensor linkage if (sensorProperty.sensor.linkedSensor == null) { labelOffset.Text = Strings.Workbench.Viewer.SHSC_SETUP; } else { var meas = sensorProperty.temperatureDelta - record.sensor.targetSHSC; labelOffset.Text = SensorUtils.ToFormattedString(ESensorType.Temperature, meas, true); } }
private void InvalidatePrimary() { var roc = record.manifold.GetSensorPropertyOfType <RateOfChangeSensorProperty>(); if (roc == null) { return; } var c = title.Context; if (roc.isStable) { measurement.Text = c.GetString(Resource.String.stable); unit.Visibility = ViewStates.Gone; icon.Visibility = ViewStates.Invisible; } else { var averageChange = roc.primaryRateOfChange; var amount = Math.Abs(averageChange.magnitude); var sensor = record.sp.sensor; var max = sensor.maxMeasurement; var dmax = max.amount / 12.5; if (amount > dmax) { measurement.Text = "> " + SensorUtils.ToFormattedString(sensor.unit.OfSpan(dmax)); } else { measurement.Text = SensorUtils.ToFormattedString(averageChange.unit.OfScalar(amount)); } unit.Visibility = ViewStates.Visible; unit.Text = sensor.unit + "/" + c.GetString(Resource.String.time_minute_abrv); var dir = Math.Sign(averageChange.magnitude); if (averageChange.magnitude == 0) { } else if (dir == 1) { icon.Visibility = ViewStates.Visible; icon.SetImageBitmap(cache.GetBitmap(Resource.Drawable.ic_arrow_trendup)); } else { icon.Visibility = ViewStates.Visible; icon.SetImageBitmap(cache.GetBitmap(Resource.Drawable.ic_arrow_trenddown)); } } }
public override void Invalidate() { base.Invalidate(); if (record == null) { return; } var c = foreground.Context; var pt = record.manifold.ptChart; if (pt.fluid.mixture) { switch (pt.state) { case Fluid.EState.Bubble: title.Text = c.GetString(Resource.String.fluid_bubble_abrv); break; case Fluid.EState.Dew: title.Text = foreground.Context.GetString(Resource.String.fluid_dew_abrv); break; default: break; } } else { title.Text = c.GetString(Resource.String.fluid_pt_abrv); } fluid.Text = record.manifold.ptChart.fluid.name; fluid.SetBackgroundColor(new Color(record.manifold.ptChart.fluid.color)); switch (record.sp.sensor.type) { case ESensorType.Pressure: measurement.Text = SensorUtils.ToFormattedString(record.sp.modifiedMeasurement); break; case ESensorType.Temperature: measurement.Text = SensorUtils.ToFormattedString(record.sp.modifiedMeasurement); break; } unit.Text = record.sp.unit.ToString(); }
private void HandlePTChartSensorPropertyChanged(PTChartSensorProperty sensorProperty) { var ion = AppState.context; //UpdateToFluid(sensorProperty.manifold.ptChart.fluid); UpdateToFluid(ion.fluidManager.lastUsedFluid); //var fluid = sensorProperty.manifold.ptChart.fluid; var fluid = ion.fluidManager.lastUsedFluid; if (fluid.mixture) { //switch (sensorProperty.manifold.ptChart.state) { switch (sensorProperty.sensor.fluidState) { case Fluid.EState.Bubble: labelTitle.Text = Strings.Fluid.PT_CHART_BUB; break; case Fluid.EState.Dew: labelTitle.Text = Strings.Fluid.PT_CHART_DEW; break; default: labelTitle.Text = Strings.UNKNOWN; break; } } else { labelTitle.Text = Strings.Fluid.PT; } switch (sensorProperty.sensor.type) { case ESensorType.Pressure: labelMeasurement.Text = SensorUtils.ToFormattedString(sensorProperty.modifiedMeasurement); break; case ESensorType.Temperature: labelMeasurement.Text = SensorUtils.ToFormattedString(sensorProperty.modifiedMeasurement); break; } }
public void setLHUI() { if (currentSensor != null) { LabelTop.Text = currentSensor.name; LabelMiddle.Text = SensorUtils.ToFormattedString(currentSensor.measurement); LabelBottom.Text = currentSensor.measurement.unit.ToString() + " "; LabelSubview.Text = " " + LabelTop.Text + Util.Strings.Analyzer.LHTABLE; if (currentSensor.device.isConnected) { Connection.Image = UIImage.FromBundle("ic_bluetooth_connected"); connectionColor.BackgroundColor = UIColor.Green; LabelMiddle.Font = UIFont.FromName("DroidSans-Bold", 42f); } else { Connection.Image = UIImage.FromBundle("ic_bluetooth_disconnected"); connectionColor.BackgroundColor = UIColor.Red; LabelMiddle.Font = UIFont.FromName("DroidSans", 20f); } DeviceImage.Image = DeviceUtil.GetUIImageFromDeviceModel(currentSensor.device.serialNumber.deviceModel); Connection.Hidden = false; connectionColor.Hidden = false; } else if (manualSensor != null) { LabelTop.Text = manualSensor.name; LabelMiddle.Text = SensorUtils.ToFormattedString(manualSensor.measurement); LabelBottom.Text = manualSensor.measurement.unit.ToString() + " "; LabelSubview.Text = " " + LabelTop.Text + Util.Strings.Analyzer.LHTABLE; DeviceImage.Image = UIImage.FromBundle("ic_edit"); Connection.Hidden = true; connectionColor.Hidden = true; } LabelTop.Hidden = false; DeviceImage.Hidden = false; LabelMiddle.Hidden = false; LabelBottom.Hidden = false; LabelSubview.Hidden = false; subviewHide.Hidden = false; subviewTable.Hidden = false; headingDivider.Hidden = false; LabelMiddle.Font = UIFont.FromName("DroidSans-Bold", 42f); }
// Overridden from IONActivity protected override void OnResume() { base.OnResume(); if (!sensorLocked) { var s = new ManualSensor(ESensorType.Pressure, false); s.unit = ion.preferences.units.pressure; s.ForceSetMeasurement(ion.preferences.units.pressure.OfScalar(0)); OnSensorChanged(s); ion.PostToMainDelayed(() => { slider.ScrollToPressure(s.measurement, true); }, TimeSpan.FromMilliseconds(500)); } Refresh(); slider.onScroll += OnSliderScroll; ion.locationManager.onLocationChanged += OnLocationChanged; elevation.Text = SensorUtils.ToFormattedString(ion.locationManager.lastKnownLocation.altitude.ConvertTo(ion.preferences.units.length), true); }
private async void DoUpdateRocCell(ISensorProperty property) { if (!(property is RateOfChangeSensorProperty)) { return; } await Task.Delay(TimeSpan.FromMilliseconds(2)); var rocproperty = property as RateOfChangeSensorProperty; var roc = rocproperty.GetPrimaryAverageRateOfChange(); var abs = Math.Abs(roc.magnitude); var range = (rocproperty.sensor.maxMeasurement - rocproperty.sensor.minMeasurement) / 10; if (abs > range.magnitude) { rocReading.Text = ">" + SensorUtils.ToFormattedString(rocproperty.sensor.type, range, false) + " " + roc.unit.ToString() + "/min"; } else { rocReading.Text = SensorUtils.ToFormattedString(rocproperty.sensor.type, roc.unit.OfScalar(abs), false) + " " + roc.unit.ToString() + "/min"; } if (roc.magnitude == 0) { rocImage.Image = null; rocReading.Text = Strings.Workbench.Viewer.ROC_STABLE; isUpdating = false; } else { if (roc.magnitude < 0) { rocImage.Image = UIImage.FromBundle("ic_arrow_trend_down"); } else { rocImage.Image = UIImage.FromBundle("ic_arrow_trend_up"); } await Task.Delay(TimeSpan.FromMilliseconds(500)); DoUpdateRocCell(rocproperty); } }
public override void Invalidate() { var prefs = AppState.context.preferences.units; if (!record.lowest.Equals(default(Scalar))) { var low = prefs.ToDefaultUnit(record.lowest); _lowMeasurementView.Text = SensorUtils.ToFormattedString(low); _lowMeasurementUnitView.Text = low.unit.ToString(); } if (!record.highest.Equals(default(Scalar))) { var high = prefs.ToDefaultUnit(record.highest); _highMeasurementView.Text = SensorUtils.ToFormattedString(high); _highMeasurementUnitView.Text = high.unit.ToString(); } if (!record.average.Equals(default(Scalar))) { var average = prefs.ToDefaultUnit(record.average); _avgMeasurementView.Text = SensorUtils.ToFormattedString(average); _avgMeasurementUnitView.Text = average.unit.ToString(); } _checkView.Checked = record.isChecked; if (record.detailView) { _detailContainer.Visibility = ViewStates.Visible; _graphContainer.Visibility = ViewStates.Invisible; } else { _detailContainer.Visibility = ViewStates.Invisible; _graphContainer.Visibility = ViewStates.Visible; _model.InvalidatePlot(true); } _overlay.leftPercent = _adapter.leftPercent; _overlay.rightPercent = _adapter.rightPercent; _toggleContainer.Invalidate(); }
/// <summary> /// Called when the pressure sensor's measurement is changed. /// </summary> /// <param name="sensor">Sensor.</param> private void OnPressureSensorChanged(SensorEvent sensorEvent) { var measurement = sensorEvent.sensor.measurement; if (!editPressure.IsEditing) { editPressure.Text = SensorUtils.ToFormattedString(measurement); } pressureUnit = measurement.unit; if (sensorEvent.sensor != null) { var temp = ion.fluidManager.lastUsedFluid.GetSaturatedTemperature(sensorEvent.sensor.fluidState, sensorEvent.sensor.measurement, ion.locationManager.lastKnownLocation.altitude).ConvertTo(temperatureUnit); labelSatTempMeasurement.Text = SensorUtils.ToFormattedString(temp); labelSatTempUnit.Text = temp.unit.ToString(); } UpdateDelta(); }
private void OnSliderScroll(FluidSliderView slider, bool touching, Scalar pressure, Scalar temperature) { if (touching) { SetPressureInputQuietly(SensorUtils.ToFormattedString(pressure.ConvertTo(pressureUnit))); SetTemperatureInputQuietly(SensorUtils.ToFormattedString(temperature.ConvertTo(temperatureUnit))); } else { if (!pressureEntryView.HasFocus) { SetPressureInputQuietly(SensorUtils.ToFormattedString(pressure.ConvertTo(pressureUnit))); } if (!temperatureEntryView.HasFocus) { SetTemperatureInputQuietly(SensorUtils.ToFormattedString(temperature.ConvertTo(temperatureUnit))); } } }
/// <summary> /// Called when the temperature sensor's measurement is changed. /// </summary> /// <param name="sensor">Sensor.</param> private void OnTemperatureSensorChanged(SensorEvent sensorEvent) { var measurement = sensorEvent.sensor.measurement; if (!editTemperature.IsEditing) { editTemperature.Text = SensorUtils.ToFormattedString(measurement); } temperatureUnit = measurement.unit; buttonTemperatureUnit.SetTitle(measurement.unit.ToString(), UIControlState.Normal); if (pressureSensor == null) { pressureSensor = new ManualSensor(ion.manualSensorContainer, ESensorType.Pressure, new Scalar(pressureUnit, 0.0)); } var temp = ion.fluidManager.lastUsedFluid.GetSaturatedTemperature(pressureSensor.fluidState, pressureSensor.measurement, ion.locationManager.lastKnownLocation.altitude).ConvertTo(temperatureUnit); labelSatTempUnit.Text = temp.unit.ToString(); UpdateDelta(); }
private async void DoUpdateCell() { var sp = record.sensorProperty as RateOfChangeSensorProperty; var rocScalar = sp.GetPrimaryAverageRateOfChange(); var abs = Math.Abs(rocScalar.magnitude); var range = (sp.sensor.maxMeasurement.ConvertTo(rocScalar.unit) - sp.sensor.minMeasurement.ConvertTo(rocScalar.unit)) / 10; if (abs > range.magnitude) { labelMeasurement.Text = ">" + SensorUtils.ToFormattedString(sp.sensor.type, range) + " " + rocScalar.unit.ToString() + Strings.Measure.PER_MINUTE; } else { labelMeasurement.Text = SensorUtils.ToFormattedString(sp.sensor.type, rocScalar.unit.OfScalar(abs)) + " " + rocScalar.unit.ToString() + Strings.Measure.PER_MINUTE; } if (rocScalar.magnitude == 0) { buttonIcon.Hidden = true; labelMeasurement.Text = Strings.Workbench.Viewer.ROC_STABLE; isUpdating = false; } else { buttonIcon.Hidden = false; if (rocScalar < 0) { buttonIcon.SetImage(UIImage.FromBundle("ic_arrow_trend_down"), UIControlState.Normal); } else { buttonIcon.SetImage(UIImage.FromBundle("ic_arrow_trend_up"), UIControlState.Normal); } await Task.Delay(100); DoUpdateCell(); } }
public void Invalidate() { if (!(sensor is ManualSensor)) { primaryTextView.Text = sensor.ToFormattedString(false); } Scalar measurement; switch (sensor.type) { case ESensorType.Pressure: measurement = AppState.context.fluidManager.lastUsedFluid.GetSaturatedTemperature(sensor.fluidState, sensor.measurement, AppState.context.locationManager.lastKnownLocation.altitude).ConvertTo(otherUnit); derivedTextView.Text = SensorUtils.ToFormattedString(measurement); vc.pressureUnit = sensor.unit; break; case ESensorType.Temperature: measurement = AppState.context.fluidManager.lastUsedFluid.GetPressureFromSaturatedTemperature(sensor.fluidState, sensor.measurement, AppState.context.locationManager.lastKnownLocation.altitude).ConvertTo(otherUnit); derivedTextView.Text = SensorUtils.ToFormattedString(measurement); vc.temperatureUnit = sensor.unit; break; } }
/// <summary> /// Updates the axis to the given state for RoC based measurements. /// </summary> /// <param name="axis">Axis.</param> private void UpdateAxis(LinearAxis axis, Scalar min, Scalar max, Scalar range, Unit u, UILabel topLabel, UILabel bottomLabel, Scalar sensorMin) { if (max.amount < sensorMin.amount) { return; } if (min.amount - (range.amount / 2) < sensorMin.amount) { axis.Minimum = sensorMin.amount; bottomLabel.Text = SensorUtils.ToFormattedString(sensorMin.ConvertTo(u), true); } else { axis.Minimum = min.amount - (range.amount / 2); var diffScalar = new Scalar(u.standardUnit, (min.amount - (range.amount / 2))); bottomLabel.Text = SensorUtils.ToFormattedString(diffScalar.ConvertTo(u), true); } if (max.amount + (range.amount / 2) < sensorMin.amount + range.amount) { axis.Maximum = sensorMin.amount + range.amount; var diffScalar = new Scalar(u.standardUnit, sensorMin.amount + range.amount); topLabel.Text = SensorUtils.ToFormattedString(diffScalar.ConvertTo(u), true); } else { axis.Maximum = max.amount + (range.amount / 2); var diffScalar = new Scalar(u.standardUnit, (max.amount + (range.amount / 2))); topLabel.Text = SensorUtils.ToFormattedString(diffScalar.ConvertTo(u), true); } axis.MinimumPadding = 0.25; axis.MaximumPadding = 0.25; axis.AxislineStyle = LineStyle.Solid; axis.AxislineThickness = 1; plotView.Model.PlotMargins = new OxyThickness(0, double.NaN, 0, double.NaN); }
public override void Invalidate() { base.Invalidate(); if (record == null) { return; } title.Text = record.sp.GetLocalizedStringAbreviation(foreground.Context); if (record.sp.supportedReset) { icon.SetImageBitmap(cache.GetBitmap(Resource.Drawable.ic_refresh)); divider.Visibility = ViewStates.Visible; } else { icon.Visibility = ViewStates.Invisible; divider.Visibility = ViewStates.Invisible; } measurement.Text = SensorUtils.ToFormattedString(record.sp.modifiedMeasurement, false); unit.Text = record.sp.modifiedMeasurement.unit.ToString(); }
private void OnSensorPropertyChanged(ISensorProperty sensorProperty) { labelMeasurement.Text = SensorUtils.ToFormattedString(sensorProperty.sensor.type, sensorProperty.modifiedMeasurement, true); }
/// <summary> /// Sets up the graph for live trending /// </summary> /// <returns>The plot model.</returns> public PlotModel CreatePlotModel() { //var roc = initialRecord.manifold.GetSensorPropertyOfType<RateOfChangeSensorProperty>(); var roc = initialRecord.sensor.GetSensorPropertyOfType <RateOfChangeSensorProperty>(); var model = new PlotModel(); primaryColor = OxyColors.Blue; secondaryColor = OxyColors.Red; //if (roc.manifold.primarySensor.type == ESensorType.Temperature) { if (roc.sensor.type == ESensorType.Temperature) { primaryColor = OxyColors.Red; secondaryColor = OxyColors.Blue; //} else if (roc.manifold.primarySensor.type == ESensorType.Vacuum) { } else if (roc.sensor.type == ESensorType.Vacuum) { primaryColor = OxyColors.Maroon; } BAX = new LinearAxis() { Position = AxisPosition.Bottom, Minimum = DateTime.Now.AddSeconds(-30).ToFileTime() - 100000, Maximum = DateTime.Now.ToFileTime() - 100000, IsAxisVisible = true, IsZoomEnabled = false, IsPanEnabled = false, Key = "time", LabelFormatter = (arg) => { var d = DateTime.FromFileTime((long)arg); return(d.Hour.ToString("00") + ":" + d.Minute.ToString("00") + ":" + d.Second.ToString("00")); }, Font = model.DefaultFont, FontSize = 13, TextColor = OxyColors.Black, AxislineThickness = 0, AxislineStyle = LineStyle.None, MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, AxisTickToLabelDistance = 0.0, }; //var baseUnit = roc.manifold.primarySensor.unit.standardUnit; var baseUnit = roc.sensor.unit.standardUnit; LAX = new LinearAxis() { Position = AxisPosition.Left, Minimum = 0, Maximum = 100, IsAxisVisible = true, IsZoomEnabled = false, IsPanEnabled = false, Key = "first", LabelFormatter = (arg) => { //var u = roc.manifold.primarySensor.unit; var u = roc.sensor.unit; var p = SensorUtils.ToFormattedString(u.standardUnit.OfScalar(arg).ConvertTo(u), true); return(p); }, Font = model.DefaultFont, FontSize = 15, TextColor = OxyColors.Black, AxislineThickness = 0, AxislineStyle = LineStyle.None, MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, AxisTickToLabelDistance = 0.0, }; RAX = new LinearAxis() { Position = AxisPosition.Right, Minimum = 0, Maximum = 100, IsAxisVisible = true, IsZoomEnabled = false, IsPanEnabled = false, Key = "second", LabelFormatter = (arg) => { //if (roc.manifold.secondarySensor != null) { if (roc.sensor.linkedSensor != null) { //var u = roc.manifold.secondarySensor.unit; var u = roc.sensor.linkedSensor.unit; return(SensorUtils.ToFormattedString(u.standardUnit.OfScalar(arg).ConvertTo(u), true)); } else { return(""); } }, Font = model.DefaultFont, FontSize = 15, TextColor = OxyColors.Black, AxislineThickness = 0, AxislineStyle = LineStyle.None, MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, AxisTickToLabelDistance = 0.0, }; primarySeries = new LineSeries() { StrokeThickness = 1, Color = primaryColor, MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent, MarkerStrokeThickness = 0, YAxisKey = "first", }; secondarySeries = new LineSeries() { StrokeThickness = 1, Color = secondaryColor, MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent, MarkerStrokeThickness = 0, YAxisKey = "second", }; model.Background = OxyColors.Transparent; model.PlotMargins = new OxyThickness(0, double.NaN, 0, 0); model.TitlePadding = 0.0; model.PlotType = PlotType.XY; model.Axes.Add(BAX); model.Axes.Add(LAX); model.Axes.Add(RAX); model.Series.Add(primarySeries); model.Series.Add(secondarySeries); model.PlotAreaBorderThickness = new OxyThickness(0); model.PlotAreaBorderColor = OxyColors.Transparent; return(model); }
public void makeEvents(lowHighSensor lhSensor, CGRect tableRect) { cellHeader = new UILabel(new CGRect(0, 0, 1.006 * tableRect.Width, .5 * lhSensor.cellHeight)); cellButton = new UIButton(new CGRect(0, .5 * lhSensor.cellHeight, tableRect.Width, .5 * lhSensor.cellHeight)); cellHeader.Text = "ALT"; cellHeader.TextColor = UIColor.White; cellHeader.BackgroundColor = UIColor.Black; cellHeader.Font = UIFont.FromName("Helvetica-Bold", 21f); cellHeader.TextAlignment = UITextAlignment.Center; cellHeader.AdjustsFontSizeToFitWidth = true; cellReading = lhSensor.altReading; cellReading.AdjustsFontSizeToFitWidth = true; cellReading.TextAlignment = UITextAlignment.Right; cellButton.BackgroundColor = UIColor.Clear; cellButton.Layer.BorderColor = UIColor.Black.CGColor; if (lhSensor.isManual) { if (lhSensor.currentSensor.type == ESensorType.Pressure) { manSensor = new ManualSensor(AppState.context.manualSensorContainer, ESensorType.Pressure, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Pressure).OfScalar(0.0)); //manSensor = new ManualSensor(ESensorType.Pressure, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Pressure).OfScalar(0.0)); manSensor.unit = AnalyserUtilities.getManualUnit(ESensorType.Pressure, lhSensor.LabelBottom.Text.ToLower()); ((ManualSensor)manSensor).SetMeasurement(manSensor.unit.OfScalar(Convert.ToDouble(lhSensor.LabelMiddle.Text))); lhSensor.alt = new AlternateUnitSensorProperty(manSensor); } else if (lhSensor.currentSensor.type == ESensorType.Temperature) { manSensor = new ManualSensor(AppState.context.manualSensorContainer, ESensorType.Temperature, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Temperature).OfScalar(0.0)); //manSensor = new ManualSensor(ESensorType.Temperature, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Temperature).OfScalar(0.0)); manSensor.unit = AnalyserUtilities.getManualUnit(ESensorType.Temperature, lhSensor.LabelBottom.Text.ToLower()); ((ManualSensor)manSensor).SetMeasurement(manSensor.unit.OfScalar(Convert.ToDouble(lhSensor.LabelMiddle.Text))); lhSensor.alt = new AlternateUnitSensorProperty(manSensor); } else if (lhSensor.currentSensor.type == ESensorType.Vacuum) { manSensor = new ManualSensor(AppState.context.manualSensorContainer, ESensorType.Vacuum, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Vacuum).OfScalar(0.0)); //manSensor = new ManualSensor(ESensorType.Vacuum, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Vacuum).OfScalar(0.0)); manSensor.unit = AnalyserUtilities.getManualUnit(ESensorType.Vacuum, lhSensor.LabelBottom.Text.ToLower()); ((ManualSensor)manSensor).SetMeasurement(manSensor.unit.OfScalar(Convert.ToDouble(lhSensor.LabelMiddle.Text))); lhSensor.alt = new AlternateUnitSensorProperty(manSensor); } if (lhSensor.altUnit != null) { lhSensor.alt.unit = lhSensor.altUnit; } else { lhSensor.alt.unit = manSensor.unit; } cellReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true); } else { lhSensor.alt = new AlternateUnitSensorProperty(lhSensor.currentSensor as Sensor); if (lhSensor.altUnit != null) { lhSensor.alt.unit = lhSensor.altUnit; } else { if (lhSensor.currentSensor.type == ESensorType.Pressure) { lhSensor.alt.unit = AnalyserUtilities.getManualUnit(lhSensor.currentSensor.type, lhSensor.altUnits[0].Replace("/", "").ToLower()); } else if (lhSensor.currentSensor.type == ESensorType.Temperature) { lhSensor.alt.unit = AnalyserUtilities.getManualUnit(lhSensor.currentSensor.type, lhSensor.tempUnits[0].Replace("/", "").ToLower()); } else if (lhSensor.currentSensor.type == ESensorType.Vacuum) { lhSensor.alt.unit = AnalyserUtilities.getManualUnit(lhSensor.currentSensor.type, lhSensor.vacUnits[0].Replace("/", "").ToLower()); } } } cellButton.TouchUpInside += delegate { var window = UIApplication.SharedApplication.KeyWindow; var vc = window.RootViewController; while (vc.PresentedViewController != null) { vc = vc.PresentedViewController; } UIAlertController altUnit = UIAlertController.Create(Util.Strings.Analyzer.CHOOSEUNIT, "", UIAlertControllerStyle.Alert); if (lhSensor.alt.sensor.type == ESensorType.Pressure) { foreach (String unit in lhSensor.altUnits) { altUnit.AddAction(UIAlertAction.Create(unit, UIAlertActionStyle.Default, (action) => { if (lhSensor.isManual) { lhSensor.altUnit = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower()); lhSensor.alt.unit = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower()); lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true); } else { lhSensor.altUnit = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower()); lhSensor.alt.unit = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower()); lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true); } })); } } else if (lhSensor.alt.sensor.type == ESensorType.Temperature) { foreach (String unit in lhSensor.tempUnits) { altUnit.AddAction(UIAlertAction.Create(unit, UIAlertActionStyle.Default, (action) => { if (lhSensor.isManual) { lhSensor.altUnit = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower()); lhSensor.alt.unit = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower()); lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true); } else { lhSensor.altUnit = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower()); lhSensor.alt.unit = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower()); lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true); } })); } } else if (lhSensor.alt.sensor.type == ESensorType.Vacuum) { foreach (String unit in lhSensor.vacUnits) { altUnit.AddAction(UIAlertAction.Create(unit, UIAlertActionStyle.Default, (action) => { if (lhSensor.isManual) { lhSensor.altUnit = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower()); lhSensor.alt.unit = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower()); lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true); } else { lhSensor.altUnit = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower()); lhSensor.alt.unit = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower()); lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true); } })); } } altUnit.AddAction(UIAlertAction.Create(Util.Strings.CANCEL, UIAlertActionStyle.Cancel, (action) => {})); vc.PresentViewController(altUnit, true, null); }; this.AddSubview(cellHeader); this.AddSubview(cellButton); this.AddSubview(cellReading); }
private void HandleSuperheatSubcoolSensorPropertyChanged(SuperheatSubcoolSensorProperty sensorProperty) { UpdateToFluid(AppState.context.fluidManager.lastUsedFluid); if (AppState.context.fluidManager.lastUsedFluid.mixture) { //switch (sensorProperty.manifold.ptChart.state) { switch (sensorProperty.sensor.fluidState) { case Fluid.EState.Bubble: labelTitle.Text = Strings.Fluid.SUBCOOL_ABRV; break; case Fluid.EState.Dew: labelTitle.Text = Strings.Fluid.SUPERHEAT_ABRV; break; default: labelTitle.Text = Strings.UNKNOWN; break; } } else { if (sensorProperty.pressureSensor == null || sensorProperty.temperatureSensor == null) { labelTitle.Text = Strings.Fluid.SHSC; } else { var meas = sensorProperty.modifiedMeasurement; if (meas > 0) { labelTitle.Text = Strings.Fluid.SH; } else if (meas < 0) { labelTitle.Text = Strings.Fluid.SC; } else { labelTitle.Text = Strings.Fluid.SATURATED; } } } if (sensorProperty.pressureSensor == null || sensorProperty.temperatureSensor == null) { labelMeasurement.Text = Strings.Workbench.Viewer.SHSC_SETUP; } else { var meas = sensorProperty.temperatureDelta; if (AppState.context.fluidManager.lastUsedFluid.mixture) { labelMeasurement.Text = SensorUtils.ToFormattedString(ESensorType.Temperature, meas, true); } else { if (meas < 0) { meas = meas * -1; } labelMeasurement.Text = SensorUtils.ToFormattedString(ESensorType.Temperature, meas, true); } } }
/// <summary> /// Initializes the temperature widgets for the activity. /// </summary> private void InitTemperatureWidgets() { var temperatureView = FindViewById(Resource.Id.temperature); temperatureAddView = temperatureView.FindViewById(Resource.Id.add); temperatureLockIconView = temperatureAddView.FindViewById <ImageView>(Resource.Id.padlock); temperatureSensorIconView = temperatureAddView.FindViewById <ImageView>(Resource.Id.icon); temperatureEntryView = temperatureView.FindViewById <EditText>(Resource.Id.edit); temperatureUnitView = temperatureView.FindViewById <Button>(Resource.Id.unit); temperatureClearView = temperatureView.FindViewById <Button>(Resource.Id.clear); temperatureView.SetOnTouchListener(new ClearFocusListener(temperatureEntryView)); temperatureTextWatcher = new Watcher((editable) => { var text = editable.ToString(); if (!"".Equals(text)) { double amount = 0; if (double.TryParse(text, out amount)) { var ts = temperatureUnit.OfScalar(amount); var press = ptChart.GetRelativePressure(ts).ConvertTo(pressureUnit); SetPressureInputQuietly(press.amount.ToString("#.##")); slider.ScrollToTemperature(ts, false); } } else { ClearInput(); } }); temperatureAddView.SetOnClickListener(new ViewClickAction((view) => { if (!sensorLocked && !hasPressureSensor) { new GaugeDeviceSensorSelectDialog(this, ion, ESensorType.Temperature, (sensor) => { _sensor = sensor; }).Show(); } })); temperatureAddView.SetOnLongClickListener(new ViewLongClickAction((view) => { if (!sensorLocked) { _sensor = null; slider.ScrollToTemperature(temperatureUnit.OfScalar(0), true); } })); temperatureClearView.SetOnClickListener(new ViewClickAction((view) => { ClearInput(); })); temperatureUnitView.Text = temperatureUnit.ToString(); temperatureUnitView.SetOnClickListener(new ViewClickAction((v) => { if (_sensor == null || ESensorType.Pressure == _sensor.type) { UnitDialog.Create(this, SensorUtils.DEFAULT_TEMPERATURE_UNITS, (obj, unit) => { if (initialManifold != null && initialManifold.primarySensor.type == ESensorType.Pressure) { UpdateManifold(unit); } var text = temperatureEntryView.Text; var oldUnit = temperatureUnit; temperatureUnit = unit; try { if (!"".Equals(text) && _sensor == null) { var amount = double.Parse(text); var ts = oldUnit.OfScalar(amount).ConvertTo(temperatureUnit); SetTemperatureInputQuietly(SensorUtils.ToFormattedString(ts)); } else { ClearInput(); } } catch (Exception) { return; } Refresh(); }).Show(); } })); temperatureEntryView.AddTextChangedListener(temperatureTextWatcher); }
/// <summary> /// Called when the application's location changes. /// </summary> /// <param name="lm">Lm.</param> /// <param name="oldLocation">Old location.</param> /// <param name="newLocation">New location.</param> private void OnLocationChanged(ILocationManager lm, ILocation oldLocation, ILocation newLocation) { elevation.Text = SensorUtils.ToFormattedString(newLocation.altitude.ConvertTo(ion.preferences.units.length), true); }
/// <summary> /// Updates the calculated temperature delta value for the superheat/subcool calculations. /// </summary> private void UpdateDelta() { labelFluidState.BackgroundColor = new UIColor(Colors.RED); switchFluidState.TintColor = new UIColor(Colors.RED); if (editPressure.Text.Equals("") || editTemperature.Text.Equals("") || pressureSensor == null || temperatureSensor == null) { labelFluidDelta.Text = ""; switch (pressureSensor.fluidState) { case Fluid.EState.Bubble: labelFluidState.BackgroundColor = new UIColor(Colors.RED); switchFluidState.TintColor = new UIColor(Colors.RED); labelFluidState.Text = Strings.Fluid.SUBCOOL; break; case Fluid.EState.Dew: labelFluidState.BackgroundColor = new UIColor(Colors.BLUE); switchFluidState.TintColor = new UIColor(Colors.BLUE); labelFluidState.Text = Strings.Fluid.SUPERHEAT; break; default: labelFluidState.BackgroundColor = new UIColor(Colors.BLUE); switchFluidState.TintColor = new UIColor(Colors.BLUE); labelFluidState.Text = Strings.Fluid.SUPERHEAT; break; //throw new Exception("Cannot update delta for state: " + ptChart.state); } return; } var pressureScalar = ion.fluidManager.lastUsedFluid.ConvertRelativePressureToAbsolute(pressureSensor.measurement, ion.locationManager.lastKnownLocation.altitude); var temperatureScalar = temperatureSensor.measurement; var calculation = ion.fluidManager.lastUsedFluid.CalculateTemperatureDelta(pressureSensor.fluidState, pressureScalar, temperatureScalar, ion.locationManager.lastKnownLocation.altitude).ConvertTo(temperatureUnit); if (ion.fluidManager.lastUsedFluid.mixture) { switch (pressureSensor.fluidState) { case Fluid.EState.Bubble: labelFluidState.BackgroundColor = new UIColor(Colors.RED); switchFluidState.TintColor = new UIColor(Colors.RED); labelFluidState.Text = Strings.Fluid.SUBCOOL; break; case Fluid.EState.Dew: labelFluidState.BackgroundColor = new UIColor(Colors.BLUE); switchFluidState.TintColor = new UIColor(Colors.BLUE); labelFluidState.Text = Strings.Fluid.SUPERHEAT; break; default: labelFluidState.BackgroundColor = new UIColor(Colors.BLUE); switchFluidState.TintColor = new UIColor(Colors.BLUE); labelFluidState.Text = Strings.Fluid.SUPERHEAT; Log.E(this, "Cannot update delta for state: " + pressureSensor.fluidState); break; //throw new Exception("Cannot update delta for state: " + ptChart.state); } if (calculation.magnitude < 0) { imageNegativeWarning.Hidden = false; View.BringSubviewToFront(imageNegativeWarning); } else { imageNegativeWarning.Hidden = true; View.BringSubviewToFront(imageNegativeWarning); } } else { imageNegativeWarning.Hidden = true; if (System.Math.Abs(calculation.magnitude) < 0.1) { labelFluidState.BackgroundColor = new UIColor(Colors.GREEN); labelFluidState.Text = Strings.Fluid.SATURATED; } else if (calculation > 0) { labelFluidState.BackgroundColor = new UIColor(Colors.BLUE); labelFluidState.Text = Strings.Fluid.SUPERHEAT; } else { labelFluidState.BackgroundColor = new UIColor(Colors.RED); labelFluidState.Text = Strings.Fluid.SUBCOOL; //should never show a negative temperature so multiply by -1 calculation = calculation * -1; } } labelFluidDelta.Text = SensorUtils.ToFormattedString(ESensorType.Temperature, calculation, true); }
/// <summary> /// Sets up the graph for live trending /// </summary> /// <returns>The plot model.</returns> public PlotModel CreatePlotModel() { var model = new PlotModel(); BAX = new LinearAxis() { Position = AxisPosition.Bottom, Minimum = DateTime.Now.AddSeconds(-30).ToFileTime() - 100000, Maximum = DateTime.Now.ToFileTime() - 100000, IsAxisVisible = true, IsZoomEnabled = false, IsPanEnabled = false, Key = "time", LabelFormatter = (arg) => { var d = DateTime.FromFileTime((long)arg); return(d.Hour.ToString("00") + ":" + d.Minute.ToString("00") + ":" + d.Second.ToString("00")); }, Font = model.DefaultFont, FontSize = 10, TextColor = OxyColors.Black, AxislineThickness = 0, AxislineStyle = LineStyle.None, MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, AxisTickToLabelDistance = 0.0, TickStyle = TickStyle.None, }; var baseUnit = cellSensor.unit.standardUnit; LAX = new LinearAxis() { Position = AxisPosition.Left, Minimum = 0, Maximum = 100, IsAxisVisible = false, IsZoomEnabled = false, IsPanEnabled = false, Key = "first", LabelFormatter = (arg) => { var u = cellSensor.unit; var p = SensorUtils.ToFormattedString(u.standardUnit.OfScalar(arg).ConvertTo(u), true); return(p); }, Font = model.DefaultFont, FontSize = 15, TextColor = OxyColors.Black, AxislineThickness = 0, AxislineStyle = LineStyle.None, MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, AxisTickToLabelDistance = 0.0, TickStyle = TickStyle.None, }; RAX = new LinearAxis() { Position = AxisPosition.Right, Minimum = 0, Maximum = 100, IsAxisVisible = false, IsZoomEnabled = false, IsPanEnabled = false, Key = "second", LabelFormatter = (arg) => { if (cellSensor.linkedSensor != null) { var u = cellSensor.linkedSensor.unit; return(SensorUtils.ToFormattedString(u.standardUnit.OfScalar(arg).ConvertTo(u), true)); } else { return(""); } }, Font = model.DefaultFont, FontSize = 15, TextColor = OxyColors.Black, AxislineThickness = 0, AxislineStyle = LineStyle.None, MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, AxisTickToLabelDistance = 0.0, TickStyle = TickStyle.None, }; primarySeries = new LineSeries() { StrokeThickness = 1, Color = primaryColor, MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent, MarkerStrokeThickness = 0, YAxisKey = "first", }; secondarySeries = new LineSeries() { StrokeThickness = 1, Color = secondaryColor, MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent, MarkerStrokeThickness = 0, YAxisKey = "second", }; model.Background = OxyColors.Transparent; model.PlotMargins = new OxyThickness(-7, -7, -7, -5); model.TitlePadding = 0.0; model.PlotType = PlotType.XY; model.Axes.Add(BAX); model.Axes.Add(LAX); model.Axes.Add(RAX); model.Series.Add(primarySeries); model.Series.Add(secondarySeries); model.PlotAreaBorderThickness = new OxyThickness(0); model.PlotAreaBorderColor = OxyColors.Transparent; return(model); }
/// <summary> /// Updates the state of the calculation measurement. /// </summary> private void UpdateCalculationMeasurements() { if (pressureSensor == null || temperatureSensor == null) { deltaView.Visibility = ViewStates.Gone; } if (pressureSensor == null) { saturatedTemperatureTextView.Text = ""; return; } var tu = temperatureUnit; var satTemp = ptChart.GetTemperature(pressureSensor.measurement, pressureSensor.isRelative); satTemp = satTemp.ConvertTo(tu); saturatedTemperatureTextView.Text = SensorUtils.ToFormattedString(satTemp); saturatedTemperatureUnitView.Text = temperatureUnit.ToString(); switch (ptChart.state) { case Fluid.EState.Bubble: fluidStateTextView.Text = GetString(Resource.String.fluid_sc); fluidStateTextView.SetBackgroundColor(Resource.Color.red.AsResourceColor(this)); break; case Fluid.EState.Dew: fluidStateTextView.Text = GetString(Resource.String.fluid_sh); fluidStateTextView.SetBackgroundColor(Resource.Color.blue.AsResourceColor(this)); break; } if (temperatureSensor == null) { return; } deltaView.Visibility = ViewStates.Visible; ScalarSpan delta; if (pressureSensor.isRelative) { delta = ptChart.CalculateTemperatureDeltaRelative(pressureSensor.measurement, temperatureSensor.measurement); } else { delta = ptChart.CalculateTemperatureDeltaAbsolute(pressureSensor.measurement, temperatureSensor.measurement); } delta = delta.ConvertTo(temperatureUnit); if (ptChart.fluid.mixture && delta.magnitude < 0) { warning.Visibility = ViewStates.Visible; } else { warning.Visibility = ViewStates.Gone; } if (!ptChart.fluid.mixture) { if (delta.magnitude < 0) { // dew __ptChart = ptChart.fluid.GetPtChart(Fluid.EState.Dew); } else { // bubble __ptChart = ptChart.fluid.GetPtChart(Fluid.EState.Bubble); } calculationTextView.Text = SensorUtils.ToFormattedString(ESensorType.Temperature, delta.Abs(), true); } else { calculationTextView.Text = SensorUtils.ToFormattedString(ESensorType.Temperature, delta, true); } }