示例#1
0
 public void EndConnection()
 {
     shimmerDevice.StopStreaming();
     Thread.Sleep(200);
     shimmerDevice.Disconnect();
     Thread.Sleep(1000);
     shimmerDevice = null;
 }
示例#2
0
 public void TestInitialize()
 {
     shimmerDevice = new ShimmerLogAndStreamSystemSerialPort(deviceName, comPort);
     shimmerDevice.Connect();
     while (shimmerDevice.GetState() != ShimmerBluetooth.SHIMMER_STATE_CONNECTED)
     {
         Thread.Sleep(100);
         if (shimmerDevice.GetState() == ShimmerBluetooth.SHIMMER_STATE_NONE)
         {
             Assert.Fail("ConnectionFail");
         }
     }
 }
示例#3
0
 public void InitializeConnection()
 {
     shimmerDevice             = new ShimmerLogAndStreamSystemSerialPort(deviceName, comPort);
     shimmerDevice.UICallback += this.HandleEvent;
     ojc = null;
     ojcArray.Clear();
     shimmerDevice.Connect();
     while (shimmerDevice.GetState() != ShimmerBluetooth.SHIMMER_STATE_CONNECTED)
     {
         Thread.Sleep(100);
         if (shimmerDevice.GetState() == ShimmerBluetooth.SHIMMER_STATE_NONE)
         {
             Assert.Fail();
         }
     }
 }
        public void TestMethodConstructor()
        {
            ShimmerLogAndStreamSystemSerialPort shimmerDevice = new ShimmerLogAndStreamSystemSerialPort("", comport);

            shimmerDevice.UICallback += this.HandleEvent;
            ojcArray.Clear();
            ojc = null;
            shimmerDevice.Connect();
            while (shimmerDevice.GetState() != ShimmerBluetooth.SHIMMER_STATE_CONNECTED)
            {
                Thread.Sleep(100);
                if (shimmerDevice.GetState() == ShimmerBluetooth.SHIMMER_STATE_NONE)
                {
                    Assert.Fail();
                }
            }
            int enabledSensors = ((int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG1_24BIT | (int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG2_24BIT); // this is to enable the two EXG Chips on the Shimmer3

            byte[] defaultECGReg1 = ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG1;                                                                                 //also see ShimmerBluetooth.SHIMMER3_DEFAULT_TEST_REG1 && ShimmerBluetooth.SHIMMER3_DEFAULT_EMG_REG1
            byte[] defaultECGReg2 = ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG2;                                                                                 //also see ShimmerBluetooth.SHIMMER3_DEFAULT_TEST_REG2 && ShimmerBluetooth.SHIMMER3_DEFAULT_EMG_REG2
            shimmerDevice.WriteEXGConfigurations(defaultECGReg1, defaultECGReg2);
            Thread.Sleep(500);
            shimmerDevice.WriteSensors(enabledSensors);
            Thread.Sleep(1000);

            String[] array = shimmerDevice.GetSignalNameArray();
            Assert.AreEqual(array[1], Shimmer3Configuration.SignalNames.EXG1_STATUS);

            shimmerDevice.StartStreaming();
            System.Console.WriteLine("StartStreaming");
            Thread.Sleep(5000);
            if (ojc == null)
            {
                Assert.AreEqual(true, false);
            }
            else
            {
                SensorData data = ojc.GetData(Shimmer3Configuration.SignalNames.ECG_LA_RA, "CAL");
                Assert.AreNotEqual(null, data);
            }
            shimmerDevice.StopStreaming();
            Thread.Sleep(200);
            shimmerDevice.Disconnect();
            Thread.Sleep(1000);
            shimmerDevice = null;
        }
示例#5
0
        public void start()
        {
            //Setup PPG to HR filters and algorithm
            PPGtoHeartRateCalculation = new PPGToHRAlgorithm(SamplingRate, NumberOfHeartBeatsToAverage, TrainingPeriodPPG);
            LPF_PPG = new Filter(Filter.LOW_PASS, SamplingRate, new double[] { LPF_CORNER_FREQ_HZ });
            HPF_PPG = new Filter(Filter.HIGH_PASS, SamplingRate, new double[] { HPF_CORNER_FREQ_HZ });


            int enabledSensors = ((int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_A_ACCEL | (int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_GSR | (int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_INT_A13);

            //int enabledSensors = ((int)Shimmer.SensorBitmapShimmer3.SENSOR_A_ACCEL | (int)Shimmer.SensorBitmapShimmer3.SENSOR_EXG1_24BIT | (int)Shimmer.SensorBitmapShimmer3.SENSOR_EXG2_24BIT);

            //shimmer = new Shimmer("ShimmerID1", "COM17");
            Shimmer = new ShimmerLogAndStreamSystemSerialPort("ShimmerID1", "COM12", SamplingRate, 0, ShimmerBluetooth.GSR_RANGE_AUTO, enabledSensors, false, false, false, 1, 0, Shimmer3Configuration.EXG_EMG_CONFIGURATION_CHIP1, Shimmer3Configuration.EXG_EMG_CONFIGURATION_CHIP2, true);

            Shimmer.UICallback += this.HandleEvent;
            Shimmer.Connect();
        }
示例#6
0
        public void start()
        {
            //There are two main uses of the constructors, first one just connects to the device without setting and specific configurations
            //shimmer = new ShimmerSDBT("ShimmerID1", "COM15");
            int    enabledSensors = ((int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG1_24BIT | (int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG2_24BIT); // this is to enable the two EXG Chips on the Shimmer3
            double samplingRate   = 256;

            ECG_To_HR_and_RR = new ECGToHRAdaptive(SamplingRate);
            //byte[] defaultECGReg1 = new byte[10] { 0x00, 0xA0, 0x10, 0x40, 0x40, 0x2D, 0x00, 0x00, 0x02, 0x03 }; //see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG1
            //byte[] defaultECGReg2 = new byte[10] { 0x00, 0xA0, 0x10, 0x40, 0x47, 0x00, 0x00, 0x00, 0x02, 0x01 }; //see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG2
            byte[] defaultECGReg1 = ShimmerBluetooth.SHIMMER3_DEFAULT_TEST_REG1; //also see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG1 && ShimmerBluetooth.SHIMMER3_DEFAULT_EMG_REG1
            byte[] defaultECGReg2 = ShimmerBluetooth.SHIMMER3_DEFAULT_TEST_REG2; //also see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG2 && ShimmerBluetooth.SHIMMER3_DEFAULT_EMG_REG2
            //The constructor below allows the user to specify the shimmer configurations which is set upon connection to the device
            //shimmer = new ShimmerLogAndStreamSystemSerialPort("ShimmerID1", "COM5", samplingRate, 0, 4, enabledSensors, false, false, false, 0, 0, defaultECGReg1, defaultECGReg2, false);
            shimmer             = new ShimmerLogAndStreamSystemSerialPort("ShimmerID1", "COM5", samplingRate, 0, 4, enabledSensors, true, true, true, 0, 0, defaultECGReg1, defaultECGReg2, false);
            shimmer.UICallback += this.HandleEvent;

            shimmer.Connect();
            if (shimmer.GetState() == ShimmerBluetooth.SHIMMER_STATE_CONNECTED)
            {
                System.Console.WriteLine("EXG CONFIGURATION SET USING SHIMMER CONSTRUCTOR");
                System.Console.WriteLine("EXG CHIP 1 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG1RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\nEXG CHIP 2 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG2RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\n");

                shimmer.WriteSensors(enabledSensors);

                System.Console.WriteLine("IN ABOUT 5 SECONDS STREAMING WILL START AFTER THE BEEP");
                Thread.Sleep(5000);
                System.Console.Beep();

                shimmer.StartStreaming();
            }
        }
示例#7
0
        public void start()
        {
            //There are two main uses of the constructors, first one just connects to the device without setting and specific configurations
            //shimmer = new ShimmerSDBT("ShimmerID1", "COM15");
            int    enabledSensors = ((int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_A_ACCEL); // this is to enable Analog Accel also known as low noise accelerometer
            double samplingRate   = 51.2;

            //byte[] defaultECGReg1 = new byte[10] { 0x00, 0xA0, 0x10, 0x40, 0x40, 0x2D, 0x00, 0x00, 0x02, 0x03 }; //see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG1
            //byte[] defaultECGReg2 = new byte[10] { 0x00, 0xA0, 0x10, 0x40, 0x47, 0x00, 0x00, 0x00, 0x02, 0x01 }; //see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG2
            byte[] defaultECGReg1 = ShimmerBluetooth.SHIMMER3_DEFAULT_TEST_REG1; //also see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG1
            byte[] defaultECGReg2 = ShimmerBluetooth.SHIMMER3_DEFAULT_TEST_REG2; //also see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG2
            //The constructor below allows the user to specify the shimmer configurations which is set upon connection to the device
            shimmer             = new ShimmerLogAndStreamSystemSerialPort("ShimmerID1", "COM12", 1, 0, 4, enabledSensors, false, false, false, 0, 0, defaultECGReg1, defaultECGReg2, false);
            shimmer.UICallback += this.HandleEvent;
            shimmer.Connect();
            if (shimmer.GetState() == ShimmerBluetooth.SHIMMER_STATE_CONNECTED)
            {
                shimmer.WriteSamplingRate(samplingRate);
                shimmer.WriteSensors(enabledSensors);
                shimmer.StartStreaming();
            }
        }
示例#8
0
        public void start()
        {
            System.IO.File.Delete(logLocation + "dataGSR.txt");
            System.IO.File.Delete(logLocation + "stressLevelsLog.txt");
            System.IO.File.Delete(logLocation + "stressLevelsStream.txt");

            initSocket();

            //Setup PPG to HR filters and algorithm
            PPGtoHeartRateCalculation = new PPGToHRAlgorithm(SamplingRate, NumberOfHeartBeatsToAverage, TrainingPeriodPPG);
            LPF_PPG = new Filter(Filter.LOW_PASS, SamplingRate, new double[] { LPF_CORNER_FREQ_HZ });
            HPF_PPG = new Filter(Filter.HIGH_PASS, SamplingRate, new double[] { HPF_CORNER_FREQ_HZ });

            //Init raw data collector
            rawData = new double[kmeansDelay][];

            int enabledSensors = ((int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_GSR | (int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_INT_A13);


            Shimmer = new ShimmerLogAndStreamSystemSerialPort("ShimmerID1", comPort, SamplingRate, 0, ShimmerBluetooth.GSR_RANGE_AUTO, enabledSensors, false, false, false, 1, 0, Shimmer3Configuration.EXG_EMG_CONFIGURATION_CHIP1, Shimmer3Configuration.EXG_EMG_CONFIGURATION_CHIP2, true);

            Shimmer.UICallback += this.HandleEvent;
            Shimmer.Connect();
        }
示例#9
0
        public void start()
        {
            //There are two main uses of the constructors, first one just connects to the device without setting and specific configurations
            //shimmer = new ShimmerSDBT("ShimmerID1", "COM15");
            int    enabledSensors = ((int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG1_24BIT | (int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG2_24BIT); // this is to enable the two EXG Chips on the Shimmer3
            double samplingRate   = 512;

            //byte[] defaultECGReg1 = new byte[10] { 0x00, 0xA0, 0x10, 0x40, 0x40, 0x2D, 0x00, 0x00, 0x02, 0x03 }; //see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG1
            //byte[] defaultECGReg2 = new byte[10] { 0x00, 0xA0, 0x10, 0x40, 0x47, 0x00, 0x00, 0x00, 0x02, 0x01 }; //see ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG2
            byte[] defaultECGReg1 = ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG1; //also see ShimmerBluetooth.SHIMMER3_DEFAULT_TEST_REG1 && ShimmerBluetooth.SHIMMER3_DEFAULT_EMG_REG1
            byte[] defaultECGReg2 = ShimmerBluetooth.SHIMMER3_DEFAULT_ECG_REG2; //also see ShimmerBluetooth.SHIMMER3_DEFAULT_TEST_REG2 && ShimmerBluetooth.SHIMMER3_DEFAULT_EMG_REG2
            //The constructor below allows the user to specify the shimmer configurations which is set upon connection to the device
            shimmer             = new ShimmerLogAndStreamSystemSerialPort("ShimmerID1", "COM169", samplingRate, 0, 4, enabledSensors, false, false, false, 0, 0, defaultECGReg1, defaultECGReg2, false);
            shimmer.UICallback += this.HandleEvent;
            shimmer.Connect();
            if (shimmer.GetState() == ShimmerBluetooth.SHIMMER_STATE_CONNECTED)
            {
                System.Console.WriteLine("\n");
                System.Console.WriteLine("EXG CONFIGURATION SET USING SHIMMER CONSTRUCTOR");
                System.Console.WriteLine("EXG CHIP 1 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG1RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\nEXG CHIP 2 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG2RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\n");

                //Note the data rate of the EXG chips (exgrate) is automatically set via writesamplingrate(). For a sampling rate of 512Hz, the exgrate is set to 0x03, which corresponds to 1000 SPS.
                //The exgrate can be set to a different settting afterwards, e.g. to 2000 SPS:
                shimmer.WriteEXGRate(4);

                //The gain of the EXG chips is also configurable. The default gain = 4 (0x04). Now the gain is set to 0x05, which corresponds to a gain of 8:
                shimmer.WriteEXGGain(5);

                shimmer.ReadEXGConfigurations(1);
                shimmer.ReadEXGConfigurations(2);
                System.Console.WriteLine("EXG CONFIGURATION AFTER MANUALLY SETTING THE VALUES (RATE and GAIN)");
                System.Console.WriteLine("EXG CHIP 1 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG1RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\nEXG CHIP 2 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG2RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\n");

                //Example code for changing the ecg resolution from 24bit to 16bit - to limit the amount of data transmitted over the Bluetooth link
                enabledSensors = ((int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG1_16BIT | (int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG2_16BIT); // this is to enable the two EXG Chips on the Shimmer3 at 16 bit resolution
                shimmer.WriteSensors(enabledSensors);

                //Example code for changing the ecg resolution back to 24bit - recommended
                enabledSensors = ((int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG1_24BIT | (int)ShimmerBluetooth.SensorBitmapShimmer3.SENSOR_EXG2_24BIT); // this is to enable the two EXG Chips on the Shimmer3 at 24 bit resolution
                shimmer.WriteSensors(enabledSensors);

                //Example code for setting the default ecg settings again (exggain = 4, exgrate >= sampling rate)
                //First write the default register settings for both EXG chips
                shimmer.WriteEXGConfigurations(defaultECGReg1, defaultECGReg2);
                shimmer.ReadEXGConfigurations(1);
                shimmer.ReadEXGConfigurations(2);
                System.Console.WriteLine("SET DEFAULT ECG CONFIGURATIONS AGAIN");
                System.Console.WriteLine("EXG CHIP 1 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG1RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\nEXG CHIP 2 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG2RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\n");
                //Second write the exgrate via writesamplingrate() this time
                shimmer.WriteSamplingRate(512);
                shimmer.ReadEXGConfigurations(1);
                shimmer.ReadEXGConfigurations(2);
                System.Console.WriteLine("SET ECG DATA RATE AUTOMATICALLY BY CHANGING THE SAMPLING RATE OF THE SHIMMER");
                System.Console.WriteLine("EXG CHIP 1 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG1RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\nEXG CHIP 2 CONFIGURATION");
                for (int i = 0; i < 10; i++)
                {
                    System.Console.Write(shimmer.GetEXG2RegisterContents()[i] + " ");
                }
                System.Console.WriteLine("\n");

                System.Console.WriteLine("IN ABOUT 5 SECONDS STREAMING WILL START AFTER THE BEEP");
                Thread.Sleep(5000);
                System.Console.Beep();

                shimmer.StartStreaming();
            }
        }
示例#10
0
 public void TestMethodDeviceName()
 {
     shimmerDevice = new ShimmerLogAndStreamSystemSerialPort(deviceName, comPort);
     Assert.AreEqual(deviceName, shimmerDevice.GetDeviceName());
 }
示例#11
0
 public void Finish()
 {
     shimmerDevice.Disconnect();
     Thread.Sleep(1000);
     shimmerDevice = null;
 }