private void AddSensorToWorkbench(GaugeDeviceSensor sensor) { if (ion.currentWorkbench.ContainsDevice(this.device)) { Toast(GetString(Resource.String.workbench_error_already_contains_sensor)); } else { var device = sensor.device; var deviceType = device.serialNumber.deviceModel; if (deviceType == EDeviceModel.PT500 || deviceType == EDeviceModel.PT800) { /// TODO make fixed add temp to workbench var manifold = new Manifold(device.sensors[0], device.sensors[1]); manifold.AddSensorProperty(new SecondarySensorProperty(manifold)); manifold.AddSensorProperty(new SuperheatSubcoolSensorProperty(manifold)); ion.currentWorkbench.Add(manifold); Toast(GetString(Resource.String.workbench_added_sensor)); } else { var manifold = new Manifold(sensor); if (deviceType == EDeviceModel.AV760) { manifold.AddSensorProperty(new RateOfChangeSensorProperty(manifold, ion.preferences.device.trendInterval)); } ion.currentWorkbench.AddSensor(sensor); Toast(GetString(Resource.String.workbench_added_sensor)); } Activity.Finish(); } }
/// <summary> /// Attempts to add all of the subviews to the manifold, as long as they aren't already present. /// </summary> private void AddAllSubviews(Manifold manifold) { if (!manifold.HasSensorPropertyOfType(typeof(AlternateUnitSensorProperty))) { manifold.AddSensorProperty(new AlternateUnitSensorProperty(manifold)); } if (!manifold.HasSensorPropertyOfType(typeof(RateOfChangeSensorProperty))) { manifold.AddSensorProperty(new RateOfChangeSensorProperty(manifold, ion.preferences.device.trendInterval)); } if (!manifold.HasSensorPropertyOfType(typeof(MinSensorProperty))) { manifold.AddSensorProperty(new MinSensorProperty(manifold)); } if (!manifold.HasSensorPropertyOfType(typeof(MaxSensorProperty))) { manifold.AddSensorProperty(new MaxSensorProperty(manifold)); } if (!manifold.HasSensorPropertyOfType(typeof(HoldSensorProperty))) { manifold.AddSensorProperty(new HoldSensorProperty(manifold)); } if (!manifold.HasSensorPropertyOfType(typeof(TimerSensorProperty))) { manifold.AddSensorProperty(new TimerSensorProperty(manifold)); } if (ESensorType.Pressure == manifold.primarySensor.type || ESensorType.Temperature == manifold.primarySensor.type) { if (!manifold.HasSensorPropertyOfType(typeof(PTChartSensorProperty))) { manifold.AddSensorProperty(new PTChartSensorProperty(manifold)); } if (!manifold.HasSensorPropertyOfType(typeof(SuperheatSubcoolSensorProperty))) { manifold.AddSensorProperty(new SuperheatSubcoolSensorProperty(manifold)); } } }
/// <summary> /// Shows the add subview dialog. /// </summary> /// <param name="manifold">Manifold.</param> private void ShowAddSubviewDialog(Manifold manifold) { Func <int, int, string> format = delegate(int full, int abrv) { return(GetString(full) + " (" + GetString(abrv) + ")"); }; var ldb = new ListDialogBuilder(Activity); ldb.SetTitle(GetString(Resource.String.manifold_add_subview)); if (manifold.secondarySensor != null) { if (!manifold.HasSensorPropertyOfType(typeof(SecondarySensorProperty))) { var t = manifold.secondarySensor.type; var type = t.GetTypeString(); var abrv = t.GetTypeAbreviationString(); ldb.AddItem(String.Format(GetString(Resource.String.workbench_linked_sensor_2sarg), type, abrv), () => { manifold.AddSensorProperty(new SecondarySensorProperty(manifold)); }); } } if (!manifold.HasSensorPropertyOfType(typeof(AlternateUnitSensorProperty))) { ldb.AddItem(format(Resource.String.workbench_alt, Resource.String.workbench_alt_abrv), () => { manifold.AddSensorProperty(new AlternateUnitSensorProperty(manifold)); }); } if (!(manifold.primarySensor is ManualSensor) && !manifold.HasSensorPropertyOfType(typeof(RateOfChangeSensorProperty))) { ldb.AddItem(format(Resource.String.workbench_roc, Resource.String.workbench_roc_abrv), () => { manifold.AddSensorProperty(new RateOfChangeSensorProperty(manifold, ion.preferences.device.trendInterval)); }); } if (!manifold.HasSensorPropertyOfType(typeof(MinSensorProperty))) { ldb.AddItem(format(Resource.String.workbench_min, Resource.String.workbench_min_abrv), () => { manifold.AddSensorProperty(new MinSensorProperty(manifold)); }); } if (!manifold.HasSensorPropertyOfType(typeof(MaxSensorProperty))) { ldb.AddItem(format(Resource.String.workbench_max, Resource.String.workbench_max_abrv), () => { manifold.AddSensorProperty(new MaxSensorProperty(manifold)); }); } if (!manifold.HasSensorPropertyOfType(typeof(HoldSensorProperty))) { ldb.AddItem(format(Resource.String.workbench_hold, Resource.String.workbench_hold_abrv), () => { manifold.AddSensorProperty(new HoldSensorProperty(manifold)); }); } if (!manifold.HasSensorPropertyOfType(typeof(TimerSensorProperty))) { ldb.AddItem(format(Resource.String.workbench_timer, Resource.String.workbench_timer_abrv), () => { manifold.AddSensorProperty(new TimerSensorProperty(manifold)); }); } if (ESensorType.Pressure == manifold.primarySensor.type || ESensorType.Temperature == manifold.primarySensor.type) { if (!manifold.HasSensorPropertyOfType(typeof(PTChartSensorProperty))) { ldb.AddItem(format(Resource.String.workbench_ptchart, Resource.String.fluid_pt_abrv), () => { manifold.AddSensorProperty(new PTChartSensorProperty(manifold)); }); } if (!manifold.HasSensorPropertyOfType(typeof(SuperheatSubcoolSensorProperty))) { ldb.AddItem(format(Resource.String.workbench_shsc, Resource.String.workbench_shsc_abrv), () => { manifold.AddSensorProperty(new SuperheatSubcoolSensorProperty(manifold)); }); } } ldb.AddItem(Resource.String.workbench_add_all, () => { AddAllSubviews(manifold); }); ldb.Show(); }