public void DelegatesSampleRateToController() { var c = new NIDAQController(); var s = new NIDAQInputStream("none", 0, c); var srate = new Measurement(1000, "Hz"); c.SampleRate = srate; Assert.That(s.SampleRate, Is.EqualTo(c.SampleRate)); Assert.Throws<NotSupportedException>(() => s.SampleRate = srate); }
private double ReadSingleAnalog(NIDAQInputStream stream) { using (var t = new DAQTask()) { t.AIChannels.CreateVoltageChannel(stream.PhysicalName, "", (AITerminalConfiguration) (-1), Device.AIVoltageRanges.Min(), Device.AIVoltageRanges.Max(), AIVoltageUnits.Volts); var reader = new AnalogSingleChannelReader(t.Stream); return reader.ReadSingleSample(); } }
private double ReadSingleDigital(NIDAQInputStream stream) { using (var t = new DAQTask()) { t.DIChannels.CreateChannel(stream.PhysicalName, "", ChannelLineGrouping.OneChannelForAllLines); var reader = new DigitalSingleChannelReader(t.Stream); return reader.ReadSingleSamplePortUInt32(); } }
public IInputData ReadStream(NIDAQInputStream stream) { double quantity; if (stream.PhysicalChannelType == PhysicalChannelTypes.AI) quantity = ReadSingleAnalog(stream); else if (stream.PhysicalChannelType == PhysicalChannelTypes.DIPort) quantity = ReadSingleDigital(stream); else throw new NotSupportedException("Unsupported stream channel type"); var inData = new InputData( new List<IMeasurement> {new Measurement(quantity, 0, stream.DAQUnits)}, new Measurement(0, 0, "Hz"), DateTimeOffset.Now) .DataWithStreamConfiguration(stream, stream.Configuration); return inData.DataWithUnits(stream.MeasurementConversionTarget); }