public void TestBatteryVoltageWhileStreaming() { if (shimmerDevice.GetFirmwareIdentifier() == ShimmerBluetooth.FW_IDENTIFIER_LOGANDSTREAM) { shimmerDevice.StartStreaming(); Thread.Sleep(5000); shimmerDevice.ReadBattery(); Thread.Sleep(1000); if (shimmerDevice.getBatteryVoltage() < 2 || shimmerDevice.getBatteryVoltage() > 5) { System.Console.WriteLine("Battery Voltage: " + shimmerDevice.getBatteryVoltage()); System.Console.WriteLine("Battery Status: " + shimmerDevice.getBatteryChargingStatus()); Assert.Fail(); } else { System.Console.WriteLine("Battery Voltage: " + shimmerDevice.getBatteryVoltage()); System.Console.WriteLine("Battery Status: " + shimmerDevice.getBatteryChargingStatus()); } shimmerDevice.StopStreaming(); } else { Assert.Fail("This Shimmer Device Firmware version is not supported"); } }
public void TestECG() { 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.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); } }
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; }
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(); } }
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(); } }
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(); } }
private async Task delayedWork() { await Task.Delay(1000); Shimmer.StartStreaming(); }