using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using FxpConvert.Common;

namespace NIFPGA
{
    partial class Interop
	{

        public enum NiFpga_FifoProperty
        {

            /// NiFpga_FifoProperty_BytesPerElement -> 1
            NiFpga_FifoProperty_BytesPerElement = 1,

            /// NiFpga_FifoProperty_HostBufferAllocationGranularity -> 2
            NiFpga_FifoProperty_HostBufferAllocationGranularity = 2,

            /// NiFpga_FifoProperty_HostBufferSize -> 3
            NiFpga_FifoProperty_HostBufferSize = 3,

            /// NiFpga_FifoProperty_HostBufferMirrorSize -> 4
            NiFpga_FifoProperty_HostBufferMirrorSize = 4,

            /// NiFpga_FifoProperty_HostBufferType -> 5
            NiFpga_FifoProperty_HostBufferType = 5,

            /// NiFpga_FifoProperty_HostBuffer -> 6
            NiFpga_FifoProperty_HostBuffer = 6,

            /// NiFpga_FifoProperty_FlowControl -> 7
            NiFpga_FifoProperty_FlowControl = 7,

            /// NiFpga_FifoProperty_ElementsCurrentlyAcquired -> 8
            NiFpga_FifoProperty_ElementsCurrentlyAcquired = 8,
        }

        public enum NiFpga_CloseAttribute
        {

            /// NiFpga_CloseAttribute_NoResetIfLastSession -> 1
            NiFpga_CloseAttribute_NoResetIfLastSession = 1,
        }

        public enum NiFpga_RunAttribute
        {
            NiFpga_RunAttribute_None=0,
            /// NiFpga_RunAttribute_WaitUntilDone -> 1
            NiFpga_RunAttribute_WaitUntilDone = 1,
        }

