Esempio n. 1
0
 def count(self, type):
     """Return the number of channels or ranges per the type specifier using the prevailing device and/or channel for those types that require it.
     
     :type type: int
     Available Options can be accessed as
         COUNT.ANALOG - analog channels on the selected device
         COUNT.LOGIC - logic channels on the selected device
         COUNT.RANGE - number of analog ranges on the selected channel
     
     :param type: specifies the type for which count must be found
     
     :return: count of the selected type
     """
     if type in [
             bitlib.BL_COUNT_ANALOG, bitlib.BL_COUNT_LOGIC,
             bitlib.BL_COUNT_RANGE
     ]:
         if type == bitlib.BL_COUNT_ANALOG:
             self.analog_count = bitlib.BL_Count(type)
             return self.analog_count
         if type == bitlib.BL_COUNT_LOGIC:
             self.logic_count = bitlib.BL_Count(type)
             return self.logic_count
         if type == bitlib.BL_COUNT_RANGE:
             self.analog_range_count = bitlib.BL_Count(type)
             return self.analog_range_count
     else:
         logger.debug("Invalid Count Type")
         return 0
Esempio n. 2
0
 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)
Esempio n. 3
0
    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))
Esempio n. 4
0
 def count(self, type=bitlib.BL_COUNT_DEVICE):
     """Return the number of prevailing device available.
     
     :type type: int
     Available Options are
         COUNT.DEVICE - successfully opened devices
     
     :param type: specifies the type for which count must be found
     
     :return: count of the selected type
     """
     if type == bitlib.BL_COUNT_DEVICE:
         self.device_count = bitlib.BL_Count(type)
         return self.device_count
     else:
         logger.debug("Invalid Count Type")
         return 0
Esempio n. 5
0
    def __init__(self, probe_files=None, count=1):
        """Initialise the Scope Object.
        
        Open devices listed in probe file probe_files (string) or a literal list of links,
        also specified via probe_files (individual links are separated by newlines). If
        not specified, the standard probe file is used. Opens the first valid
        link found unless count is specified in which case count links are attempted and
        valid links are opened. Returns number of successfully opened links.

        Initializes Device Objects for each opened device
        Initializes Channel Objects for each channel available in the device.
        
        :type probe_files: string
        :param probe_files: USB Port Connected to Bitscope
        :type count: int
        :param count: number of devices to be opened. default 1
        
        :returns: instance of the class Scope  
        """

        # Finds number of Devices Opened
        self.device_count = bitlib.BL_Open(probe_files, count)

        if self.device_count == 0:
            logger.debug("  FAILED: no devices found (check your probe file).")
            return

        # create Device object for each and append in scope.devices
        self.devices = [
            Device(device)
            for device in range(0, bitlib.BL_Count(bitlib.BL_COUNT_DEVICE))
        ]

        # number of corresponding channels
        # instanciate Object from Sub Classess
        self.tracer = Tracer()
        logger.debug("Bitscope Micro Units Opened : {}".format(
            len(self.devices)))