Esempio n. 1
0
 def doSetPreset(self, **preset):
     new_preset = preset
     if P_MON_SF in preset and P_MON_NSF in preset:
         if self._attached_flipper.read() == ON:
             m = preset[P_MON_SF]
         else:
             m = preset[P_MON_NSF]
         new_preset = {P_MON: m}
     elif P_MON_SF in preset or P_MON_NSF in preset:
         self.log.warning('Incorrect preset setting. Specify either both '
                          '%s and %s or only %s.',
                          P_MON_SF, P_MON_NSF, P_MON)
         return
     elif P_TIME_SF in preset and P_TIME_NSF in preset:
         if self._attached_flipper.read() == ON:
             t = preset[P_TIME_SF]
         else:
             t = preset[P_TIME_NSF]
         new_preset = {P_TIME: t}
     elif P_TIME_SF in preset or P_TIME_NSF in preset:
         self.log.warning('Incorrect preset setting. Specify either both '
                          '%s and %s or only %s.',
                          P_TIME_SF, P_TIME_NSF, P_TIME)
         return
     elif P_MON in preset:
         new_preset = {P_MON: preset[P_MON]}
     elif P_TIME in preset:
         new_preset = {P_TIME: preset[P_TIME]}
     Detector.doSetPreset(self, **new_preset)
Esempio n. 2
0
 def doPreinit(self, mode):
     if len(self._attached_others) != 1 or not isinstance(
             self._attached_others[0], Configuration):
         raise ConfigurationError(
             'pilatus detectors require exactly one "other" channel that '
             'is an instance of {}'.format(Configuration))
     self._cfg_channel = self._attached_others[0]._dev
     GenericDetector.doPreinit(self, mode)
Esempio n. 3
0
 def doStart(self):
     # open shutter
     if self.ctrl_gammashutter:
         self._attached_gammashutter.maw(OPEN)
     if self.ctrl_photoshutter:
         self._attached_photoshutter.maw(OPEN)
     Detector.doStart(self)
     self._prepared = False
Esempio n. 4
0
 def doStop(self):
     Detector.doStop(self)
     # close shutter
     if self.ctrl_photoshutter:
         self._attached_photoshutter.maw(CLOSED)
     if self.ctrl_gammashutter:
         self._attached_gammashutter.maw(CLOSED)
     self._prepared = False
Esempio n. 5
0
 def doPrepare(self):
     if not self._prepared:
         # close shutter
         if self.ctrl_photoshutter:
             self._attached_photoshutter.maw(CLOSED)
         if self.ctrl_gammashutter:
             self._attached_gammashutter.maw(CLOSED)
         Detector.doPrepare(self)
     self._prepared = True
Esempio n. 6
0
 def doFinish(self):
     Detector.doFinish(self)
     self._check_shutter()
     # close shutter
     if self.ctrl_photoshutter:
         self._attached_photoshutter.maw(CLOSED)
     if self.ctrl_gammashutter:
         self._attached_gammashutter.maw(CLOSED)
     self._prepared = False
Esempio n. 7
0
 def doResume(self):
     Detector.doResume(self)
     if self.pausepv:
         paused = self._get_pv('pausepv')
         if paused != 0:
             self._put_pv('pausepv', 0)
         else:
             self.log.info('Device is not paused.')
     else:
         self.log.warning(
             'Cant resume, provide pausepv parameter for this to work')
Esempio n. 8
0
 def doInit(self, session_mode):
     Detector.doInit(self, session_mode)
     self._img = self._attached_images[0]
     if session_mode == MASTER:
         if not self._attached_images or \
            not isinstance(self._attached_images[0], (KWSImageChannel,
                                                      VirtualKWSImageChannel)):
             raise ConfigurationError(
                 self, 'KWSDetector needs a KWSChannel '
                 'as attached image')
         self.kwscounting = False
Esempio n. 9
0
 def doPause(self):
     Detector.doPause(self)
     if self.pausepv:
         paused = self._get_pv('pausepv')
         if paused != 1:
             self._put_pv('pausepv', 1)
         else:
             self.log.info('Device is already paused.')
     else:
         self.log.warning(
             'Cant pause, provide pausepv parameter for this to work')
Esempio n. 10
0
 def _presetiter(self):
     for i, dev in enumerate(self._attached_lives):
         if i == 0:
             yield ("live", dev)
         yield ("live%d" % (i + 1), dev)
     for itm in Detector._presetiter(self):
         yield itm
Esempio n. 11
0
    def doRead(self, maxage=0):
        ret = GenericDetector.doRead(self, maxage)
        meastime = float(ret[0])
        monitor = int(ret[1])
        counts = int(ret[2])
        if meastime >= self._attached_timers[0].preselection:
            difftim = meastime = 0
        else:
            difftim = meastime - self._last_time

        monrate = monitor / meastime if meastime else 0
        if monitor == 0 and self._last_moncounts > 0:
            self._last_moncounts = 0
        monrate_inst = (monitor - self._last_moncounts) / difftim if difftim \
            else 0

        detrate = counts / meastime if meastime else 0
        if counts == 0 and self._last_counts > 0:
            self._last_counts = 0
        detrate_inst = (counts - self._last_counts) / difftim if difftim \
            else 0
        self._setROParam('rates', [[detrate, monrate],
                                   [detrate_inst, monrate_inst]])
        self._last_time = meastime
        self._last_counts = counts
        self._last_moncounts = monitor
        return ret
