//========================================================================================== /// <summary> /// Gets the values supported by the camera attribute. /// </summary> /// <returns> /// The values supported by the camera attribute. /// </returns> /// <exception cref="System.ObjectDisposedException"> /// The session has been disposed. /// </exception> //========================================================================================== public ImaqdxEnumAttributeItem[] GetSupportedValues() { // This is a method to make it clear that it should not be called directly in a loop Session.ValidateSessionHandle(); return(ImaqdxAttributeManager.EnumerateAttributeValues(Session.Handle, Name)); }
//========================================================================================== /// <summary> /// Gets the current value for a camera attribute. /// </summary> /// <returns> /// The value of the specified attribute. The value is returned as an <see cref="System.Object" crefType="Unqualified"/>. /// </returns> /// <exception cref="System.ObjectDisposedException"> /// The session has been disposed. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The type of the attribute is invalid or not supported. /// </exception> //========================================================================================== public object GetValue() { _session.ValidateSessionHandle(); object value; switch (_type) { case ImaqdxAttributeType.UInt32: uint uintValue; ImaqdxAttributeManager.GetAttribute(_session.Handle, _name, out uintValue); value = uintValue; break; case ImaqdxAttributeType.Int64: long longValue; ImaqdxAttributeManager.GetAttribute(_session.Handle, _name, out longValue); value = longValue; break; case ImaqdxAttributeType.Double: double doubleValue; ImaqdxAttributeManager.GetAttribute(_session.Handle, _name, out doubleValue); value = doubleValue; break; case ImaqdxAttributeType.String: string stringValue; ImaqdxAttributeManager.GetAttribute(_session.Handle, _name, out stringValue); value = stringValue; break; case ImaqdxAttributeType.Enum: ImaqdxEnumAttributeItem enumValue; ImaqdxAttributeManager.GetAttribute(_session.Handle, _name, out enumValue); value = enumValue; break; case ImaqdxAttributeType.Boolean: bool boolValue; ImaqdxAttributeManager.GetAttribute(_session.Handle, _name, out boolValue); value = boolValue; break; case ImaqdxAttributeType.Command: throw ExceptionBuilder.CommandAttributesNotReadable(); default: throw ExceptionBuilder.UnknownDataType(); } return(value); }
internal ImaqdxAttributeCollection(ImaqdxSession session) : base(new List <ImaqdxAttribute>()) { _session = session; _attributeLookupTable = new Dictionary <string, int>(); // Initialize the attribute collection ImaqdxAttributeInformation[] attributeInfoArray = ImaqdxAttributeManager.EnumeratePublicAttributes(session.Handle); for (int i = 0; i < attributeInfoArray.Length; i++) { AddAttribute(attributeInfoArray[i]); } }
public void AddPrivateAttribute(string name) { _session.ValidateSessionHandle(); if (name == null) { throw ExceptionBuilder.ArgumentNull("name"); } if (name.Length == 0) { throw ExceptionBuilder.EmptyString("name"); } ImaqdxAttributeInformation[] attributeInfoArray = ImaqdxAttributeManager.EnumeratePrivateAttributes(_session.Handle); for (int i = 0; i < attributeInfoArray.Length; i++) { if (attributeInfoArray[i].Name == name) { AddAttribute(attributeInfoArray[i]); return; } } throw ExceptionBuilder.NonexistentPrivateAttribute(); }
//========================================================================================== /// <summary> /// Executes the attribute operation. /// </summary> /// <exception cref="System.ObjectDisposedException"> /// The session has been disposed. /// </exception> //========================================================================================== public void Execute() { Session.ValidateSessionHandle(); ImaqdxAttributeManager.SetAttribute(Session.Handle, Name, true); }
//========================================================================================== /// <summary> /// Sets the value for a camera attribute. /// </summary> /// <param name="value"> /// The value to set the camera attribute to. /// </param> /// <exception cref="System.ObjectDisposedException"> /// The session has been disposed. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="value"/> is <see langword="null"/>. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The type of the value is invalid or not supported. /// </exception> //========================================================================================== public void SetValue(object value) { _session.ValidateSessionHandle(); if (value == null) { throw ExceptionBuilder.ArgumentNull("value"); } Type dataType = value.GetType(); if (dataType == typeof(sbyte)) { sbyte sbyteValue = (sbyte)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)sbyteValue); } else if (dataType == typeof(byte)) { byte byteValue = (byte)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)byteValue); } else if (dataType == typeof(short)) { short shortValue = (short)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)shortValue); } else if (dataType == typeof(ushort)) { ushort ushortValue = (ushort)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)ushortValue); } else if (dataType == typeof(int)) { int intValue = (int)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)intValue); } else if (dataType == typeof(uint)) { uint uintValue = (uint)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, uintValue); } else if (dataType == typeof(long)) { long longValue = (long)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, longValue); } else if (dataType == typeof(ulong)) { ulong ulongValue = (ulong)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (long)ulongValue); } else if (dataType == typeof(decimal)) { decimal decimalValue = (decimal)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (double)decimalValue); } else if (dataType == typeof(float)) { float floatValue = (float)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (double)floatValue); } else if (dataType == typeof(double)) { double doubleValue = (double)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, doubleValue); } else if (dataType == typeof(string)) { string stringValue = (string)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, stringValue); } else if (dataType == typeof(ImaqdxEnumAttributeItem)) { ImaqdxEnumAttributeItem enumItemValue = (ImaqdxEnumAttributeItem)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, enumItemValue); } else if (dataType == typeof(bool)) { bool boolValue = (bool)value; ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, boolValue); } else { throw ExceptionBuilder.UnknownDataType(); } }