fixate.drivers package

class fixate.drivers.Driver

Bases: object

Driver base class for creating self connecting drivers.

connect() is called whenever a public method api call is made and is_connected = False:

def _my_func(self):
    pass

will not call connect, as it is a private function by convention. Whereas this will:

def my_func(self):
    pass

Exceptions to this rule are connect(), disconnect() and function strings as can be defined by creating a list called _connect_ignore on the class definition

connect()

Override connect() function, but ensure that self.is_connected is set if connected or an exception occurs if connection could not be established

disconnect()

Override disconnect function, but ensure that self.is_connected is set to False

is_connected = False
class fixate.drivers.DriverManager(**kwargs)

Bases: object

Driver manager allows for multiple drivers to be collated and managed from a central location. Drivers must be either derived from the driver class or must implement the functions:

def connect(self): # No Parameters
def disconnect(self): # No Parameters

and have an attribute:

is_connected (Boolean)
add_drivers(**kwargs)
Parameters:

kwargs (dict) – kwargs of <id>=<driver>.

Returns:

None

Example

>>> class MyDmm(Driver):
>>>     def hello(self):
>>>         print("World")
>>> dm = DriverManager(dmm=MyDmm())
>>> dm.dmm.hello()
World
cleanup_clear()
cleanup_execute()
cleanup_register(func, *args, **kwargs)

Registers a cleanup function to be executed on cleanup_execute call. The registered functions are executed in the order they are added via this function. Use cleanup_clear() to remove all the registered cleanup functions

Parameters:
  • func – function as directly refrenced. eg. dm.dmm.disconnect

  • *args – The arguments that should be called with the func

  • **kwargs – The keyword arguments that should be called with the func

Returns:

None

register_initialisation(id, init_funcs)
remove_drivers(*ids)
Parameters:

ids – Drivers to be removed

Returns:

None

Example

>>> class MyDmm(Driver):
>>>     def hello(self):
>>>         print("Hello World")
>>> dm = DriverManager(dmm=MyDmm(), dmm2=MyDmm())
>>> dm.dmm.hello()
Hello World
>>> dm.remove_drivers('dmm', 'dmm2')
>>> dm.dmm.hello()
AttributeError: 'DriverManager' object has no attribute 'dmm'
class fixate.drivers.DriverMeta(clsname, bases, dct)

Bases: type

class fixate.drivers.DriverProtocol(*args, **kwargs)

Bases: Protocol

REGEX_ID: str
get_identity() str

Query the instrument for it identity.

For visa instruments, this is generally the results of the idn? command. For other drivers, it can be any meaningful id. Where possible it should include a unique identifier like a serial number.

exception fixate.drivers.InstrumentNotFoundError

Bases: Exception

exception fixate.drivers.InstrumentOpenError

Bases: Exception

fixate.drivers.log_instrument_open(instrument: DriverProtocol) None

Subpackages

Submodules

fixate.drivers.ftdi module

class fixate.drivers.ftdi.BIT_MODE

Bases: object

FT_BITMODE_ASYNC_BITBANG = c_ulong(1)
FT_BITMODE_CBUS_BITBANG = c_ulong(32)
FT_BITMODE_FAST_SERIAL = c_ulong(16)
FT_BITMODE_MCU_HOST = c_ulong(8)
FT_BITMODE_MPSSE = c_ulong(2)
FT_BITMODE_RESET = c_ulong(0)
FT_BITMODE_SYNC_BITBANG = c_ulong(4)
FT_BITMODE_SYNC_FIFO = c_ulong(64)
class fixate.drivers.ftdi.FLAGS

Bases: object

FT_OPEN_BY_DESCRIPTION = c_ulong(2)
FT_OPEN_BY_LOCATION = c_ulong(4)
FT_OPEN_BY_SERIAL_NUMBER = c_ulong(1)
exception fixate.drivers.ftdi.FTD2XXError

Bases: FixateError

