Beispiel #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();
                }
            }
        }