Ejemplo n.º 1
0
        /* If the device provides a heartbeat timeout, this function will set the heartbeat timeout.
         * When the device provides the parameter, the old value is returned, -1 otherwise.
         * The heartbeat timeout is a parameter provided by the transport layer.
         * The transport layer parameters are exposed as a GenApi node map that
         * can be retrieved from the device.
         */
        private static long setHeartbeatTimeout(PYLON_DEVICE_HANDLE hDev, long timeout_ms)
        {
            NODEMAP_HANDLE hNodemap;   /* Handle to the node map. */
            NODE_HANDLE    hNode;      /* Handle to a node, i.e., a feature. */
            long           oldTimeout; /* The current timeout value. */

            /* Get the node map for the transport layer parameters. */
            hNodemap = Pylon.DeviceGetTLNodeMap(hDev);

            if (!hNodemap.IsValid)
            {
                /* The device doesn't provide a transport layer node map. Nothing to do. */
                Console.WriteLine("The device doesn't provide a transport layer node map. Cannot set heartbeat timeout.");
                return(-1);
            }
            /* Get the node for the heartbeat timeout parameter. */
            hNode = GenApi.NodeMapGetNode(hNodemap, "HeartbeatTimeout");

            if (!hNode.IsValid)
            {
                /* There is no heartbeat timeout parameter. Nothing to do. */
                Console.WriteLine("There is no heartbeat timeout parameter. Cannot set heartbeat timeout.");
                return(-1);
            }

            /* Get the current value. */
            oldTimeout = GenApi.IntegerGetValue(hNode);

            /* Set the new value. */
            GenApi.IntegerSetValue(hNode, timeout_ms);

            /* Return the old value. */
            return(oldTimeout);
        }