Ejemplo n.º 1
0
        /// <summary>
        /// Called when a sensor property is clicked in the analyzer view. Note: either the low or high side may be clicked
        /// </summary>
        /// <param name="manifold">Manifold.</param>
        /// <param name="sensorProperty">Sensor property.</param>
        private void OnSensorPropertyClicked(Manifold manifold, ISensorProperty sensorProperty)
        {
            var sensor = sensorProperty.sensor;

            if (sensorProperty is AlternateUnitSensorProperty)
            {
                var asp = sensorProperty as AlternateUnitSensorProperty;
                UnitDialog.Create(Activity, sensor.supportedUnits, (obj, u) => {
                    asp.unit = u;
                }).Show();
            }
            else if (sensorProperty is PTChartSensorProperty)
            {
                ViewInPtChartActivity(manifold, sensorProperty);
            }
            else if (sensorProperty is SuperheatSubcoolSensorProperty)
            {
                ViewInSuperheatSubcoolActivity(manifold, sensorProperty);
            }
            else if (sensorProperty is RateOfChangeSensorProperty)
            {
                var ps = manifold.primarySensor as GaugeDeviceSensor;
                if (ps != null && !ps.device.isConnected)
                {
                    Toast.MakeText(Activity, Resource.String.devices_error_connect_for_roc, ToastLength.Long).Show();
                }
                else
                {
                    var i = new Intent(Activity, typeof(RoCActivity));
                    i.PutExtra(RoCActivity.EXTRA_MANIFOLD, new AnalyzerManifoldParcelable(analyzer.lowSideManifold == manifold));
                    StartActivity(i);
                }
            }
        }
            public BoundedHandler(SensorAlarmActivity activity, IION ion, BoundedSensorAlarm alarm, View view)
            {
                this.activity = activity;
                this.alarm    = alarm;

                toggle      = view.FindViewById <Switch>(Resource.Id.toggle);
                measurement = view.FindViewById <EditText>(Resource.Id.measurement);
                unit        = view.FindViewById <Button>(Resource.Id.unit);

                toggle.SetOnCheckedChangeListener(new ViewCheckChangedAction((but, check) => {
                    alarm.Reset();
                }));
                unit.SetOnClickListener(new ViewClickAction((v) => {
                    UnitDialog.Create(activity, alarm.sensor.supportedUnits, (obj, u) => {
                        var dialog = obj as Android.App.Dialog;

                        if (dialog != null)
                        {
                            dialog.Dismiss();
                        }

                        unit.Text = u.ToString();
                        unitCode  = UnitLookup.GetCode(u);
                    }).Show();
                }));

                toggle.Checked   = alarm.enabled;
                measurement.Text = alarm.bounds.amount + "";
                unit.Text        = alarm.bounds.unit.ToString();
                unitCode         = UnitLookup.GetCode(alarm.bounds.unit);
            }
        private async void handleClickUpdateUnit(object sender, RoutedEventArgs e)
        {
            var unitDialog    = new UnitDialog(this.learningUnit);
            var buttonClicked = await unitDialog.ShowAsync();

            if (buttonClicked == ContentDialogResult.Primary)
            {
                Debug.WriteLine(unitDialog.result.name);
                this.learningUnitName = unitDialog.result.name;
            }
        }
		private void OnOnSensorPropertyClicked(Manifold manifold, ISensorProperty sensorProperty) {
			var sensor = sensorProperty.sensor;

			if (sensorProperty is AlternateUnitSensorProperty) {
				var asp = sensorProperty as AlternateUnitSensorProperty;
				UnitDialog.Create(Activity, sensor.supportedUnits, (obj, u) => {
					asp.unit = u;
				}).Show();
			} else if (sensorProperty is PTChartSensorProperty) {
				var i = new Intent(Activity, typeof(PTChartActivity));
				i.SetAction(Intent.ActionPick);
				i.PutExtra(PTChartActivity.EXTRA_WORKBENCH_MANIFOLD, workbench.IndexOf(manifold));
				if (ion is RemoteION) {
					StartActivity(i);
				} else {
					StartActivityForResult(i, REQUEST_SHOW_PTCHART);
				}
			} else if (sensorProperty is SuperheatSubcoolSensorProperty) {
				var i = new Intent(Activity, typeof(SuperheatSubcoolActivity));
				i.SetAction(Intent.ActionPick);
				i.PutExtra(SuperheatSubcoolActivity.EXTRA_WORKBENCH_MANIFOLD, workbench.IndexOf(manifold));
				i.PutExtra(SuperheatSubcoolActivity.EXTRA_FLUID_NAME, manifold.ptChart.fluid.name);
				i.PutExtra(SuperheatSubcoolActivity.EXTRA_FLUID_STATE, (int)manifold.ptChart.state);
				if (ion is RemoteION) {
					StartActivity(i);
				} else {
					StartActivityForResult(i, REQUEST_SHOW_SUPERHEAT_SUBCOOL);
				}
			} else if (sensorProperty is RateOfChangeSensorProperty) {
        var ps = manifold.primarySensor as GaugeDeviceSensor;
        if (ps != null && !ps.device.isConnected) {
          Toast.MakeText(Activity, Resource.String.devices_error_connect_for_roc, ToastLength.Long).Show();
        } else {
          var i = new Intent(Activity, typeof(RoCActivity));
          i.PutExtra(RoCActivity.EXTRA_MANIFOLD, new WorkbenchManifoldParcelable(workbench.IndexOf(manifold)));
          StartActivity(i);
        }
			}
		}
        /// <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);
        }
Ejemplo n.º 6
0
        /// <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);

            temperatureTextWatcher = new Watcher((editable) => {
                var text = editable.ToString();
                try {
                    if (temperatureSensor == null)
                    {
                        temperatureSensor      = new ManualSensor(ESensorType.Temperature, false);
                        temperatureSensor.name = GetString(Resource.String.name);
                        temperatureSensor.unit = temperatureUnit;
                    }
                    if (!"".Equals(text))
                    {
                        temperatureSensor.measurement = temperatureSensor.unit.OfScalar(double.Parse(text));
                    }
                } catch (System.Exception) {
                }
            });

            temperatureAddView.SetOnClickListener(new ViewClickAction((view) => {
                if (!isTemperatureLocked)
                {
                    new GaugeDeviceSensorSelectDialog(this, ion, ESensorType.Temperature, (sensor) => {
                        temperatureSensor = sensor;
                    }).Show();
                }
            }));

            temperatureAddView.SetOnLongClickListener(new ViewLongClickAction((view) => {
                if (!isTemperatureLocked)
                {
                    temperatureSensor = null;
                }
            }));

            temperatureClearView.SetOnClickListener(new ViewClickAction((view) => {
                SetTemperatureInputQuietly("");
            }));

            temperatureUnitView.Text = temperatureUnit.ToString();
            temperatureUnitView.SetOnClickListener(new ViewClickAction((v) => {
                var units = temperatureSensor != null ? temperatureSensor.supportedUnits : SensorUtils.DEFAULT_TEMPERATURE_UNITS;
                UnitDialog.Create(this, units, (obj, unit) => {
                    temperatureUnit = unit;
                    temperatureEntryView.ClearFocus();
                    if (temperatureSensor != null && temperatureSensor.isEditable)
                    {
                        temperatureSensor.unit = unit;
                    }
                }).Show();
            }));
            temperatureEntryView.AddTextChangedListener(temperatureTextWatcher);
        }