Esempio n. 1
0
    def _startRaw(self, target):
        if self._mode != SIMULATION \
                and session.daemon_device._controller.status == STATUS_INBREAK:
            raise UsageError('Doppler speed can not be changed when script is '
                             'paused.')
        if self._seq_is_running():
            if self._mode == SIMULATION:
                self._seq_thread.join()
            else:
                self._seq_thread.join(0)
            self._seq_thread = None

        if not self.waitForAcq(10):
            return

        seq = list()
        # to change the doppler speed it has to be stopped first
        seq.append(SeqDev(self._attached_switch, 'off'))
        seq.append(SeqCall(session.delay, 0.5))
        if target[0] != 0:
            seq.append(SeqCall(MultiSwitcher._startRaw, self, target))
            seq.append(SeqDev(self._attached_switch, 'on'))

        seq.append(SeqCall(self.waitForSync, target))
        self._startSequence(seq)
Esempio n. 2
0
    def _generateSequence(self, target):
        seq = []

        pos = self.read(0)
        self._save_pos()

        xpos = self._beamstop_pos[pos]
        seq.append((SeqDev(self._attached_y, -450),
                    SeqDev(self._attached_x, xpos)))
        seq.append(SeqMethod(self, '_testArrival', xpos, -450.))

        seq.append(SeqLimDev(self._attached_y, -549, -549))
        seq.append(SeqMethod(self, '_testArrival', xpos, -549.))

        xpos = self._beamstop_pos[int(target)]
        seq.append(SeqDev(self._attached_x, xpos))
        seq.append(SeqMethod(self, '_testArrival', xpos,
                             -549.))

        seq.append(SeqLimDev(self._attached_y, -450, -450))
        seq.append(SeqMethod(self, '_testArrival', xpos, -450))

        seq.append((SeqDev(self._attached_y, self._in_y),
                    SeqDev(self._attached_x, self._in_x)))

        return seq
Esempio n. 3
0
 def _generateSequence(self, target):
     seq = []
     if target == self.onvalue:
         seq.append(SeqDev(self._attached_moveable, self.onvalue))
         seq.append(SeqSleep(self.ontime))
     seq.append(SeqDev(self._attached_moveable, self.offvalue))
     return seq
Esempio n. 4
0
    def _generateSequence(self, target):
        seq = []
        if not self.isAtTarget(self.read(0)):
            position = None
            for i, val in enumerate(self._switchlist[0]):
                if target == val:
                    position = self._switchlist[1][i]
                    break
            # ask for diaphragma to switch in
            if position == 0:
                self.log.debug('no diaphragma')
                seq.append(SeqDev(self._pairs[3], 'cover'))
            else:
                self.log.debug('diaphragma')
                seq.append(SeqDev(self._pairs[3], 'frame'))
            seq.append(SeqSleep(self.chkmotiontime))

            # ask for changing the devices pair 1-3
            for i in range(3):
                if self._pairs[i]:  # Ignore pair1 if not used
                    if (position & (1 << i)):
                        self.log.debug('switching to frame: %s',
                                       self._pairs[i])
                        seq.append(SeqDev(self._pairs[i], 'frame'))
                    else:
                        self.log.debug('switching to cover: %s',
                                       self._pairs[i])
                        seq.append(SeqDev(self._pairs[i], 'cover'))
                    seq.append(SeqSleep(self.chkmotiontime))
        return seq
Esempio n. 5
0
    def _startRaw(self, pos):
        if self._seq_is_running():
            if self._mode == SIMULATION:
                self._seq_thread.join()
                self._seq_thread = None
            else:
                raise MoveError(
                    self, 'Cannot start device, sequence is still '
                    'running (at %s)!' % self._seq_status[1])

        det_z = self._attached_det_z
        seq = []
        seq.append(SeqDev(self._attached_bs_y, pos[1], stoppable=True))
        seq.append(SeqDev(self._attached_bs_x, pos[0], stoppable=True))
        seq.append(SeqDev(det_z, pos[2], stoppable=True))

        # if z has to move, reposition beamstop y afterwards by going to
        # some other value (damping vibrations) and back
        if self.beamstopsettlepos is not None and \
           abs(det_z.read(0) - pos[2]) > det_z.precision:
            seq.append(
                SeqDev(self._attached_bs_y,
                       self.beamstopsettlepos,
                       stoppable=True))
            seq.append(SeqSleep(30))
            seq.append(SeqDev(self._attached_bs_y, pos[1], stoppable=True))

        self._startSequence(seq)
