public void ConfigureChannels(IEnumerable <HekaDAQStream> streams) { uint err = ItcmmCall(() => ITCMM.ITC_ResetChannels(DevicePtr)); if (err != ITCMM.ACQ_SUCCESS) { throw new HekaDAQException("Channel Reset", err); } var infoList = streams .Select((s) => s.ChannelInfo); err = ItcmmCall(() => ITCMM.ITC_SetChannels(DevicePtr, (uint)infoList.Count(), infoList.ToArray())); if (err != ITCMM.ACQ_SUCCESS) { throw new HekaDAQException("Set Channels", err); } err = ItcmmCall(() => ITCMM.ITC_UpdateChannels(DevicePtr)); if (err != ITCMM.ACQ_SUCCESS) { throw new HekaDAQException("Update Channels", err); } }
public void RoundTripChannelConfig() { HekkaDevice device = HekkaDevice.Zero; uint err = ITCMM.ITC_OpenDevice(ITCMM.USB18_ID, 0, ITCMM.SMART_MODE, out device); if (err != ITCMM.ACQ_SUCCESS) { Assert.Fail(ErrorDescription.ErrorString(err)); } try { //ITCMM.HWFunction hwf = new ITCMM.HWFunction(); err = ITCMM.ITC_InitDevice(device, IntPtr.Zero); //ref hwf); ITCMM.ITCPublicConfig config = new ITCMM.ITCPublicConfig(); config.OutputEnable = 1; err = ITCMM.ITC_ConfigDevice(device, ref config); if (err != ITCMM.ACQ_SUCCESS) { Assert.Fail(ErrorDescription.ErrorString(err)); } Assert.NotNull(device); err = ITCMM.ITC_ResetChannels(device); if (err != ITCMM.ACQ_SUCCESS) { Assert.Fail(ErrorDescription.ErrorString(err)); } ITCMM.ITCChannelInfo[] info = new ITCMM.ITCChannelInfo[2]; info[0].ChannelNumber = 0; info[0].ChannelType = ITCMM.OUTPUT_GROUP; info[1].ChannelNumber = 0; info[1].ChannelType = ITCMM.INPUT_GROUP; const double srate = 8000; info[0].SamplingRate = srate; info[1].SamplingRate = srate; err = ITCMM.ITC_SetChannels(device, 2, info); if (err != ITCMM.ACQ_SUCCESS) { Assert.Fail(ErrorDescription.ErrorString(err)); } err = ITCMM.ITC_UpdateChannels(device); if (err != ITCMM.ACQ_SUCCESS) { Assert.Fail(ErrorDescription.ErrorString(err)); } ITCMM.ITCChannelInfo[] actual = new ITCMM.ITCChannelInfo[2]; actual[0].ChannelType = info[0].ChannelType; actual[0].ChannelNumber = info[0].ChannelNumber; actual[1].ChannelType = info[1].ChannelType; actual[1].ChannelNumber = info[1].ChannelNumber; err = ITCMM.ITC_GetChannels(device, 2, actual); if (err != ITCMM.ACQ_SUCCESS) { Assert.Fail(ErrorDescription.ErrorString(err)); } Assert.AreEqual(info[0].SamplingRate, actual[0].SamplingRate); Assert.AreEqual(info[1].SamplingRate, actual[1].SamplingRate); } finally { err = ITCMM.ITC_CloseDevice(device); Assert.AreEqual(ITCMM.ACQ_SUCCESS, err, ErrorDescription.ErrorString(err) ); } }