Esempio n. 1
0
    def start_store(self):

        if (self.restoreInfo() != self.HANDLE_RESTORE):
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'DT5720 Device not initialized')
            return 0

        vmeAddress = 0

        #Module type
        devType = c_int(0)
        status = CAENDT5720.caenLib.CAENVME_ReadCycle(
            self.handle, c_int(vmeAddress + 0x8140), byref(devType),
            c_int(self.cvA32_S_DATA), c_int(self.cvD32))
        if status != 0:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error reading board info')
            return 0
        """
      if (devType.value & 0x000000FF) != 0 :
        Data.execute('DevLogErr($1,$2)', self.getNid(), 'Invalid board type. Device must be DT5720 model')
        return 0

      if (devType.value & 0x0000FF00) >> 8 == 0x01 :
        self.chanMemory = self.MEM_512kS
      else:
        self.chanMemory = self.MEM_4MS
      """

        if (devType.value & 0x000000FF) != 0 and (devType.value
                                                  & 0x000000FF) != 0x3:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Invalid board type. Device must be DT5720 model')
            return 0

        if (devType.value & 0x000000FF) == 0:
            if (devType.value & 0x0000FF00) >> 8 == 0x01:
                self.chanMemory = self.MEM_512kS
            else:
                self.chanMemory = self.MEM_4MS

        if (devType.value & 0x000000FF) == 0x3:
            if (devType.value & 0x0000FF00) >> 8 == 0x2:
                #self.chanMemory = self.MEM_1_25MS
                self.chanMemory = self.MEM_1MS
            else:
                self.chanMemory = self.MEM_10MS

        try:
            self.board_id.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Invalid Board ID specification')
            return 0
        try:
            clock = self.clock_source.evaluate()
            dt = clock.getDelta().data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating clock source')
            return 0
        try:
            triggerSourceNid = TreePath(self.trig_source.getFullPath())
            #trigTime = self.trig_source.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating trigger source')
            return 0
        try:
            startIdx = self.start_idx.data()
            endIdx = self.end_idx.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating start or end idx')
            return 0
        try:
            pts = self.pts.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating Post Trigger Samples')
            return 0

        #Compute Segment Size
        try:
            nSegments = self.num_segments.data()
            segmentSamples = self.chanMemory / nSegments
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error reading max number of segments')
            return 0
        # currStartIdx = segmentSamples - pts + startIdx
        # currEndIdx = segmentSamples - pts + endIdx

        #Get Active channels
        chanMask = c_int(0)
        status = CAENDT5720.caenLib.CAENVME_ReadCycle(
            self.handle, c_int(vmeAddress + 0x8120), byref(chanMask),
            c_int(self.cvA32_S_DATA), c_int(self.cvD32))
        nActChans = 0
        chanMask = chanMask.value
        numChannels = self.num_channels.data()
        for chan in range(0, numChannels):
            if (chanMask & (1 << chan)) != 0:
                nActChans = nActChans + 1
        if nActChans == 0:
            print('No active groups')
            return 1
        segmentSize = 16 + 2 * segmentSamples * nActChans
        acqMode = self.acq_mode.data()

        for chan in range(0, numChannels):
            if (chanMask & (1 << chan)) != 0:
                try:
                    dac_offset = getattr(self, 'channel_%d_dac_offset' %
                                         (chan + 1)).data()
                except:
                    Data.execute('DevLogErr($1,$2)', self.getNid(),
                                 'Error reading channel DAC offset')
                    return 0
                if acqMode == 'CONTINUOUS WITH COUNTER':
                    useCounter = True
                    data = Data.compile(
                        "2.25*($1 - 2048)/4096.+$2",
                        TreePath(
                            getattr(self, 'channel_%d_seg_raw' %
                                    (chan + 1)).getFullPath()), dac_offset)
                else:
                    useCounter = False
                    segRawPath = TreePath(
                        getattr(self, 'channel_%d_seg_raw' %
                                (chan + 1)).getFullPath())
                    data = Data.compile("(2.25*( $ - 2048)/4096. + $ )",
                                        segRawPath, Float32(dac_offset))
                try:
                    getattr(self, 'channel_%d_data' % (chan + 1)).putData(data)
                except:
                    Data.execute('DevLogErr($1,$2)', self.getNid(),
                                 'Error Writing data')
                    return 0
        #endfor chan in range(0,numChannels):

        self.worker = self.AsynchStore()
        self.worker.daemon = True
        self.worker.stopReq = False

        #self.worker.configure(self.handle, acqMode, startIdx, endIdx, pts, chanMask, nActChans, dt, trigTime, triggerSourceNid, segmentSamples, segmentSize, chanMask, self.getNid(), self, self.cv, self.readCv, useCounter, self.irq_events.data() + 1)

        self.worker.configure(self.handle, acqMode, startIdx, endIdx, pts,
                              chanMask, nActChans, dt, triggerSourceNid,
                              segmentSamples, segmentSize, chanMask,
                              self.getNid(), self, self.cv, self.readCv,
                              useCounter,
                              self.irq_events.data() + 1)

        try:
            runCommand = 4
            """
          #External cllock not yet implemented
          if clockMode == 'EXTERNAL':
          runCommand = runCommand | 0x00000040
        """
            #Module SW trigger
            data = c_int(0)
            status = CAENDT5720.caenLib.CAENVME_WriteCycle(
                self.handle, c_int(vmeAddress + 0x8100),
                byref(c_int(runCommand)), c_int(self.cvA32_S_DATA),
                c_int(self.cvD32))
            if status != 0:
                Data.execute('DevLogErr($1,$2)', self.getNid(),
                             'Error starting acquisition on DT5720 Device')
                return 0
        except:
            Data.execute(
                'DevLogErr($1,$2)', self.getNid(),
                'Cannot starting acquisition on DT5720 Device SW exception')
            return 0

        self.saveWorker()
        self.worker.start()
        """
      try:
        if  acqMode == 'TRANSIENT RECORDER':
          trigSoft = self.trig_soft.data()
          if trigSoft == 'ENABLED':
             trigSource = self.trig_source.data()
             t0 = trigSource[0]
             sleep(t0)
             print "SW Trigger ", trigSource[0]
             status = CAENDT5720.caenLib.CAENVME_WriteCycle(self.handle, c_int(vmeAddress + 0x8108), byref(c_int(0L)), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
             if status != 0:
               Data.execute('DevLogErr($1,$2)', self.getNid(), 'Error in sofware trigger DT5720 Device'  )
               return 0

             if len(trigSource) == 1 :
               sleep( 1 )
               status = CAENDT5720.caenLib.CAENVME_WriteCycle(self.handle, c_int(vmeAddress + 0x8108), byref(c_int(0L)), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
               if status != 0:
                 Data.execute('DevLogErr($1,$2)', self.getNid(), 'Error in sofware trigger(1) DT5720 Device'  )
                 return 0

             for delay in trigSource[1 : ] :
               sleep( delay - t0 )
               t0 = delay
               print "SW Trigger ", delay
               status = CAENDT5720.caenLib.CAENVME_WriteCycle(self.handle, c_int(vmeAddress + 0x8108), byref(c_int(0L)), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
               if status != 0:
                 Data.execute('DevLogErr($1,$2)', self.getNid(), 'Error in sofware trigger DT5720 Device'  )
                 return 0
      except:
        Data.execute('DevLogErr($1,$2)', self.getNid(), 'Cannot starting acquisition on DT5720 Device SW exception'  )
        return 0
      """

        return 1