Esempio n. 6
0
    def doStart(self, target):
        th, tv = target

        seq = []
        seq.append(SeqDev(self._attached_horizontal, th))
        seq.append(SeqDev(self._attached_vertical, tv))

        self._startSequence(seq)
Esempio n. 7
0
 def _generateSequence(self, target):
     return [
         SeqDev(self._attached_switch, self.switchvalues[1]),
         SeqSleep(self.startdelay),
         SeqCall(Axis.doStart, self, target),
         SeqCall(self._hw_wait),
         SeqSleep(self.stopdelay),
         SeqDev(self._attached_switch, self.switchvalues[0]),
     ]
Esempio n. 8
0
    def doReference(self):
        """Reference the NOK in a sophisticated way.

        First we try to reach the lowest point ever needed for referencing,
        then we reference the lower refpoint first, and the higher later.
        After referencing is done, we go to (0, 0).
        """
        # XXX: EXTRA BIG TODO !!!
        if self._seq_is_running():
            raise MoveError(self, 'Cannot reference device, it is still '
                            'moving!')

        devices = self._devices
        refpos = [d.refpos for d in devices]

        # referencing is easier if device[0].refpos is always lower than
        #  device[1].refpos
        if refpos[1] < refpos[0]:
            # wrong order: flip oder of entries
            devices.reverse()
            refpos.reverse()

        # go below lowest interesting point
        minpos = min(self.read() + refpos +
                     [t + self.backlash for t in refpos])

        # build a referencing sequence
        sequence = []

        # go to lowest position first
        sequence.append([SeqDevMin(d, minpos) for d in devices])

        # if one of the motors should have triggered the low-level-switch
        # move them up a little and wait until the movement has finished
        sequence.append([
            SeqMoveOffLimitSwitch(d, backoffby=self.backlash / 4.)
            for d in devices
        ])

        # ref lowest position, should finish at refpos[0]
        # The move should be first, as the referencing may block!
        sequence.append([
            SeqDev(devices[1], refpos[0]),
            SeqMethod(devices[0], 'reference')
        ])

        # ref highest position, should finish at refpos[1]
        sequence.append([
            SeqDev(devices[0], refpos[1]),
            SeqMethod(devices[1], 'reference')
        ])

        # fun: move both to 0
        sequence.append([SeqDev(d, 0) for d in devices])

        # GO
        self._startSequence(sequence)
Esempio n. 9
0
 def _generateSequence(self, target):
     seq = []
     if target != self.doRead(0):
         seq.append(SeqDev(self._attached_push, 'up', stoppable=False))
         seq.append(SeqSleep(self.delay))
         seq.append(
             SeqSampleMotor(self._attached_motor, target, stoppable=False))
         seq.append(SeqSleep(self.delay))
         seq.append(SeqDev(self._attached_push, 'down', stoppable=False))
     return seq
Esempio n. 10
0
    def _startRaw(self, pos):
        if self._seq_is_running():
            if self._mode == SIMULATION:
                self._seq_thread.join()
                self._seq_thread = None
            else:
                raise MoveError(
                    self, 'Cannot start device, sequence is still '
                    'running (at %s)!' % self._seq_status[1])

        # switch det_img alias synchronously, the chopper sets its mode param!
        det_img_alias = session.getDevice('det_img')
        if pos[3]:
            det_img_alias.alias = 'det_img_jum'
        else:
            det_img_alias.alias = 'det_img_ge'

        seq = []
        seq.append(SeqDev(self._attached_attenuator, pos[4]))
        if pos[3]:
            seq.append(
                SeqDev(self._attached_det_z, self.detbackpos, stoppable=True))
            seq.append(SeqDev(self._attached_psd_y, pos[1], stoppable=True))
            seq.append(SeqDev(self._attached_psd_x, pos[0], stoppable=True))
        else:
            seq.append(SeqDev(self._attached_psd_x, 0, stoppable=True))
            seq.append(
                SeqDev(self._attached_psd_y, self.psdtoppos, stoppable=True))
            seq.append(SeqDev(self._attached_bs_y, pos[1], stoppable=True))
            seq.append(SeqDev(self._attached_bs_x, pos[0], stoppable=True))
            seq.append(SeqDev(self._attached_det_z, pos[2], stoppable=True))
            # maybe reposition beamstop Y axis to counter jitter.
            seq.append(SeqCall(self._check_bsy, pos[1]))

        self._startSequence(seq)
