예제 #1
0
        static public bool GetAcqDeviceOptionsFromCommandLine(string[] args, MyAcquisitionParams acparams)
        {
            // Check the command line for user commands
            if (args[1].Equals("/?") || args[1].Equals("-?"))
            {
                // print help
                Console.WriteLine("Usage:\n");
                Console.WriteLine("GigECameraLut [<acquisition server name> <acquisition device index>]\n");
                return(false);
            }

            // Check if enough arguments were passed
            if (args.Length < 3)
            {
                Console.WriteLine("Invalid command line!\n");
                return(false);
            }

            // Validate server name
            if (SapManager.GetServerIndex(args[1]) < 0)
            {
                Console.WriteLine("Invalid acquisition server name!\n");
                return(false);
            }

            // Does the server support acquisition?
            int deviceCount = SapManager.GetResourceCount(args[1], SapManager.ResourceType.AcqDevice);

            if (deviceCount == 0)
            {
                Console.WriteLine("This server does not support acquisition!\n");
                return(false);
            }

            // Validate device index
            if (int.Parse(args[2]) < 0 || int.Parse(args[2]) >= deviceCount)
            {
                Console.WriteLine("Invalid acquisition device index!\n");
                return(false);
            }

            // Fill-in output variables
            acparams.ServerName    = args[1];
            acparams.ResourceIndex = int.Parse(args[2]);

            return(true);
        }
예제 #2
0
        const int MAX_CONFIG_FILES = 36;       // 10 numbers + 26 letters
        //static char configFileNames[MAX_CONFIG_FILES][MAX_PATH] = {0};


        static public bool GetOptionsFromCommandLine(string[] argv, MyAcquisitionParams acqParams)
        {
            // Check the command line for user commands
            if (argv[1].Equals("/?") || argv[1].Equals("-?"))
            {
                // print help
                Console.WriteLine("Usage:\n");
                Console.WriteLine("Grab  [<acquisition server name> <acquisition device index> <config filename>]\n");
                return(false);
            }

            // Check if enough arguments were passed
            if (argv.Length < 4)
            {
                Console.WriteLine("Invalid command line!\n");
                return(false);
            }

            // Validate server name
            if (SapManager.GetServerIndex(argv[1]) < 0)
            {
                Console.WriteLine("Invalid acquisition server name!\n");
                return(false);
            }

            // Does the server support acquisition?
            int deviceCount = SapManager.GetResourceCount(argv[1], SapManager.ResourceType.Acq);
            int cameraCount = SapManager.GetResourceCount(argv[1], SapManager.ResourceType.AcqDevice);

            if (deviceCount + cameraCount == 0)
            {
                Console.WriteLine("This server does not support acquisition!\n");
                return(false);
            }

            // Validate device index
            if (int.Parse(argv[2]) < 0 || int.Parse(argv[2]) >= deviceCount + cameraCount)
            {
                Console.WriteLine("Invalid acquisition device index!\n");
                return(false);
            }

            if (cameraCount == 0)
            {
                if (!File.Exists(argv[3]))
                {
                    Console.WriteLine("The specified config file (" + argv[3] + "is invalid!\n");
                    return(false);
                }
            }

            // Fill-in output variables
            acqParams.ServerName    = argv[1];
            acqParams.ResourceIndex = int.Parse(argv[2]);
            if (cameraCount == 0)
            {
                acqParams.ConfigFileName = argv[3];
            }

            return(true);
        }