        public static Boolean NiFpga_IsError(NiFpga_Status status) => status < NiFpga_Status.Success;
        public static Boolean NiFpga_IsNotError(NiFpga_Status status) => status >= NiFpga_Status.Success;
        public static float NiFpga_CalculateFxpDeltaFloat(NiFpga_FxpTypeInfo typeInfo)
        {
            int exponent = typeInfo.integerWordLength - typeInfo.wordLength;
            return (float)ldexp(FLT_EPSILON, exponent + FLT_MANT_DIG - 1);
        }
        public static double NiFpga_CalculateFxpDeltaDouble(NiFpga_FxpTypeInfo typeInfo)
        {
            int exponent = typeInfo.integerWordLength - typeInfo.wordLength;
            return ldexp(DBL_EPSILON, exponent + DBL_MANT_DIG - 1);
        }
        public static float NiFpga_ConvertFromFxpToFloat(NiFpga_FxpTypeInfo typeInfo,ulong data)
        {
            float delta = NiFpga_CalculateFxpDeltaFloat(typeInfo);
            return (float)NiFpga_Private_FxpToFloatingPoint(typeInfo, delta, data);
        }
        public static double NiFpga_ConvertFromFxpToDouble(NiFpga_FxpTypeInfo typeInfo, ulong data)
        {
            double delta = NiFpga_CalculateFxpDeltaDouble(typeInfo);
            return NiFpga_Private_FxpToFloatingPoint(typeInfo, delta, data);
        }
        static double NiFpga_Private_FxpToFloatingPoint(NiFpga_FxpTypeInfo typeInfo,double delta,ulong data)
        {
            ulong wordLengthMask = (1UL << typeInfo.wordLength) -1;
            data &= wordLengthMask;
            if(typeInfo.isSigned)
            {
                ulong signedMask = 1UL << (typeInfo.wordLength - 1);
                if((data& signedMask)!=0)
                {
                    long signedData = (long)(data ^ wordLengthMask);
                    signedData = (signedData + 1) * -1;
                    return delta * signedData;
                }
            }
            return delta * data;
        }
        public static ulong NiFpga_ConvertFromFloatToFxp(NiFpga_FxpTypeInfo typeInfo, float data)
        {
            float delta = NiFpga_CalculateFxpDeltaFloat(typeInfo);
            return NiFpga_Private_FloatingPointToFxp(typeInfo, delta, data);
        }
        public static ulong NiFpga_ConvertFromDoubleToFxp(NiFpga_FxpTypeInfo typeInfo, double data)
        {
            double delta = NiFpga_CalculateFxpDeltaDouble(typeInfo);
            return NiFpga_Private_FloatingPointToFxp(typeInfo, delta, data);
        }
        static ulong NiFpga_Private_FloatingPointToFxp(NiFpga_FxpTypeInfo typeInfo, double delta, double data)
        {
            ulong wordLengthMask = (1UL << typeInfo.wordLength) - 1;
            if (data < 0)
            {
                if (typeInfo.isSigned)
                {
                    long fxpRepresentation = (long)(data / delta);
                    fxpRepresentation ^= (long)wordLengthMask;
                    fxpRepresentation += 1;
                    fxpRepresentation *= -1;
                    if ((long)(fxpRepresentation & (long)wordLengthMask) == fxpRepresentation)
                    {
                        return (ulong)fxpRepresentation;
                    }
                    else /* minimum */
                    {
                        return (ulong)(-1L * (1L << (typeInfo.wordLength - 1)))& wordLengthMask;
                    }
                }
                else
                {
                    return 0;
                }
            }
            else
            {
                ulong fxpRepresentation = (ulong)(data / delta);
                if ((fxpRepresentation & wordLengthMask) == fxpRepresentation)
                {
                    return fxpRepresentation;
                }
                else /* maxmimum */
                {
                    byte magnitude = (byte)(typeInfo.wordLength - (typeInfo.isSigned? 1 : 0));
                    return (ulong)(1 << magnitude) - 1;
                }
            }
        }
        const int DBL_MANT_DIG = 53;
        const double DBL_EPSILON = 2.2204460492503131e-016;
        const long DBL_EXP_MASK = 0x7ff0000000000000L;
        const int DBL_MANT_BITS = 52;
        const long DBL_MANT_MASK = 0x000fffffffffffffL;
        const long DBL_SGN_MASK = -1 - 0x7fffffffffffffffL;
        const long DBL_EXP_CLR_MASK = DBL_SGN_MASK | DBL_MANT_MASK;
        const float FLT_EPSILON =1.192092896e-07F;
        const int FLT_MANT_DIG = 24;
        public static double ldexp(double number, long exponent)
        {
            long bits = System.BitConverter.DoubleToInt64Bits(number);
            int exp = (int)((bits & DBL_EXP_MASK) >> DBL_MANT_BITS);
            // Check for infinity or NaN.
            if (exp == 0x7ff)
                return number;
            // Check for 0 or subnormal.
            if (exp == 0)
            {
                // Check for 0.
                if ((bits & DBL_MANT_MASK) == 0)
                    return number;
                // Subnormal, scale number so that it is in [1, 2).
                number *= System.BitConverter.Int64BitsToDouble(0x4350000000000000L); // 2^54
                bits = System.BitConverter.DoubleToInt64Bits(number);
                exp = (int)((bits & DBL_EXP_MASK) >> DBL_MANT_BITS) - 54;
            }
            // Check for underflow.
            if (exponent < -50000)
                return Math.CopySign(0D, number);
            // Check for overflow.
            if (exponent > 50000 || (long)exp + exponent > 0x7feL)
                return Math.CopySign(System.Double.PositiveInfinity, number);
            exp += (int)exponent;
            // Check for normal.
            if (exp > 0)
                return System.BitConverter.Int64BitsToDouble((bits & DBL_EXP_CLR_MASK) | ((long)exp << DBL_MANT_BITS));
            // Check for underflow.
            if (exp <= -54)
                return Math.CopySign(0D, number);
            // Subnormal.
            exp += 54;
            
            number = System.BitConverter.Int64BitsToDouble((bits & DBL_EXP_CLR_MASK) | ((long)exp << DBL_MANT_BITS));
            return number * System.BitConverter.Int64BitsToDouble(0x3c90000000000000L); // 2^-54
        }


