def rawAIBurst(self, channel0PGAMUX = 8, channel1PGAMUX = 9, channel2PGAMUX = 10, channel3PGAMUX = 11, NumberOfScans = 8, TriggerIONum = 0, TriggerState = 0, UpdateIO = False, LEDState = True, IO3ToIO0States = 0, FeatureReports = False, TriggerOn = False, SampleInterval = 15000):
        """
        Name: U12.rawAIBurst( channel0PGAMUX = 8, channel1PGAMUX = 9,
                              channel2PGAMUX = 10, channel3PGAMUX = 11,
                              NumberOfScans = 8, TriggerIONum = 0,
                              TriggerState = 0, UpdateIO = False,
                              LEDState = True, IO3ToIO0States = 0,
                              FeatureReports = False, TriggerOn = False,
                              SampleInterval = 15000 )
        
        Args: channel0PGAMUX, A byte that contains channel0 information
              channel1PGAMUX, A byte that contains channel1 information
              channel2PGAMUX, A byte that contains channel2 information
              channel3PGAMUX, A byte that contains channel3 information
              NumberOfScans, The number of scans you wish to take. Rounded up
                             to a power of 2.
              TriggerIONum, IO to trigger burst on.
              TriggerState, State to trigger on.
              UpdateIO, True if you want to update the IO/D line. False to 
                        False to just read their values.
              LEDState, Turns the status LED on or off.
              IO3ToIO0States, 4 bits for IO3-0 states
              FeatureReports, Use feature reports, or not.
              TriggerOn, Use trigger to start acquisition.
              SampleInterval, = int(6000000.0/(ScanRate * NumberOfChannels))
                              must be greater than (or equal to) 733.
        
        Desc: After receiving a AIBurst command, the LabJack collects 4
              channels at the specified data rate, and puts data in the buffer.
              This continues until the buffer is full, at which time the
              LabJack starts sending the data to the host. Data is sent to the
              host 1 scan at a time while checking for a command from the host.
              If a command is received the burst operation is canceled and the
              command is executed normally. If the LED is enabled, it blinks at
              4 Hz while waiting for a trigger, is off during acquisition,
              blinks at about 8 Hz during data delivery, and is set on when
              done or stopped. See Section 5.5 of the User's Guide.
              
              This function sends the AIBurst command, then reads all the
              responses. Separating the write and read is not currently
              supported (like in the UW driver).
              
              By default, it does single-ended readings on AI0-4 at 100Hz for 8
              scans.
              
        Returns: A dictionary with the following keys:
            Channel0-3, A list of the readings on the channels
            PGAOvervoltages, A list of the over-voltage flags
            IO3toIO0State, A list of the IO states
            IterationCounters, A list of the values of the iteration counter
            Backlogs, value*256 = number of packets in the backlog.
            BufferOverflowOrChecksumErrors, If True and Backlog = 31,
                                            then a buffer overflow occurred. If
                                            True and Backlog = 0, then Checksum
                                            error occurred.
        
        Example:
        >>> import u12
        >>> d = u12.U12()
        >>> d.rawAIBurst()
        {
          'Channel0': [1.484375, 1.513671875, ... , 1.46484375],
          
          'Channel1': [1.455078125, 1.455078125, ... , 1.455078125],
          
          'Channel2': [1.46484375, 1.474609375, ... , 1.46484375],
          
          'Channel3': [1.435546875, 1.42578125, ... , 1.435546875],
          
          'PGAOvervoltages': [False, False, ..., False],
          
          'IO3toIO0States': 
            [<BitField object: [ IO3 = Low (0), IO2 = Low (0), IO1 = Low (0),
                                 IO0 = Low (0) ] >, ... ],
          
          'IterationCounters': [0, 1, 2, 3, 4, 5, 6, 0],
          
          'Backlogs': [0, 0, 0, 0, 0, 0, 0, 0],
          
          'BufferOverflowOrChecksumErrors': [False, False, ... , False]
        }

        
        """
        command = [ 0 ] * 8
        
        # Bits 6-4: PGA for 1st Channel
        # Bits 3-0: MUX command for 1st Channel
        command[0] = int(channel0PGAMUX)
        
        tempNum = command[0] & 7 # 7 = 0b111
        channel0Number = tempNum if (command[0] & 0xf) > 7 else tempNum+8
        channel0Gain = (command[0] >> 4) & 7 # 7 = 0b111
        
        command[1] = int(channel1PGAMUX)
        
        tempNum = command[1] & 7 # 7 = 0b111
        channel1Number = tempNum if (command[1] & 0xf) > 7 else tempNum+8
        channel1Gain = (command[1] >> 4) & 7 # 7 = 0b111
        
        command[2] = int(channel2PGAMUX)
        
        tempNum = command[2] & 7 # 7 = 0b111
        channel2Number = tempNum if (command[2] & 0xf) > 7 else tempNum+8
        channel2Gain = (command[2] >> 4) & 7 # 7 = 0b111
        
        command[3] = int(channel3PGAMUX)
        
        tempNum = command[3] & 7 # 7 = 0b111
        channel3Number = tempNum if (command[3] & 0xf) > 7 else tempNum+8
        channel3Gain = (command[3] >> 4) & 7 # 7 = 0b111

        if NumberOfScans > 1024 or NumberOfScans < 8:
            raise U12Exception("The number of scans must be between 1024 and 8 (inclusive)")
        
        NumScansExponentMod = 10 - int(math.ceil(math.log(NumberOfScans, 2)))
        NumScans = 2 ** (10 - NumScansExponentMod)
        
        bf = BitField( rawByte = (NumScansExponentMod << 5) )
        # bits 4-3: IO to Trigger on
        bf.bit2 = 0
        bf.bit1 = int(bool(UpdateIO))
        bf.bit0 = int(bool(LEDState))
        command[4] = int(bf)
        
        bf2 = BitField(rawByte = int(IO3ToIO0States))
        #Bits 7-4: 1010 (Start Burst)
        bf2.bit7 = 1
        bf2.bit5 = 1
        command[5] = int(bf2)
        
        if SampleInterval < 733:
            raise U12Exception("SampleInterval must be greater than 733.")
        
        bf3 = BitField( rawByte = ((SampleInterval >> 8) & 0xf) )
        bf3.bit7 = int(bool(FeatureReports))
        bf3.bit6 = int(bool(TriggerOn))
        command[6] = int(bf3)
        
        command[7] = SampleInterval & 0xff
        
        self.write(command)
        
        resultsList = []
        for i in range(NumScans):
            resultsList.append(self.read())
            
            
        returnDict = {}
        
        returnDict['BufferOverflowOrChecksumErrors'] = list()
        returnDict['PGAOvervoltages'] = list()
        returnDict['IO3toIO0States'] = list()
        
        returnDict['IterationCounters'] = list()
        returnDict['Backlogs'] = list()

        returnDict['Channel0'] = list()
        
        returnDict['Channel1'] = list()
        
        returnDict['Channel2'] = list()
        
        returnDict['Channel3'] = list()
        
        for results in resultsList:
            bf = BitField(rawByte = results[0])
            
            if bf.bit7 != 1 or bf.bit6 != 0:
                raise U12Exception("Expected a AIBurst response, got %s instead." % results[0])
            
            returnDict['BufferOverflowOrChecksumErrors'].append(bool(bf.bit5))
            returnDict['PGAOvervoltages'].append(bool(bf.bit4))
            returnDict['IO3toIO0States'].append(BitField(results[0], "IO", list(range(3, -1, -1)), "Low", "High"))
            
            returnDict['IterationCounters'].append((results[1] >> 5))
            returnDict['Backlogs'].append(results[1] & 0xf)
            
            channel0 = (results[2] >> 4) & 0xf
            channel1 = (results[2] & 0xf)
            channel2 = (results[5] >> 4) & 0xf
            channel3 = (results[5] & 0xf)
            
            channel0 = (channel0 << 8) + results[3]
            returnDict['Channel0'].append(self.bitsToVolts(channel0Number, channel0Gain, channel0))
            
            channel1 = (channel1 << 8) + results[4]
            returnDict['Channel1'].append(self.bitsToVolts(channel1Number, channel1Gain, channel1))
            
            channel2 = (channel2 << 8) + results[6]
            returnDict['Channel2'].append(self.bitsToVolts(channel2Number, channel2Gain, channel2))
            
            channel3 = (channel3 << 8) + results[7]
            returnDict['Channel3'].append(self.bitsToVolts(channel3Number, channel3Gain, channel3))
            
        return returnDict
dataset/ETHPy150Open LabPy/lantz/lantz/drivers/labjack/_internal/u12.py/U12.rawAIBurst/original