public NidaQmxDevice2(string device, IIDGenerator idgen) { Name = device; var bufferInputChannelNames = new StringBuilder(256 + 1); var resultQueryAI = NidaQmxHelper.DAQmxGetDevAIPhysicalChans(device, bufferInputChannelNames, bufferInputChannelNames.Length - 1); if (resultQueryAI < 0) { throw new SystemException("Could not query input channels for nidaq device " + device); } var bufferOutputChannelNames = new StringBuilder(256 + 1); var resultQueryAO = NidaQmxHelper.DAQmxGetDevAOPhysicalChans(device, bufferOutputChannelNames, bufferOutputChannelNames.Length - 1); if (resultQueryAO < 0) { throw new SystemException("Could not query input channels for nidaq device " + device); } var ai = bufferInputChannelNames.ToString() .Split(',') .Select(s => (NidaQmxChannel) new NidaQmxChannelInput(this, s.Trim(), idgen)); var ao = bufferOutputChannelNames.ToString() .Split(',') .Select(s => (NidaQmxChannel) new NidaQmxChannelOutput(this, s.Trim(), idgen)); _channels = ai.Concat(ao).ToList(); if (!CreateTaskHandle()) { throw new SystemException("Could not acquire nidaq task handle"); } Id = idgen.GetID(); }