Esempio n. 11
0
    def _generateSequence(self, target):
        if not target:
            target = self._components()

        # Add everything to be done in the seq list
        seq = []

        # If the laser is now on, turn it on
        if self._attached_switch.read(0) != 'ON':
            seq.append(SeqDev(self._attached_switch, 'ON'))
            seq.append(SeqSleep(5))

        seq.append(
            SeqCall(self._logvalues,
                    ['Component', 'Read', 'Final', 'Comments'], True))

        for component in target:
            if component not in self._components():
                comments = 'Skipping! Component not valid..'
                seq.append(
                    SeqCall(self._logvalues, [component, '', '', comments]))
                continue

            if component in self.fixedcomponents:
                comments = 'Skipping! Component fixed..'
                seq.append(
                    SeqCall(self._logvalues, [component, '', '', comments]))
                continue

            if component not in self._attached_positioner.mapping:
                comments = 'Skipping! Height not configured..'
                seq.append(
                    SeqCall(self._logvalues, [component, '', '', comments]))
                continue

            # Move the laser to the component height
            seq.append(SeqDev(self._attached_positioner, component))

            # Sleep for few seconds before reading the value
            seq.append(SeqSleep(3))

            # Read in and change the distance measured by laser
            seq.append(SeqCall(self._update_raw_distance, component))
            seq.append(SeqCall(self._update_component, component, True))

        seq.append(SeqCall(self.log.info, 'Parking and turning off laser..'))
        seq.append(SeqDev(self._attached_positioner, 'park'))
        seq.append(SeqDev(self._attached_switch, 'OFF'))
        seq.append(SeqCall(self.log.info, 'Done! Summary below:'))
        seq.append(SeqCall(self.__call__, target))
        seq.append(SeqCall(self._update))

        return seq
Esempio n. 12
0
 def _generateSequence(self, target):
     anodes = self._attached_anodes + self._attached_banodes
     seq = [
         [
             SeqDev(dev, self.mapping[target][dev.name])
             for dev in self._attached_window
         ],
         [SeqDev(dev, self.mapping[target][dev.name]) for dev in anodes],
         [
             SeqDev(dev, self.mapping[target][dev.name])
             for dev in self._attached_cathodes
         ],
     ]
     return seq
Esempio n. 13
0
 def _generateSequence(self):
     seq = []
     if self._tths:
         self._startpos = self._tths
         seq.append(
             SeqDev(self._attached_motor, self._startpos, stoppable=True))
     for step in range(self.resosteps):
         pos = self._startpos - step * self._step_size
         seq.append(SeqDev(self._attached_motor, pos, stoppable=True))
         seq.append(SeqCall(self._startDet))
         seq.append(SeqWait(self._attached_detector))
         seq.append(SeqCall(self._read_value))
         seq.append(SeqCall(self._incStep))
     return seq
Esempio n. 14
0
 def _generateSequence(self, target):
     seq = []
     if self._attached_selector.read(0) > self.maxtiltspeed:
         seq.insert(
             0,
             SeqDev(self._attached_selector,
                    self.maxtiltspeed,
                    stoppable=True))
     seq.append(SeqMethod(self, '_check_speed'))
     seq.append(SeqMethod(self._attached_motor, 'release'))
     seq.append(SeqDev(self._attached_motor, target, stoppable=True))
     seq.append(
         SeqMethod(self._attached_motor, 'fix',
                   'only move this using %s' % self))
     return seq
Esempio n. 15
0
 def _generateSequence(self, target):
     pos = self.read(0)
     s = self.microstep if (target - pos) >= 0 else -self.microstep
     n = int((target - pos) / s)
     # handle floating point overflows
     # check whether or not one last microstep fits into movement to target.
     if (math.fabs((pos + (n + 1) * s) - target) < math.fabs(
             self.microstep / 10)):
         n += 1
     res = [(SeqDev(self._attached_motor,
                    pos + i * s), SeqSleep(self._delay))
            for i in range(1, n)]
     res.append((SeqDev(self._attached_motor,
                        target), SeqSleep(self._delay)))
     return res
