本文整理汇总了C#中Record.Open方法的典型用法代码示例。如果您正苦于以下问题:C# Record.Open方法的具体用法?C# Record.Open怎么用?C# Record.Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UsingRecord
private static void UsingRecord()
{
Console.WriteLine("pgain Using Record Class");
using (var record = new Record("data/100s"))
{
record.Open();
int counter = 0;
foreach (var signal in record)// or (var signal in record.Signals)
{
Console.WriteLine("Signal {0} gain = {1}", counter, signal.Gain);
counter++;
}
}
}
示例2: DisposeTest
public void DisposeTest()
{
var record = new Record("data/100s");
record.Open();
Assert.IsFalse(record.IsNew);
//Assert.AreEqual(" 69 M 1085 1629 x1", record.Info);
Assert.AreEqual((Frequency)360, record.SamplingFrequency);
Assert.AreEqual(2, record.Signals.Count());
record.Dispose();
Assert.AreEqual(0, record.Signals.Count());
Assert.IsTrue(record.IsNew);
Assert.AreEqual(string.Empty, record.Info);
Assert.AreEqual((Frequency)0, record.SamplingFrequency);
Assert.AreEqual(0, record.Signals.Count());
}
示例3: IndexerTest
public void IndexerTest()
{
var record = new Record("data/100s");
using (record)
{
record.Open();
Assert.AreEqual(record.Signals.ToList()[0], record[0]);
Assert.AreEqual(record.Signals.ToList()[1], record[1]);
}
try
{
var signal = record[0];
Assert.Fail("IndexOutOfRangeException should have been thrown");
}
catch (ArgumentOutOfRangeException)
{
}
}
示例4: UsingWrapperClasses
public static void UsingWrapperClasses()
{
var record = new Record("data/100s");
record.Open();
Console.WriteLine("Record Name : " + record.Name);
Console.WriteLine("Record Info : " + record.Info);
Console.WriteLine("Record's Sampling Frequency : " + record.SamplingFrequency);
Console.WriteLine("Available signals.");
foreach (Signal signal in record.Signals)
{
Console.WriteLine("=====================================");
Console.WriteLine("Signal's Name : " + signal.FileName);
Console.WriteLine("Signal's Description : " + signal.Description);
Console.WriteLine("Signal's Number of samples : " + signal.NumberOfSamples);
Console.WriteLine("Signal's First Sample : " + signal.InitValue);
Console.WriteLine("------------------------------------------");
Console.WriteLine("Showing the first 10 samples of the signal");
Console.WriteLine("------------------------------------------");
List<Sample> samples = signal.ReadNext(10).ToList();
for (int i = 0; i < samples.Count; i++)
{
Console.WriteLine("Sample " + i + " Value (adu) = " + samples[i].Adu);
Console.WriteLine(" Value (microvolt) = " + samples[i].ToMicrovolts());
Console.WriteLine(" Value (millivolt) = " + samples[i].ToPhys());
}
Console.WriteLine("--------------------------------------");
Console.WriteLine("=====================================");
}
record.Dispose();
}
示例5: RecordTest
public void RecordTest()
{
using (var r = new Record("data/100s"))
{
r.Open();
Assert.IsTrue(r.Signals.ToList()[0].Record == r);
Assert.IsTrue(r.Signals.ToList()[1].Record == r);
}
var signals = new List<Signal>(Signal.GetSignals("data/100s"));
Assert.IsTrue(signals[0].Record == signals[1].Record);
}
示例6: SeekTest
public void SeekTest()
{
// Testing On Signal's Samples
using (var record = new Record("data/100s"))
{
record.Open();
var expectedSignal1Samples0 = record[0].ReadNext(10); // read 10 samples of the first 10
var expectedSignal2Samples0 = record[1].ReadNext(10); // read 10 samples of the first 10
record.Signals.First().Seek(10); // advance the 1st pointer by ten samples
var expectedSignal1Samples10 = record[0].ReadNext(10); // read 10 samples after the first 10 samples
record.Signals.Skip(1).First().Seek(10); // advance the 1st pointer by ten samples
var expectedSignal2Samples10 = record[1].ReadNext(10); // read 10 samples after the first 10 samples
record.Seek(0);
Assert.AreEqual(expectedSignal1Samples0, record[0].ReadNext(10));
Assert.AreEqual(expectedSignal2Samples0, record[1].ReadNext(10));
record.Seek(10);
Assert.AreEqual(expectedSignal1Samples10, record[0].ReadNext(10));
Assert.AreEqual(expectedSignal2Samples10, record[1].ReadNext(10));
}
}
示例7: SignalsTest
public void SignalsTest()
{
var record = new Record("data/100s");
using (record)
{
record.Open();
Assert.AreEqual(2, record.Signals.Count());
Assert.AreEqual("100s.dat", record.Signals.ToList()[0].FileName);
Assert.AreEqual("100s.dat", record.Signals.ToList()[1].FileName);
Assert.AreEqual("MLII", record.Signals.ToList()[0].Description);
Assert.AreEqual("V5", record.Signals.ToList()[1].Description);
Assert.AreEqual(21600, record.Signals.ToList()[0].NumberOfSamples);
Assert.AreEqual(21600, record.Signals.ToList()[1].NumberOfSamples);
Assert.AreEqual(SignalStorageFormat.Sf212Bit, record.Signals.ToList()[0].Format);
Assert.AreEqual(SignalStorageFormat.Sf212Bit, record.Signals.ToList()[1].Format);
Assert.AreEqual(1, record.Signals.ToList()[0].SamplesPerFrame);
Assert.AreEqual(1, record.Signals.ToList()[1].SamplesPerFrame);
Assert.AreEqual(Gain.DefaultGain, record.Signals.ToList()[0].Gain);
Assert.AreEqual(Gain.DefaultGain, record.Signals.ToList()[1].Gain);
Assert.AreEqual(200.0, record.Signals.ToList()[0].Gain.Value);
Assert.AreEqual(200.0, record.Signals.ToList()[1].Gain.Value);
Assert.AreEqual(11, record.Signals.ToList()[0].AdcResolution);
Assert.AreEqual(11, record.Signals.ToList()[1].AdcResolution);
Assert.AreEqual(1024, record.Signals.ToList()[0].AdcZero);
Assert.AreEqual(1024, record.Signals.ToList()[1].AdcZero);
Assert.AreEqual(1024, record.Signals.ToList()[0].Baseline);
Assert.AreEqual(1024, record.Signals.ToList()[1].Baseline);
Assert.AreEqual(995, record.Signals.ToList()[0].InitValue);
Assert.AreEqual(1011, record.Signals.ToList()[1].InitValue);
Assert.AreEqual(0, record.Signals.ToList()[0].Group);
Assert.AreEqual(0, record.Signals.ToList()[1].Group);
Assert.AreEqual(0, record.Signals.ToList()[0].BlockSize);
Assert.AreEqual(0, record.Signals.ToList()[1].BlockSize);
Assert.AreEqual(21537, record.Signals.ToList()[0].CheckSum);
Assert.AreEqual(-3962, record.Signals.ToList()[1].CheckSum);
}
}
示例8: OpenTest
public void OpenTest()
{
var record = new Record("data/100s");
using (record)
{
record.Open();
Assert.IsFalse(record.IsNew);
Assert.AreEqual(" 69 M 1085 1629 x1\n Aldomet, Inderal\nProduced by xform from record 100, beginning at 0:0", record.Info);
Assert.AreEqual((Frequency)360, record.SamplingFrequency);
Assert.AreEqual(2, record.Signals.Count());
}
Assert.AreEqual(0, record.Signals.Count());
Assert.IsTrue(record.IsNew);
Assert.AreEqual(string.Empty, record.Info);
Assert.AreEqual((Frequency)0, record.SamplingFrequency);
Assert.AreEqual(0, record.Signals.Count());
using (record)
{
record.Open();
Assert.IsFalse(record.IsNew);
Assert.AreEqual(" 69 M 1085 1629 x1\n Aldomet, Inderal\nProduced by xform from record 100, beginning at 0:0", record.Info);
Assert.AreEqual((Frequency)360, record.SamplingFrequency);
Assert.AreEqual(2, record.Signals.Count());
}
}
示例9: SamplingFrequencyTest
public void SamplingFrequencyTest()
{
var record = new Record("data/100s");
using (record)
{
record.Open();
Assert.AreEqual((Frequency)360, record.SamplingFrequency); // Get test
record.SamplingFrequency = 320; // set test
Assert.AreEqual((Frequency)320, record.SamplingFrequency); // Get test
}
}
示例10: UsingWrapperClasses3
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.First().ReadNext(10).ToList();
record.Signals.Skip(1).First().Seek(10); // moving the reading pointer of the second signal by ten positions
var samples2 = record.Signals.Skip(1).First().ReadNext(10).ToList();
for (int i = 0; i < 10; i++)
{
Console.WriteLine("{0}\t{1}", samples1[i], samples2[i]);
}
}
Wfdb.Quit();
}
示例11: IndexerTest
public void IndexerTest()
{
using (var r = new Record("data/100s"))
{
r.Open();
var signal = r.Signals.First();
Assert.IsFalse(signal.IsEof);
var expectedSamples = signal.ReadAll().ToList();
for (int i = 0; i < expectedSamples.Count; i++)
{
Assert.AreEqual(expectedSamples[i], signal[i]);
}
try
{
var sample = signal[signal.Duration + 5];
Assert.Fail("InvalidOperationException should have been thrown.");
}
catch (InvalidOperationException)
{
}
}
}
示例12: ReadAllTest
public void ReadAllTest()
{
using (var r = new Record("data/100s"))
{
r.Open();
var signal = r.Signals.First();
Assert.IsFalse(signal.IsEof);
Assert.AreEqual(signal.NumberOfSamples, signal.ReadAll().Count());
Assert.IsTrue(signal.IsEof);
// Recall
Assert.AreEqual(signal.NumberOfSamples, signal.ReadAll().Count());
Assert.IsTrue(signal.IsEof);
}
}
示例13: IsEofTest
public void IsEofTest()
{
using (var r = new Record("data/100s"))
{
r.Open();
var signal = r.Signals.First();
Assert.IsFalse(signal.IsEof);
signal.ReadNext();
Assert.IsFalse(signal.IsEof);
signal.ReadNext((int)signal.NumberOfSamples / 2);
Assert.IsFalse(signal.IsEof);
signal.ReadAll().ToList();
Assert.IsTrue(signal.IsEof);
signal.Seek(0);
Assert.IsFalse(signal.IsEof);
signal.Seek((int)signal.NumberOfSamples - 1);
Assert.IsFalse(signal.IsEof);
signal.ReadNext();
Assert.IsTrue(signal.IsEof);
}
}
示例14: ReadToEndTest
public void ReadToEndTest()
{
using (var r = new Record("data/100s"))
{
r.Open();
var signal = r.Signals.First();
var expectedSamples = signal.ReadAll().ToList();
signal.Seek(0);
Assert.AreEqual(expectedSamples, signal.ReadToEnd());
Assert.IsTrue(signal.IsEof);
Assert.AreEqual(new List<Sample>(), signal.ReadToEnd()); // no more samples to read
signal.Seek(signal.Duration/2);
var samples = signal.ReadToEnd();
expectedSamples.RemoveRange(0, signal.Duration/2);
Assert.AreEqual(expectedSamples, samples);
}
}
示例15: ReadNextTimeTest
public void ReadNextTimeTest()
{
using (var r = new Record("data/100s"))
{
r.Open();
var signal = r.Signals.First();
Assert.IsFalse(signal.IsEof);
var expectedSamples = signal.ReadAll().ToList();
var expectedFirstSample = expectedSamples[0];
Assert.AreEqual(expectedFirstSample, signal.ReadNext(Time.Zero));
Assert.AreEqual(signal.InitValue, signal.ReadNext(Time.Zero));
var expectedLastSample = expectedSamples[expectedSamples.Count - 1];
Time lastSampleTime = signal.Duration - 1;
Assert.AreEqual(expectedLastSample, signal.ReadNext(lastSampleTime));
// EOF REACHED
try
{
signal.ReadNext(signal.Duration + 5);
Assert.Fail("InvalidOperationException should have been thrown cause the end of signal has been reached.");
}
catch (InvalidOperationException)
{
}
}
}