diff options
| author | morefigs <morefigs@gmail.com> | 2019-01-27 11:58:21 +1100 |
|---|---|---|
| committer | morefigs <morefigs@gmail.com> | 2019-01-27 11:58:21 +1100 |
| commit | 888eb9d0f9bb10e41bb5e928a51162b0b4683104 (patch) | |
| tree | c920d12fd75b47118dcf569659a1f4b5645eec9f | |
| parent | 5187175c5fe668659e9b35d527e2ddd1d9d9a725 (diff) | |
| download | pymba-888eb9d0f9bb10e41bb5e928a51162b0b4683104.tar.gz pymba-888eb9d0f9bb10e41bb5e928a51162b0b4683104.zip | |
nice structure class with better repr
| -rw-r--r-- | pymba/vimba_c.py | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/pymba/vimba_c.py b/pymba/vimba_c.py index b996720..034df6e 100644 --- a/pymba/vimba_c.py +++ b/pymba/vimba_c.py @@ -73,14 +73,35 @@ else: CALLBACK_FUNCTYPE = CFUNCTYPE -class VmbVersionInfo(Structure): +class NiceStructure(Structure): + def __repr__(self): + field_names = (field[0] for field in self._fields_) + return f'{type(self).__name__}(' \ + f'{", ".join("=".join((field, str(getattr(self, field)))) for field in field_names)})' + + +class VmbVersionInfo(NiceStructure): _fields_ = [ ('major', c_uint32), ('minor', c_uint32), ('patch', c_uint32)] -class VmbCameraInfo(Structure): +class VmbInterfaceInfo(NiceStructure): + _fields_ = [ + # Unique identifier for each interface + ('interfaceIdString', c_char_p), + # Interface type, see VmbInterfaceType + ('interfaceType', c_uint32), + # Interface name, given by the transport layer + ('interfaceName', c_char_p), + # Serial number + ('serialString', c_char_p), + # Used access mode, see VmbAccessModeType + ('permittedAccess', c_uint32)] + + +class VmbCameraInfo(NiceStructure): _fields_ = [ # Unique identifier for each camera ('cameraIdString', c_char_p), @@ -96,7 +117,7 @@ class VmbCameraInfo(Structure): ('interfaceIdString', c_char_p)] -class VmbFeatureInfo(Structure): +class VmbFeatureInfo(NiceStructure): _fields_ = [ ('name', c_char_p), ('featureDataType', c_uint32), @@ -155,28 +176,14 @@ class VmbFrame(Structure): ('timestamp', c_uint64)] -class VmbInterfaceInfo(Structure): - _fields_ = [ - # Unique identifier for each interface - ('interfaceIdString', c_char_p), - # Interface type, see VmbInterfaceType - ('interfaceType', c_uint32), - # Interface name, given by the transport layer - ('interfaceName', c_char_p), - # Serial number - ('serialString', c_char_p), - # Used access mode, see VmbAccessModeType - ('permittedAccess', c_uint32)] - - _vimba_lib = dll_loader.LoadLibrary(vimbaC_path) # ----- The below function signatures are defined in VimbaC.h ----- # callback for frame queue -vmb_frame_callback = CALLBACK_FUNCTYPE(c_void_p, - c_void_p, - POINTER(VmbFrame)) +vmb_frame_callback_func = CALLBACK_FUNCTYPE(c_void_p, + c_void_p, + POINTER(VmbFrame)) vmb_version_query = _vimba_lib.VmbVersionQuery vmb_version_query.restype = c_int32 |
