public void GetFrequencyTest() { Frequency freq; try { freq = Frequency.GetFrequency("data/invalid"); Assert.Fail("ArgumentException should have been thrown."); } catch (ArgumentException) { } try { freq = Frequency.GetFrequency("inexistent file"); Assert.Fail("ArgumentException should have been thrown."); } catch (ArgumentException) { } freq = Frequency.GetFrequency("data/100s"); Assert.IsTrue(freq == 360); Wfdb.Quit(); }
public void GetSignalsNoInputFileTest() { try { Signal.GetSignals(null); Assert.Fail("ArgumentNullException should have been thrown."); } catch (ArgumentNullException) { } try { Signal.GetSignals(string.Empty); Assert.Fail("ArgumentNullException should have been thrown."); } catch (ArgumentNullException) { } try { Signal.GetSignals("some inexistent file"); Assert.Fail("ArgumentNullException should have been thrown."); } catch (ArgumentNullException) { } Wfdb.Quit(); }
public void GetSignalsCountTestValidDataTest() { var count = Signal.GetSignalsCount("data/100s"); Assert.AreEqual(2, count); Wfdb.Quit(); }
public void DescriptionTest() { var s = new Signal(); s.Description = null; var validDescription = string.Empty; var random = new Random(1); for (int i = 0; i < Signal.MaxDescriptionLength; i++) { validDescription += (char)random.Next(1, 255); } try { s.Description = validDescription; } catch (Exception) { Assert.Fail("Exception should not have been thrown."); } var invalidDescription = validDescription + (char)random.Next(1, 255); try { s.Description = invalidDescription; Assert.Fail("ArgumentException should have been thrown."); } catch (ArgumentException) { } Wfdb.Quit(); }
private static void UsingSignal() { Console.WriteLine("pgain Using Signal Class"); var signals = Signal.GetSignals("data/100s"); int counter = 0; foreach (var signal in signals) { Console.WriteLine("Signal {0} gain = {1}", counter, signal.Gain); counter++; } Wfdb.Quit(); }
private static void UsingWrapperClasses2() { Console.WriteLine("exgetvec Using Wrapper Signal class"); using (var record = new Record("data/100s")) { record.Open(); var samples1 = record.Signals[0].ReadNext(10); var samples2 = record.Signals[1].ReadNext(10); for (int i = 0; i < 10; i++) { Console.WriteLine("{0}\t{1}", samples1[i], samples2[i]); } } Wfdb.Quit(); }
private static void UsingWrapperClasses3() { Console.WriteLine("exgetvec Using Wrapper Signal class and Signal.Seek Method"); using (var record = new Record("data/100s")) { record.Open(); var samples1 = record.Signals[0].ReadNext(10); record.Signals[1].Seek(10); // moving the reading pointer of the second signal by ten positions var samples2 = record.Signals[1].ReadNext(10); for (int i = 0; i < 10; i++) { Console.WriteLine("{0}\t{1}", samples1[i], samples2[i]); } } Wfdb.Quit(); }
private static void UsingWrapperClasses1() { Console.WriteLine("exgetvec Using Wrapper Record Class"); using (var record = new Record("data/100s")) { record.Open(); var samples = record.GetSamples(10); foreach (var s in samples) { for (int i = 0; i < s.Length; i++) { Console.Write(string.Format("{0}\t", s[i])); } Console.WriteLine(); } } Wfdb.Quit(); }
public void TestFixtureTearDown() { Wfdb.Quit(); }
private void btnStart_Click(object sender, EventArgs e) { string inword; int cnt = 0; int totCnt = 0; int sendCnt = 0; int readCnt = 0; int iteration = 0; btnStart.Enabled = false; btnStop.Enabled = true; ////using (var record = new Record("c:\\users\\Al\\Dropbox\\Medical Projects\\ECG Simulator\\EcgSim\\EcgSim\\data\\100s")) using (var record = new Record("data/aami-ec13/aami3a")) //using (var record = new Record(txtFile.Text.Substring(2, txtFile.Text.Length - 6))) { record.Open(); //next line added by Al as test Frequency.InputFrequency = 125; var samples = record.GetSamples(1000); int loop = 0; int val; string outword; // serOut.BaudRate = 38400; serOut.BaudRate = 115200; serOut.Open(); Console.Write("Ser wBuf Size "); Console.WriteLine(serOut.WriteBufferSize); Console.Write("Ser rBuf Size "); Console.WriteLine(serOut.ReadBufferSize); Console.WriteLine("Iteration " + iteration); while (iteration++ < 100) { foreach (var s in samples) { for (int i = 0; i < s.Length; i++) { loop++; // Console.WriteLine(loop); //Console.Write(s[i].ToString()); //Console.Write(string.Format("D{0000}\t", s[i])); //real val = s[i]; // real //if ((loop == 1) || (loop == 1000)) // Console.WriteLine("BorE " + s[i]); val = (s[i] - 1950) * 10; if (val > 4096) { val = 4096; } if (val < 0) { val = 0; } // val = loop; outword = "D" + val.ToString("0000"); serOut.Write(outword); // Console.WriteLine(outword); if ((readCnt = serOut.BytesToRead) > 0) { // Console.Write("rCnt:"); // Console.WriteLine(readCnt); inword = serOut.ReadLine(); cnt = inword.Count(c => c == '>'); totCnt += cnt; Console.Write(inword); #if VERBOSE Console.Write("$"); Console.Write(totCnt); Console.Write("$c"); Console.WriteLine(sendCnt); #endif Console.Write("]"); // Console.WriteLine(cnt); // Thread.Sleep(1); } else { Console.WriteLine(","); Thread.Sleep(1); } } Console.WriteLine(); sendCnt++; do { if ((readCnt = serOut.BytesToRead) > 0) { // Console.Write("rCnt:"); // Console.WriteLine(readCnt); Console.Write("["); inword = serOut.ReadLine(); cnt = inword.Count(c => c == '>'); totCnt += cnt; Console.Write(inword); #if VERBOSE Console.Write("|"); Console.Write(totCnt); Console.Write("|c"); Console.WriteLine(sendCnt); Console.WriteLine(cnt); #endif Console.Write("]"); Console.Write(totCnt); // Console.Write("|c"); // Console.WriteLine(cnt); // Thread.Sleep(1); } else { Console.Write("."); Thread.Sleep(1); } } while ((sendCnt - totCnt) > 30); } Application.DoEvents(); if (btnStart.Enabled) { break; } } } // Wait for final bytes to drain do { if ((readCnt = serOut.BytesToRead) > 0) { Console.Write("rCnt:"); Console.WriteLine(readCnt); inword = serOut.ReadLine(); cnt = inword.Count(c => c == '>'); totCnt += cnt; Console.Write(inword); Console.Write("-"); Console.Write(totCnt); Console.Write("-"); Console.WriteLine(sendCnt); Thread.Sleep(10); } else { Console.WriteLine("No1"); Thread.Sleep(1000); } } while ((sendCnt - totCnt) > 0); Console.WriteLine(cnt); Console.WriteLine("End 1"); if ((readCnt = serOut.BytesToRead) > 0) { inword = serOut.ReadLine(); Console.Write(inword); } else { Console.WriteLine("No2"); Thread.Sleep(1000); } Thread.Sleep(1000); Console.WriteLine("End 2"); if ((readCnt = serOut.BytesToRead) > 0) { inword = serOut.ReadLine(); Console.Write(inword); } else { Console.WriteLine("No3."); Thread.Sleep(1000); } serOut.Close(); btnStart.Enabled = true; btnStop.Enabled = false; Wfdb.Quit(); }
public void FreeResources() { Wfdb.Quit(); }
public void GetSignalsValidDataTest() { // Dealing with real data. var s = Signal.GetSignals("data/100s").ToList(); Assert.AreEqual(2, s.Count); // Check for results : Signal 100s Assert.AreEqual("100s.dat", s[0].FileName); Assert.AreEqual("100s.dat", s[1].FileName); Assert.AreEqual("MLII", s[0].Description); Assert.AreEqual("V5", s[1].Description); Assert.AreEqual(21600, s[0].NumberOfSamples); Assert.AreEqual(21600, s[1].NumberOfSamples); Assert.AreEqual(SignalStorageFormat.Sf212Bit, s[0].Format); Assert.AreEqual(SignalStorageFormat.Sf212Bit, s[1].Format); Assert.AreEqual(1, s[0].SamplesPerFrame); Assert.AreEqual(1, s[1].SamplesPerFrame); Assert.AreEqual(Gain.DefaultGain, s[0].Gain); Assert.AreEqual(Gain.DefaultGain, s[1].Gain); Assert.AreEqual(200.0, s[0].Gain.Value); Assert.AreEqual(200.0, s[1].Gain.Value); Assert.AreEqual(11, s[0].AdcResolution); Assert.AreEqual(11, s[1].AdcResolution); Assert.AreEqual(1024, s[0].AdcZero); Assert.AreEqual(1024, s[1].AdcZero); Assert.AreEqual(1024, s[0].Baseline); Assert.AreEqual(1024, s[1].Baseline); Assert.AreEqual(995, s[0].InitValue); Assert.AreEqual(1011, s[1].InitValue); Assert.AreEqual(0, s[0].Group); Assert.AreEqual(0, s[1].Group); Assert.AreEqual(0, s[0].BlockSize); Assert.AreEqual(0, s[1].BlockSize); Assert.AreEqual(21537, s[0].CheckSum); Assert.AreEqual(-3962, s[1].CheckSum); Assert.AreEqual(s[0].SamplesPerFrame, s[1].SamplesPerFrame); Assert.IsTrue(s[0].Record.Equals(s[1].Record)); Assert.IsTrue(s[0].Record.Signals.ToList()[0].Equals(s[0])); Assert.IsTrue(s[0].Record.Signals.ToList()[1].Equals(s[1])); Assert.IsTrue(s[1].Record.Signals.ToList()[0].Equals(s[0])); Assert.IsTrue(s[1].Record.Signals.ToList()[1].Equals(s[1])); Wfdb.Quit(); }