Impact Acquire SDK Python
|
When you are familiar with the C++ interface of Impact Acquire already there are some of important differences you need to know! They shall be explained briefly:
Impact Acquire < 3.0.1
was tested using Python 3.7.4 and Python 2.7.2.1). If you encounter issues with this or other versions of Python you are working with please get in touch! However, Balluff does not intend to support Python versions that receive no support from the Python Software Foundation (PSF). In particular, Impact Acquire >= 3.0.1
does not support any version of Python 2. See the Python Developer's Guide for more information on the PSF's supported versions and maintenance schedules.Impact Acquire >= 3.0.1
is required.There are not too many differences between the C++ and the Python API but some of them are important. They shall be explained briefly:
// C++ const TInterfaceLayout interfaceLayout = mvIMPACT::acquire::dilGenICam; # Python interfaceLayout = mvIMPACT.acquire.dilGenICamHowever in Python there will be no type
TInterfaceLayout
. As most of the documentation in this manual has been auto-translated from the C++ API reference there will be some locations where these enum types are still referenced. Valid enumeration values in this case can be derived from the building a matching prefix yourself. Take all the capital letters from the type (EXCLUDING the first 'T') and check the documentation for matching values. For the type TDeviceInterfaceLayout this prefix will be dil!
getter
functions may be wrapped as Python properties to have a more Python-like
interface. So e.g. the function Component::isValid() will be a property (Component.isValid) in Pythonget
. So you call c = acquire.Component(hObj) # member function c.visibilityAsString() # static member function acquire.Component.getVisibilityAsString(acquire.cvGuru)
Apart from that if someone is familiar with the C++ interface it shouldn't be too difficult to use Impact Acquire with Python.
Some APIs like mvIMPACT::acquire::Request::attachUserBuffer require a buffer aligned to a certain size. In Python, objects supporting the Buffer protocol can be used for these APIs (e.g. bytearray
), but there is no convenient way of fulfilling the alignment requirement. A useful method of achieving arbitrary alignment is to use the ctypes
module to obtain the address of the underlying buffer and offset it to match the alignment: