コード例 #1
0
 public void Dispose()
 {
     if (AccP1 != null)
     {
         AccP1.Dispose();
         AccP1 = null;
     }
     if (BarP1 != null)
     {
         BarP1.Dispose();
         BarP1 = null;
     }
     if (AccP2 != null)
     {
         AccP2.Dispose();
         AccP2 = null;
     }
     if (BarP2 != null)
     {
         BarP2.Dispose();
         BarP2 = null;
     }
     if (SensePoll != null)
     {
         SensePoll.Cancel();
         SensePoll = null;
     }
 }
コード例 #2
0
        private SensorManager(DeviceInformation i2cBus)
        {
            currTest = null;
            AccP1    = null;
            BarP1    = null;
            AccP2    = null;
            BarP2    = null;

            CurrPeep1 = 0;
            CurrPeep2 = 0;

            NextPeep1 = float.MaxValue;
            NextPeep2 = float.MaxValue;

            InhaleExhale = true;
            LastChange1  = -1;
            LastChange2  = -1;
            PrevVolume1  = 0;
            PrevVolume2  = 0;

            VolDeriv1 = 0;
            VolDeriv2 = 0;

            MaxVol1 = 0;
            MaxVol2 = 0;
            MinVol1 = 0;
            MinVol2 = 0;

            CurrMaxVol1 = float.MinValue;
            CurrMaxVol2 = float.MinValue;
            CurrMinVol1 = float.MaxValue;
            CurrMinVol2 = float.MaxValue;

            LastDiff1 = 1;
            LastDiff2 = 1;

            PollCounter = 0;

            NextValueBecomesCurrValue = (int)(30 / (1 / SensorConstants.ACCEL_POLL_FREQ));

            try
            {
                AccP1 = new Accelerometer(i2cBus, Enums.Patient.A);
            } catch (Exception e)
            {
                Debug.WriteLine("Could not create accelerometer instance");
                Debug.WriteLine(e);
            }

            try
            {
                AccP2 = new Accelerometer(i2cBus, Enums.Patient.B);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Could not create accelerometer instance");
                Debug.WriteLine(e);
            }

            try
            {
                BarP1 = new Barometer(i2cBus, Enums.Patient.A);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Could not create accelerometer instance");
                Debug.WriteLine(e);
            }

            try
            {
                BarP2 = new Barometer(i2cBus, Enums.Patient.B);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Could not create accelerometer instance");
                Debug.WriteLine(e);
            }

            SensePoll = ThreadPoolTimer.CreatePeriodicTimer(PollSensors,
                                                            new TimeSpan(0, 0, 0, 0, (int)(1000 * 1 / SensorConstants.ACCEL_POLL_FREQ)));

            AngleToVolumeConversion = 0.5F / 90; // Calculate later
        }