示例#1
0
        public void TestMethodEXGSaw()
        {
            if (shimmerDevice.GetFirmwareIdentifier() == ShimmerBluetooth.FW_IDENTIFIER_SHIMMERECGMD)
            {
                double freq = 51.2;
                double samplingperiodinms = (1 / freq) * 1000;
                shimmerDevice.WriteSamplingRate(51.2);
                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
                shimmerDevice.WriteSensors(enabledSensors);
                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(1000);

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

                shimmerDevice.StartStreamingEXGSawtoothTestSignal(5000);
                Thread.Sleep(5000);
                if (ojc == null)
                {
                    Assert.Fail();
                }
                else
                {
                    SensorData data = ojc.GetData(Shimmer3Configuration.SignalNames.ECG_LA_RA, SignalFormats.CAL);
                    Assert.AreNotEqual(null, data);
                    data = ojc.GetData(Shimmer3Configuration.SignalNames.ECG_LL_RA, SignalFormats.CAL);
                    Assert.AreNotEqual(null, data);
                    data = ojc.GetData(Shimmer3Configuration.SignalNames.ECG_VX_RL, SignalFormats.CAL);
                    Assert.AreNotEqual(null, data);
                }

                if (ojcArray.Count > 2)
                {
                    SensorData data1           = ((ObjectCluster)ojcArray[0]).GetData(Shimmer3Configuration.SignalNames.ECG_LA_RA, SignalFormats.RAW);
                    SensorData data2           = ((ObjectCluster)ojcArray[1]).GetData(Shimmer3Configuration.SignalNames.ECG_LA_RA, SignalFormats.RAW);
                    SensorData datats1         = ((ObjectCluster)ojcArray[0]).GetData(ShimmerConfiguration.SignalNames.TIMESTAMP, SignalFormats.CAL);
                    SensorData datats2         = ((ObjectCluster)ojcArray[1]).GetData(ShimmerConfiguration.SignalNames.TIMESTAMP, SignalFormats.CAL);
                    double     numberofsamples = Math.Round((datats2.Data - datats1.Data) / samplingperiodinms);
                    double     difference      = data2.Data - data1.Data;
                    if (difference == 5000 * numberofsamples)
                    {
                        System.Console.WriteLine(difference + " " + numberofsamples);
                    }
                    else
                    {
                        Assert.Fail();
                    }
                }
                else
                {
                    Assert.Fail();
                }
            }
        }
示例#2
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();
            }
        }
示例#3
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();
            }
        }