public static string GetFullAttributeName(ImaqdxSessionHandle session, string partialName) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(partialName != null, "The partialName parameter cannot be null."); IntPtr stringPtr = IntPtr.Zero; try { int status = NiImaqdxDll.IMAQdxGetFullyQualifiedAttributeName(session, partialName, ref stringPtr); if (status == -1074360305) { // This error is returned when the attribute is not supported by the camera // In this case we do not want to return an exception // Return an empty string to indicate the the attribute was not found return(string.Empty); } ExceptionBuilder.CheckErrorAndThrow(status); return(Marshal.PtrToStringAnsi(stringPtr)); } finally { if (stringPtr != IntPtr.Zero) { int status = NiImaqdxDll.IMAQdxDispose(stringPtr); ExceptionBuilder.CheckErrorAndThrow(status); } } }
public static void Close(ImaqdxSessionHandle session) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); int status = NiImaqdxDll.IMAQdxCloseCamera(session); ExceptionBuilder.CheckErrorAndThrow(status); }
public static void WriteRegister(ImaqdxSessionHandle session, ulong offset, uint value) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); int status = NiImaqdxDll.IMAQdxWriteRegister(session, (uint)offset, value); ExceptionBuilder.CheckErrorAndThrow(status); }
public static void ReadAttributesFromCameraFile(ImaqdxSessionHandle session) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); int status = NiImaqdxDll.IMAQdxReadAttributes(session, null); ExceptionBuilder.CheckErrorAndThrow(status); }
public static void InstallPnpEventHandler(ImaqdxSessionHandle session, ImaqdxPnpEvent pnpEvent, ImaqdxPnpEventHandler callback) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(callback != null, "The callback parameter cannot be null."); int status = NiImaqdxDll.IMAQdxRegisterPnpEvent(session, pnpEvent, callback, IntPtr.Zero); ExceptionBuilder.CheckErrorAndThrow(status); }
public static void InstallImageAcquiredEventHandler(ImaqdxSessionHandle session, ImaqdxFrameDoneEventHandler callback) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(callback != null, "The callback parameter cannot be null."); int status = NiImaqdxDll.IMAQdxRegisterFrameDoneEvent(session, DefaultBufferInterval, callback, IntPtr.Zero); ExceptionBuilder.CheckErrorAndThrow(status); }
public static void Snap(ImaqdxSessionHandle session, VisionImage image) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(image != null, "The image parameter cannot be null."); int status = NiImaqdxDll.IMAQdxSnap(session, image._image); ExceptionBuilder.CheckErrorAndThrow(status); }
public static void WriteMemory(ImaqdxSessionHandle session, ulong offset, byte[] values) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(values != null, "The values parameter cannot be null."); int status = NiImaqdxDll.IMAQdxWriteMemory(session, (uint)offset, values, (uint)values.Length); ExceptionBuilder.CheckErrorAndThrow(status); }
public static void WriteAttributesToFile(ImaqdxSessionHandle session, string fullPath) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(fullPath != null, "The fullPath parameter cannot be null."); int status = NiImaqdxDll.IMAQdxWriteAttributes(session, fullPath); ExceptionBuilder.CheckErrorAndThrow(status); }
public static void SetAttribute(ImaqdxSessionHandle session, string name, string value) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(name != null, "The name parameter cannot be null."); int status = NiImaqdxDll.IMAQdxSetAttribute(session, name, ImaqdxAttributeType.String, value); ExceptionBuilder.CheckErrorAndThrow(status); }
public static void ConfigureAcquisition(ImaqdxSessionHandle session, ImaqdxAcquisitionType acquisitionType, int bufferCount) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(bufferCount > 0, "The bufferCount parameter must be greater than zero."); bool isContinuous = (acquisitionType == ImaqdxAcquisitionType.Continuous); int status = NiImaqdxDll.IMAQdxConfigureAcquisition(session, Convert.ToUInt32(isContinuous), (uint)bufferCount); ExceptionBuilder.CheckErrorAndThrow(status); }
private static void CreateImageDataArray(ImaqdxSessionHandle session, ref byte[] data) { uint bufferSize; int status = NiImaqdxDll.IMAQdxGetRawBufferSize(session, out bufferSize); ExceptionBuilder.CheckErrorAndThrow(status); if (data == null || data.Length != bufferSize) { data = new byte[bufferSize]; } }
public static uint GetImage(ImaqdxSessionHandle session, ImaqdxBufferNumberMode bufferNumberMode, VisionImage image) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(image != null, "The image parameter cannot be null."); uint actualBufferNumber; int status = NiImaqdxDll.IMAQdxGetImage(session, image._image, bufferNumberMode, (uint)0, out actualBufferNumber); ExceptionBuilder.CheckErrorAndThrow(status); return(actualBufferNumber); }
public static string GetAttributeUnits(ImaqdxSessionHandle session, string name) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(name != null, "The name parameter cannot be null."); string units; int status = NiImaqdxDll.IMAQdxGetAttributeUnitsCW(session, name, out units); ExceptionBuilder.CheckErrorAndThrow(status); return(units == null ? string.Empty : units); }
public static uint Grab(ImaqdxSessionHandle session, VisionImage image, bool waitForNextBuffer) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(image != null, "The image parameter cannot be null."); uint actualBufferNumber; int status = NiImaqdxDll.IMAQdxGrab(session, image._image, Convert.ToUInt32(waitForNextBuffer), out actualBufferNumber); ExceptionBuilder.CheckErrorAndThrow(status); return(actualBufferNumber); }
public static ImaqdxAttributeVisibility GetAttributeVisibility(ImaqdxSessionHandle session, string name) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(name != null, "The name parameter cannot be null."); ImaqdxAttributeVisibility visibility; int status = NiImaqdxDll.IMAQdxGetAttributeVisibility(session, name, out visibility); ExceptionBuilder.CheckErrorAndThrow(status); return(visibility); }
public static bool GetIsAttributeWritable(ImaqdxSessionHandle session, string name) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(name != null, "The name parameter cannot be null."); uint writable; int status = NiImaqdxDll.IMAQdxIsAttributeWritable(session, name, out writable); ExceptionBuilder.CheckErrorAndThrow(status); return(Convert.ToBoolean(writable)); }
public static void GetAttribute(ImaqdxSessionHandle session, string name, out string value) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(name != null, "The name parameter cannot be null."); object objectValue; int status = NiImaqdxDll.IMAQdxGetAttributeCW(session, name, ImaqdxAttributeType.String, out objectValue); ExceptionBuilder.CheckErrorAndThrow(status); value = (objectValue == null ? string.Empty : (string)objectValue); }
public static void GetAttribute(ImaqdxSessionHandle session, string name, out bool value) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(name != null, "The name parameter cannot be null."); byte byteValue; int status = NiImaqdxDll.IMAQdxGetAttribute(session, name, ImaqdxAttributeType.Boolean, out byteValue); ExceptionBuilder.CheckErrorAndThrow(status); value = Convert.ToBoolean(byteValue); }
public static void GetAttribute(ImaqdxSessionHandle session, string name, out ImaqdxEnumAttributeItem value) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(name != null, "The name parameter cannot be null."); ImaqdxEnumItem enumItemValue; int status = NiImaqdxDll.IMAQdxGetAttribute(session, name, ImaqdxAttributeType.Enum, out enumItemValue); ExceptionBuilder.CheckErrorAndThrow(status); value = new ImaqdxEnumAttributeItem(enumItemValue); }
public static byte[] ReadMemory(ImaqdxSessionHandle session, ulong offset, int count) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(count > 0, "The count parameter must be greater than zero."); byte[] values = new byte[count]; int status = NiImaqdxDll.IMAQdxReadMemory(session, (uint)offset, values, (uint)count); ExceptionBuilder.CheckErrorAndThrow(status); return(values); }
public static uint GetImageData(ImaqdxSessionHandle session, ImaqdxBufferNumberMode bufferNumberMode, ref byte[] data) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); CreateImageDataArray(session, ref data); uint actualBufferNumber; int status = NiImaqdxDll.IMAQdxGetImageData(session, data, (uint)data.Length, bufferNumberMode, (uint)0, out actualBufferNumber); ExceptionBuilder.CheckErrorAndThrow(status); return(actualBufferNumber); }
public static ImaqdxAttributeInformation[] EnumeratePrivateAttributes(ImaqdxSessionHandle session) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); uint count; int status = NiImaqdxDll.IMAQdxEnumerateAttributes2(session, null, out count, "", PrivateVisibility); ExceptionBuilder.CheckErrorAndThrow(status); ImaqdxAttributeInformation[] attributeInfoArray = new ImaqdxAttributeInformation[count]; status = NiImaqdxDll.IMAQdxEnumerateAttributes2(session, attributeInfoArray, out count, "", PrivateVisibility); ExceptionBuilder.CheckErrorAndThrow(status); return(attributeInfoArray); }
public static void Sequence(ImaqdxSessionHandle session, VisionImage[] images) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(images != null, "The images parameter cannot be null."); IntPtr[] imagePtrs = new IntPtr[images.Length]; for (int i = 0; i < images.Length; i++) { imagePtrs[i] = images[i]._image; } int status = NiImaqdxDll.IMAQdxSequence(session, imagePtrs, (uint)imagePtrs.Length); ExceptionBuilder.CheckErrorAndThrow(status); }
public static ImaqdxEnumAttributeItem[] EnumerateAttributeValues(ImaqdxSessionHandle session, string name) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); Debug.Assert(name != null, "The name parameter cannot be null."); uint count; int status = NiImaqdxDll.IMAQdxEnumerateAttributeValues(session, name, null, out count); ExceptionBuilder.CheckErrorAndThrow(status); ImaqdxEnumItem[] enumItemArray = new ImaqdxEnumItem[count]; status = NiImaqdxDll.IMAQdxEnumerateAttributeValues(session, name, enumItemArray, out count); ExceptionBuilder.CheckErrorAndThrow(status); ImaqdxEnumAttributeItem[] enumItems = new ImaqdxEnumAttributeItem[count]; for (int i = 0; i < count; i++) { enumItems[i] = new ImaqdxEnumAttributeItem(enumItemArray[i]); } return(enumItems); }
public static string WriteAttributesToString(ImaqdxSessionHandle session) { Debug.Assert(session != null, "The session parameter cannot be null."); Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle."); IntPtr stringPtr = IntPtr.Zero; try { int status = NiImaqdxDll.IMAQdxWriteAttributesToString(session, ref stringPtr); ExceptionBuilder.CheckErrorAndThrow(status); string attributesString = Marshal.PtrToStringAnsi(stringPtr); return(attributesString == null ? string.Empty : attributesString); } finally { if (stringPtr != IntPtr.Zero) { int status = NiImaqdxDll.IMAQdxDispose(stringPtr); ExceptionBuilder.CheckErrorAndThrow(status); } } }
public static extern int IMAQdxGetAttributeMaximum(ImaqdxSessionHandle id, string name, ImaqdxAttributeType type, out uint val);
public static extern int IMAQdxIsAttributeWritable(ImaqdxSessionHandle id, string name, out uint writable);
public static extern int IMAQdxGetAttributeVisibility(ImaqdxSessionHandle id, string name, out ImaqdxAttributeVisibility visibility);
public static extern int IMAQdxGetAttributeUnitsCW(ImaqdxSessionHandle id, string name, [MarshalAs(UnmanagedType.BStr)] out string units);