예제 #1
0
        //---------------------------------------------------------------------------
        //
        // Function    :  DisplayBoardInfo
        //
        // Description :  Display information about a board
        //
        //---------------------------------------------------------------------------

        static public unsafe bool DisplayBoardInfo(UInt32 systemId, UInt32 boardId)
        {
            UInt32 retCode;

            IntPtr handle = AlazarAPI.AlazarGetBoardBySystemID(systemId, boardId);

            if (handle == IntPtr.Zero)
            {
                Console.WriteLine("Error: Open systemId {0} boardId {1} failed", systemId, boardId);
                return(false);
            }

            UInt32 samplesPerChannel;
            byte   bitsPerSample;

            retCode = AlazarAPI.AlazarGetChannelInfo(handle, &samplesPerChannel, &bitsPerSample);
            if (retCode != AlazarAPI.ApiSuccess)
            {
                Console.WriteLine("Error: AlazarGetChannelInfo failed -- " +
                                  AlazarAPI.AlazarErrorToText(retCode));
                return(false);
            }

            UInt32 aspocType;

            retCode = AlazarAPI.AlazarQueryCapability(handle, AlazarAPI.ASOPC_TYPE, 0, &aspocType);
            if (retCode != AlazarAPI.ApiSuccess)
            {
                Console.WriteLine("Error: AlazarQueryCapability failed -- " +
                                  AlazarAPI.AlazarErrorToText(retCode));
                return(false);
            }

            byte cpldMajor;
            byte cpldMinor;

            retCode = AlazarAPI.AlazarGetCPLDVersion(handle, &cpldMajor, &cpldMinor);
            if (retCode != AlazarAPI.ApiSuccess)
            {
                Console.WriteLine("Error: AlazarGetCPLDVersion failed -- " +
                                  AlazarAPI.AlazarErrorToText(retCode));
                return(false);
            }

            UInt32 serialNumber;

            retCode = AlazarAPI.AlazarQueryCapability(handle, AlazarAPI.GET_SERIAL_NUMBER, 0, &serialNumber);
            if (retCode != AlazarAPI.ApiSuccess)
            {
                Console.WriteLine("Error: AlazarQueryCapability failed -- " +
                                  AlazarAPI.AlazarErrorToText(retCode));
                return(false);
            }

            UInt32 latestCalDate;

            retCode = AlazarAPI.AlazarQueryCapability(handle, AlazarAPI.GET_LATEST_CAL_DATE, 0, &latestCalDate);
            if (retCode != AlazarAPI.ApiSuccess)
            {
                Console.WriteLine("Error: AlazarQueryCapability failed -- " +
                                  AlazarAPI.AlazarErrorToText(retCode));
                return(false);
            }

            Console.WriteLine("System ID                 = {0}", systemId);
            Console.WriteLine("Board ID                  = {0}", boardId);
            Console.WriteLine("Serial number             = {0}", serialNumber);
            Console.WriteLine("Bits per sample           = {0}", bitsPerSample);
            Console.WriteLine("Max samples per channel   = {0}", samplesPerChannel);
            Console.WriteLine("CPLD version              = {0}.{1}", cpldMajor, cpldMinor);
            Console.WriteLine("FPGA version              = {0}", (aspocType >> 16) & 0xff, (aspocType >> 24) & 0xf);
            Console.WriteLine("ASoPC signature           = {0}", aspocType);
            Console.WriteLine("Latest calibration date   = {0}", latestCalDate);

            if (IsPcieDevice(handle))
            {
                // Display PCI Express link information

                UInt32 linkSpeed;
                retCode = AlazarAPI.AlazarQueryCapability(handle, AlazarAPI.GET_PCIE_LINK_SPEED, 0, &linkSpeed);
                if (retCode != AlazarAPI.ApiSuccess)
                {
                    Console.WriteLine("Error: AlazarQueryCapability failed -- " +
                                      AlazarAPI.AlazarErrorToText(retCode));
                    return(false);
                }

                UInt32 linkWidth;
                retCode = AlazarAPI.AlazarQueryCapability(handle, AlazarAPI.GET_PCIE_LINK_WIDTH, 0, &linkWidth);
                if (retCode != AlazarAPI.ApiSuccess)
                {
                    Console.WriteLine("Error: AlazarQueryCapability failed -- " +
                                      AlazarAPI.AlazarErrorToText(retCode));
                    return(false);
                }

                Console.WriteLine("PCIe link speed           = {0} Gbps", 2.5 * linkSpeed);
                Console.WriteLine("PCIe link width           = {0} lanes", linkWidth);
            }

            Console.WriteLine("");

            // Toggling the LED on the PCIe/PCIe mounting bracket of the board

            int cycleCount     = 2;
            int cyclePeriod_ms = 200;

            if (!FlashLed(handle, cycleCount, cyclePeriod_ms))
            {
                return(false);
            }

            return(true);
        }