Esempio n. 2
0
    def start_store(self):
        try:
            self.board_id.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Invalid Board ID specification')
            raise mdsExceptions.TclFAILED_ESSENTIAL
        vmeAddress = 0
        try:
            clock = self.clock_source.evaluate()
            dt = clock.getDelta().data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating clock source')
            raise mdsExceptions.TclFAILED_ESSENTIAL
        try:
            trigTime = self.trig_source.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating trigger source')
            raise mdsExceptions.TclFAILED_ESSENTIAL
        try:
            startIdx = self.start_idx.data()
            endIdx = self.end_idx.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating start or end idx')
            raise mdsExceptions.TclFAILED_ESSENTIAL
        try:
            pts = self.pts.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating Post Trigger Samples')
            raise mdsExceptions.TclFAILED_ESSENTIAL

    #Compute Segment Size
        try:
            nSegments = self.num_segments.data()
            segmentSamples = 1048576 / nSegments
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error reading max number of segments')
            raise mdsExceptions.TclFAILED_ESSENTIAL

    # Get Active channels
        chanMask = c_int(0)
        CAENDT5720.caenLib.CAENVME_ReadCycle(self.handle,
                                             c_int(vmeAddress + 0x8120),
                                             byref(chanMask),
                                             c_int(self.cvA32_S_DATA),
                                             c_int(self.cvD32))
        nActChans = 0
        chanMask = chanMask.value
        numChannels = self.num_channels.data()
        for chan in range(0, numChannels):
            if (chanMask & (1 << chan)) != 0:
                nActChans = nActChans + 1
        if nActChans == 0:
            print('No active groups')
            return
        segmentSize = 16 + 2 * segmentSamples * nActChans
        acqMode = self.acq_mode.data()

        for chan in range(0, numChannels):
            if (chanMask & (1 << chan)) != 0:
                try:
                    offset = getattr(self,
                                     'channel_%d_offset' % (chan + 1)).data()
                except:
                    Data.execute('DevLogErr($1,$2)', self.getNid(),
                                 'Error reading channel offset')
                    raise mdsExceptions.TclFAILED_ESSENTIAL
                if acqMode == 'CONTINUOUS WITH COUNTER':
                    useCounter = True
                    data = Data.compile(
                        "2*($1 - 2048)/4096.+$2",
                        TreePath(
                            getattr(self, 'channel_%d_seg_raw' %
                                    (chan + 1)).getFullPath()), offset)
                else:
                    useCounter = False
                    startTime = startIdx * dt
                    endTime = (endIdx - 1) * dt
                    segRawPath = TreePath(
                        getattr(self, 'channel_%d_seg_raw' %
                                (chan + 1)).getFullPath())
                    trigPath = TreePath(self.trig_source.getFullPath())
                    data = Data.compile(
                        "BUILD_SIGNAL(2*($VALUE - 2048)/4096.+$1, DATA($2), MAKE_RANGE($3+$4, $3+$5, REPLICATE($6,0,SIZE($3))))",
                        Float32(offset), segRawPath, trigPath,
                        Float64(startTime), Float64(endTime), Float64(dt))
                try:
                    getattr(self, 'channel_%d_data' % (chan + 1)).putData(data)
                except:
                    Data.execute('DevLogErr($1,$2)', self.getNid(),
                                 'Error Writing data')
                    raise mdsExceptions.TclFAILED_ESSENTIAL
        #endfor chan in range(0,numChannels):

        self.worker = self.AsynchStore()
        self.worker.daemon = True
        self.worker.stopReq = False
        self.worker.configure(self.handle, startIdx, endIdx, pts, chanMask,
                              nActChans, dt, trigTime,
                              segmentSamples, segmentSize, chanMask,
                              self.getNid(), self, self.cv, self.readCv,
                              useCounter,
                              self.irq_events.data() + 1)
        self.worker.start()
        return