Esempio n. 16
0
    def _generateSequence(self):
        seq = []

        shutter_mode = self._attached_auto.read(0)

        if shutter_mode == 'auto':
            seq.append(SeqDev(self._attached_shutter, 'open'))

        # Wait for arm to become 0
        seq.append(WaitPV(self, 'armpv', 0, timeout=self.arm_timeout))

        # set valid 0
        seq.append(PutPV(self, 'validpv', 0))

        # wait for beam
        seq.append(Message(self, 'Waiting for beam...'))
        s = WaitThreshold(self, self._attached_beam_current,
                          self._attached_rate_threshold.read())
        seq.append(s)
        seq.append(Message(self, 'Beam is on, exposing...'))

        # Start the detector
        seq.append(PutPV(self, 'trigpv', 1))

        # wait for the detector to actually start
        s = WaitNotPV(self, 'shutpv', 1, timeout=self.shutter_timeout)
        seq.append(s)

        # Reset the start signal
        seq.append(PutPV(self, 'trigpv', 0))

        # Wait for counting to finish
        s = WaitPV(self, 'shutpv', 1, timeout=self.exposure_timeout)
        seq.append(s)

        # Write the metadata
        seq.append(SeqMethod(self, '_writeMetaData'))

        # Camini is tired, needs a little sleep
        seq.append(SeqSleep(.1))

        # set valid 1
        seq.append(PutPV(self, 'validpv', 1))

        if shutter_mode == 'auto':
            seq.append(SeqDev(self._attached_shutter, 'closed'))

        return seq
Esempio n. 17
0
    def park(self, blocking=True):
        """Move device to the ``park`` position.

        The park position is given by the ``parkposition`` parameter.
        It generate ands starts a sequence if none is running.

        The call blocks the daemon execution if ``blocking`` is set to True.
        """
        if self._seq_is_running():
            if self._mode == SIMULATION:
                self._seq_thread.join()
                self._seq_thread = None
            else:
                raise MoveError(
                    self, 'Cannot park device, sequence is still '
                    'running (at %s)!' % self._seq_status[1])
        self._startSequence([
            SeqMethod(self, '_move_guides_to_zero_pos'),
            SeqMethod(self, '_move_detectors', self.parkpos),
        ] + [
            SeqDev(d, p)
            for d, p in zip(self._rotguide1, self.parkpos[11:][::-1])
        ])
        if blocking:
            # block the move to be sure that the device has reached target
            # before it can be dismounted or the position sensitive detectors
            # can be used
            self.wait()
Esempio n. 18
0
 def _generateSequence(self, value):
     sequence = []
     currentsource = self._attached_currentsource
     if value != 0:
         need_pol = +1 if value > 0 else -1
         curr_pol = self._get_field_polarity()
         # if the switch values are not correct, drive to zero and switch
         if curr_pol != need_pol:
             if currentsource.read() != 0:
                 sequence.append(SeqDev(currentsource, 0.))
             # insert switching Sequence
             self._seq_set_field_polarity(need_pol, sequence)
     sequence.append(SeqDev(currentsource, abs(value)))
     if value == 0:
         self._seq_set_field_polarity(0, sequence)
     return sequence
Esempio n. 19
0
    def change(self, old, whereto):
        ''' cool kurze Wechselroutine
        Der Knackpunkt ist in den Hilfsroutinen!'''
        if not (old in self.monos + ['None']):
            raise UsageError(
                self, '\'%s\' is illegal value for Mono, use one '
                'of ' % old + ', '.join(self.monos + ['None']))
        if not (whereto in self.monos + ['None']):
            raise UsageError(
                self, '\'%s\' is illegal value for Mono, use one '
                'of ' % whereto + ', '.join(self.monos + ['None']))
        self.PrepareChange()
        if self.monos.index(whereto) == self.monos.index(old):
            # Nothing to do, requested Mono is supposed to be on the table
            return
        # Ok, we have a good state, the only thing we do not know is which mono
        # is on the table......
        # for this we use the (cached) parameter mono_on_table

        if self.mono_on_table != old:
            raise UsageError(
                self, 'Mono %s is not supposed to be on the '
                'table, %s is!' % (old, self.mono_on_table))

        seq = []
        # 0) move magazine to mono position
        magpos_to_put = self.positions[self.monos.index(old)]
        seq.append(SeqMethod(self, 'CheckMagazinSlotEmpty', magpos_to_put))
        seq.append(SeqDev(self._attached_magazine, magpos_to_put))
        # 1) move away the old mono, if any
        if old != 'None':
            seq.extend(self._gen_table2lift())
            seq.extend(
                self._gen_lift2mag(self.positions[self.monos.index(old)]))
        # 2) fetch the new mono (if any) from the magazin
        if whereto != 'None':
            seq.extend(
                self._gen_mag2lift(self.positions[self.monos.index(whereto)]))
            seq.extend(self._gen_lift2table())
            seq.append(
                SeqDev(self._attached_magazine,
                       self.shields[self.monos.index(whereto)]))

        # seq.append(SeqDev(self._attached_enable, 0)) - will be done in FinishChange
        seq.append(SeqMethod(self, 'FinishChange'))
        self._start(seq)
        self.wait()
