コード例 #1
0
        public void Bind(IION ion, GaugeDeviceSensor gds)
        {
            this.ion    = ion;
            this.sensor = gds;

            Invalidate();
        }
コード例 #2
0
 public RequestCalibrationCertificates(IION ion, params ISerialNumber[] serialNumbers)
 {
     Log.D(this, GENERAL_OBFUSCATION_KEY.ToByteString());
     this.ion           = ion;
     this.serialNumbers = serialNumbers;
     tokenSource        = new CancellationTokenSource();
 }
コード例 #3
0
            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);
            }
コード例 #4
0
 /// <summary>
 /// Creates a new manual sensor within this device. The sensor will last until explicitly destroyed.
 /// </summary>
 /// <param name="ion"></param>
 /// <param name="sensorType"></param>
 /// <returns></returns>
 public ManualSensor CreateNewSensor(IION ion, ESensorType sensorType, bool isRelative = true)
 {
     //var u = ion.preferences.units.DefaultUnitFor(sensorType);
     //var ret = new ManualSensor(this, sensorType, u.OfScalar(0), isRelative);
     //return ret;
     return(null);
 }
コード例 #5
0
        public sensor(CGRect sensorRect, string identifier, UIView mainView)
        {
            ion      = AppState.context;
            snapArea = new UIView(sensorRect)
            {
                AccessibilityIdentifier = identifier,
            };
            snapArea.ClipsToBounds = true;

            availableView = new UIView(new CGRect(0, 0, snapArea.Bounds.Width, snapArea.Bounds.Height))
            {
                BackgroundColor         = UIColor.FromRGB(204, 153, 0),
                Alpha                   = .4f,
                UserInteractionEnabled  = true,
                AccessibilityIdentifier = identifier,
                Hidden                  = false,
            };


            addIcon                          = new UIImageView(new CGRect(.107 * snapArea.Bounds.Width, .107 * snapArea.Bounds.Height, .786 * snapArea.Bounds.Width, .786 * snapArea.Bounds.Height));
            addIcon.Image                    = UIImage.FromBundle("ic_device_add");
            addIcon.BackgroundColor          = UIColor.Clear;
            snapArea.Layer.CornerRadius      = 5;
            availableView.Layer.CornerRadius = 5;
            snapArea.Layer.BorderColor       = UIColor.Black.CGColor;
            snapArea.Layer.BorderWidth       = 2f;
            snapArea.AddSubview(availableView);
            snapArea.AddSubview(addIcon);
            snapArea.BringSubviewToFront(addIcon);

            mainView.AddSubview(snapArea);

            topLabel.ViewForBaselineLayout.Frame = new CoreGraphics.CGRect(0, 0, .99 * snapArea.Frame.Size.Width, .307 * snapArea.Frame.Size.Height);
            topLabel.AdjustsFontSizeToFitWidth   = true;
            topLabel.Text          = " Press " + snapArea.AccessibilityIdentifier;
            topLabel.Hidden        = true;
            topLabel.ClipsToBounds = true;
            topLabel.TextColor     = UIColor.Gray;
            topLabel.TextAlignment = UITextAlignment.Center;

            middleLabel.ViewForBaselineLayout.Frame = new CoreGraphics.CGRect(0, .261 * snapArea.Bounds.Height, .984 * snapArea.Frame.Size.Width, .461 * snapArea.Frame.Size.Height);
            middleLabel.AdjustsFontSizeToFitWidth   = true;
            middleLabel.Text          = "0.00 ";
            middleLabel.Hidden        = true;
            middleLabel.TextAlignment = UITextAlignment.Right;
            middleLabel.Font          = UIFont.BoldSystemFontOfSize(20);

            bottomLabel.ViewForBaselineLayout.Frame = new CoreGraphics.CGRect(0, .676 * snapArea.Bounds.Height, .99 * snapArea.Frame.Size.Width, .3 * snapArea.Frame.Size.Height);
            bottomLabel.AdjustsFontSizeToFitWidth   = true;
            bottomLabel.Text          = "";
            bottomLabel.Hidden        = true;
            bottomLabel.ClipsToBounds = true;
            bottomLabel.TextAlignment = UITextAlignment.Center;
            bottomLabel.TextColor     = UIColor.Gray;

            snapArea.AddSubview(topLabel);
            snapArea.AddSubview(middleLabel);
            snapArea.AddSubview(bottomLabel);
            snapArea.BringSubviewToFront(topLabel);
        }
