public static string ErrorString(uint hekkaError) { byte[] text = new byte[200]; int size = text.Length; IntPtr textPtr = Marshal.AllocHGlobal(size); string result = null; try { ITCMM.ITC_AnalyzeError((int)hekkaError, textPtr, (uint)size); Marshal.Copy(textPtr, text, 0, size); System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); result = enc.GetString(text); } finally { Marshal.FreeHGlobal(textPtr); } return(result); }
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 ); }