Esempio n. 3
0
    def start_store(self):

        if (self.restoreInfo() != self.HANDLE_RESTORE):
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'DT5724 Device not initialized')
            raise mdsExceptions.DevINV_SETUP

        vmeAddress = 0

        # Module type
        devType = c_int(0)
        status = CAENDT5724.caenLib.CAENVME_ReadCycle(self.handle, c_int(
            vmeAddress + 0x8140), byref(devType), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
        if status != 0:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error reading board info')
            raise mdsExceptions.DevCOMM_ERROR

        if (devType.value & 0x000000FF) != 0:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Invalid board type. Device must be DT5724 model')
            raise mdsExceptions.DevCOMM_ERROR

        if (devType.value & 0x0000FF00) >> 8 == 0x01:
            self.chanMemory = self.MEM_512kS
        else:
            self.chanMemory = self.MEM_4MS

        try:
            clock = self.clock_source.evaluate()
            dt = clock.getDelta().data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating clock source')
            raise mdsExceptions.DevBAD_PARAMETER
        try:
            triggerSourceNid = TreePath(self.trig_source.getFullPath())
            #trigTime = self.trig_source.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating trigger source')
            raise mdsExceptions.DevBAD_PARAMETER
        try:
            startIdx = self.start_idx.data()
            endIdx = self.end_idx.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating start or end idx')
            raise mdsExceptions.DevBAD_PARAMETER
        try:
            pts = self.pts.data()
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error evaluating Post Trigger Samples')
            raise mdsExceptions.DevBAD_PARAMETER

        # Compute Segment Size
        try:
            nSegments = self.num_segments.data()
            segmentSamples = self.chanMemory/nSegments
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(),
                         'Error reading max number of segments')
            raise mdsExceptions.DevBAD_PARAMETER
        #currStartIdx = segmentSamples - pts + startIdx
        #currEndIdx = segmentSamples - pts + endIdx

        # Get Active channels
        chanMask = c_int(0)
        status = CAENDT5724.caenLib.CAENVME_ReadCycle(self.handle, c_int(
            vmeAddress + 0x8120), byref(chanMask), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
        nActChans = 0
        chanMask = chanMask.value
        numChannels = self.num_channels.data()
        for chan in range(0, numChannels):
            if (chanMask & (1 << chan)) != 0:
                nActChans = nActChans + 1
        if nActChans == 0:
            print ('No active groups')
            return
        segmentSize = 16 + 2 * segmentSamples * nActChans
        acqMode = self.acq_mode.data()

        for chan in range(0, numChannels):
            if (chanMask & (1 << chan)) != 0:
                try:
                    dac_offset = getattr(
                        self, 'channel_%d_dac_offset' % (chan+1)).data()
                except:
                    Data.execute('DevLogErr($1,$2)', self.getNid(),
                                 'Error reading channel DAC offset')
                    raise
                if acqMode == 'CONTINUOUS WITH COUNTER':
                    useCounter = True
                    data = Data.compile("2.25*($1 - 8192)/16384.+$2", TreePath(
                        getattr(self, 'channel_%d_seg_raw' % (chan+1)).getFullPath()), dac_offset)
                else:
                    useCounter = False
                    segRawPath = TreePath(
                        getattr(self, 'channel_%d_seg_raw' % (chan+1)).getFullPath())
                    data = Data.compile(
                        "(2.25*( $ - 8192)/16384. + $ )", segRawPath, Float32(dac_offset))
                try:
                    getattr(self, 'channel_%d_data' % (chan+1)).putData(data)
                except:
                    Data.execute('DevLogErr($1,$2)',
                                 self.getNid(), 'Error Writing data')
                    raise
        # endfor chan in range(0,numChannels):

        self.worker = self.AsynchStore()
        self.worker.daemon = True
        self.worker.stopReq = False

        #self.worker.configure(self.handle, acqMode, startIdx, endIdx, pts, chanMask, nActChans, dt, trigTime, triggerSourceNid, segmentSamples, segmentSize, chanMask, self.getNid(), self, self.cv, self.readCv, useCounter, self.irq_events.data() + 1)

        self.worker.configure(self.handle, acqMode, startIdx, endIdx, pts, chanMask, nActChans, dt, triggerSourceNid, segmentSamples,
                              segmentSize, chanMask, self.getNid(), self, self.cv, self.readCv, useCounter, self.irq_events.data() + 1)

        try:
            runCommand = 4
            """
          #External cllock not yet implemented
          if clockMode == 'EXTERNAL':
          runCommand = runCommand | 0x00000040
        """
            # Module SW trigger
            data = c_int(0)
            status = CAENDT5724.caenLib.CAENVME_WriteCycle(self.handle, c_int(
                vmeAddress + 0x8100), byref(c_int(runCommand)), c_int(self.cvA32_S_DATA), c_int(self.cvD32))
            if status != 0:
                Data.execute('DevLogErr($1,$2)', self.getNid(),
                             'Error starting acquisition on DT5724 Device')
                raise mdsExceptions.DevCOMM_ERROR
        except:
            Data.execute('DevLogErr($1,$2)', self.getNid(
            ), 'Cannot starting acquisition on DT5724 Device SW exception')
            raise mdsExceptions.DevCOMM_ERROR

        self.saveWorker()
        self.worker.start()
        """