class fixate.drivers.ftdi.FTDI2xx(ftdi_description)

Bases: object

INSTR_TYPE = 'FTDI'
property baud_rate
close()
configure_bit_bang(bit_mode, bytes_required, latch_mask=1, clk_mask=2, data_mask=4, invert_mask=0)
Parameters:
  • bit_mode

  • bytes_required

  • latch_mask – CBUS Pin for latch. 1 Default for Relay Matrix

  • clk_mask – CBUS Pin for clock. 2 Default for Relay Matrix

  • data_mask – CBUS Pin for data. 4 Default for Relay Matrix

  • invert_mask

    Mask for inverting. Based on 0b<latch><clock><data>

    e.g. 0b100 Would mean the latch bit is inverted. 0b011 would mean the clock and data bits are inverted.

Returns:

get_cbus_pins()
get_identity() str

Return identity string representing connected ftdi object

property parity
read()
read_raw()
serial_shift_bit_bang(data, bytes_required=None)
property stop_bits
property word_length
write(data, size=None)
write_bit_mode(mask, validate=False)
Parameters:

mask

value to write for the mask for BIT_MODE.FT_BITMODE_CBUS_BITBANG

  • upper nibble is input (0) output (1)

  • lower nibble is pin value low (0) high (1)

class fixate.drivers.ftdi.FT_DEVICE

Bases: object

FT_DEVICE_100AX = c_ulong(2)
FT_DEVICE_2232C = c_ulong(4)
FT_DEVICE_2232H = c_ulong(6)
FT_DEVICE_232AM = c_ulong(1)
FT_DEVICE_232BM = c_ulong(0)
FT_DEVICE_232H = c_ulong(8)
FT_DEVICE_232R = c_ulong(5)
FT_DEVICE_4232H = c_ulong(7)
FT_DEVICE_UNKNOWN = c_ulong(3)
FT_DEVICE_X_SERIES = c_ulong(9)
class fixate.drivers.ftdi.FT_DEVICE_LIST_INFO_NODE

Bases: Structure

Description

Structure/Union member

Flags

Structure/Union member

ID

Structure/Union member

LocId

Structure/Union member

SerialNumber

Structure/Union member

Type

Structure/Union member

ftHandle

Structure/Union member

fixate.drivers.ftdi.LPDWORD

alias of LP_c_ulong

class fixate.drivers.ftdi.PARITY

Bases: object

FT_PARITY_EVEN = c_ubyte(2)
FT_PARITY_MARK = c_ubyte(3)
FT_PARITY_NONE = c_ubyte(0)
FT_PARITY_ODD = c_ubyte(1)
FT_PARITY_SPACE = c_ubyte(4)
fixate.drivers.ftdi.PUCHAR

alias of LP_c_ubyte

class fixate.drivers.ftdi.STOP_BITS

Bases: object

FT_STOP_BITS_1 = c_ubyte(0)
FT_STOP_BITS_2 = c_ubyte(2)
class fixate.drivers.ftdi.WORD_LENGTH

Bases: object

FT_BITS_7 = c_ubyte(7)
FT_BITS_8 = c_ubyte(8)
fixate.drivers.ftdi.check_return(return_code)
fixate.drivers.ftdi.create_device_info_list()
fixate.drivers.ftdi.get_device_info_list()
fixate.drivers.ftdi.open(ftdi_description='') FTDI2xx

Open FTDI Driver

fixate.drivers.handlers module

This module implements concrete AddressHandler type, that can be used to implement IO for the fixate.core.switching module.

class fixate.drivers.handlers.FTDIAddressHandler(pins: Sequence[str], ftdi_description: str)

Bases: PinValueAddressHandler

An address handler which uses the ftdi driver to control pins.

We create this concrete address handler because we use it most often. FT232 is used to bit-bang to shift register that are control the switching in a jig.

close() None

Optional close method to clean-up resources.

This will be called automatically by the JigDriver for any address handlers passed into the JigDriver when it as created.