Пример #1
0
    /*
     * PhxCommonDefaultConfig()
     * Create a default file name (including relative path) for a Config File.
     * This is built up using pre-defined strings for the file name,
     * relative path, and if necessary absolute path to the current directory.
     * If the default file cannot be opened, it is set to NULL.
     */
    public Phx.etStat PhxCommonDefaultConfig(
        ref tPhxCmd ptPhxCmd /* Structure containing parsed information */
        )
    {
        String strPcfFile;

        Phx.etStat eStat = Phx.etStat.PHX_OK;

        /* The default config file is in the examples directory not in the directory containing the executable.
         * This is calculated as a relative path from the application directory.
         */
        strPcfFile = DEFAULT_UP_DIR + DEFAULT_CFG_FILENAME;

        if (!File.Exists(strPcfFile))
        {
            strPcfFile = DEFAULT_UP_DIR_CXP_OLD + DEFAULT_CFG_FILENAME;
            if (!File.Exists(strPcfFile))
            {
                strPcfFile = DEFAULT_UP_DIR_CL_OLD + DEFAULT_CFG_FILENAME;
                if (!File.Exists(strPcfFile))
                {
                    strPcfFile = "";
                }
            }
        }

        ptPhxCmd.strConfigFileName = strPcfFile;

        return(eStat);
    }
Пример #2
0
    /*
     * PhxCommonDisplayErrorHandler()
     * Handles errors from display library.
     */
    public void PhxCommonDisplayErrorHandler(
        String strFnName,        /* Function name */
        Phx.etStat eErrCode,     /* Error code */
        String strDescString     /* Error description */
        )
    {
        String strErrorMessage = String.Format("{0} failed with error code {1:x}.\n", strFnName, eErrCode);

        if (strDescString.Length > 0)
        {
            String.Concat(strErrorMessage, strDescString);
        }
        Console.WriteLine("{0}", strErrorMessage);
    }
Пример #3
0
    /*
     * PhxCommonWriteCxpReg()
     * Write to a 32 bit CXP register in camera.
     */
    public unsafe Phx.etStat PhxCommonWriteCxpReg(
        uint hCamera,   /* PHX handle */
        uint dwAddress, /* Address of the camera register */
        uint dwValue,   /* Value to write */
        uint dwTimeout  /* Timeout for operation */
        )
    {
        Phx.etStat eStat  = Phx.etStat.PHX_OK;
        uint       dwSize = sizeof(uint);

        dwValue = htonl(dwValue);

        eStat = Phx.PHX_ControlWrite(hCamera, Phx.etControlPort.PHX_REGISTER_DEVICE, ref dwAddress, ref dwValue, ref dwSize, dwTimeout);
        return(eStat);
    }
Пример #4
0
    /*
     * PhxCommonGetCxpDiscoveryStatus()
     * Checks if CXP camera is discovered.
     */
    public Phx.etStat PhxCommonGetCxpDiscoveryStatus(
        uint hCamera,
        uint dwTimeoutSec,
        ref bool fIsDiscovered
        )
    {
        Phx.etStat eStat   = Phx.etStat.PHX_OK;
        uint       dwIndex = 0;

        Console.WriteLine("Checking for CXP camera discovery...");

        fIsDiscovered = false;
        while (dwIndex++ < dwTimeoutSec * 2) /* Sleep between two attempts is only 500 ms */
        {
            Phx.etCxpInfo eDiscoveryStatus = 0;
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_CXP_INFO, ref eDiscoveryStatus);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Exit;
            }
            if ((int)Phx.etCxpInfo.PHX_CXP_CAMERA_DISCOVERED == ((int)eDiscoveryStatus & (int)(Phx.etCxpInfo.PHX_CXP_CAMERA_DISCOVERED)))
            {
                fIsDiscovered = true;
                break;
            }

            Console.Write(".");

            System.Threading.Thread.Sleep(500);
        }
        Console.WriteLine("");

        if (fIsDiscovered)
        {
            Console.WriteLine("CXP camera is discovered.");
        }
        else
        {
            Console.WriteLine("CXP camera was not discovered.");
        }

Exit:
        return(eStat);
    }
