Exemple #1
0
        public static void WriteStreamFormat(PYLON_DEVICE_HANDLE deviceHandle, string selectedFormatSymbol)
        {
            string enumerationName = "PixelFormat";

            NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle);
            NODE_HANDLE    nodeHandle    = GenApi.NodeMapGetNode(nodeMapHandle, enumerationName);

            if (!nodeHandle.IsValid)
            {
                return;
            }

            try
            {
                bool available = GenApi.NodeIsAvailable(nodeHandle);
                if (!available)
                {
                    return;
                }

                uint itemCount = GenApi.EnumerationGetNumEntries(nodeHandle);
                for (uint i = 0; i < itemCount; i++)
                {
                    NODE_HANDLE entryHandle = GenApi.EnumerationGetEntryByIndex(nodeHandle, i);

                    if (!GenApi.NodeIsAvailable(entryHandle))
                    {
                        continue;
                    }

                    string value = GenApi.EnumerationEntryGetSymbolic(entryHandle);
                    if (value != selectedFormatSymbol)
                    {
                        continue;
                    }

                    if (GenApi.NodeToString(nodeHandle) == value)
                    {
                        continue;
                    }

                    GenApi.NodeFromString(nodeHandle, value);
                    break;
                }
            }
            catch
            {
                // Silent catch.
            }
        }
Exemple #2
0
        /* Get the current values from the node and display them. */
        private void UpdateValues()
        {
            try
            {
                if (m_hNode.IsValid)
                {
                    if (GenApi.NodeGetType(m_hNode) == EGenApiNodeType.EnumerationNode) /* Check is proper node type. */
                    {
                        /* Check is writable. */
                        bool writable = GenApi.NodeIsWritable(m_hNode);

                        /* Get the number of enumeration values. */
                        uint itemCount = GenApi.EnumerationGetNumEntries(m_hNode);

                        /* Clear the combo box. */
                        comboBox.Items.Clear();

                        /* Get all enumeration values, add them to the combo box, and set the selected item. */

                        string aa       = PylonC.NET.Pylon.DeviceFeatureToString((PylonC.NET.PYLON_DEVICE_HANDLE)m_imageProvider.m_hDevice, NodeName);
                        string selected = GenApi.NodeToString(m_hNode);
                        for (uint i = 0; i < itemCount; i++)
                        {
                            NODE_HANDLE hEntry = GenApi.EnumerationGetEntryByIndex(m_hNode, i);
                            if (GenApi.NodeIsAvailable(hEntry))
                            {
                                comboBox.Items.Add(GenApi.NodeGetDisplayName(hEntry));
                                if (selected == GenApi.EnumerationEntryGetSymbolic(hEntry))
                                {
                                    comboBox.SelectedIndex = comboBox.Items.Count - 1;
                                }
                            }
                        }

                        /* Update accessibility. */
                        comboBox.Enabled  = writable;
                        labelName.Enabled = writable;
                        return;
                    }
                }
            }
            catch
            {
                /* If errors occurred disable the control. */
            }
            Reset();
        }
Exemple #3
0
        public static List <StreamFormat> GetSupportedStreamFormats(PYLON_DEVICE_HANDLE deviceHandle)
        {
            // We get a list of all possible values from GenICam API.
            // We cannot use the Pylon .NET enum names because of casing mismatches.
            // Then for each possible value, we poll for availability through Pylon API.

            string enumerationName = "PixelFormat";

            NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle);
            NODE_HANDLE    nodeHandle    = GenApi.NodeMapGetNode(nodeMapHandle, enumerationName);

            if (!nodeHandle.IsValid)
            {
                return(null);
            }

            EGenApiNodeType nodeType = GenApi.NodeGetType(nodeHandle);

            if (nodeType != EGenApiNodeType.EnumerationNode)
            {
                return(null);
            }

            List <StreamFormat> supportedList = new List <StreamFormat>();
            uint total = GenApi.EnumerationGetNumEntries(nodeHandle);

            for (uint i = 0; i < total; i++)
            {
                NODE_HANDLE enumEntryHandle = GenApi.EnumerationGetEntryByIndex(nodeHandle, i);

                string symbol = GenApi.EnumerationEntryGetSymbolic(enumEntryHandle);
                //string symbol = GenApi.NodeGetDisplayName(entryHandle);

                //string featureName = string.Format("EnumEntry_{0}_{1}", enumerationName, symbol);
                //bool supported = Pylon.DeviceFeatureIsAvailable(deviceHandle, featureName);
                bool supported = GenApi.NodeIsAvailable(enumEntryHandle);

                if (supported)
                {
                    string displayName = GenApi.NodeGetDisplayName(enumEntryHandle);
                    supportedList.Add(new StreamFormat(symbol, displayName));
                }
            }

            return(supportedList);
        }