Esempio n. 20
0
    def _generateSequence(self, target):
        hvdev = self._attached_supply
        disdev = self._attached_discharger
        seq = [SeqMethod(hvdev, 'stop'), SeqMethod(hvdev, 'wait')]

        now = currenttime()

        # below first rampstep is treated as poweroff
        if target <= self.rampsteps[0][0]:
            # fast ramp
            seq.append(SeqParam(hvdev, 'ramp', self.fastramp))
            seq.append(SeqDev(disdev, 1 if self.read() > target else 0))
            if self.read() > self.rampsteps[0][0]:
                seq.append(SeqDev(hvdev, self.rampsteps[0][0]))
            seq.append(SeqMethod(hvdev, 'start', target))
            return seq

        # check off time
        if self.lasthv and now - self.lasthv <= self.maxofftime:
            # short ramp up sequence
            seq.append(SeqParam(hvdev, 'ramp', self.fastramp))
            seq.append(SeqDev(disdev, 1 if self.read() > target else 0))
            seq.append(SeqDev(hvdev, target))
            # retry if target not reached
            seq.append(SeqMethod(hvdev, 'start', target))
            return seq

        # long sequence
        self.log.warning(
            'Voltage was down for more than %.2g hours, '
            'ramping up slowly, be patient!', self.maxofftime / 3600)

        self.log.info(
            'Voltage will be ready around %s',
            strftime('%X',
                     localtime(now + self.doTime(self.doRead(0), target))))

        seq.append(SeqParam(hvdev, 'ramp', self.slowramp))
        seq.append(SeqDev(disdev, 0))
        for voltage, minutes in self.rampsteps:
            # check for last point in sequence
            if target <= voltage:
                seq.append(SeqDev(hvdev, target))
                seq.append(
                    SeqSleep(minutes * 60,
                             'Stabilizing HV for %d minutes' % minutes))
                break
            else:  # append
                seq.append(SeqDev(hvdev, voltage))
                seq.append(
                    SeqSleep(minutes * 60,
                             'Stabilizing HV for %d minutes' % minutes))
        seq.append(SeqDev(hvdev, target))  # be sure...
        seq.append(SeqMethod(hvdev, 'poll'))  # force a read
        return seq
Esempio n. 21
0
    def _generateSequence(self, target):
        theta, trans = self._calcMonoPosition(target)

        seq = []

        seq.append((SeqDev(self._attached_mth1, self.safe_position),
                    SeqDev(self._attached_mth2, self.safe_position)))

        seq.append(SeqMethod(self, '_checksafe'))

        seq.append(SeqMethod(self, '_runMtx', trans))

        seq.append((SeqDev(self._attached_mth1, theta),
                    SeqDev(self._attached_mth2, theta)))

        seq.append(SeqMethod(self, '_checkArrival'))

        return seq
