Beispiel #1
0
        /// <summary>
        /// Set camera config.
        /// </summary>
        /// <param name="device">camera device</param>
        /// <param name="featureName">name of config</param>
        /// <param name="value">value of config</param>
        private void SetConfig(PYLON_DEVICE_HANDLE device, string featureName, object value)
        {
            try
            {
                if (value == null)
                {
                    return;
                }

                // Check to see if a feature is implemented, writable.
                bool isAvailable;
                bool isWritable;

                // Check feature
                isAvailable = Pylon.DeviceFeatureIsImplemented(device, featureName);
                isWritable  = Pylon.DeviceFeatureIsWritable(device, featureName);

                // Set config feature
                if (isAvailable && isWritable)
                {
                    if (value.GetType() == typeof(int))
                    {
                        Pylon.DeviceSetIntegerFeature(device, featureName, (int)value);
                    }

                    if (value.GetType() == typeof(float))
                    {
                        Pylon.DeviceSetFloatFeature(device, featureName, (float)value);
                    }

                    if (value.GetType() == typeof(string))
                    {
                        Pylon.DeviceFeatureFromString(device, featureName, (string)value);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        /* This function demonstrates how to check the presence, readability, and writability
         *  of a feature. */
        private static void demonstrateAccessibilityCheck(PYLON_DEVICE_HANDLE hDev)
        {
            bool val;  /* Output of the check functions. */

            /* Check to see if a feature is implemented at all. */
            val = Pylon.DeviceFeatureIsImplemented(hDev, "Width");

            Console.WriteLine("The 'Width' feature {0} implemented.", val ? "is" : "isn't");
            val = Pylon.DeviceFeatureIsImplemented(hDev, "MyCustomFeature");
            Console.WriteLine("The 'MyCustomFeature' feature {0} implemented.", val ? "is" : "isn't");

            /* Although a feature is implemented by the device, it may not be available
             * with the device in its current state. Check to see if the feature is currently
             * available. The PylonDeviceFeatureIsAvailable sets val to 0 if either the feature
             * is not implemented or if the feature is not currently available. */

            val = Pylon.DeviceFeatureIsAvailable(hDev, "BinningVertical");
            Console.WriteLine("The 'BinningVertical' feature {0} available.", val ? "is" : "isn't");

            /* If a feature is available, it can be read-only, write-only, or both
             * readable and writable. Use the PylonDeviceFeatureIsReadable() and the
             * PylonDeviceFeatureIsWritable() functions(). It is safe to call these functions
             * for features that are currently not available or not implemented by the device.
             * A feature that is not available or not implemented is neither readable nor writable.
             * The readability and writability of a feature can change depending on the current
             * state of the device. For example, the Width parameter may not be writable when
             * the camera is acquiring images. */

            val = Pylon.DeviceFeatureIsReadable(hDev, "Width");
            Console.WriteLine("The 'Width' feature {0} readable.", val ? "is" : "isn't");

            val = Pylon.DeviceFeatureIsReadable(hDev, "MyCustomFeature");
            Console.WriteLine("The 'MyCustomFeature' feature {0} readable.", val ? "is" : "isn't");

            val = Pylon.DeviceFeatureIsWritable(hDev, "Width");
            Console.WriteLine("The 'Width' feature {0} writable.", val ? "is" : "isn't");
            Console.WriteLine("");
        }