예제 #1
0
 /* A device has been opened. Update the control. */
 private void DeviceOpenedEventHandler()
 {
     if (InvokeRequired)
     {
         /* If called from a different thread, we must use the Invoke method to marshal the call to the proper thread. */
         BeginInvoke(new ImageProvider.DeviceOpenedEventHandler(DeviceOpenedEventHandler));
         return;
     }
     try
     {
         /* Get the node. */
         m_hNode = m_imageProvider.GetNodeFromDevice(name);
         /* Register for changes. */
         m_hCallbackHandle = GenApi.NodeRegisterCallback(m_hNode, m_nodeCallbackHandler);
         /* Update the displayed name. */
         labelName.Text = GenApi.NodeGetDisplayName(m_hNode) + ":";
         /* Update the control values. */
         UpdateValues();
     }
     catch
     {
         /* If errors occurred disable the control. */
         Reset();
     }
 }
 /* A device has been opened. Update the control. */
 private void DeviceOpenedEventHandler()
 {
     if (InvokeRequired)
     {
         /* If called from a different thread, we must use the Invoke method to marshal the call to the proper thread. */
         BeginInvoke(new ImageProvider.DeviceOpenedEventHandler(DeviceOpenedEventHandler));
         return;
     }
     try
     {
         /* Get the node. */
         m_hNode = m_imageProvider.GetNodeFromDevice(name);
         /* Register for changes. */
         m_hCallbackHandle = GenApi.NodeRegisterCallback(m_hNode, m_nodeCallbackHandler);
         /* Update the displayed name. */
         labelName.Text = GenApi.NodeGetDisplayName(m_hNode) + ":";
         /* Update the control values. */
         UpdateValues();
     }
     catch
     {
         /* If errors occurred disable the control. */
         Reset();
     }
 }
예제 #3
0
        /// <summary>
        ///  A device has been opened. Update the control.
        /// </summary>
        public void DeviceOpenedEventHandler()
        {
            if (InvokeRequired)
            {
                /* If called from a different thread, we must use the Invoke method to marshal the call to the proper thread. */
                BeginInvoke(new MethodInvoker(DeviceOpenedEventHandler));                 //new ImageProvider.DeviceOpenedEventHandler (DeviceOpenedEventHandler));
                return;
            }
            try {
                /* Get the node. */
                m_hNode = m_imageProvider.GetNodeFromDevice(name);

                /* Features, like 'Gain', are named according to the GenICam Standard Feature Naming Convention (SFNC).
                 * The SFNC defines a common set of features, their behavior, and the related parameter names.
                 * This ensures the interoperability of cameras from different camera vendors.
                 *
                 * Some cameras, e.g. cameras compliant to the USB3 Vision standard, use a later SFNC version than
                 * previous Basler GigE and Firewire cameras. Accordingly, the behavior of these cameras and
                 * some parameters names will be different.
                 */
                if (!m_hNode.IsValid &&              /* No node has been found using the provided name. */
                    (name == "GainRaw" || name == "ExposureTimeRaw"))                        /* This means probably that the camera is compliant to a later SFNC version. */
                {
                    /* Check to see if a compatible node exists. The SFNC 2.0, implemented by Basler USB Cameras for instance, defines Gain
                     * and ExposureTime as features of type Float.*/
                    if (name == "GainRaw")
                    {
                        m_hNode = m_imageProvider.GetNodeFromDevice("Gain");
                    }
                    else if (name == "ExposureTimeRaw")
                    {
                        m_hNode = m_imageProvider.GetNodeFromDevice("ExposureTime");
                    }
                    /* Update the displayed name. */
                    labelName.Text = GenApi.NodeGetDisplayName(m_hNode) + ":";

                    /* The underlying integer representation of Gain and ExposureTime can be accessed using
                     * the so called alias node. The alias is another representation of the original parameter.
                     *
                     * Since this slider control can only be used with Integer nodes we have to use
                     * the alias node here to display and modify Gain and ExposureTime.
                     */
                    m_hNode = GenApi.NodeGetAlias(m_hNode);
                    /* Register for changes. */
                    m_hCallbackHandle = GenApi.NodeRegisterCallback(m_hNode, m_nodeCallbackHandler);
                }
                else
                {
                    /* Update the displayed name. */
                    labelName.Text = GenApi.NodeGetDisplayName(m_hNode) + "مقدار:";
                    /* Register for changes. */
                    m_hCallbackHandle = GenApi.NodeRegisterCallback(m_hNode, m_nodeCallbackHandler);
                }
                /* Update the control values. */
                UpdateValues();
            }
            catch {
                /* If errors occurred disable the control. */
                Reset();
            }
        }