Esempio n. 22
0
    def _generateSequence(self, target):
        self.wlmin, self.wlmax = limits(
            (target.get('wlmin', self.wlmin), target.get('wlmax', self.wlmax)))
        self.dist = target.get('D', self.dist)
        self.gap = target.get('gap', self.gap)
        chopper2_pos = target.get('chopper2_pos')

        speed, angles = chopper_config(self.wlmin,
                                       self.wlmax,
                                       self.dist,
                                       chopper2_pos,
                                       gap=self.gap)

        self.log.debug('speed: %d, angles = %s', speed, angles)

        seq = []
        shutter_pos = self._attached_shutter.read(0)
        shutter_ok = self._attached_shutter.status(0)[0] == status.OK
        if chopper2_pos == 6:
            self._setROParam('mode', 'virtual_disc2_pos_6')
        else:
            self._setROParam('mode', 'normal_mode')
            chopper2_pos_akt = self._attached_chopper2.pos
            if chopper2_pos_akt != chopper2_pos:
                if shutter_ok:
                    seq.append(
                        SeqDev(self._attached_shutter,
                               'closed',
                               stoppable=True))
                seq.append(SeqDev(self._attached_chopper1, 0, stoppable=True))
                seq.append(
                    SeqSlowParam(self._attached_chopper2, 'pos', chopper2_pos))

        for dev, t in zip(self._choppers[1:], angles[1:]):
            # The Chopper measures the phase in the opposite direction
            # as we do this was catered for here, we have moved the
            # sign conversion to the doWritePhase function
            # dev.phase = -t  # sign by history
            seq.append(SeqFuzzyParam(dev, 'phase', t, 0.5))
        seq.append(SeqDev(self._attached_chopper1, speed, stoppable=True))
        if shutter_ok:
            seq.append(
                SeqDev(self._attached_shutter, shutter_pos, stoppable=True))
        return seq
Esempio n. 23
0
    def doStart(self, targets):
        """Generate and start a sequence if none is running.

        The sequence is optimised for negative backlash.
        It will first move both motors to the lowest value of
        (target + backlash, current_position) and then
        to the final target.
        So, inbetween, the NOK should be parallel to the beam.
        MP 12.12.2017 09:16:05
        """
        if self._seq_is_running():
            raise MoveError(self, 'Cannot start device, it is still moving!')

        # check precision, only move if needed!
        traveldists = [
            target - dev.read(0) - ofs
            for target, dev, ofs in zip(targets, self._devices, self.offsets)
        ]
        if max(abs(v) for v in traveldists) <= self.precision:
            return

        devices = self._devices

        # XXX: backlash correction and repositioning later

        # build a moving sequence
        sequence = []

        # now go to target
        sequence.append([
            SeqDev(d, t + ofs, stoppable=True)
            for d, t, ofs in zip(devices, targets, self.offsets)
        ])

        # now go to target again
        sequence.append([
            SeqDev(d, t + ofs, stoppable=True)
            for d, t, ofs in zip(devices, targets, self.offsets)
        ])

        self.log.debug('Seq: %r', sequence)
        self._startSequence(sequence)
Esempio n. 24
0
 def run(self):
     while self.dev.status(0)[0] == status.BUSY:
         # if still BUSY, stop first
         self.dev.stop()
         session.delay(0.3)
         self.dev.wait()
         session.delay(0.3)
     try:
         self.dev.wait()
         NicosSeqDev.run(self)
     except Exception:
         while True:
             # stop first
             self.dev.stop()
             session.delay(0.3)
             self.dev.wait()
             session.delay(0.3)
             if self.dev.status(0)[0] != status.BUSY:
                 NicosSeqDev.run(self)
                 break
Esempio n. 25
0
    def _generateSequence(self, target):
        """Generate and start a sequence if none is running.

        be sure not to cross the blades
        """

        targets = self._calculate_slits(target, False)
        if (target[1] - self.center.read(0)) < 0:
            self.log.debug('DoubleSlitSequence Seq swap')
            sequence = [
                SeqDev(self._attached_slit_s, targets[1], stoppable=True),
                SeqDev(self._attached_slit_r, targets[0], stoppable=True),
            ]
        else:
            self.log.debug('DoubleSlitSequence Seq org')
            sequence = [
                SeqDev(self._attached_slit_r, targets[0], stoppable=True),
                SeqDev(self._attached_slit_s, targets[1], stoppable=True),
            ]
        self.log.debug('Seq_2: %r', sequence)
        return sequence
Esempio n. 26
0
 def _generateSequence(self):
     seq = []
     order = (0, 1) if self._attached_flipper.read() == self.flipvalues[0] \
             else (1, 0)
     for i, phase in enumerate(order):
         if i:
             seq.append(SeqDev(self._attached_flipper, self.flipvalues[phase]))
         seq.append(SeqCall(self._startDet, phase))
         seq.append(SeqWait(self._attached_detector))
         seq.append(SeqCall(self._readDet, phase))
     seq.append(SeqCall(self._evaluateResults))
     return seq