Exemple #4
0
        public static void WriteEnum(NODE_HANDLE nodeHandle, string enumerationName, string enumerationValue)
        {
            if (!nodeHandle.IsValid)
            {
                return;
            }

            try
            {
                bool available = GenApi.NodeIsAvailable(nodeHandle);
                if (!available)
                {
                    return;
                }

                uint itemCount = GenApi.EnumerationGetNumEntries(nodeHandle);
                for (uint i = 0; i < itemCount; i++)
                {
                    NODE_HANDLE entryHandle = GenApi.EnumerationGetEntryByIndex(nodeHandle, i);

                    if (!GenApi.NodeIsAvailable(entryHandle))
                    {
                        continue;
                    }

                    string value = GenApi.EnumerationEntryGetSymbolic(entryHandle);
                    if (value != enumerationValue)
                    {
                        continue;
                    }

                    if (GenApi.NodeToString(nodeHandle) == value)
                    {
                        continue;
                    }

                    GenApi.NodeFromString(nodeHandle, value);
                    break;
                }
            }
            catch
            {
                // Silent catch.
            }
        }
Exemple #5
0
        /* Handle selection changes. */
        private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_hNode.IsValid)
            {
                try
                {
                    /* If writable and combo box selection ok. */
                    if (GenApi.NodeIsAvailable(m_hNode) && comboBox.SelectedIndex >= 0)
                    {
                        /* Get the displayed selected enumeration value. */
                        string selectedDisplayName = comboBox.GetItemText(comboBox.Items[comboBox.SelectedIndex]);

                        /* Get the number of enumeration values. */
                        uint itemCount = GenApi.EnumerationGetNumEntries(m_hNode);

                        /* Determine the symbolic name of the selected item and set it if different. */
                        for (uint i = 0; i < itemCount; i++)
                        {
                            NODE_HANDLE hEntry = GenApi.EnumerationGetEntryByIndex(m_hNode, i);
                            if (GenApi.NodeIsAvailable(hEntry))
                            {
                                if (GenApi.NodeGetDisplayName(hEntry) == selectedDisplayName)
                                {
                                    /* Get the value to set. */
                                    string value = GenApi.EnumerationEntryGetSymbolic(hEntry);
                                    /* Set the value if other than the current value of the node. */
                                    if (GenApi.NodeToString(m_hNode) != value)
                                    {
                                        GenApi.NodeFromString(m_hNode, value);
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                    /* Ignore any errors here. */
                }
            }
        }
Exemple #6
0
        public static StreamFormat GetCurrentStreamFormat(PYLON_DEVICE_HANDLE deviceHandle)
        {
            StreamFormat sf = null;

            string enumerationName = "PixelFormat";

            NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle);
            NODE_HANDLE    nodeHandle    = GenApi.NodeMapGetNode(nodeMapHandle, enumerationName);

            if (!nodeHandle.IsValid)
            {
                return(null);
            }

            string selected = GenApi.NodeToString(nodeHandle);

            uint itemCount = GenApi.EnumerationGetNumEntries(nodeHandle);

            for (uint i = 0; i < itemCount; i++)
            {
                NODE_HANDLE entryHandle = GenApi.EnumerationGetEntryByIndex(nodeHandle, i);
                string      symbol      = GenApi.EnumerationEntryGetSymbolic(entryHandle);
                if (selected != symbol)
                {
                    continue;
                }

                if (!GenApi.NodeIsAvailable(entryHandle))
                {
                    continue;
                }

                string displayName = GenApi.NodeGetDisplayName(entryHandle);
                sf = new StreamFormat(symbol, displayName);
                break;
            }

            return(sf);
        }