コード例 #6
0
        /// <summary>
        /// Updates the device table cell to the given device.
        /// </summary>
        /// <param name="device">Device.</param>
        public void UpdateTo(IION ion, DeviceRecord record, double cellWidth)
        {
            this.ion               = ion;
            this.record            = record;
            this.BackgroundColor   = UIColor.White;
            this.Layer.BorderWidth = 1f;

            var cellHeight = 48;

            viewBackground = new UIView(new CGRect(0, 0, cellWidth, cellHeight));
            viewBackground.BackgroundColor = UIColor.White;

            buttonConnect = new UIButton(new CGRect(cellWidth - cellHeight, 0, cellHeight, cellHeight));
            buttonConnect.SetBackgroundImage(UIImage.FromBundle("ButtonGold").AsNinePatch(), UIControlState.Normal);
            buttonConnect.SetBackgroundImage(UIImage.FromBundle("ButtonBlack").AsNinePatch(), UIControlState.Selected);

            imageDeviceIcon = new UIImageView(new CGRect(0, 0, cellHeight, cellHeight));

            labelDeviceType = new UILabel(new CGRect(cellHeight, 0, cellWidth - cellHeight, .5 * cellHeight));
            labelDeviceName = new UILabel(new CGRect(cellHeight, .5 * cellHeight, cellWidth - cellHeight, .5 * cellHeight));

            viewBackground.AddSubview(buttonConnect);
            viewBackground.AddSubview(imageDeviceIcon);
            viewBackground.AddSubview(labelDeviceName);
            viewBackground.AddSubview(labelDeviceType);
            this.AddSubview(viewBackground);

            UpdateLabels();
            UpdateActivityViews();
        }
コード例 #7
0
        // Overridden from ManifoldParser
        //public override void DoWriteManifold(IION ion, Manifold manifold, BinaryWriter writer){
        public override void DoWriteManifold(IION ion, Sensor sensor, BinaryWriter writer)
        {
            // Write primary sensor
            //SensorParser.WriteSensor(ion, manifold.primarySensor, writer);
            SensorParser.WriteSensor(ion, sensor, writer);
            // Write secondary sensor
            //SensorParser.WriteSensor(ion, manifold.secondarySensor, writer);
            SensorParser.WriteSensor(ion, sensor.linkedSensor, writer);

            // Write fluid name
            //if (sensor.ptChart == null) {
            //	writer.Write(false); // Doens't have a pt chart.
            //} else {
            //	writer.Write(true); // Does have a pt chart
            //	writer.Write(Enum.GetName(typeof(Fluid.EState), sensor.fluidState));
            //	if (ion.fluidManager.lastUsedFluid == null) {
            //		writer.Write("");
            //	} else {
            //		writer.Write(ion.fluidManager.lastUsedFluid.name);
            //	}
            //}

            // The number of sensor properties that the manifold ha
            //writer.Write(manifold.sensorProperties.Count);
            writer.Write(sensor.sensorProperties.Count);
            // Write sensor properties
            //foreach (var sp in manifold.sensorProperties)	{
            foreach (var sp in sensor.sensorProperties)
            {
                WriteSensorProperty(sp, writer);
            }
        }
コード例 #8
0
 public LoggingSessionSource(List <SessionData> allSessions, nfloat height, ObservableCollection <int> selectedSessions)
 {
     tableItems    = allSessions;
     cellHeight    = height;
     usingSessions = selectedSessions;
     ion           = AppState.context;
 }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetStyle(DialogFragmentStyle.NoFrame, Resource.Style.ComplicatedDialogTheme);

            ion = AppState.context;
        }