Пример #5
0
        /*
         * phxlive()
         * Simple live capture application code, using image conversion in order to reduce
         * the amount of PCI bandwidth used.
         */
        unsafe static int phxlive(
            Phx.etParamValue eBoardNumber,            /* Board number, i.e. 1, 2, or 0 for next available */
            Phx.etParamValue eChannelNumber,          /* Channel number */
            String strConfigFileName,                 /* Name of config file */
            PhxCommon.tCxpRegisters sCameraRegs       /* Camera CXP registers */
            )
        {
            Phx.etStat          eStat             = Phx.etStat.PHX_OK;           /* Status variable */
            Phx.etParamValue    eAcqType          = 0;                           /* Parameter for use with PHX_ParameterSet/Get calls */
            Pbl.etPblParamValue eBayCol           = 0;
            Phx.etParamValue    eParamValue       = 0;
            Pbl.etPblParamValue ePblCaptureFormat = 0;
            Phx.etParamValue    eCamSrcCol        = 0;
            Phx.etParamValue    eCaptureFormat    = Phx.etParamValue.PHX_BUS_FORMAT_MONO8;
            Phx.etParamValue    eCamFormat        = 0;
            uint      dwBufferReadyLast           = 0;                           /* Previous BufferReady count value */
            IntPtr    pParamValue = IntPtr.Zero;
            IntPtr    pConfigFile = IntPtr.Zero;
            PhxCommon myPhxCommon = new PhxCommon();

            Phx.PHX_AcquireCallBack PHX_Callback   = new Phx.PHX_AcquireCallBack(phxlive_callback);
            Phx.stImageBuff[]       asImageBuffers = null;                       /* Capture buffer array */
            uint[]   ahCaptureBuffers = null;                                    /* Capture buffer handle array */
            tPhxLive sPhxLive;                                                   /* User defined event context */
            uint     hCamera                = 0;                                 /* Camera handle */
            uint     hDisplay               = 0;                                 /* Display handle */
            uint     hDisplayBuffer         = 0;                                 /* Display buffer handle */
            uint     dwAcqNumBuffers        = 0;
            uint     dwBufferWidth          = 0;
            uint     dwBufferHeight         = 0;
            uint     dwBufferStride         = 0;
            uint     dwCamSrcDepth          = 0;
            bool     fDebayer               = false;
            bool     fCameraIsCxp           = false;
            bool     fIsCxpCameraDiscovered = false;


            /* Create a Phx handle */
            eStat = Phx.PHX_Create(ref hCamera, Phx.PHX_ErrHandlerDefault);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Set the configuration file name */
            if (!String.IsNullOrEmpty(strConfigFileName))
            {
                pConfigFile = Marshal.UnsafeAddrOfPinnedArrayElement(PhxCommon.GetBytesFromString(strConfigFileName), 0);
                eStat       = Phx.PHX_ParameterSet(hCamera, Phx.etParam.PHX_CONFIG_FILE, ref pConfigFile);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    goto Error;
                }
            }

            /* Set the board number */
            eStat = Phx.PHX_ParameterSet(hCamera, Phx.etParam.PHX_BOARD_NUMBER, ref eBoardNumber);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Set the channel number */
            eStat = Phx.PHX_ParameterSet(hCamera, Phx.etParam.PHX_CHANNEL_NUMBER, ref eChannelNumber);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Open the board using the above configuration file */
            eStat = Phx.PHX_Open(hCamera);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Read various parameter values in order to generate the capture buffers. */
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_ROI_XLENGTH, ref dwBufferWidth);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_ROI_YLENGTH, ref dwBufferHeight);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_CAM_SRC_DEPTH, ref dwCamSrcDepth);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_CAM_SRC_COL, ref eCamSrcCol);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_BUS_FORMAT, ref eCaptureFormat);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_CAM_FORMAT, ref eCamFormat);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_ACQ_FIELD_MODE, ref eAcqType);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_ACQ_NUM_BUFFERS, ref dwAcqNumBuffers);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Interlaced Camera in Field Mode */
            if (Phx.etParamValue.PHX_CAM_INTERLACED == eCamFormat &&
                (Phx.etParamValue.PHX_ACQ_FIELD_12 == eAcqType ||
                 Phx.etParamValue.PHX_ACQ_FIELD_21 == eAcqType ||
                 Phx.etParamValue.PHX_ACQ_FIELD_NEXT == eAcqType ||
                 Phx.etParamValue.PHX_ACQ_FIELD_1 == eAcqType ||
                 Phx.etParamValue.PHX_ACQ_FIELD_2 == eAcqType))
            {
                dwBufferHeight /= 2;
            }

            /* Determine PHX_BUS_FORMAT based on the camera format */
            eStat = myPhxCommon.PhxCommonGetBusFormat(eCamSrcCol, dwCamSrcDepth, eCaptureFormat, ref eCaptureFormat);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Determine bayer format */
            fDebayer = true;
            if (Phx.etParamValue.PHX_CAM_SRC_BAYER_BG == eCamSrcCol)
            {
                eBayCol = Pbl.etPblParamValue.PBL_BAY_COL_BLU;
            }
            else if (Phx.etParamValue.PHX_CAM_SRC_BAYER_GB == eCamSrcCol)
            {
                eBayCol = Pbl.etPblParamValue.PBL_BAY_COL_GRNB;
            }
            else if (Phx.etParamValue.PHX_CAM_SRC_BAYER_GR == eCamSrcCol)
            {
                eBayCol = Pbl.etPblParamValue.PBL_BAY_COL_GRNR;
            }
            else if (Phx.etParamValue.PHX_CAM_SRC_BAYER_RG == eCamSrcCol)
            {
                eBayCol = Pbl.etPblParamValue.PBL_BAY_COL_RED;
            }
            else
            {
                fDebayer = false;
            }

            /* Update the PHX_BUS_FORMAT, as it may have changed (above) */
            eStat = Phx.PHX_ParameterSet(hCamera, (Phx.etParam.PHX_BUS_FORMAT | Phx.etParam.PHX_CACHE_FLUSH), ref eCaptureFormat);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Read back the Buffer Stride */
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_BUF_DST_XLENGTH, ref dwBufferStride);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Init the array of capture buffer handles */
            ahCaptureBuffers = new uint[dwAcqNumBuffers];

            /* Init the array of image buffers */
            asImageBuffers = new Phx.stImageBuff[dwAcqNumBuffers + 1];

            /* Create and initialise our capture buffers (not associated with display) */
            for (int i = 0; i < dwAcqNumBuffers; i++)
            {
                /* We create a capture buffer for our double buffering */
                eStat = Pbl.PBL_BufferCreate(ref ahCaptureBuffers[i], Pbl.etPblBufferMode.PBL_BUFF_SYSTEM_MEM_DIRECT, 0, hCamera, myPhxCommon.PhxCommonDisplayErrorHandler);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    goto Error;
                }

                /* Initialise our capture buffer */
                eStat = Pbl.PBL_BufferParameterSet(ahCaptureBuffers[i], Pbl.etPblParam.PBL_BUFF_WIDTH, ref dwBufferWidth);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    goto Error;
                }
                eStat = Pbl.PBL_BufferParameterSet(ahCaptureBuffers[i], Pbl.etPblParam.PBL_BUFF_HEIGHT, ref dwBufferHeight);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    goto Error;
                }
                eStat = Pbl.PBL_BufferParameterSet(ahCaptureBuffers[i], Pbl.etPblParam.PBL_BUFF_STRIDE, ref dwBufferStride);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    goto Error;
                }
                ePblCaptureFormat = (Pbl.etPblParamValue)eCaptureFormat;
                eStat             = Pbl.PBL_BufferParameterSet(ahCaptureBuffers[i], Pbl.etPblParam.PBL_DST_FORMAT, ref ePblCaptureFormat);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    goto Error;
                }
                eStat = Pbl.PBL_BufferInit(ahCaptureBuffers[i]);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    goto Error;
                }

                /* Set up the type of Bayer conversion required */
                if (fDebayer)
                {
                    Pbl.etPblParamValue ePblParamValue = Pbl.etPblParamValue.PBL_BAY_DEC_DUP;
                    eStat = Pbl.PBL_BufferParameterSet(ahCaptureBuffers[i], Pbl.etPblParam.PBL_BUFF_BAYDEC, ref ePblParamValue);
                    if (Phx.etStat.PHX_OK != eStat)
                    {
                        goto Error;
                    }
                    eStat = Pbl.PBL_BufferParameterSet(ahCaptureBuffers[i], Pbl.etPblParam.PBL_BUFF_BAYCOL, ref eBayCol);
                    if (Phx.etStat.PHX_OK != eStat)
                    {
                        goto Error;
                    }
                }

                /* Build up our array of capture buffers */
                Pbl.PBL_BufferParameterGet(ahCaptureBuffers[i], Pbl.etPblParam.PBL_BUFF_ADDRESS, ref asImageBuffers[i].pvAddress);
                asImageBuffers[i].pvContext = (IntPtr)ahCaptureBuffers[i];
            }
            /* Terminate the array */
            asImageBuffers[dwAcqNumBuffers].pvAddress = System.IntPtr.Zero;
            asImageBuffers[dwAcqNumBuffers].pvContext = System.IntPtr.Zero;

            /* The above code has created dwAcqNumBuffers acquisition buffers.
             * Therefore ensure that the Phoenix is configured to use this number, by overwriting
             * the value already loaded from the config file.
             */
            eStat = Phx.PHX_ParameterSet(hCamera, Phx.etParam.PHX_ACQ_NUM_BUFFERS, ref dwAcqNumBuffers);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* These are 'direct' buffers, so we must tell Phoenix about them
             * so that it can capture data directly into them.
             */
            eStat = Phx.PHX_ParameterSet(hCamera, Phx.etParam.PHX_BUF_DST_XLENGTH, ref dwBufferStride);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eStat = Phx.PHX_ParameterSet(hCamera, Phx.etParam.PHX_BUF_DST_YLENGTH, ref dwBufferHeight);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eStat = Phx.PHX_ParameterSet(hCamera, Phx.etParam.PHX_DST_PTRS_VIRT, asImageBuffers);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            eParamValue = Phx.etParamValue.PHX_DST_PTR_USER_VIRT;
            eStat       = Phx.PHX_ParameterSet(hCamera, (Phx.etParam.PHX_DST_PTR_TYPE | Phx.etParam.PHX_CACHE_FLUSH | Phx.etParam.PHX_FORCE_REWRITE), ref eParamValue);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* We create our display with a NULL hWnd, this will automatically create an image window. */
            eStat = Pdl.PDL_DisplayCreate(ref hDisplay, IntPtr.Zero, hCamera, myPhxCommon.PhxCommonDisplayErrorHandler);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* We create a display buffer (indirect) */
            eStat = Pdl.PDL_BufferCreate(ref hDisplayBuffer, hDisplay, Pdl.etPdlBufferMode.PDL_BUFF_SYSTEM_MEM_INDIRECT);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Initialise the display, this associates the display buffer with the display */
            eStat = Pdl.PDL_DisplayInit(hDisplay);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Enable FIFO Overflow events */
            eParamValue = Phx.etParamValue.PHX_INTRPT_FIFO_OVERFLOW;
            eStat       = Phx.PHX_ParameterSet(hCamera, Phx.etParam.PHX_INTRPT_SET, ref eParamValue);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Setup our own event context */
            eStat = Phx.PHX_ParameterSet(hCamera, Phx.etParam.PHX_EVENT_CONTEXT, (void *)&sPhxLive);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Check if camera is CXP */
            eStat = Phx.PHX_ParameterGet(hCamera, Phx.etParam.PHX_BOARD_VARIANT, ref eParamValue);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }
            if (Phx.etParamValue.PHX_BOARD_FBD_4XCXP6_2PE8 == eParamValue ||
                Phx.etParamValue.PHX_BOARD_FBD_2XCXP6_2PE8 == eParamValue ||
                Phx.etParamValue.PHX_BOARD_FBD_1XCXP6_2PE8 == eParamValue)
            {
                fCameraIsCxp = true;
            }

            /* Check that camera is discovered (only applies to CXP) */
            if (fCameraIsCxp)
            {
                myPhxCommon.PhxCommonGetCxpDiscoveryStatus(hCamera, 10, ref fIsCxpCameraDiscovered);
                if (!fIsCxpCameraDiscovered)
                {
                    goto Error;
                }
            }

            /* Now start our capture, using the callback method */
            eStat = Phx.PHX_StreamRead(hCamera, Phx.etAcq.PHX_START, PHX_Callback);
            if (Phx.etStat.PHX_OK != eStat)
            {
                goto Error;
            }

            /* Now start camera */
            if (fCameraIsCxp && 0 != sCameraRegs.dwAcqStartAddress)
            {
                eStat = myPhxCommon.PhxCommonWriteCxpReg(hCamera, sCameraRegs.dwAcqStartAddress, sCameraRegs.dwAcqStartValue, 800);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    goto Error;
                }
            }

            /* Continue processing data until the user presses a key in the console window
             * or a FIFO overflow is detected.
             */
            Console.WriteLine("Press a key to exit");
            while (0 == myPhxCommon.PhxCommonKbHit())
            {
                /* Wait here until either:
                 * (a) The user aborts the wait by pressing a key in the console window
                 * (b) The BufferReady event occurs indicating that the image is complete
                 * (c) The FIFO overflow event occurs indicating that the image is corrupt
                 * Keep calling the sleep function to avoid burning CPU cycles
                 */
                while (0 == myPhxCommon.PhxCommonKbHit() && !sPhxLive.fBufferReady && !sPhxLive.fFifoOverflow)
                {
                    System.Threading.Thread.Sleep(10);
                }

                if (dwBufferReadyLast != sPhxLive.dwBufferReadyCount)
                {
                    uint dwStaleBufferCount;

                    /* If the processing is too slow to keep up with acquisition,
                     * then there may be more than 1 buffer ready to process.
                     * The application can either be designed to process all buffers
                     * knowing that it will catch up, or as here, throw away all but the
                     * latest
                     */
                    dwStaleBufferCount = sPhxLive.dwBufferReadyCount - dwBufferReadyLast;
                    dwBufferReadyLast += dwStaleBufferCount;

                    /* Throw away all but the last image */
                    if (1 < dwStaleBufferCount)
                    {
                        do
                        {
                            eStat = Phx.PHX_StreamRead(hCamera, Phx.etAcq.PHX_BUFFER_RELEASE, IntPtr.Zero);
                            if (Phx.etStat.PHX_OK != eStat)
                            {
                                goto Error;
                            }
                            dwStaleBufferCount--;
                        } while (dwStaleBufferCount > 1);
                    }
                }
                sPhxLive.fBufferReady = false;

                Phx.stImageBuff stBuffer;
                stBuffer.pvAddress = IntPtr.Zero;
                stBuffer.pvContext = IntPtr.Zero;

                /* Get the info for the last acquired buffer */
                eStat = Phx.PHX_StreamRead(hCamera, Phx.etAcq.PHX_BUFFER_GET, ref stBuffer);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    eStat = Phx.PHX_StreamRead(hCamera, Phx.etAcq.PHX_BUFFER_RELEASE, IntPtr.Zero);
                    if (Phx.etStat.PHX_OK != eStat)
                    {
                        goto Error;
                    }
                    continue;
                }

                /* Process the newly acquired buffer,
                 * which in this simple example is a call to display the data.
                 * For our display function we use the pvContext member variable to
                 * pass a display buffer handle.
                 * Alternatively the actual video data can be accessed at stBuffer.pvAddress
                 */
                byte[] wtf = new byte[4036608];
                Marshal.Copy(stBuffer.pvAddress, wtf, 0, 4036608);
                // Console.WriteLine(wtf[0].ToString());
                for (int i = 50000; i < 500000; i++)
                {
                    wtf[i] = 0;
                }
                Marshal.Copy(wtf, 0, stBuffer.pvAddress, 4036608);

                uint hBufferHandle = (uint)stBuffer.pvContext;

                /* This copies/converts data from the direct capture buffer to the indirect display buffer */
                eStat = Pil.PIL_Convert(hBufferHandle, hDisplayBuffer);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    eStat = Phx.PHX_StreamRead(hCamera, Phx.etAcq.PHX_BUFFER_RELEASE, IntPtr.Zero);
                    if (Phx.etStat.PHX_OK != eStat)
                    {
                        goto Error;
                    }
                    continue;
                }

                Pdl.PDL_BufferPaint(hDisplayBuffer);

                /* Having processed the data, release the buffer ready for further image data */
                eStat = Phx.PHX_StreamRead(hCamera, Phx.etAcq.PHX_BUFFER_RELEASE, IntPtr.Zero);
                if (Phx.etStat.PHX_OK != eStat)
                {
                    goto Error;
                }
            }

            /* In this simple example we abort the processing loop on an error condition (FIFO overflow).
             * However handling of this condition is application specific, and generally would involve
             * aborting the current acquisition, and then restarting.
             */
            if (sPhxLive.fFifoOverflow)
            {
                Console.WriteLine("FIFO Overflow detected. Aborting.");
            }

