コード例 #1
0
        public static bool VLFD_AppFIFOReadData(int iBoard, Span <ushort> Buffer)
        {
            var p = Marshal.AllocHGlobal(Marshal.SizeOf <ushort>() * Buffer.Length);
            var r = NativeExtension.Get().NativeMethods.VLFD_AppFIFOReadData_init(iBoard, p, (uint)Buffer.Length);

            unsafe
            {
                var buf = new Span <ushort>(p.ToPointer(), Buffer.Length);
                buf.CopyTo(Buffer);
            }
            Marshal.FreeHGlobal(p);
            return(r);
        }
コード例 #2
0
 /// <summary>
 /// Gets singleton instance of this class.
 /// The native extension is loaded when called for the first time.
 /// </summary>
 public static NativeExtension Get()
 {
     if (instance == null)
     {
         lock (staticLock)
         {
             if (instance == null)
             {
                 instance = new NativeExtension();
             }
         }
     }
     return(instance);
 }
コード例 #3
0
        public static bool VLFD_IO_WriteReadData(int iBoard, Span <ushort> WriteBuffer, Span <ushort> ReadBuffer)
        {
            var writebufpointer = Marshal.AllocHGlobal(Marshal.SizeOf <ushort>() * WriteBuffer.Length);
            var readbufpointer  = Marshal.AllocHGlobal(Marshal.SizeOf <ushort>() * ReadBuffer.Length);

            unsafe
            {
                var writebuf = new Span <ushort>(writebufpointer.ToPointer(), WriteBuffer.Length);
                WriteBuffer.CopyTo(writebuf);

                var readbuf = new Span <ushort>(readbufpointer.ToPointer(), ReadBuffer.Length);
                var r       = NativeExtension.Get().NativeMethods.VLFD_IO_WriteReadData_init(iBoard, writebufpointer, readbufpointer, (uint)ReadBuffer.Length);

                readbuf.CopyTo(ReadBuffer);

                Marshal.FreeHGlobal(writebufpointer);
                Marshal.FreeHGlobal(readbufpointer);

                return(r);
            }
        }
コード例 #4
0
        // Signatures of native methods are generated from a template
        // and can be found in NativeMethods.Generated.cs

        /// <summary>
        /// Gets singleton instance of this class.
        /// </summary>
        public static NativeMethods Get()
        {
            return(NativeExtension.Get().NativeMethods);
        }
コード例 #5
0
        public static string VLFD_GetLastErrorMsg(int iBoard)
        {
            var p = NativeExtension.Get().NativeMethods.VLFD_GetLastErrorMsg_init(iBoard);

            return(Marshal.PtrToStringAnsi(p));
        }
コード例 #6
0
 public static bool VLFD_IO_Close(int iBoard) => NativeExtension.Get().NativeMethods.VLFD_IO_Close_init(iBoard);
コード例 #7
0
 public static bool VLFD_AppChannelSelector(int iBoard, byte channel) => NativeExtension.Get().NativeMethods.VLFD_AppChannelSelector_init(iBoard, channel);
コード例 #8
0
 public static bool VLFD_IO_Open(int iBoard, string SerialNO) => NativeExtension.Get().NativeMethods.VLFD_IO_Open_init(iBoard, SerialNO);
コード例 #9
0
 public static bool VLFD_ProgramFPGA(int iBoard, string BitFile) => NativeExtension.Get().NativeMethods.VLFD_ProgramFPGA_init(iBoard, BitFile);