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) ); } }
internal static IHekaDevice OpenDevice(uint deviceType, uint deviceNumber, out ITCMM.GlobalDeviceInfo deviceInfo) { IntPtr dev; uint numDevices = 0; uint err = ITCMM.ITC_Devices(deviceType, ref numDevices); if (err != ITCMM.ACQ_SUCCESS) { throw new HekaDAQException("Unable to find devices", err); } err = ITCMM.ITC_OpenDevice(deviceType, deviceNumber, ITCMM.SMART_MODE, out dev); if (err != ITCMM.ACQ_SUCCESS) { log.Error("Unable to open ITC device"); throw new HekaDAQException("Unable to get device handle", err); } //ITCMM.HWFunction sHWFunction = new ITCMM.HWFunction(); err = ITCMM.ITC_InitDevice(dev, IntPtr.Zero); //ref sHWFunction); //ITC_SetSoftKey // Configure device ITCMM.ITCPublicConfig config = new ITCMM.ITCPublicConfig(); config.OutputEnable = 1; config.ControlLight = 1; err = ITCMM.ITC_ConfigDevice(dev, ref config); if (err != ITCMM.ACQ_SUCCESS) { throw new HekaDAQException("Unable to configure device", err); } deviceInfo = new ITCMM.GlobalDeviceInfo(); err = ITCMM.ITC_GetDeviceInfo(dev, ref deviceInfo); if (err != ITCMM.ACQ_SUCCESS) { throw new HekaDAQException("Unable to get device info", err); } return new QueuedHekaHardwareDevice(dev, deviceInfo.NumberOfADCs + deviceInfo.NumberOfDIs + deviceInfo.NumberOfAUXIs, deviceInfo.NumberOfDACs + deviceInfo.NumberOfDOs + deviceInfo.NumberOfAUXOs ); }
public void ReadAvailableSamples() { 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); ITCMM.ITCChannelInfo channelInfo = new ITCMM.ITCChannelInfo(); channelInfo.ChannelType = ITCMM.H2D; channelInfo.ChannelNumber = 0; channelInfo.SamplingRate = 1000.0; Assert.AreEqual(System.IntPtr.Zero, channelInfo.FIFOPointer); Assert.AreEqual(ITCMM.ACQ_SUCCESS, ITCMM.ITC_SetChannels(device, 1, new ITCMM.ITCChannelInfo[] { channelInfo }) ); Assert.AreEqual(ITCMM.ACQ_SUCCESS, (int)ITCMM.ITC_UpdateChannels(device) ); ITCMM.ITCChannelDataEx info = new ITCMM.ITCChannelDataEx(); info.ChannelType = ITCMM.H2D; info.ChannelNumber = 0; ITCMM.ITCChannelDataEx[] arr = new ITCMM.ITCChannelDataEx[] { info }; err = ITCMM.ITC_GetDataAvailable(device, 1, arr); if (err != ITCMM.ACQ_SUCCESS) { Assert.Fail(ErrorDescription.ErrorString(err)); } info = arr[0]; Assert.That(info.Value, Is.GreaterThanOrEqualTo(0)); } finally { err = ITCMM.ITC_CloseDevice(device); Assert.AreEqual(ITCMM.ACQ_SUCCESS, err, ErrorDescription.ErrorString(err) ); } }