Exemple #1
0
        /* There are camera features, such as AcquisitionStart, that represent a command.
         * This function that loads the default set, illustrates how to execute a command feature.  */
        private static void demonstrateCommandFeature(PYLON_DEVICE_HANDLE hDev)
        {
            string selectorName = "UserSetSelector",
                   commandName  = "UserSetLoad";
            NODEMAP_HANDLE  hNodeMap;
            NODE_HANDLE     hCommand, hSelector;
            EGenApiNodeType nodeType;
            bool            bval;

            /* Get a handle for the device's node map. */
            hNodeMap = Pylon.DeviceGetNodeMap(hDev);

            /* Look up the command node. */
            hCommand = GenApi.NodeMapGetNode(hNodeMap, commandName);
            if (!hCommand.IsValid)
            {
                Console.WriteLine("There is no node named '" + commandName + "'.");
                return;
            }

            /* Look up the selector node. */
            hSelector = GenApi.NodeMapGetNode(hNodeMap, selectorName);
            if (!hSelector.IsValid)
            {
                Console.WriteLine("There is no node named '" + selectorName + "'.");
                return;
            }

            /* We want a command feature node. */
            nodeType = GenApi.NodeGetType(hCommand);

            if (EGenApiNodeType.CommandNode != nodeType)
            {
                Console.WriteLine("'" + selectorName + "' is not a command feature.");
                return;
            }

            /* Before executing the user set load command, the user set selector must be
             * set to the default set. */

            /* Check to see if the selector is writable. */
            bval = GenApi.NodeIsWritable(hSelector);

            if (bval)
            {
                /* Choose the default set (which includes one of the factory setups). */
                GenApi.NodeFromString(hSelector, "Default");
            }
            else
            {
                Console.WriteLine("Cannot set selector '{0}' - node not writable.", selectorName);
            }


            /* Check to see if the command is writable. */
            bval = GenApi.NodeIsWritable(hCommand);

            if (bval)
            {
                /* Execute the user set load command. */
                Console.WriteLine("Loading the default set.");
                GenApi.CommandExecute(hCommand);
            }
            else
            {
                Console.WriteLine("Cannot execute command '{0}' - node not writable.", commandName);
            }
        }