Error:
            /* Now cease all captures */
            if (0 != hCamera)
            {
                /* Stop camera */
                if (fIsCxpCameraDiscovered && 0 != sCameraRegs.dwAcqStopAddress)
                {
                    myPhxCommon.PhxCommonWriteCxpReg(hCamera, sCameraRegs.dwAcqStopAddress, sCameraRegs.dwAcqStopValue, 800);
                }
                /* Stop frame grabber */
                Phx.PHX_StreamRead(hCamera, Phx.etAcq.PHX_ABORT, IntPtr.Zero);
            }

            Console.WriteLine("Exiting");
            return(0);
        }
Пример #6
0
    /*
     * PhxCommonGetBusFormat()
     * Determine the PHX_BUS_FORMAT based on PHX_CAM_SRC_COL and PHX_CAM_SRC_DEPTH.
     */
    public Phx.etStat PhxCommonGetBusFormat(
        Phx.etParamValue ePhxCamSrcCol,       /* PHX_CAM_SRC_COL value */
        uint dwPhxCamSrcDepth,                /* PHX_CAM_SRC_DEPTH value */
        Phx.etParamValue ePhxBusFormatIn,     /* Current PHX_BUS_FORMAT value */
        ref Phx.etParamValue ePhxBusFormatOut /* PHX_BUS_FORMAT return value */
        )
    {
        Phx.etStat eStat       = Phx.etStat.PHX_OK;
        int        nBayerDepth = 0;

        /* Check if legacy PHX_DST_FORMAT_BAY value is being used, and replace it with new PHX_BUS_FORMAT_BAYER value if needed */
        if (Phx.etParamValue.PHX_DST_FORMAT_BAY8 == ePhxBusFormatIn)
        {
            switch (ePhxCamSrcCol)
            {
            case Phx.etParamValue.PHX_CAM_SRC_BAYER_RG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG8; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GR: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR8; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GB: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB8; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_BG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG8; break;

            default: break;
            }
        }
        else if (Phx.etParamValue.PHX_DST_FORMAT_BAY10 == ePhxBusFormatIn)
        {
            switch (ePhxCamSrcCol)
            {
            case Phx.etParamValue.PHX_CAM_SRC_BAYER_RG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG10; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GR: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR10; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GB: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB10; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_BG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG10; break;

            default: break;
            }
        }
        else if (Phx.etParamValue.PHX_DST_FORMAT_BAY12 == ePhxBusFormatIn)
        {
            switch (ePhxCamSrcCol)
            {
            case Phx.etParamValue.PHX_CAM_SRC_BAYER_RG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG12; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GR: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR12; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GB: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB12; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_BG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG12; break;

            default: break;
            }
        }
        else if (Phx.etParamValue.PHX_DST_FORMAT_BAY14 == ePhxBusFormatIn)
        {
            switch (ePhxCamSrcCol)
            {
            case Phx.etParamValue.PHX_CAM_SRC_BAYER_RG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG14; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GR: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR14; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GB: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB14; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_BG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG14; break;

            default: break;
            }
        }
        else if (Phx.etParamValue.PHX_DST_FORMAT_BAY16 == ePhxBusFormatIn)
        {
            switch (ePhxCamSrcCol)
            {
            case Phx.etParamValue.PHX_CAM_SRC_BAYER_RG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG16; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GR: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR16; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_GB: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB16; break;

            case Phx.etParamValue.PHX_CAM_SRC_BAYER_BG: ePhxBusFormatIn = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG16; break;

            default: break;
            }
        }

        /* Check if Bayer format (used when determining the PHX_BUS_FORMAT for a Mono source) */
        if (Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR8 <= ePhxBusFormatIn &&
            Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG8 >= ePhxBusFormatIn)
        {
            nBayerDepth = 8;
        }
        else if (Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR10 <= ePhxBusFormatIn &&
                 Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG10 >= ePhxBusFormatIn)
        {
            nBayerDepth = 10;
        }
        else if (Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR12 <= ePhxBusFormatIn &&
                 Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG12 >= ePhxBusFormatIn)
        {
            nBayerDepth = 12;
        }
        else if (Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR14 <= ePhxBusFormatIn &&
                 Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG14 >= ePhxBusFormatIn)
        {
            nBayerDepth = 14;
        }
        else if (Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR16 <= ePhxBusFormatIn &&
                 Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG16 >= ePhxBusFormatIn)
        {
            nBayerDepth = 16;
        }

        /* Set the return value to the input PHX_BUS_FORMAT value */
        ePhxBusFormatOut = ePhxBusFormatIn;

        /* Determine PHX_BUS_FORMAT output value */
        switch (ePhxCamSrcCol)
        {
        case Phx.etParamValue.PHX_CAM_SRC_MONO:
            switch (dwPhxCamSrcDepth)
            {
            case 8:
                if (Phx.etParamValue.PHX_BUS_FORMAT_MONO8 != ePhxBusFormatIn && 8 != nBayerDepth)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_MONO8;
                }
                break;

            case 10:
                if (Phx.etParamValue.PHX_BUS_FORMAT_MONO10P != ePhxBusFormatIn &&
                    Phx.etParamValue.PHX_BUS_FORMAT_MONO10 != ePhxBusFormatIn && 10 != nBayerDepth)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_MONO10;
                }
                break;

            case 12:
                if (Phx.etParamValue.PHX_BUS_FORMAT_MONO12P != ePhxBusFormatIn &&
                    Phx.etParamValue.PHX_BUS_FORMAT_MONO12 != ePhxBusFormatIn && 12 != nBayerDepth)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_MONO12;
                }
                break;

            case 14:
                if (Phx.etParamValue.PHX_BUS_FORMAT_MONO14P != ePhxBusFormatIn &&
                    Phx.etParamValue.PHX_BUS_FORMAT_MONO14 != ePhxBusFormatIn && 14 != nBayerDepth)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_MONO14;
                }
                break;

            case 16:
                if (Phx.etParamValue.PHX_BUS_FORMAT_MONO16 != ePhxBusFormatIn && 16 != nBayerDepth)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_MONO16;
                }
                break;

            default:
                eStat = Phx.etStat.PHX_ERROR_BAD_PARAM_VALUE;
                goto Exit;
            }
            break;

        case Phx.etParamValue.PHX_CAM_SRC_RGB:
            switch (dwPhxCamSrcDepth)
            {
            case 8:
                if (Phx.etParamValue.PHX_BUS_FORMAT_RGB8 != ePhxBusFormatIn &&
                    Phx.etParamValue.PHX_BUS_FORMAT_BGR8 != ePhxBusFormatIn)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGB8;
                }
                break;

            case 10:
                if (Phx.etParamValue.PHX_BUS_FORMAT_RGB10 != ePhxBusFormatIn &&
                    Phx.etParamValue.PHX_BUS_FORMAT_BGR10 != ePhxBusFormatIn)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGB10;
                }
                break;

            case 12:
                if (Phx.etParamValue.PHX_BUS_FORMAT_RGB12 != ePhxBusFormatIn &&
                    Phx.etParamValue.PHX_BUS_FORMAT_BGR12 != ePhxBusFormatIn)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGB12;
                }
                break;

            case 14:
                if (Phx.etParamValue.PHX_BUS_FORMAT_RGB14 != ePhxBusFormatIn &&
                    Phx.etParamValue.PHX_BUS_FORMAT_BGR14 != ePhxBusFormatIn)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGB14;
                }
                break;

            case 16:
                if (Phx.etParamValue.PHX_BUS_FORMAT_RGB16 != ePhxBusFormatIn &&
                    Phx.etParamValue.PHX_BUS_FORMAT_BGR16 != ePhxBusFormatIn)
                {
                    ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGB16;
                }
                break;

            default:
                eStat = Phx.etStat.PHX_ERROR_BAD_PARAM_VALUE;
                goto Exit;
            }
            break;

        case Phx.etParamValue.PHX_CAM_SRC_BAYER_RG:
            switch (dwPhxCamSrcDepth)
            {
            case  8: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG8;  break;

            case 10: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG10; break;

            case 12: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG12; break;

            case 14: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG14; break;

            case 16: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_RG16; break;

            default: eStat = Phx.etStat.PHX_ERROR_BAD_PARAM_VALUE; goto Exit;
            }
            break;

        case Phx.etParamValue.PHX_CAM_SRC_BAYER_GR:
            switch (dwPhxCamSrcDepth)
            {
            case  8: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR8;  break;

            case 10: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR10; break;

            case 12: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR12; break;

            case 14: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR14; break;

            case 16: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GR16; break;

            default: eStat = Phx.etStat.PHX_ERROR_BAD_PARAM_VALUE; goto Exit;
            }
            break;

        case Phx.etParamValue.PHX_CAM_SRC_BAYER_GB:
            switch (dwPhxCamSrcDepth)
            {
            case  8: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB8;  break;

            case 10: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB10; break;

            case 12: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB12; break;

            case 14: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB14; break;

            case 16: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_GB16; break;

            default: eStat = Phx.etStat.PHX_ERROR_BAD_PARAM_VALUE; goto Exit;
            }
            break;

        case Phx.etParamValue.PHX_CAM_SRC_BAYER_BG:
            switch (dwPhxCamSrcDepth)
            {
            case  8: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG8;  break;

            case 10: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG10; break;

            case 12: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG12; break;

            case 14: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG14; break;

            case 16: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_BAYER_BG16; break;

            default: eStat = Phx.etStat.PHX_ERROR_BAD_PARAM_VALUE; goto Exit;
            }
            break;

        case Phx.etParamValue.PHX_CAM_SRC_YUV422:
            switch (dwPhxCamSrcDepth)
            {
            case 8:
            case 16: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_YUV422_8; break;

            default: eStat = Phx.etStat.PHX_ERROR_BAD_PARAM_VALUE; goto Exit;
            }
            break;

        case Phx.etParamValue.PHX_CAM_SRC_RGBA:
            switch (dwPhxCamSrcDepth)
            {
            case  8: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGBA8;   break;

            case 10: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGBA10;  break;

            case 12: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGBA12;  break;

            case 14: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGBA14;  break;

            case 16: ePhxBusFormatOut = Phx.etParamValue.PHX_BUS_FORMAT_RGBA16;  break;

            default: eStat = Phx.etStat.PHX_ERROR_BAD_PARAM_VALUE; goto Exit;
            }
            break;

        default:
            eStat = Phx.etStat.PHX_ERROR_BAD_PARAM_VALUE;
            goto Exit;
        }

