Exemple #1
0
            // Overridden from ISensorModel
            public Sensor ToSensor(IION ion)
            {
                var sensorType = (ESensorType)Enum.Parse(typeof(ESensorType), type);
                //var ret = new ManualSensor(sensorType, AppState.context.preferences.units.DefaultUnitFor(sensorType).OfScalar(0.0), isRelative);
                var ret = new ManualSensor(ion.manualSensorContainer, sensorType, AppState.context.preferences.units.DefaultUnitFor(sensorType).OfScalar(0.0), isRelative);

                ret.name = name;
                ret.SetMeasurement(UnitLookup.GetUnit(unit).OfScalar(measurement));

                if (hasMinMeasurement)
                {
                    ret.minMeasurement = UnitLookup.GetUnit(minUnit).OfScalar(minMeasurement);
                }

                if (hasMaxMeasurement)
                {
                    ret.maxMeasurement = UnitLookup.GetUnit(maxUnit).OfScalar(maxMeasurement);
                }

                return(ret);
            }
Exemple #2
0
        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);
        }
Exemple #3
0
        //private void ReadSensorProperty(IION ion, Manifold manifold, BinaryReader reader)	{
        private void ReadSensorProperty(IION ion, Sensor sensor, BinaryReader reader)
        {
            var name = reader.ReadString();

            if (name != null)
            {
                if (name.Equals(typeof(MinSensorProperty).Name))
                {
                    //manifold.AddSensorProperty(new MinSensorProperty(manifold));
                    sensor.AddSensorProperty(new MinSensorProperty(sensor));
                }
                else if (name.Equals(typeof(MaxSensorProperty).Name))
                {
                    //manifold.AddSensorProperty(new MaxSensorProperty(manifold));
                    sensor.AddSensorProperty(new MaxSensorProperty(sensor));
                }
                else if (name.Equals(typeof(PTChartSensorProperty).Name))
                {
                    //manifold.AddSensorProperty(new PTChartSensorProperty(manifold));
                    sensor.AddSensorProperty(new PTChartSensorProperty(sensor));
                }
                else if (name.Equals(typeof(RateOfChangeSensorProperty).Name))
                {
                    //manifold.AddSensorProperty(new RateOfChangeSensorProperty(manifold, ion.preferences.device.trendInterval));
                    sensor.AddSensorProperty(new RateOfChangeSensorProperty(sensor, ion.preferences.device.trendInterval));
                }
                else if (name.Equals(typeof(SecondarySensorProperty).Name))
                {
                    //manifold.AddSensorProperty(new SecondarySensorProperty(manifold));
                    sensor.AddSensorProperty(new SecondarySensorProperty(sensor));
                }
                else if (name.Equals(typeof(SuperheatSubcoolSensorProperty).Name))
                {
                    //manifold.AddSensorProperty(new SuperheatSubcoolSensorProperty(manifold));
                    sensor.AddSensorProperty(new SuperheatSubcoolSensorProperty(sensor));
                }
                else if (name.Equals(typeof(TimerSensorProperty).Name))
                {
                    //manifold.AddSensorProperty(new TimerSensorProperty(manifold));
                    sensor.AddSensorProperty(new TimerSensorProperty(sensor));
                }
                else if (name.Equals(typeof(HoldSensorProperty).Name))
                {
                    //manifold.AddSensorProperty(new HoldSensorProperty(manifold));
                    sensor.AddSensorProperty(new HoldSensorProperty(sensor));
                }
                else if (name.Equals(typeof(AlternateUnitSensorProperty).Name))
                {
                    var sp = new AlternateUnitSensorProperty(sensor);
                    //manifold.AddSensorProperty(sp);
                    sensor.AddSensorProperty(sp);
                    var usunit = reader.ReadInt32();
                    sp.unit = UnitLookup.GetUnit(usunit);
                }
                else
                {
                    Log.E(this, "Name for sensor property doesn't match an ISensorProperty");
                }
            }
            else
            {
                Log.E(this, "Couldn't read the name from the binary file for the sensor property");
            }
        }