コード例 #10
0
        /// <summary>
        /// Creates an IDevice from this device definition.
        /// </summary>
        /// <returns>The device.</returns>
        /// <exception cref="ArgumentException">If the IDevice could not be created with the given arguments.</exception>
        /// <param name="serialNumber">Serial number.</param>
        /// <param name="connection">Connection.</param>
        /// <param name="protocol">Protocol.</param>
        public IDevice CreateDevice(IION ion, ISerialNumber serialNumber, IConnection connection, IProtocol protocol)
        {
            if (!(serialNumber is GaugeSerialNumber))
            {
                /////should not throw exeptions
                //throw new ArgumentException("Cannot create device: expected GaugeSerialNumber, received: " + serialNumber.GetType().Name);
                return(null);
            }

            if (!(protocol is IGaugeProtocol))
            {
                /////should not throw exeptions
                //throw new ArgumentException("Cannot create device: expected an IGaugeProtocol, received: " + protocol.GetType().Name);
                return(null);
            }

            var ret = new GaugeDevice(serialNumber as GaugeSerialNumber, connection, protocol as IGaugeProtocol);
            var s   = new List <GaugeDeviceSensor>();

            int i = 0;

            foreach (var sensorDefinition in sensorDefinitions)
            {
                var sensor = new GaugeDeviceSensor(ion, ret, i++, sensorDefinition.sensorType, sensorDefinition.isRelative);
                sensor.removable      = sensorDefinition.isRemovable;
                sensor.minMeasurement = sensorDefinition.minimumMeasurement;
                sensor.maxMeasurement = sensorDefinition.maximumMeasurement;
                sensor.SetSupportedUnits(sensorDefinition.supportedUnits.ToArray());
                s.Add(sensor);
            }

            ret.sensors = s.ToArray();

            return(ret);
        }
コード例 #11
0
 public GaugeDeviceSensor(IION ion, GaugeDevice device, int index, ESensorType sensorType, bool relative = true)
     : base(sensorType, ion.preferences.units.DefaultUnitFor(sensorType).OfScalar(0.0), relative)
 {
     this.device = device;
     this.index  = index;
     this.name   = device.name;
 }
コード例 #12
0
        /// <summary>
        /// Creates a new DateIndexLookup built around the given sessionIds.
        /// </summary>
        /// <returns>The from sessions async.</returns>
        /// <param name="sessionIds">Session identifiers.</param>
        public static Task <DateIndexLookup> CreateFromSessionsAsync(IION ion, IEnumerable <int> sessionIds)
        {
            return(Task.Factory.StartNew(() => {
                // Gather all of the dates.
                var dates = new HashSet <DateTime>();
                foreach (var id in sessionIds)
                {
                    var smrQuery = ion.database.Table <SensorMeasurementRow>().Where(x => x.frn_SID == id)
                                   .Select(x => new { x.recordedDate });
                    foreach (var smr in smrQuery)
                    {
                        dates.Add(smr.recordedDate);
                    }
                }

                // Sort the dates.
                var sorted = new List <DateTime>(dates);
                sorted.Sort();

                var ret = new Dictionary <DateTime, int>();

                var i = 0;
                foreach (var dt in sorted)
                {
                    ret[dt] = i++;
                }

                return new DateIndexLookup(ret);
            }));
        }
コード例 #13
0
 public CreatedJobSource(List <int> jobs, SetActiveJob chooseActiveJob, JobViewController managerVC = null)
 {
     jobID            = jobs;
     ion              = AppState.context;
     vc               = managerVC;
     clickedJobActive = chooseActiveJob;
 }
