public void ExceptionalStopOnOutputUnderrun() { foreach (HekaDAQController daq in HekaDAQController.AvailableControllers()) { try { bool receivedExc = false; FixtureForController(daq, durationSeconds: 1.0); InputDevice.InputData[InputStream] = new List <IInputData>(); daq.ExceptionalStop += (c, args) => receivedExc = true; daq.Start(false); Assert.That(receivedExc, Is.True.After(1000, 10)); } finally { if (daq.HardwareReady) { daq.CloseHardware(); } } } }
public void ShouldOpenHardwareOnStart() { foreach (HekaDAQController daq in HekaDAQController.AvailableControllers()) { try { bool receivedExc = false; FixtureForController(daq, durationSeconds: 1.0); InputDevice.InputData[InputStream] = new List <IInputData>(); daq.ProcessIteration += (c, args) => { Console.WriteLine("Blowing up the pipeline."); throw new Exception("bam!"); }; daq.ExceptionalStop += (c, args) => receivedExc = true; daq.CloseHardware(); daq.Start(false); Assert.That(receivedExc, Is.True.After(1000, 10)); } finally { daq.CloseHardware(); } } }
public void RoundTripStreamITChannelInfo() { foreach (HekaDAQController daq in HekaDAQController.AvailableControllers()) { daq.InitHardware(); try { daq.ExceptionalStop += (c, arg) => { throw arg.Exception; }; foreach (HekaDAQStream stream in daq.Streams.Cast <HekaDAQStream>()) { daq.SampleRate = new Measurement(stream.ChannelNumber, 1, "Hz"); ITCMM.ITCChannelInfo info = stream.ChannelInfo; Assert.AreEqual(stream.ChannelNumber, info.ChannelNumber); Assert.AreEqual((uint)stream.ChannelType, info.ChannelType); //NO_SCALE is seconds scale (Hz) Assert.AreEqual(ITCMM.USE_FREQUENCY & ITCMM.NO_SCALE & ITCMM.ADJUST_RATE, info.SamplingIntervalFlag); Assert.That(info.SamplingRate, Is.EqualTo(stream.SampleRate.QuantityInBaseUnit)); Assert.AreEqual(IntPtr.Zero, info.FIFOPointer); Assert.AreEqual(0, info.Gain); } } finally { daq.CloseHardware(); } } }
public void StopDAQControllers() { foreach (HekaDAQController controller in HekaDAQController.AvailableControllers()) { if (controller.Running) { controller.Stop(); } if (controller.HardwareReady) { //controller.CloseHardware(); } } }
public void SegregatesStreams() { foreach (HekaDAQController controller in HekaDAQController.AvailableControllers()) { Assert.False(controller.HardwareReady); controller.InitHardware(); try { CollectionAssert.AllItemsAreInstancesOfType(controller.StreamsOfType(StreamType.ANALOG_IN), typeof(HekaDAQInputStream)); CollectionAssert.AllItemsAreInstancesOfType(controller.StreamsOfType(StreamType.ANALOG_OUT), typeof(HekaDAQOutputStream)); } finally { controller.CloseHardware(); } } }
public void InitializesHardware() { foreach (HekaDAQController controller in HekaDAQController.AvailableControllers()) { Assert.False(controller.HardwareReady); controller.InitHardware(); try { Assert.True(controller.HardwareReady); } finally { controller.CloseHardware(); Assert.False(controller.HardwareReady); } } }
public void SetsChannelInfo() { foreach (HekaDAQController daq in HekaDAQController.AvailableControllers()) { const decimal srate = 10000; daq.InitHardware(); Assert.True(daq.HardwareReady); Assert.False(daq.HardwareRunning); try { foreach (IDAQOutputStream s in daq.OutputStreams) { daq.SampleRate = new Measurement(srate, "Hz"); TestDevice externalDevice = new TestDevice("OUT-DEVICE", null); s.Device = externalDevice; } daq.ConfigureChannels(); foreach (HekaDAQStream s in daq.OutputStreams.Cast <HekaDAQStream>()) { ITCMM.ITCChannelInfo actual = daq.ChannelInfo(s.ChannelType, s.ChannelNumber); ITCMM.ITCChannelInfo expected = s.ChannelInfo; Assert.AreEqual(expected.ChannelNumber, actual.ChannelNumber); Assert.AreEqual(expected.ChannelType, actual.ChannelType); Assert.AreEqual(expected.SamplingIntervalFlag, actual.SamplingIntervalFlag); Assert.AreEqual(expected.SamplingRate, actual.SamplingRate); // Gain set by hardware. } } finally { daq.CloseHardware(); } } }
public void ShouldResetHardwareWhenStopsWithException() { foreach (HekaDAQController daq in HekaDAQController.AvailableControllers()) { bool receivedExc = false; FixtureForController(daq, durationSeconds: 1.0); InputDevice.InputData[InputStream] = new List <IInputData>(); daq.ProcessIteration += (c, args) => { Console.WriteLine("Blowing up the pipeline."); throw new Exception("bam!"); }; daq.ExceptionalStop += (c, args) => receivedExc = true; daq.Start(false); Assert.That(receivedExc, Is.True.After(1000, 10)); daq.CloseHardware(); //Should be ready to initialize again try { Assert.That(() => daq.InitHardware(), Throws.Nothing); } finally { if (daq.HardwareReady) { daq.CloseHardware(); } } } }
public void AvailableControllers() { Assert.GreaterOrEqual(HekaDAQController.AvailableControllers().Count(), 1); }