public NidaQmxChannel(NidaQmxDevice2 device, string channel, ChannelDirection direction, IIDGenerator idgen) { _status = DevicePortStatus.Idle; Id = idgen.GetID(); Channel = channel; Device = device; _direction = direction; }
public bool Start(NidaQmxDevice2 device) { if (Recording) { return(false); } _device = device; InOutPortFlags flags = 0; if (device.ListeningPorts.Any(p => p.Direction == ChannelDirection.Input)) { flags |= InOutPortFlags.UseInput; } if (device.ListeningPorts.Any(p => p.Direction == ChannelDirection.Output)) { flags |= InOutPortFlags.UseOutput; } if (!CreateVirtualChannel(flags)) { return(false); } if (!ConfigureDevClock(flags)) { return(false); } if (flags.HasFlag(InOutPortFlags.UseInput)) { Data = Marshal.AllocHGlobal(sizeof(double) * device.SamplesPerChannelInput * device.ListeningPorts.Count()); foreach (var port in device.ListeningPorts.OfType <NidaQmxChannelInput>()) { port.SetBufferSize(device.SamplesPerChannelInput); } } if (!RunTask(flags)) { return(false); } _stopThread = false; if (flags.HasFlag(InOutPortFlags.UseInput)) { _pollThread = new Thread(EveryNCallback); _pollThread.Start(); } Recording = true; return(true); }
public NidaQmxChannelInput(NidaQmxDevice2 device, string channel, IIDGenerator idgen) : base(device, channel, ChannelDirection.Input, idgen) { }