		public delegate NiFpga_Status NiFpgaDll_Open([System.Runtime.InteropServices.InAttribute()][System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string bitfile, [System.Runtime.InteropServices.InAttribute()][System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string signature, [System.Runtime.InteropServices.InAttribute()][System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string resource, NiFpga_OpenAttribute attribute, ref uint session);
        public delegate NiFpga_Status NiFpgaDll_Finalize();
        public delegate NiFpga_Status NiFpgaDll_Close(uint session, NiFpga_CloseAttribute attribute);
        public delegate NiFpga_Status NiFpgaDll_Run(uint session, NiFpga_RunAttribute attribute);
        public delegate NiFpga_Status NiFpgaDll_Abort(uint session);
        public delegate NiFpga_Status NiFpgaDll_Reset(uint session);
        public delegate NiFpga_Status NiFpgaDll_Download(uint session);
        public delegate NiFpga_Status NiFpgaDll_ReadBool(uint session, uint indicator, ref byte value);
        public delegate NiFpga_Status NiFpgaDll_ReadI8(uint session, uint indicator, ref sbyte value);
        public delegate NiFpga_Status NiFpgaDll_ReadU8(uint session, uint indicator, ref byte value);
        public delegate NiFpga_Status NiFpgaDll_ReadI16(uint session, uint indicator, ref short value); 
        public delegate NiFpga_Status NiFpgaDll_ReadU16(uint session, uint indicator, ref ushort value);
        public delegate NiFpga_Status NiFpgaDll_ReadI32(uint session, uint indicator, ref int value);
        public delegate NiFpga_Status NiFpgaDll_ReadU32(uint session, uint indicator, ref uint value);
        public delegate NiFpga_Status NiFpgaDll_ReadI64(uint session, uint indicator, ref long value);
        public delegate NiFpga_Status NiFpgaDll_ReadU64(uint session, uint indicator, ref ulong value);

        public delegate NiFpga_Status NiFpgaDll_ReadSgl(uint session, uint indicator, ref float value);
        public delegate NiFpga_Status NiFpgaDll_ReadDbl(uint session, uint indicator, ref double value);
        public delegate NiFpga_Status NiFpgaDll_WriteBool(uint session, uint control, byte value);
        public delegate NiFpga_Status NiFpgaDll_WriteI8(uint session, uint control, sbyte value);
        public delegate NiFpga_Status NiFpgaDll_WriteU8(uint session, uint control, byte value);
        public delegate NiFpga_Status NiFpgaDll_WriteI16(uint session, uint control, short value);
        public delegate NiFpga_Status NiFpgaDll_WriteU16(uint session, uint control, ushort value);
        public delegate NiFpga_Status NiFpgaDll_WriteI32(uint session, uint control, int value);
        public delegate NiFpga_Status NiFpgaDll_WriteU32(uint session, uint control, uint value);
        public delegate NiFpga_Status NiFpgaDll_WriteI64(uint session, uint control, long value);

        public delegate NiFpga_Status NiFpgaDll_WriteU64(uint session, uint control, ulong value);
        public delegate NiFpga_Status NiFpgaDll_WriteSgl(uint session, uint control, float value);
        public delegate NiFpga_Status NiFpgaDll_WriteDbl(uint session, uint control, double value);
        public delegate NiFpga_Status NiFpgaDll_ReadArrayBool(uint session, uint indicator, ref byte array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReadArrayI8(uint session, uint indicator, ref sbyte array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReadArrayU8(uint session, uint indicator, ref byte array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size); 
        public delegate NiFpga_Status NiFpgaDll_ReadArrayI16(uint session, uint indicator, ref short array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReadArrayU16(uint session, uint indicator, ref ushort array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReadArrayI32(uint session, uint indicator, ref int array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReadArrayU32(uint session, uint indicator, ref uint array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReadArrayI64(uint session, uint indicator, ref long array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReadArrayU64(uint session, uint indicator, ref ulong array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReadArraySgl(uint session, uint indicator, ref float array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReadArrayDbl(uint session, uint indicator, ref double array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArrayBool(uint session, uint control, ref byte array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);

        public delegate NiFpga_Status NiFpgaDll_WriteArrayI8(uint session, uint control, ref sbyte array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArrayU8(uint session, uint control, ref byte array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArrayI16(uint session, uint control, ref short array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArrayU16(uint session, uint control, ref ushort array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArrayI32(uint session, uint control, ref int array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArrayU32(uint session, uint control, ref uint array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArrayI64(uint session, uint control, ref long array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArrayU64(uint session, uint control, ref ulong array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArraySgl(uint session, uint control, ref float array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_WriteArrayDbl(uint session, uint control, ref double array, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint size);
        public delegate NiFpga_Status NiFpgaDll_ReserveIrqContext(uint session, ref System.IntPtr context);
        public delegate NiFpga_Status NiFpgaDll_UnreserveIrqContext(uint session, System.IntPtr context);
        public delegate NiFpga_Status NiFpgaDll_WaitOnIrqs(uint session, System.IntPtr context, NiFpga_Irq irqs, uint timeout, ref uint irqsAsserted, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.I1)] ref bool timedOut);
        public delegate NiFpga_Status NiFpgaDll_AcknowledgeIrqs(uint session, NiFpga_Irq irqs);
        public delegate NiFpga_Status NiFpgaDll_ConfigureFifo(uint session, uint fifo, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint depth);
        public delegate NiFpga_Status NiFpgaDll_ConfigureFifo2(uint session, uint fifo, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint requestedDepth, ref uint actualDepth);
        public delegate NiFpga_Status NiFpgaDll_SetFifoPropertyU32(uint session, uint fifo, NiFpga_FifoProperty property, uint value);
        public delegate NiFpga_Status NiFpgaDll_SetFifoPropertyI32(uint session, uint fifo, NiFpga_FifoProperty property, int value);
        public delegate NiFpga_Status NiFpgaDll_SetFifoPropertyU64(uint session, uint fifo, NiFpga_FifoProperty property, ulong value);
        public delegate NiFpga_Status NiFpgaDll_SetFifoPropertyI64(uint session, uint fifo, NiFpga_FifoProperty property, long value); 
        public delegate NiFpga_Status NiFpgaDll_SetFifoPropertyPtr(uint session, uint fifo, NiFpga_FifoProperty property, IntPtr value);
        public delegate NiFpga_Status NiFpgaDll_GetFifoPropertyU32(uint session, uint fifo, NiFpga_FifoProperty property, ref uint value);
        public delegate NiFpga_Status NiFpgaDll_GetFifoPropertyI32(uint session, uint fifo, NiFpga_FifoProperty property, ref int value);
        public delegate NiFpga_Status NiFpgaDll_GetFifoPropertyU64(uint session, uint fifo, NiFpga_FifoProperty property, ref ulong value);
        public delegate NiFpga_Status NiFpgaDll_GetFifoPropertyI64(uint session, uint fifo, NiFpga_FifoProperty property, ref long value);
        public delegate NiFpga_Status NiFpgaDll_GetFifoPropertyPtr(uint session, uint fifo, NiFpga_FifoProperty property, ref IntPtr value);
        public delegate NiFpga_Status NiFpgaDll_CommitFifoConfiguration(uint session, uint fifo);
        public delegate NiFpga_Status NiFpgaDll_StartFifo(uint session, uint fifo);
        public delegate NiFpga_Status NiFpgaDll_StopFifo(uint session, uint fifo);
        public delegate NiFpga_Status NiFpgaDll_UnreserveFifo(uint session, uint fifo);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoBool(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoI8(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoU8(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoI16(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoU16(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoI32(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoU32(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoI64(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoU64(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoSgl(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoDbl(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReadFifoComposite(uint session, uint fifo, ref byte data, uint bytesPerElement, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoBool(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoI8(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoU8(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoI16(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoU16(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoI32(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoU32(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoI64(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoU64(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoSgl(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoDbl(uint session, uint fifo, ref byte data, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_WriteFifoComposite(uint session, uint fifo, ref byte data, uint bytesPerElement, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint numberOfElements, uint timeout, ref uint emptyElementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsBool(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsI8(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsU8(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsI16(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsU16(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsI32(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsI64(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsU64(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsSgl(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoReadElementsDbl(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsBool(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsI8(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsU8(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsI16(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsU16(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsI32(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsU32(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsI64(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsU64(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsSgl(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_AcquireFifoWriteElementsDbl(uint session, uint fifo, ref System.IntPtr elements, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elementsRequested, uint timeout, ref uint elementsAcquired, ref uint elementsRemaining);
        public delegate NiFpga_Status NiFpgaDll_ReleaseFifoElements(uint session, uint fifo, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U4)] uint elements);
        public delegate NiFpga_Status NiFpgaDll_GetPeerToPeerFifoEndpoint(uint session, uint fifo, ref uint endpoint);

    }
}