Esempio n. 27
0
    def _generateSequence(self, target):
        seq = []

        if target < 5:
            seq.append(SeqDev(self._attached_setp, 0))
            seq.append(SeqWaitValue(self._attached_rbv, 0, 5))
            seq.append(SeqDev(self._attached_state, 'off'))
        elif abs(self._attached_rbv.read(0) - target) >= 1.0:
            seq.append(SeqDev(self._attached_state, 'on'))
            seq.append(SeqDev(self._attached_setp, target))
            seq.append(SeqWaitValue(self._attached_rbv, target, 1.0))
            # Repeat enough of this pair until sufficient stabilisation
            # has been reached
            seq.append(SeqSleep(5))
            seq.append(SeqWaitValue(self._attached_rbv, target, 1.0))
            seq.append(SeqSleep(5))
            seq.append(SeqWaitValue(self._attached_rbv, target, 1.0))
            seq.append(SeqSleep(5))
            seq.append(SeqWaitValue(self._attached_rbv, target, 1.0))

        return seq
Esempio n. 28
0
    def _generateSequence(self, target):
        seq = []

        s = SeqMethod(self, '_release')
        seq.append(s)

        if target == 'out':
            seq.append(SeqMethod(self, '_save_pos'))

            seq.append(SeqDev(self._attached_x, self._out_x))

            seq.append(SeqLimDev(self._attached_y, self._out_y, self._out_y))

            seq.append(SeqMethod(self, '_fix'))
        else:
            seq.append(SeqMethod(self, '_release'))

            seq.append(SeqLimDev(self._attached_y, self._in_y, -450))

            seq.append(SeqDev(self._attached_x, self._in_x))

        return seq
Esempio n. 29
0
 def _generateSequence(self, target):
     seq = []
     if not self.isAtTarget(self.doRead(0)):
         # The limited space at some positions requires a folding of the
         # instrument
         st_target = 60. if self.angle > -85. else 109.
         if st_target != self.stpos:
             raise ConfigurationError(self, 'st_target != stpos')
         # Only move if the setup (folding of 'st') is not correctly
         if abs(self._attached_st.read(0) - self.stpos) > \
            self._attached_st.precision:
             seq.append(SeqDev(self._attached_tt, -60., stoppable=True))
             seq.append(
                 SeqDev(self._attached_st, self.stpos, stoppable=True))
         # the configured positions are with offet = 0 !
         # if the user changes the offset the change positions will not
         # change!
         tt_pos = self.angle - self._attached_tt.offset
         seq.append(SeqDev(self._attached_tt, tt_pos, stoppable=True))
         seq.append(SeqDev(self._attached_block, target))
         seq.append(SeqSleep(2))
     return seq
Esempio n. 30
0
    def doStart(self, pos):
        self.doWriteScatteringsense(self.scatteringsense)
        qh, qk, ql, ny = pos
        ny = self._thz(ny)
        angles = self._attached_cell.cal_angles([qh, qk, ql], ny,
                                                self.scanmode,
                                                self.scanconstant,
                                                self.scatteringsense[1],
                                                self.axiscoupling, self.psi360)
        mono, ana, phi, psi, alpha = self._attached_mono, self._attached_ana, \
            self._attached_phi, self._attached_psi, self._attached_alpha

        movefirst = []
        self.log.debug('moving mono to %s', angles[0])
        movefirst.append(SeqDev(mono, from_k(angles[0], mono.unit)))
        self.log.debug('moving phi/stt to %s', angles[2])
        movefirst.append(SeqDev(phi, angles[2]))
        self.log.debug('moving psi/sth to %s', angles[3])
        movefirst.append(SeqDev(psi, angles[3]))
        if alpha is not None:
            self.log.debug('moving alpha to %s', angles[4])
            movefirst.append(SeqDev(alpha, angles[4]))
        seq = []
        # move mono/sample all at once
        seq.append(movefirst)
        # afterwards correct ana
        if self.scanmode != 'DIFF':
            self.log.debug('moving ana to %s', angles[1])
            seq.append(SeqDev(ana, from_k(angles[1], ana.unit)))
        # spurion check
        if self.spurioncheck and self._mode == SIMULATION:
            self._spurionCheck(pos)
        # store the min and max values of h,k,l, and E for simulation
        self._sim_setValue(pos)
        # start
        self._startSequence(seq)