def decode(filename): f = open(filename, 'rb') bytes = f.read() f.close() if (bytes[:11] != b'[offset:0]\n'): print('[Error] Unknown format for file %s' % filename) return '' client = Client64(module32='wrapper') result = client.request32('decrypt', bytes[11:]) result = decompress(result) return str(result, encoding='utf-8')
def __init__(self, record): """A wrapper around the :class:`~.benhw32.Bentham32` class. This class can be used with either a 32- or 64-bit Python interpreter to call the 32-bit functions in ``benhw32_cdecl.dll``. The :attr:`~msl.equipment.record_types.ConnectionRecord.properties` for a Bentham connection supports the following key-value pairs in the :ref:`connections_database`:: 'cfg': str, the path to the System.cfg file [default: None] 'atr': str, the path to the System.atr file [default: None] If the ``cfg`` and ``atr`` values are not defined in the :ref:`connections_database` then you will have to call :meth:`build_system_model`, :meth:`load_setup` and :meth:`initialise` (in that order) to configure the SDK. Do not instantiate this class directly. Use the :meth:`~.EquipmentRecord.connect` method to connect to the equipment. Parameters ---------- record : :class:`~.EquipmentRecord` A record from an :ref:`equipment_database`. """ self._is_connected = False super(Bentham, self).__init__(record) self.set_exception_class(BenthamError) path = record.connection.address[5:] head, tail = os.path.split(path) self._tail = tail self.log_debug('Starting 32-bit server for {}'.format(tail)) # the IEEE_32M.dll library must be available on PATH env_path = [head, os.path.join(head, 'IEEE', 'Dummy')] self._client = Client64('benhw32', append_sys_path=os.path.dirname(__file__), append_environ_path=env_path, lib_path=path) self._hw_id = None cfg_path = record.connection.properties.get('cfg') atr_path = record.connection.properties.get('atr') if cfg_path and atr_path: self.build_system_model(cfg_path) self.load_setup(atr_path) self.initialise() self._is_connected = True
def __init__(self, record): """A wrapper around the :class:`~.datarayocx_32.DataRayOCX32` class. This class can be used with either a 32- or 64-bit Python interpreter to call the 32-bit functions in the ``DATARAYOCX`` library. A GUI is created to configure and visualize the images taken by the camera. The :attr:`~msl.equipment.record_types.ConnectionRecord.properties` for a DataRay connection supports the following key-value pairs in the :ref:`connections-database`:: 'area_filter': int, area filter: 1=1pixel, 2=3pixels, 3=5pixels, 4=7pixels, 5=9pixels [default: 1] 'camera_index': int, the camera to use (between 0 and 7; 0=first camera found) [default: 0] 'centroid_method': int, the centroid method to use (0, 1 or 2) [default: 0] 'filter': float, percent full scale filter (0, 0.1, 0.2, 0.5, 1, 2, 5 or 10) [default: 0.2] 'major_minor_method': int, the major/minor method to use (0, 1 or 2) [default: 0] 'ui_size': int, the size of the User Interface (value=height of a button in pixels) [default: 25] Do not instantiate this class directly. Use the :meth:`~.EquipmentRecord.connect` method to connect to the equipment. Parameters ---------- record : :class:`~.EquipmentRecord` A record from an :ref:`equipment-database`. """ self._client = None super(DataRayOCX64, self).__init__(record) self.set_exception_class(DataRayError) error_connecting = None try: self._client = Client64('datarayocx_32', append_sys_path=os.path.dirname(__file__), timeout=10, **record.connection.properties) except Exception as err: error_connecting = err if error_connecting: self.raise_exception( 'Cannot connect to the DataRay Beam Profiler.\n{}'.format( error_connecting)) self.log_debug('Connected to {}'.format(record.connection))