private static CameraProperty ReadFloatProperty(PYLON_DEVICE_HANDLE deviceHandle, string symbol) { CameraProperty p = new CameraProperty(); p.Identifier = symbol; NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle); NODE_HANDLE nodeHandle = GenApi.NodeMapGetNode(nodeMapHandle, symbol); if (!nodeHandle.IsValid) { return(p); } EGenApiAccessMode accessMode = GenApi.NodeGetAccessMode(nodeHandle); if (accessMode == EGenApiAccessMode._UndefinedAccesMode || accessMode == EGenApiAccessMode.NA || accessMode == EGenApiAccessMode.NI || accessMode == EGenApiAccessMode.WO) { return(p); } p.Supported = true; p.ReadOnly = accessMode != EGenApiAccessMode.RW; EGenApiNodeType type = GenApi.NodeGetType(nodeHandle); if (type != EGenApiNodeType.FloatNode) { return(p); } p.Type = CameraPropertyType.Float; double min = GenApi.FloatGetMin(nodeHandle); double max = GenApi.FloatGetMax(nodeHandle); EGenApiRepresentation repr = GenApi.FloatGetRepresentation(nodeHandle); double currentValue = GenApi.FloatGetValue(nodeHandle); // We don't support a dedicated control for "pure numbers" just use the regular slider. if (repr == EGenApiRepresentation.PureNumber) { repr = EGenApiRepresentation.Linear; } // Fix values that should be log. double range = Math.Log(max - min, 10); if (range > 4 && repr == EGenApiRepresentation.Linear) { repr = EGenApiRepresentation.Logarithmic; } p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); p.Representation = ConvertRepresentation(repr); p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); return(p); }
private static CameraProperty ReadIntegerProperty(PYLON_DEVICE_HANDLE deviceHandle, string symbol) { CameraProperty p = new CameraProperty(); p.Identifier = symbol; NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle); NODE_HANDLE nodeHandle = GenApi.NodeMapGetNode(nodeMapHandle, symbol); if (!nodeHandle.IsValid) { log.WarnFormat("Could not read Basler property {0}: node handle is not valid. (The property is not supported).", symbol); return(p); } EGenApiAccessMode accessMode = GenApi.NodeGetAccessMode(nodeHandle); if (accessMode == EGenApiAccessMode._UndefinedAccesMode || accessMode == EGenApiAccessMode.NA || accessMode == EGenApiAccessMode.NI || accessMode == EGenApiAccessMode.WO) { log.WarnFormat("Could not read Basler property {0}: Access mode not supported. (The property is not readable).", symbol); return(p); } EGenApiNodeType type = GenApi.NodeGetType(nodeHandle); if (type != EGenApiNodeType.IntegerNode) { log.WarnFormat("Could not read Basler property {0}: the node is of the wrong type. Expected: Integer. Received:{1}", symbol, type.ToString()); return(p); } p.Supported = true; p.Type = CameraPropertyType.Integer; p.ReadOnly = accessMode != EGenApiAccessMode.RW; long min = GenApi.IntegerGetMin(nodeHandle); long max = GenApi.IntegerGetMax(nodeHandle); long step = GenApi.IntegerGetInc(nodeHandle); EGenApiRepresentation repr = GenApi.IntegerGetRepresentation(nodeHandle); // Fix values that should be log. double range = Math.Log10(max) - Math.Log10(min); if (range > 4 && repr == EGenApiRepresentation.Linear) { repr = EGenApiRepresentation.Logarithmic; } long currentValue = GenApi.IntegerGetValue(nodeHandle); p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); p.Step = step.ToString(CultureInfo.InvariantCulture); p.Representation = ConvertRepresentation(repr); p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); return(p); }
private static CameraProperty ReadIntegerProperty(PYLON_DEVICE_HANDLE deviceHandle, string symbol) { CameraProperty p = new CameraProperty(); p.Identifier = symbol; NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle); NODE_HANDLE nodeHandle = GenApi.NodeMapGetNode(nodeMapHandle, symbol); if (!nodeHandle.IsValid) { return(p); } EGenApiAccessMode accessMode = GenApi.NodeGetAccessMode(nodeHandle); if (accessMode == EGenApiAccessMode._UndefinedAccesMode || accessMode == EGenApiAccessMode.NA || accessMode == EGenApiAccessMode.NI || accessMode == EGenApiAccessMode.WO) { return(p); } p.Supported = true; p.ReadOnly = accessMode != EGenApiAccessMode.RW; EGenApiNodeType type = GenApi.NodeGetType(nodeHandle); if (type != EGenApiNodeType.IntegerNode) { return(p); } p.Type = CameraPropertyType.Integer; long min = GenApi.IntegerGetMin(nodeHandle); long max = GenApi.IntegerGetMax(nodeHandle); long step = GenApi.IntegerGetInc(nodeHandle); EGenApiRepresentation repr = GenApi.IntegerGetRepresentation(nodeHandle); // Fix values that should be log. double range = Math.Log(max - min, 10); if (range > 4 && repr == EGenApiRepresentation.Linear) { repr = EGenApiRepresentation.Logarithmic; } long currentValue = GenApi.IntegerGetValue(nodeHandle); p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); p.Step = step.ToString(CultureInfo.InvariantCulture); p.Representation = ConvertRepresentation(repr); p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); return(p); }
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); }
private static CameraProperty ReadBooleanProperty(PYLON_DEVICE_HANDLE deviceHandle, string symbol) { CameraProperty p = new CameraProperty(); p.Identifier = symbol; NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle); NODE_HANDLE nodeHandle = GenApi.NodeMapGetNode(nodeMapHandle, symbol); if (!nodeHandle.IsValid) { log.WarnFormat("Could not read Basler property {0}: node handle is not valid. (The property is not supported).", symbol); return(p); } EGenApiAccessMode accessMode = GenApi.NodeGetAccessMode(nodeHandle); if (accessMode == EGenApiAccessMode._UndefinedAccesMode || accessMode == EGenApiAccessMode.NA || accessMode == EGenApiAccessMode.NI || accessMode == EGenApiAccessMode.WO) { log.WarnFormat("Could not read Basler property {0}: Access mode not supported. (The property is not readable).", symbol); return(p); } EGenApiNodeType type = GenApi.NodeGetType(nodeHandle); if (type != EGenApiNodeType.BooleanNode) { log.WarnFormat("Could not read Basler property {0}: the node is of the wrong type. Expected: Boolean. Received:{1}", symbol, type.ToString()); return(p); } p.Supported = true; p.Type = CameraPropertyType.Boolean; p.ReadOnly = accessMode != EGenApiAccessMode.RW; bool currentValue = GenApi.BooleanGetValue(nodeHandle); p.Representation = CameraPropertyRepresentation.Checkbox; p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); return(p); }
private static CameraProperty ReadBooleanProperty(PYLON_DEVICE_HANDLE deviceHandle, string symbol) { CameraProperty p = new CameraProperty(); p.Identifier = symbol; NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle); NODE_HANDLE nodeHandle = GenApi.NodeMapGetNode(nodeMapHandle, symbol); if (!nodeHandle.IsValid) { return(p); } EGenApiAccessMode accessMode = GenApi.NodeGetAccessMode(nodeHandle); if (accessMode == EGenApiAccessMode._UndefinedAccesMode || accessMode == EGenApiAccessMode.NA || accessMode == EGenApiAccessMode.NI || accessMode == EGenApiAccessMode.WO) { return(p); } p.Supported = true; p.ReadOnly = accessMode != EGenApiAccessMode.RW; EGenApiNodeType type = GenApi.NodeGetType(nodeHandle); if (type != EGenApiNodeType.BooleanNode) { return(p); } p.Type = CameraPropertyType.Boolean; bool currentValue = GenApi.BooleanGetValue(nodeHandle); p.Representation = CameraPropertyRepresentation.Checkbox; p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); return(p); }
private static CameraProperty ReadFramerate(PYLON_DEVICE_HANDLE deviceHandle, Dictionary <string, CameraProperty> properties) { CameraProperty p = new CameraProperty(); p.Identifier = "AcquisitionFrameRate"; p.Supported = false; p.Type = CameraPropertyType.Float; NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle); NODE_HANDLE nodeHandle = GenApi.NodeMapGetNode(nodeMapHandle, p.Identifier); if (!nodeHandle.IsValid) { p.Identifier = "AcquisitionFrameRateAbs"; nodeHandle = GenApi.NodeMapGetNode(nodeMapHandle, p.Identifier); if (!nodeHandle.IsValid) { return(p); } } EGenApiAccessMode accessMode = GenApi.NodeGetAccessMode(nodeHandle); if (accessMode == EGenApiAccessMode._UndefinedAccesMode || accessMode == EGenApiAccessMode.NA || accessMode == EGenApiAccessMode.NI || accessMode == EGenApiAccessMode.WO) { log.WarnFormat("Could not read Basler property {0}: Access mode not supported. (The property is not readable).", p.Identifier); return(p); } EGenApiNodeType type = GenApi.NodeGetType(nodeHandle); if (type != EGenApiNodeType.FloatNode) { log.WarnFormat("Could not read Basler property {0}: the node is of the wrong type. Expected: Float. Received:{1}", p.Identifier, type.ToString()); return(p); } p.ReadOnly = false; p.Supported = true; double currentValue = GenApi.FloatGetValue(nodeHandle); double min = GenApi.FloatGetMin(nodeHandle); double max = GenApi.FloatGetMax(nodeHandle); double step = 1.0; min = Math.Max(1.0, min); p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); p.Step = step.ToString(CultureInfo.InvariantCulture); // Fix values that should be log. double range = Math.Log10(max) - Math.Log10(min); p.Representation = (range >= 4) ? CameraPropertyRepresentation.LogarithmicSlider : CameraPropertyRepresentation.LinearSlider; // AcquisitionFrameRateEnable=false: the framerate is automatically set to the max value possible. // AcquisitionFrameRateEnable=true: use the custom framerate set by the user in AcquisitionFrameRate. string autoIdentifier = "AcquisitionFrameRateEnable"; p.AutomaticIdentifier = autoIdentifier; NODE_HANDLE nodeHandleAuto = GenApi.NodeMapGetNode(nodeMapHandle, autoIdentifier); p.CanBeAutomatic = nodeHandleAuto.IsValid && GenApi.NodeIsWritable(nodeHandleAuto); p.Automatic = false; if (p.CanBeAutomatic) { string currentAutoValue = GenApi.BooleanGetValue(nodeHandleAuto).ToString(CultureInfo.InvariantCulture).ToLower(); p.Automatic = currentAutoValue == GetAutoTrue(autoIdentifier); } if (properties != null) { properties.Add("framerate", p); } return(p); }