Esempio n. 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);
    }
Esempio n. 2
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);
    }