コード例 #14
0
 public DeviceGridAdapter(IION ion, int colSize, AcceptDeviceFilterDelegate filter)
 {
     this.ion     = ion;
     this.colSize = colSize;
     this.filter  = filter;
     dm           = ion.deviceManager;
 }
        public static void Export(IION ion, GaugeDeviceCalibrationCertificate certificate, Stream outStream)
        {
            var pdf = new PdfFixedDocument(EmbeddedResource.Load("digital_gauge_cert.pdf"));

            // Header
            (pdf.Form.Fields[FIELD_CERT_BY] as PdfTextBoxField).Value   = certificate.certifiedBy;
            (pdf.Form.Fields[FIELD_CERT_DATE] as PdfTextBoxField).Value = certificate.lastTestCalibrationDate.ToString("d");
            // Unit Tested
            (pdf.Form.Fields[FIELD_PART_NO] as PdfTextBoxField).Text   = certificate.testPartNumber;
            (pdf.Form.Fields[FIELD_SERIAL_NO] as PdfTextBoxField).Text = certificate.testSerialNumber + "";
            // Calibration Standard
            (pdf.Form.Fields[FIELD_CAL_MODEL] as PdfTextBoxField).Text     = certificate.controlInstrument;
            (pdf.Form.Fields[FIELD_CAL_SERIAL_NO] as PdfTextBoxField).Text = certificate.controlSerial;
//      (pdf.Form.Fields[KEY_CONTROL_TRANSDUCER] as PdfTextBoxField).Text = certificate.controlTransducer;
            (pdf.Form.Fields[FIELD_CAL_ACCURACY] as PdfTextBoxField).Text = certificate.controlAccuracy + "";
            (pdf.Form.Fields[FIELD_CAL_DATE] as PdfTextBoxField).Text     = certificate.lastControlCalibrationDate.ToString("d");
            // Ambient Conditions
            (pdf.Form.Fields[FIELD_AMB_TEMP] as PdfTextBoxField).Text = certificate.environmentTemperature + "";
            (pdf.Form.Fields[FIELD_AMB_RH] as PdfTextBoxField).Text   = certificate.environmentHumidity + "";

            // Performance Data Table
            (pdf.Form.Fields[FIELD_CAL_LIMIT] as PdfTextBoxField).Text = certificate.testAccuracy + "";
            foreach (var pair in TABLE_KEYS)
            {
                var data = certificate.calibrationDataPoints[pair.second];
                for (int i = 0; i < data.Length; i++)
                {
                    (pdf.Form.Fields[pair.first + (i + 1)] as PdfTextBoxField).Text = data[i];
                }
            }

            pdf.Form.FlattenFields();
            pdf.Save(outStream);
        }
コード例 #16
0
            public override void DoWriteSensor(IION ion, Sensor sensor, BinaryWriter writer)
            {
                var type = sensor.FindPersistentType();

                switch (type)
                {
                case EPersistSensorType.GaugeDeviceSensor:
                    // Write the internal type of the sensor
                    writer.Write((int)EPersistSensorType.GaugeDeviceSensor);
                    WriteGaugeDeviceSensor((GaugeDeviceSensor)sensor, writer);
                    break;

                case EPersistSensorType.ManualSensor:
                    // Write the internal type of the sensor
                    writer.Write((int)EPersistSensorType.ManualSensor);
                    WriteManualSensor((ManualSensor)sensor, writer);
                    break;

                case EPersistSensorType.NullSensor:
                    // Write the internal type of the sensor.
                    writer.Write((int)EPersistSensorType.NullSensor);
                    WriteNullSensor(writer);
                    break;

                default:
                    throw new Exception("Failed to write sensor of uknown persistent type: " + type);
                }
            }
コード例 #17
0
        public IOSPlatformInfo(IION ion)
        {
            UIDevice.CurrentDevice.BatteryMonitoringEnabled = true;

            manufacturer = "Apple Inc.";
            deviceName   = UIDevice.CurrentDevice.Model;
            model        = UIDevice.CurrentDevice.LocalizedModel;
            version      = UIDevice.CurrentDevice.SystemVersion;
            api          = UIDevice.CurrentDevice.SystemName;
            chipset      = "N/A";

            NetworkReachabilityFlags flag;

            Reachability.IsAdHocWiFiNetworkAvailable(out flag);

            if (flag == NetworkReachabilityFlags.Reachable)
            {
                wifiConnected = true;
            }
            else
            {
                wifiConnected = false;
            }

            batteryPercentage = (int)(UIDevice.CurrentDevice.BatteryLevel * 100);

            int freeSpace = (int)NSFileManager.DefaultManager.GetFileSystemAttributes(Environment.GetFolderPath(Environment.SpecialFolder.Personal)).FreeSize;

            freeMemory    = freeSpace;
            loggingStatus = ion.dataLogManager.isRecording;
        }
