Exemplo n.º 1
0
    def daq_readOut(self):
        data       = None
        fifo_count = 0
        attempts   = 10
        while fifo_count == 0 and attempts > 0:
            attempts -= 1
            message = "r 0x44A10014 1" # word count of data fifo
            data = self.udp.udp_client(message, self.UDP_IP, self.UDP_PORT)
            if data != None:
                data_list  = data.split(" ")
                fifo_count = int(data_list[2], 16)
            time.sleep(1)

        print "FIFOCNT ", fifo_count
        if data == None or fifo_count == 0:
            print "Warning: Did not receive data. Stop readout."
            return
        if fifo_count == 0:
            print "Warning: found 0 FIFO counts. Stop readout."
            return
        if fifo_count % 2 != 0:
            print "Warning: Lost one count in fifo reading."
            fifo_count -= 1

        peeks_per_cycle = 10
        cycles    = fifo_count / peeks_per_cycle
        remainder = fifo_count % peeks_per_cycle

        for cycle in reversed(xrange(1+cycles)):
            
            peeks     = peeks_per_cycle if cycle > 0 else remainder
            message   = "k 0x44A10010 %s" % (peeks)
            data      = self.udp.udp_client(message, self.UDP_IP, self.UDP_PORT)
            data_list = data.split()

            for iword in xrange(2, peeks+1, 2):

                word0 = int(data_list[iword],   16)
                word1 = int(data_list[iword+1], 16)

                if not word0 > 0:
                    print "Out of order or no data."
                    continue

                word0 = word0 >> 2       # get rid of first 2 bits (threshold)
                addr  = (word0 & 63) + 1 # get channel number as on GUI
                word0 = word0 >> 6       # get rid of address
                amp   = word0 & 1023     # get amplitude

                word0  = word0 >> 10     # ?
                timing = word0 & 255     # 
                word0  = word0 >> 8      # we will later check for vmm number
                vmm    = word0 &  7      # get vmm number

                bcid_gray = int(word1 & 4095)
                bcid_bin  = binstr.b_gray_to_bin(binstr.int_to_b(bcid_gray, 16))
                bcid_int  = binstr.b_to_int(bcid_bin)

                word1 = word1 >> 12      # later we will get the turn number   
                word1 = word1 >> 4       # 4 bits of zeros?
                immfe = int(word1 & 255) # do we need to convert this?

                to_print = "word0 = %s word1 = %s addr = %s amp = %s time = %s bcid = %s vmm = %s mmfe = %s"
                print to_print % (data_list[iword], data_list[iword+1],
                                  str(addr),     str(amp), str(timing), 
                                  str(bcid_int), str(vmm), str(immfe))

                with open('mmfe8Test.dat', 'a') as myfile:
                    myfile.write(str(int(addr))+'\t'+ str(int(amp))+'\t'+ str(int(timing))+'\t'+ str(bcid_int) +'\t'+ str(vmm) +'\n')
Exemplo n.º 2
0
 def params_to_ind(params):
     ind = ''
     for i in params:
         ind += binstr.b_bin_to_gray(binstr.int_to_b(i))
     return ind
Exemplo n.º 3
0
 def params_to_ind(params):
     ind = ''
     for i in params:
         ind+=binstr.b_bin_to_gray(binstr.int_to_b(i))
     return ind