def source(self, type=bitlib.BL_SOURCE_BNC): """Request the selection of a range or sources. :type type: int Available options are SOURCE.POD - analog or logic channel POD input SOURCE.BNC - analog channel BNC input (if available) SOURCE.X10 - analog input prescaled by 10 SOURCE.X20 - analog input prescaled by 20 SOURCE.X50 - analog input prescaled by 50 SOURCE.ALT - alternate input (data acquisition) SOURCE.GND - ground reference input :param type: selects the type of source for a channel """ self.select() if type in [ bitlib.BL_SOURCE_POD, bitlib.BL_SOURCE_BNC, bitlib.BL_SOURCE_X10, bitlib.BL_SOURCE_X20, bitlib.BL_SOURCE_X50, bitlib.BL_SOURCE_ALT, bitlib.BL_SOURCE_GND ]: if type != bitlib.BL_Select(bitlib.BL_SELECT_SOURCE, bitlib.BL_ASK): # select the corresponding source for the channel self.source = bitlib.BL_Select(bitlib.BL_SELECT_SOURCE, type) return self.source
def select(self): """Request the selection of a current device. :return: current selection is returned. """ # check if the required device is selected if self.id != bitlib.BL_Select(bitlib.BL_SELECT_DEVICE,bitlib.BL_ASK): # select the corresponding device first self.id = bitlib.BL_Select(bitlib.BL_SELECT_DEVICE,self.id) return self.id
def select(self): """Request the selection of a current channel. :return: current selection of channel is returned. """ # check if the corresponding device is already selected if self.device != bitlib.BL_Select(bitlib.BL_SELECT_DEVICE, bitlib.BL_ASK): # select the corresponding device first bitlib.BL_Select(bitlib.BL_SELECT_DEVICE, self.device) if self.id != bitlib.BL_Select(bitlib.BL_SELECT_CHANNEL, bitlib.BL_ASK): # select the corresponding channel next self.id = bitlib.BL_Select(bitlib.BL_SELECT_CHANNEL, self.id) return self.id
def configure(self, source=bitlib.BL_SOURCE_BNC, offset=bitlib.BL_ZERO, range=0, coupling=bitlib.BL_COUPLING_DC): """Configure the channel parameters like source, offset, analog_range, coupling for the selected device and channel. :type source: Available options are SOURCE.POD - analog or logic channel POD input SOURCE.BNC - analog channel BNC input (if available) SOURCE.X10 - analog input prescaled by 10 SOURCE.X20 - analog input prescaled by 20 SOURCE.X50 - analog input prescaled by 50 SOURCE.ALT - alternate input (data acquisition) SOURCE.GND - ground reference input :param source: selects the type of source for a channel :type offset: int :param offset: the value to be offset :type range: int :param range: maximum peak-to-peak voltage the can be captured on the selected device, channel and source. :type coupling: int Available options are COUPLING.DC - direct connection for DC signals (the default) COUPLING.AC - AC connection (eliminates DC bias) COUPLING.RF - RF connection for very high frequencies :param coupling: Selects coupling """ self.select() if source in [ bitlib.BL_SOURCE_POD, bitlib.BL_SOURCE_BNC, bitlib.BL_SOURCE_X10, bitlib.BL_SOURCE_X20, bitlib.BL_SOURCE_X50, bitlib.BL_SOURCE_ALT, bitlib.BL_SOURCE_GND ]: # select the corresponding source for the channel bitlib.BL_Select(bitlib.BL_SELECT_SOURCE, source) self.source = source # set offset bitlib.BL_Offset(offset) # set range if range >= 0 and range <= (self.analog_range_count) - 1: bitlib.BL_Range(range) # set coupling if coupling in [ bitlib.BL_COUPLING_AC, bitlib.BL_COUPLING_DC, bitlib.BL_COUPLING_RF ]: self.coupling = bitlib.BL_Coupling(coupling)
def __init__(self, device, channel): """Initialise channel objects. :type device: int :param device: device id :type channel: int :param channel: channel id """ self.device = device self.id = channel # device is seleted from previous Device class # select corresponding channel bitlib.BL_Select(bitlib.BL_SELECT_CHANNEL, channel) self.analog_count = bitlib.BL_Count(bitlib.BL_COUNT_ANALOG) self.logic_count = bitlib.BL_Count(bitlib.BL_COUNT_LOGIC) self.analog_range_count = bitlib.BL_Count(bitlib.BL_COUNT_RANGE)
def __init__(self,device): """Initialise the Device Object. :type device: int :param device: device id to be initialised :returns: instance of the class Device """ self.id = device bitlib.BL_Select(bitlib.BL_SELECT_DEVICE,device) self.name = bitlib.BL_Name() self.device_id = bitlib.BL_ID() self.version = bitlib.BL_Version(bitlib.BL_VERSION_DEVICE) # Find number of channels in each device and create Channel object for each and append in devices.channels self.channels = [] for channel in range(0,bitlib.BL_Count(bitlib.BL_COUNT_ANALOG)): self.channels.append(Channel(self.id, channel)) for channel in range(0,bitlib.BL_Count(bitlib.BL_COUNT_LOGIC)): self.channels.append(Channel(self.id, channel))