コード例 #18
0
        /// <summary>
        /// Updates the device table cell to the given device.
        /// </summary>
        /// <param name="device">Device.</param>
        public void UpdateTo(IION ion, DeviceRecord record)
        {
            this.ion    = ion;
            this.record = record;

            UpdateLabels();
            UpdateActivityViews();
        }
コード例 #19
0
    public RemoteStatus(IION ion) {
      var pi = ion.GetPlatformInformation();

      __isDataLogging = ion.dataLogManager.isRecording ? 1 : 0;
      batteryLevel = pi.batteryPercentage;
      __wifiStatus = pi.wifiConnected ? 1 : 0;
      __remainingMemory = pi.freeMemory;
    }
コード例 #20
0
 public LoggingSession(IION ion, SessionRow session, TimeSpan interval)
 {
     this.ion     = ion;
     this.session = session;
     //timer = new Timer(OnTimerCallback, interval);
     isActive = true;
     recordInterval(interval);
 }
コード例 #21
0
        public IonCBCentralManagerDelegate(IION ion)
        {
            this.ion = ion;
            var options = new CBCentralInitOptions();

            options.ShowPowerAlert = false;

            centralManager = new CBCentralManager(this, new DispatchQueue("ION Bluetooth", true), options);
        }
コード例 #22
0
        public static IDevice CreateDebugDevice(IION ion, EDeviceModel deviceModel)
        {
            var sn = deviceModel.GenerateSerialNumber();

            var factory = ion.deviceManager.deviceFactory;
            var defn    = factory.GetDeviceDefinition(sn);

            return(defn.CreateDevice(ion, sn, new DebugConnection(sn.ToString(), "DebugAddress_" + sn.batchId), null));
        }
コード例 #23
0
        // Overridden from SensorParcelable
        public override Sensor Get(IION ion)
        {
            var ret = new ManualSensor(sensorType, isRelative);

            ret.name        = name;
            ret.measurement = UnitLookup.GetUnit(unitCode).OfScalar(amount);

            return(ret);
        }
コード例 #24
0
            public Builder(Context context, IION ion, Manifold manifold)
            {
                this.context  = context;
                this.ion      = ion;
                this.manifold = manifold;

                showConnectOptions = true;
                showSubviewOptions = true;
                showAlarmsOptions  = true;
            }
コード例 #25
0
        // Implemented for ISubviewParser
        //public ISensorProperty Read(IION ion, Manifold manifold, BinaryReader reader){
        public ISensorProperty Read(IION ion, Sensor sensor, BinaryReader reader)
        {
            //var ret = new RateOfChangeSensorProperty(manifold, ion.preferences.device.trendInterval);
            var ret = new RateOfChangeSensorProperty(sensor, ion.preferences.device.trendInterval);

            ret.Resize(ion.preferences.device.trendInterval);
            ret.flags = (RateOfChangeSensorProperty.EFlags)reader.ReadInt32();

            return(ret);
        }
コード例 #26
0
 public override Manifold Get(IION ion)
 {
     if (isLow)
     {
         return(ion.currentAnalyzer.lowSideManifold);
     }
     else
     {
         return(ion.currentAnalyzer.highSideManifold);
     }
 }
コード例 #27
0
        public BaseDeviceInfo(IION ion)
        {
            var list = new List <string>();

            foreach (var d in ion.deviceManager.devices)
            {
                list.Add(d.serialNumber.ToString());
            }

            deviceSerials = list.ToArray();
        }