Esempio n. 12
0
 def duringMeasureHook(self, elapsed):
     ret = GenericDetector.duringMeasureHook(self, elapsed)
     if ret == INTERMEDIATE:
         [detrate, monrate], [detrate_inst, monrate_inst] = self.rates
         self.log.info('Monitor: rate: %8.3f counts/s, instantaneous '
                       'rate: %8.3f counts/s', monrate, monrate_inst)
         self.log.info('Signal: rate: %8.3f counts/s, instantaneous '
                       'rate: %8.3f counts/s', detrate, detrate_inst)
     return ret
Esempio n. 13
0
    def doStart(self):
        try:
            if self._attached_rc.read(0) != 'on':
                self.log.warning('radial collimator is not moving!')
        except NicosError:
            self.log.warning('could not check radial collimator', exc=1)

        self._update()

        self._last_time = 0
        self._last_counts = 0
        self._last_moncounts = 0
        self._starttime = currenttime()
        self._setROParam('rates', [[0., 0.], [0., 0.]])

        session.action('run# %06d' % session.experiment.lastpoint)

        GenericDetector.doStart(self)
Esempio n. 14
0
    def doSetPreset(self, **preset):
        Detector.doSetPreset(self, **preset)
        preset = self._getPreset(preset)
        if not preset:
            return

        for dev in self._attached_lives:
            dev.islive = False

        for name in preset:
            if name in self._presetkeys and self._presetkeys[name] and \
                    name.startswith("live"):
                dev = self._presetkeys[name]
                dev.ismaster = True
                dev.islive = True
        self.log.debug("   presets: %s", preset)
        self.log.debug("presetkeys: %s", self._presetkeys)
        self.log.debug("   masters: %s", self._masters)
        self.log.debug("    slaves: %s", self._slaves)
Esempio n. 15
0
 def doStop(self):
     Detector.doStop(self)
     self.kwscounting = False
     if self._attached_shutter and self.openshutter:
         self._attached_shutter.maw('closed')
Esempio n. 16
0
 def doStart(self):
     if self._attached_shutter and self.openshutter:
         self._attached_shutter.maw('open')
     self.kwscounting = True
     Detector.doStart(self)
Esempio n. 17
0
 def doPrepare(self):
     self._configure()
     Detector.doPrepare(self)
Esempio n. 18
0
 def doSetPreset(self, **preset):
     # override time preset in realtime mode
     if self.mode in ('realtime', 'realtime_external'):
         # set counter card preset to last RT slice
         preset = {'t': self._img.slices[-1] / 1000000.0}
     Detector.doSetPreset(self, **preset)
Esempio n. 19
0
 def doInit(self, mode):
     GenericDetector.doInit(self, mode)
     if mode == SIMULATION:
         return
     self._import_detinfo()
Esempio n. 20
0
 def doResume(self):
     GenericDetector.doResume(self)
     # Reset the time for instantaneous rates calculation
     self._last_time = 0
Esempio n. 21
0
 def duringMeasureHook(self, elapsed):
     if self._saveIntermediateFlag:
         self._saveIntermediate()
         self._saveIntermediateFlag = False
     return Detector.duringMeasureHook(self, elapsed)
Esempio n. 22
0
 def doInfo(self):
     for p in ('timechannels', 'timeinterval', 'delay', 'channelwidth'):
         self._pollParam(p)
     ret = GenericDetector.doInfo(self)
     return ret
Esempio n. 23
0
 def doSetPreset(self, **preset):
     GenericDetector.doSetPreset(self, **preset)
     if not self._user_comment:  # Comment must be fulfilled for data sink
         self._user_comment = 'No comment'
Esempio n. 24
0
 def doStart(self):
     # First start all the channels (if applicable) and then
     # set the detector startpv
     Detector.doStart(self)
     self._put_pv('startpv', 1, wait=True)
Esempio n. 25
0
 def doPrepare(self):
     GenericDetector.doPrepare(self)
     self.readArrays(FINAL)  # update readresult of image channels
Esempio n. 26
0
 def doPreinit(self, mode):
     GenericDetector.doPreinit(self, mode)
Esempio n. 27
0
 def doFinish(self):
     Detector.doFinish(self)
     if self.autoshutter:
         self._attached_shutter.maw('close')
Esempio n. 28
0
 def doFinish(self):
     # After setting the startpv to 0
     # finish all the channels
     self._put_pv('startpv', 0, wait=False)
     Detector.doFinish(self)
Esempio n. 29
0
 def doPreinit(self, mode):
     EpicsDeviceEss.doPreinit(self, mode)
     Detector.doPreinit(self, mode)
Esempio n. 30
0
 def doStop(self):
     # After setting the startpv to 0
     # stop all the channels
     self._put_pv('startpv', 0, wait=False)
     Detector.doStop(self)