Esempio n. 1
0
        public void MoveIn32(short bar, long barOffset, Int32[] data, int numToRead)
        {
            int error = AgVisa32.viMoveIn32(mSession,
                                            bar,
                                            (int)barOffset,
                                            numToRead,
                                            data);

            if (error < 0)
            {
                AgVisa32Exception.Throw(error);
            }
        }
Esempio n. 2
0
        public void MoveIn8PageAligned(short bar, long barOffset, int numBytesToRead, byte[] inData, int offset)
        {
            IntPtr inArrayUnmanaged = (IntPtr)0;

            lock ( mVirtualMemoryLock )
            {
                int num32BitWords = numBytesToRead / 4;
                if ((numBytesToRead & 0x3) != 0)
                {
                    num32BitWords++;
                }

                if (mVirtualMemorySize < num32BitWords)
                {
                    // Need more memory ... release the current memory
                    if (mVirtualMemory != (IntPtr)0)
                    {
                        VirtualFree(mVirtualMemory, (UIntPtr)0, (uint)MemoryFreeType.MEM_RELEASE);
                    }

                    // NOTE: this allocation allocates memory in units of pages. It is
                    // assumed that the pages are evenly divisible by 8 bytes.
                    mVirtualMemory = VirtualAlloc((IntPtr)null,
                                                  (UIntPtr)(num32BitWords * sizeof(int)),
                                                  AllocationType.COMMIT,
                                                  MemoryProtection.READWRITE);
                    if (mVirtualMemory == (IntPtr)0)
                    {
                        mVirtualMemorySize = 0;
                        AgVisa32Exception.Throw(AgVisa32.VI_ERROR_ALLOC);
                    }
                    mVirtualMemorySize = num32BitWords;
                }

                int error = AgVisa32.viMoveIn32(mSession,
                                                bar,
                                                (int)barOffset,
                                                num32BitWords,
                                                inArrayUnmanaged);

                if (error < 0)
                {
                    AgVisa32Exception.Throw(error);
                }

                Marshal.Copy(inArrayUnmanaged, inData, offset, numBytesToRead);
            }
        }
Esempio n. 3
0
        public Int32[] MoveIn32(short bar, long barOffset, int numToRead)
        {
            Int32[] buf32 = new Int32[numToRead];
            int     error = AgVisa32.viMoveIn32(mSession,
                                                bar,
                                                (int)barOffset,
                                                numToRead,
                                                buf32);

            if (error < 0)
            {
                AgVisa32Exception.Throw(error);
            }

            return(buf32);
        }
Esempio n. 4
0
        public Int32[] MoveIn32PageAligned(short bar, long barOffset, int numToRead)
        {
            Int32[] inArray;

            lock ( mVirtualMemoryLock )
            {
                if (mVirtualMemorySize < numToRead)
                {
                    // Need more memory ... release the current memory
                    if (mVirtualMemory != (IntPtr)0)
                    {
                        VirtualFree(mVirtualMemory, (UIntPtr)0, (uint)MemoryFreeType.MEM_RELEASE);
                    }

                    // NOTE: this allocation allocates memory in units of pages. It is
                    // assumed that the pages are evenly divisible by 8 bytes.
                    mVirtualMemory = VirtualAlloc((IntPtr)null,
                                                  (UIntPtr)(numToRead * sizeof(int)),
                                                  AllocationType.COMMIT,
                                                  MemoryProtection.READWRITE);
                    if (mVirtualMemory == (IntPtr)0)
                    {
                        mVirtualMemorySize = 0;
                        AgVisa32Exception.Throw(AgVisa32.VI_ERROR_ALLOC);
                    }
                    mVirtualMemorySize = numToRead;
                }

                int error = AgVisa32.viMoveIn32(mSession,
                                                bar,
                                                (int)barOffset,
                                                numToRead,
                                                mVirtualMemory);

                if (error < 0)
                {
                    AgVisa32Exception.Throw(error);
                }

                inArray = new Int32[numToRead];
                Marshal.Copy(mVirtualMemory, inArray, 0, numToRead);
            }

            return(inArray);
        }