コード例 #28
0
        // Implemented for ISubviewParser
        //public ISensorProperty Read(IION ion, Manifold manifold, BinaryReader reader)	{
        public ISensorProperty Read(IION ion, Sensor sensor, BinaryReader reader)
        {
            //var ret = new AlternateUnitSensorProperty(manifold);
            var ret = new AlternateUnitSensorProperty(sensor);

            var usunit = reader.ReadInt32();

            ret.unit = UnitLookup.GetUnit(usunit);

            return(ret);
        }
コード例 #29
0
        public DetailedGraphRenderer(Context context, IION ion)
        {
            this.context = context;
            this.ion     = ion;
            plot         = new PlotView(context);
            model        = new PlotModel();

            xAxis = new LinearAxis()
            {
                Position                = AxisPosition.Bottom,
                IsAxisVisible           = true,
                IsZoomEnabled           = false,
                IsPanEnabled            = false,
                MinimumPadding          = 3,
                MaximumPadding          = 3,
                AxisTickToLabelDistance = 1,
                AxislineColor           = OxyColors.Black,
                AxislineStyle           = LineStyle.Solid,
                MinorGridlineStyle      = LineStyle.None,
                MajorGridlineStyle      = LineStyle.Solid,
                AxisTitleDistance       = 5,
                TickStyle               = TickStyle.Outside,
                TextColor               = OxyColors.Black,
                FontSize                = 7,
                Angle = 90,
            };

            yAxis = new LinearAxis()
            {
                Position           = AxisPosition.Left,
                IsAxisVisible      = true,
                IsZoomEnabled      = false,
                IsPanEnabled       = false,
                MinimumPadding     = 3,
                MaximumPadding     = 3,
                AxisTitleDistance  = 20,
                AxislineColor      = OxyColors.Black,
                AxislineStyle      = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.None,
                MajorGridlineStyle = LineStyle.Solid,
                TickStyle          = TickStyle.Outside,
                TextColor          = OxyColors.Black,
                FontSize           = 7,
            };

            model.Axes.Add(xAxis);
            model.Axes.Add(yAxis);

            model.Background      = OxyColors.Transparent;
            model.DefaultFontSize = 0;

            plot.Model = model;
        }
コード例 #30
0
        public ReportGraphAdapter(IION ion, DateIndexLookup dil, IEnumerable <SensorDataLogResults> sensorResults, View parent, View leftHandle, View rightHandle)
        {
            this.ion     = ion;
            this.dil     = dil;
            _parent      = parent;
            _leftHandle  = leftHandle;
            _rightHandle = rightHandle;


            foreach (var result in sensorResults)
            {
                records.Add(new ReportGraphRecord(dil, result));
            }

            _leftHandle.Touch += (sender, e) => {
                switch (e.Event.Action)
                {
                case MotionEventActions.Down:
                    _lastLeftX = e.Event.GetX();
                    break;

                case MotionEventActions.Move:
                    var xcoord = _leftHandle.GetX() + (e.Event.GetX() - _lastLeftX);
                    xcoord = xcoord.Clamp(0, _rightHandle.GetX() - _leftHandle.Width);
                    _leftHandle.SetX(xcoord);
                    _leftHandle.Invalidate();
                    NotifyDataSetChanged();
                    leftPercent = (_leftHandle.GetX()) / (float)_parent.Width;
                    NotifyDrag();
                    break;
                }
            };

            _rightHandle.Touch += (sender, e) => {
                switch (e.Event.Action)
                {
                case MotionEventActions.Down:
                    _lastRightX = e.Event.GetX();
                    break;

                case MotionEventActions.Move:
                    var xcoord = _rightHandle.GetX() + (e.Event.GetX() - _lastRightX);
                    xcoord = xcoord.Clamp(_leftHandle.GetX() + _leftHandle.Width, _parent.Width - _rightHandle.Width);
                    _rightHandle.SetX(xcoord);
                    _rightHandle.Invalidate();
                    NotifyDataSetChanged();
                    rightPercent = (_rightHandle.GetX() + _leftHandle.Width) / (float)_parent.Width;
                    NotifyDrag();
                    break;
                }
            };
        }