Exit:
        return(eStat);
    }
Пример #7
0
    /*
     * PhxCommonParseCxpRegs()
     * Parse the PCF file for CXP camera registers.
     */
    public Phx.etStat PhxCommonParseCxpRegs(
        String strConfigFileName,            /* Name of the Phoenix Configuration File */
        ref tCxpRegisters ptCameraRegisters  /* Structure containing a description of the CXP registers */
        )
    {
        Phx.etStat eStat   = Phx.etStat.PHX_OK;
        String     strLine = "";

        if (!File.Exists(strConfigFileName))
        {
            eStat = Phx.etStat.PHX_ERROR_BAD_PARAM;
            goto Exit;
        }

        ptCameraRegisters.dwAcqStartAddress    = 0;
        ptCameraRegisters.dwAcqStartValue      = 0;
        ptCameraRegisters.dwAcqStopAddress     = 0;
        ptCameraRegisters.dwAcqStopValue       = 0;
        ptCameraRegisters.dwPixelFormatAddress = 0;

        /* Parse the configuration file */
        /* Only check for lines starting with '#!' */
        StreamReader srConfigFile = File.OpenText(strConfigFileName);

        /* Read and parse each line. */
        while (!srConfigFile.EndOfStream)
        {
            strLine = srConfigFile.ReadLine();
            String[] strSplit = strLine.Split(new Char[] { ' ', ',', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
            if (strSplit.Length >= 3)
            {
                if (strSplit[0].Length >= 2)
                {
                    /* If the first token of a line is '#!' then it could be a line describing a CXP register. */
                    if (0 == strSplit[0].CompareTo("#!"))
                    {
                        if (0 == strSplit[1].CompareTo("CXP_REG_ACQ_START_ADDRESS"))
                        {
                            ptCameraRegisters.dwAcqStartAddress = Convert.ToUInt32(strSplit[2], 16);
                        }
                        else if (0 == strSplit[1].CompareTo("CXP_REG_ACQ_START_VALUE"))
                        {
                            ptCameraRegisters.dwAcqStartValue = Convert.ToUInt32(strSplit[2], 10);
                        }
                        else if (0 == strSplit[1].CompareTo("CXP_REG_ACQ_STOP_ADDRESS"))
                        {
                            ptCameraRegisters.dwAcqStopAddress = Convert.ToUInt32(strSplit[2], 16);
                        }
                        else if (0 == strSplit[1].CompareTo("CXP_REG_ACQ_STOP_VALUE"))
                        {
                            ptCameraRegisters.dwAcqStopValue = Convert.ToUInt32(strSplit[2], 10);
                        }
                        else if (0 == strSplit[1].CompareTo("CXP_REG_PIXEL_FORMAT_ADDRESS"))
                        {
                            ptCameraRegisters.dwPixelFormatAddress = Convert.ToUInt32(strSplit[2], 16);
                        }
                    }
                }
            }
        }

        srConfigFile.Close();

Exit:
        return(eStat);
    }
Пример #8
0
    /*
     * PhxCommonParseCmd()
     * Parse the command line parameters, and place results in a common structure.
     * The command line parameters take the following form:
     * AppName -b <BoardNumber> -c <ConfigFileName> -o <OutputFileName>
     * -b <BoardNumber>              is an optional parameter specifying which board to use.
     *                               The default value is board 1.
     * -n <ChannelNumber>            is an optional parameter specifying which channel to use.
     *                               The default value is channel 1.
     * -c <ConfigFileName>           is an optional parameter specifying the Phoenix Configuration File.
     *                               The default value is an OS specific path to "default.pcf" which
     *                               is in the root directory of the example suite.
     * -l <CXPDiscovery>             is an optional parameter specifying the number of CXP links.
     *                               The default value is 0 (AUTO).
     * -g <CXPBitRate>               is an optional parameter specifying the CXP bit rate (Gbps) the camera
     *                               has to be set to.
     *                               The default value is 0 (AUTO).
     * Whilst all parameters may be specified, each example application only uses appropriate
     * parameters, for example "OutputFileName" will be ignored by the phx_info example.
     */
    public Phx.etStat PhxCommonParseCmd(
        String[]    args,    /* Command line parameters */
        ref tPhxCmd ptPhxCmd /* Structure containing parsed information */
        )
    {
        Phx.etStat eStat           = Phx.etStat.PHX_OK;
        int        argc            = args.Length;
        int        nArgvIndex      = 0;
        String     strFunctionName = "";

        /* Initialise the PhxCmd structure with default values */
        ptPhxCmd.dwBoardNumber   = 1;
        ptPhxCmd.dwChannelNumber = 1;

        eStat = PhxCommonDefaultConfig(ref ptPhxCmd);
        if (Phx.etStat.PHX_OK != eStat)
        {
            goto Error;
        }

        /* The first argument is always the function name itself */
        int nPosition = Environment.GetCommandLineArgs()[0].LastIndexOf('\\');

        if (-1 != nPosition && Environment.GetCommandLineArgs()[0].Length > nPosition)
        {
            strFunctionName = Environment.GetCommandLineArgs()[0].Substring(nPosition + 1);
            nPosition       = strFunctionName.IndexOf('.');
            if (-1 != nPosition)
            {
                strFunctionName = strFunctionName.Substring(0, nPosition);
            }
            else
            {
                strFunctionName = "";
            }
        }
        Console.WriteLine("*** Active Silicon SDK Example {0} ***\n", strFunctionName);

        /* Parse the command options */
        while (nArgvIndex < argc)
        {
            /* Board number */
            if ("-b" == args[nArgvIndex] || "-B" == args[nArgvIndex])
            {
                if (++nArgvIndex < argc)
                {
                    ptPhxCmd.dwBoardNumber = uint.Parse(args[nArgvIndex]);
                }
            }

            /* chaNnel number */
            else if ("-n" == args[nArgvIndex] || "-N" == args[nArgvIndex])
            {
                if (++nArgvIndex < argc)
                {
                    ptPhxCmd.dwChannelNumber = uint.Parse(args[nArgvIndex]);
                }
            }

            /* Config File */
            else if ("-c" == args[nArgvIndex] || "-C" == args[nArgvIndex])
            {
                if (++nArgvIndex < argc)
                {
                    ptPhxCmd.strConfigFileName = args[nArgvIndex];
                }
            }

            else
            {
                Console.WriteLine("Unrecognised parameter {0} - Ignoring", args[nArgvIndex]);
            }

            nArgvIndex++;
        }

        Console.WriteLine("Using Board Number   = {0}", ptPhxCmd.dwBoardNumber);
        Console.WriteLine("      Channel Number = {0}", ptPhxCmd.dwChannelNumber);
        Console.Write("      Config File    = ");
        if ("" == ptPhxCmd.strConfigFileName)
        {
            Console.WriteLine("<None>");
        }
        else
        {
            Console.WriteLine("{0}", ptPhxCmd.strConfigFileName);
        }
        Console.WriteLine("");

        switch (ptPhxCmd.dwBoardNumber)
        {
        case 0: ptPhxCmd.eBoardNumber = Phx.etParamValue.PHX_BOARD_NUMBER_AUTO; break;

        case 1: ptPhxCmd.eBoardNumber = Phx.etParamValue.PHX_BOARD_NUMBER_1;    break;

        case 2: ptPhxCmd.eBoardNumber = Phx.etParamValue.PHX_BOARD_NUMBER_2;    break;

        case 3: ptPhxCmd.eBoardNumber = Phx.etParamValue.PHX_BOARD_NUMBER_3;    break;

        case 4: ptPhxCmd.eBoardNumber = Phx.etParamValue.PHX_BOARD_NUMBER_4;    break;

        case 5: ptPhxCmd.eBoardNumber = Phx.etParamValue.PHX_BOARD_NUMBER_5;    break;

        case 6: ptPhxCmd.eBoardNumber = Phx.etParamValue.PHX_BOARD_NUMBER_6;    break;

        case 7: ptPhxCmd.eBoardNumber = Phx.etParamValue.PHX_BOARD_NUMBER_7;    break;

        default:
            Console.WriteLine("Unrecognised board number {0} - Ignoring", ptPhxCmd.dwBoardNumber);
            ptPhxCmd.eBoardNumber = Phx.etParamValue.PHX_BOARD_NUMBER_AUTO;
            break;
        }

        switch (ptPhxCmd.dwChannelNumber)
        {
        case 0: ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_AUTO;   break;

        case 1: ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_1;      break;

        case 2: ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_2;      break;

        case 3: ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_3;      break;

        case 4: ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_4;      break;

        case 5: ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_5;      break;

        case 6: ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_6;      break;

        case 7: ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_7;      break;

        case 8: ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_8;      break;

        default:
            Console.WriteLine("Unrecognised channel number {0} - Ignoring", ptPhxCmd.dwChannelNumber);
            ptPhxCmd.eChannelNumber = Phx.etParamValue.PHX_CHANNEL_NUMBER_AUTO;
            break;
        }
        Console.WriteLine("");

Error:
        return(eStat);
    }