using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; // For the DllImport of AIOUSB Driver API namespace AIOUSBNet { public class AIOUSB { // Prototype AIOUSB.dll data and functions in managed C# for Dot Net // Using C# data types and default marshaling of unmanaged code // Predefined constants for device index: public const UInt32 diNone = 0xFFFFFFFF; // "-1" public const UInt32 diFirst = 0xFFFFFFFE; // "-2" First board public const UInt32 diOnly = 0xFFFFFFFD; // "-3" One and only board #region General Board Utility Functions: [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 GetDevices(); // QueryDeviceInfo() Array of char Name version : [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 QueryDeviceInfo(UInt32 DeviceIndex, out UInt32 pPID, out UInt32 pNameSize, [In, Out] Char[] Name, out UInt32 pDIOBytes, out UInt32 pCounters); // QueryDeviceInfo() StringBuilder Name version : [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 QueryDeviceInfo(UInt32 DeviceIndex, out UInt32 pPID, out UInt32 pNameSize, StringBuilder Name, out UInt32 pDIOBytes, out UInt32 pCounters); // QueryDeviceInfo() String Name version : public static UInt32 QueryDeviceInfo(UInt32 DeviceIndex, out UInt32 pPID, out UInt32 pNameSize, out String Name, out UInt32 pDIOBytes, out UInt32 pCounters) { UInt32 Status; UInt32 NameSize = 256; // must pass this in by reference if you want name to be modified Char[] charName = new Char[NameSize]; Status = QueryDeviceInfo(DeviceIndex, out pPID, out NameSize, charName, out pDIOBytes, out pCounters); Name = new String(charName, 0, (Int32)NameSize); pNameSize = NameSize; return Status; } [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 AIOUSB_CloseDevice(UInt32 DeviceIndex); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ClearDevices(); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 GetDeviceUniqueStr(UInt32 DeviceIndex, out UInt32 pIIDSize, out Char pIID); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CustomEEPROMRead(UInt32 DeviceIndex, UInt32 StartAddress, out UInt32 DataSize, [In, Out] Byte[] Data); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CustomEEPROMWrite(UInt32 DeviceIndex, UInt32 StartAddress, UInt32 DataSize, [In, Out] Byte[] Data); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 GetDeviceByEEPROMByte(Byte Data); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 GetDeviceByEEPROMData(UInt32 StartAddress, UInt32 DataSize, [In, Out] Byte[] pData); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 GetDeviceSerialNumber(UInt32 DeviceIndex, out UInt64 pSerialNumber); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 GetDeviceBySerialNumber(UInt64 SerialNumber); // Rare, Advanced functions: [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ResolveDeviceIndex(UInt32 DeviceIndex); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 AIOUSB_ClearFIFO(UInt32 DeviceIndex, UInt32 TimeMethod); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 AIOUSB_GetStreamStatus(UInt32 DeviceIndex, out UInt32 Status); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 AIOUSB_SetStreamingBlockSize(UInt32 DeviceIndex, UInt32 BlockSize); #endregion #region ADC Specific Functions: // Try to use these functions, they are EASY: [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_GetChannelV(UInt32 DeviceIndex, UInt32 ChannelIndex, out double pBuf); // If you're taking more than one channel of data, ADC_GetScanV() is faster! [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_GetScanV(UInt32 DeviceIndex, [In, Out] double[] pBuf); // More ADC functions (advanced, rare) [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_GetScan(UInt32 DeviceIndex, [In, Out] UInt16[] pBuf); #endregion #region USB-AI Family (Including DPK-) Specific Functions // Array version: [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_SetConfig(UInt32 DeviceIndex, [In, Out] byte[] pConfigBuf, out UInt32 ConfigBufSize); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_GetConfig(UInt32 DeviceIndex, [In, Out] byte[] pConfigBuf, out UInt32 ConfigBufSize); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_GetConfig(UInt32 DeviceIndex, out byte pConfigBuf, out UInt32 ConfigBufSize); // the next few functions just call ADC_SetConfig for you [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_Initialize(UInt32 DeviceIndex, out byte pConfigBuf, out UInt32 pConfigBufSize, out char CalFileName); // wrapper for SetConfig AND SetCal, nothing more. [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_RangeAll(UInt32 DeviceIndex, out byte GainCodes, UInt32 bDifferential); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_Range1(UInt32 DeviceIndex, UInt32 ADChannel, byte GainCode, UInt32 bDifferential); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_ADMode(UInt32 DeviceIndex, byte TriggerMode, byte CalMode); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_SetScanLimits(UInt32 DeviceIndex, UInt32 StartChannel, UInt32 EndChannel); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_SetOversample(UInt32 DeviceIndex, byte Oversample); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_GetCalRefV(UInt32 DeviceIndex, UInt32 CalRefIndex, out double pRef); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_QueryCal(UInt32 DeviceIndex); // ADC_SetCal() char[] filename version : [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_SetCal(UInt32 DeviceIndex, [In, Out] Char[] CalFileName); // ADC_SetCal() String filename version : public static UInt32 ADC_SetCal(UInt32 DeviceIndex, String CalFileName) { UInt32 Status; Int32 NameSize = 256; // one extra char for NULL terminated string // This is the only func in dll that takes a terminator NameSize = CalFileName.Length + 1; Char[] charName = new Char[NameSize]; CalFileName.CopyTo(0, charName, 0, CalFileName.Length); Status = ADC_SetCal(DeviceIndex, charName); return Status; } // These are the FAST STREAMING functions. Capable of at least 500k samples per second (advanced) [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_BulkAcquire(UInt32 DeviceIndex, UInt32 BufSize, [In, Out] UInt16[] Buf); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_BulkPoll(UInt32 DeviceIndex, out UInt32 BytesLeft); // Continuous mode for AIOUSB.DLL: // Calbback function delegate for AIOUSB.DLL: // Declare delegate -- defines required signature: // original: procedure ADCallback(pBuf: PWord; BufSize, Flags, Context: LongWord); cdecl; // Must be Cdecl not default stdcall to match dll: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void ADCallback(IntPtr pBuf, UInt32 BufSize, UInt32 Flags, UInt32 Context); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_BulkContinuousCallbackStart(UInt32 DeviceIndex, UInt32 BufSize, UInt32 BaseBufCount, UInt32 Context, ADCallback pCallback); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_BulkContinuousEnd(UInt32 DeviceIndex, out UInt32 pIOStatus); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_InitFastITScanV(UInt32 DeviceIndex); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_ResetFastITScanV(UInt32 DeviceIndex); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_SetFastITScanVChannels(UInt32 DeviceIndex, UInt32 NewChannels); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_GetFastITScanV(UInt32 DeviceIndex, out double pBuf); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_GetITScanV(UInt32 DeviceIndex, out double pBuf); #endregion #region 8254 Counter/Timer Specific Functions: // more 8254 functions (rare, advanced) [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_8254Load(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, UInt16 LoadValue); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_8254Mode(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, UInt32 Mode); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_8254ModeLoad(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, UInt32 Mode, UInt16 LoadValue); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_8254Read(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, out UInt16 ReadValue); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_8254ReadStatus(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, out UInt16 ReadValue, out byte Status); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_8254ReadModeLoad(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, UInt32 Mode, UInt16 LoadValue, out UInt16 ReadValue); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_StartOutputFreq(UInt32 DeviceIndex, UInt32 BlockIndex, out double Hz); #endregion #region USB-CTR-15 Specific Functions [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_8254ReadAll(UInt32 DeviceIndex, [In, Out] UInt16[] pData); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_8254SelectGate(UInt32 DeviceIndex, UInt32 GateIndex); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_8254ReadLatched(UInt32 DeviceIndex, [In, Out] UInt16[] pData); // Legacy functions that were for a custom Application [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_SetWaitGates(UInt32 DeviceIndex, byte A, byte B); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_EndWaitGates(UInt32 DeviceIndex); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_WaitForGate(UInt32 DeviceIndex, byte GateIndex, out UInt16 pContent); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_StartMeasuringPulseWidth(UInt32 DeviceIndex); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_StopMeasuringPulseWidth(UInt32 DeviceIndex); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 CTR_GetPulseWidthMeasurement(UInt32 DeviceIndex, UInt32 BlockIndex, UInt32 CounterIndex, out UInt16 pReadValue); #endregion #region DIO Specific Functions: // functions to set output / input configuration // USB-DIO-32I [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_Configure(UInt32 DeviceIndex, Byte Tristate, ref UInt32 OutMask, ref UInt32 Data); // 2 byte short or Int16 you can keep other overloaded versions [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_Configure(UInt32 DeviceIndex, Byte Tristate, ref Int16 OutMask, Byte[] Data); // 2 arrays of bytes [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_Configure(UInt32 DeviceIndex, Byte Tristate, Byte[] OutMask, Byte[] Data); // 2 bytes [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_Configure(UInt32 DeviceIndex, Byte Tristate, out Byte OutMask, out Byte Data); // USB-DIO-16A family has only two tristate groups, A and the other digital ports ie B,C,D and Fast [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_ConfigureEx(UInt32 DeviceIndex, Byte[] pOutMask, Byte[] pData, Byte[] pTristateMask); // USB-DIO-96 family only [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_ConfigurationQuery(UInt32 DeviceIndex, [In, Out] Byte[] pOutMask, [In, Out] Byte[] pTristateMask); // functions to write digital outputs (including FETs and Relays) // DIO_WriteAll() marshalls 4 8 bit data bytes into one Uint32 data type: [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_WriteAll(UInt32 DeviceIndex, ref UInt32 Data); // DIO_WriteAll() array of 4 8 bit Bytes version: [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_WriteAll(UInt32 DeviceIndex, Byte[] Data); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_Write8(UInt32 DeviceIndex, UInt32 ByteIndex, Byte Data); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_Write1(UInt32 DeviceIndex, UInt32 BitIndex, Byte Data); // functions to read digital inputs // DIO_ReadAll() marshalls 4 8 bit data bytes into one Uint32 data type [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_ReadAll(UInt32 DeviceIndex, out UInt32 Data); // DIO_ReadAll() array of 4 8 bit Bytes version: [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_ReadAll(UInt32 DeviceIndex, [In, Out] Byte[] Data); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_Read8(UInt32 DeviceIndex, UInt32 ByteIndex, out Byte Data); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_Read1(UInt32 DeviceIndex, UInt32 BitIndex, out Byte Data); #endregion #region USB-DIO-16H specific (streaming, fast) functions [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_StreamOpen(UInt32 DeviceIndex, UInt32 bIsRead); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_StreamClose(UInt32 DeviceIndex); // [In, Out] DataType[] ensures arrays get marshalled to and from the caller for reads and writes [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_StreamFrame(UInt32 DeviceIndex, UInt32 FramePoints, [In, Out] UInt16[] FrameData, out UInt32 ByteTransferred); // optional send and receive as an array of bytes [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_StreamFrame(UInt32 DeviceIndex, UInt32 FramePoints, [In, Out] Byte[] FrameData, out UInt32 ByteTransferred); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_StreamSetClocks(UInt32 DeviceIndex, out Double ReadClockHz, out Double WriteClockHz); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_SPI_Read(UInt32 DeviceIndex, UInt16 Address, UInt16 Reg, out UInt16 pValue); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_SPI_Write(UInt32 DeviceIndex, UInt16 Address, UInt16 Reg, UInt16 Value); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_CSA_DoSync(UInt32 DeviceIndex, out double BaseRateHz, out double DurAms, out double DurBms, out double DurCms); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_CSA_DebounceSet(UInt32 DeviceIndex, UInt32 DebounceCounts); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_CSA_DebounceReadAll(UInt32 DeviceIndex, out UInt32 pData); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_CSA_DebounceReadAll(UInt32 DeviceIndex, [In, Out] Byte[] pData); #endregion #region DAC Specific Functions: [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DAC_CSA_SetRangeLimits(UInt32 DeviceIndex, [In, Out] Byte[] pData); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DAC_CSA_ClearRangeLimits(UInt32 DeviceIndex); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACDirect(UInt32 DeviceIndex, UInt16 Channel, UInt16 Counts); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACMultiDirect(UInt32 DeviceIndex, [In, Out] UInt16[] pDACData, UInt32 DACDataCount); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACSetBoardRange(UInt32 DeviceIndex, UInt32 RangeCode); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACSetChannelCal(UInt32 DeviceIndex, UInt32 Channel, out char CalFileName); // DACSetChannelCal() char[] filename version : [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACSetChannelCal(UInt32 DeviceIndex, UInt32 Channel, [In, Out] Char[] CalFileName); // DACSetChannelCal() String filename version : public static UInt32 DACSetChannelCal(UInt32 DeviceIndex, UInt32 Channel, String CalFileName) { UInt32 Status; Int32 NameSize = 256; NameSize = CalFileName.Length; Char[] charName = new Char[NameSize]; CalFileName.CopyTo(0, charName, 0, CalFileName.Length); Status = DACSetChannelCal(DeviceIndex, Channel, charName); return Status; } // DAC Functions for USB-DA12-8A only [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACOutputProcess(UInt32 DeviceIndex, out double ClockHz, UInt32 NumSamples, out UInt16 SampleData); // more DAC Functions for USB-DA12-8A only (advanced, rare) [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACOutputOpen(UInt32 DeviceIndex, out double ClockHZ); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACOutputCloseNoEnd(UInt32 DeviceIndex, UInt32 bWait); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACOutputFrame(UInt32 DeviceIndex, UInt32 FramePoints, out UInt16 pFrameData); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACOutputFrameRaw(UInt32 DeviceIndex, UInt32 FramePoints, out UInt16 FrameData); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACOutputSetCount(UInt32 DeviceIndex, UInt32 NewCount); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACOutputSetInterlock(UInt32 DeviceIndex, UInt32 bInterlock); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACOutputStart(UInt32 DeviceIndex); #endregion #region These functions are reserved for factory use only, or are deprecated: [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 GenericVendorRead(UInt32 DeviceIndex, Byte Request, UInt16 Value, UInt16 Index, out UInt32 pDataSize, out byte pData); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 GenericVendorWrite(UInt32 DeviceIndex, Byte Request, UInt16 Value, UInt16 Index, UInt32 DataSize, out byte pData); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_SPI_Read(UInt32 DeviceIndex, UInt32 Address, byte Reg, out byte pValue); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DIO_SPI_Write(UInt32 DeviceIndex, UInt32 Address, byte Reg, byte Value); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_Initialize(UInt32 DeviceIndex, [In, Out] byte[] pConfigBuf, out UInt32 ConfigBufSize, [In, Out] Char[] CalFileName); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 ADC_GetImmediate(UInt32 DeviceIndex, UInt32 Channel, out UInt16 pBuf); //[DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] //public static extern UInt32 DACOutputFrame(UInt32 DeviceIndex, UInt32 FramePoints, out UInt16 FrameData); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 DACOutputClose(UInt32 DeviceIndex, UInt32 bWait); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 AIOUSB_FlashRead(UInt32 DeviceIndex, UInt32 StartAddress, out UInt32 DataSize, out byte Data); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 AIOUSB_FlashWrite(UInt32 DeviceIndex, UInt32 StartAddress, UInt32 DataSize, out byte Data); [DllImport("AIOUSB.DLL", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 AIOUSB_FlashEraseSector(UInt32 DeviceIndex, UInt32 Sector); #endregion } }