def _generateSequence(self, target): return [ SeqCall(Motor.doStart, self, target), SeqCall(self._hw_wait), SeqSleep(self.stopdelay), SeqCall(Motor.doStop, self) ]
def _generateSequence(self, target): seq = [] startpos = [self._attached_xaxis.read(), self._attached_yaxis.read()] lowest_y_pos = min(self.ylimits) if startpos[1] < lowest_y_pos: raise UsageError('illegal start position for changing shape, ' 'please call instrument scientist!') # construct desired sequence: first move above slot of current shape seq.append([ SeqDev(self._attached_xaxis, self.slots[self.shape][0]), SeqDev(self._attached_yaxis, lowest_y_pos) ]) # move down to ypassage to put shape back to slot/shapeholder seq.append(SeqDev(self._attached_yaxis, self.ypassage)) # adjust self._shape seq.append(SeqCall(self._setROParam, 'shape', 'none')) # move x to slot of new shape seq.append(SeqDev(self._attached_xaxis, self.slots[target][0])) # move up to lowest yvalue seq.append(SeqDev(self._attached_yaxis, lowest_y_pos)) # adjust self._shape seq.append(SeqCall(self._setROParam, 'shape', target)) # move to last xvalue seq.append([ SeqDev(self._attached_xaxis, startpos[0]), SeqDev(self._attached_yaxis, startpos[1]) ]) return seq
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)
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]), ]
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
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
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
def _gen_lift2mag(self, magpos=None): seq = [] if magpos is None: magpos = self._attached_magazine.read(0) else: seq.append(SeqDev(self._attached_magazine, magpos)) # check preconditions seq.append( SeqCall(self.log.info, 'checking preconditions for Lift2Magazin')) seq.append(SeqCheckStatus(self._attached_magazine, status.OK)) seq.append(SeqCheckStatus(self._attached_lift, status.OK)) seq.append(SeqCheckPosition(self._attached_lift, '2')) seq.append(SeqCheckPosition(self._attached_liftclamp, 'close')) seq.append(SeqCheckPosition(self._attached_magazine, magpos)) seq.append(SeqCheckPosition(self._attached_magazineclamp, 'close')) seq.append(SeqMethod(self, 'CheckMagazinSlotEmpty', magpos)) # there needs to be a mono in the lift seq.append( SeqCall(self.log.info, 'checking if there is a mono in lift')) seq.append( SeqCheckAttr(self, 'mono_in_lift', values=[m for m in self.monos if m != 'None'])) # prepare magazin seq.append(SeqCall(self.log.info, 'testing magazin grab')) seq.append(SeqDev(self._attached_magazineclamp, 'open')) seq.append(SeqDev(self._attached_magazineclamp, 'close')) seq.append(SeqDev(self._attached_magazineclamp, 'open')) seq.append(SeqDev(self._attached_magazineclamp, 'close')) seq.append(SeqDev(self._attached_magazineclamp, 'open')) # transfer mono to lift seq.append(SeqCall(self.log.info, 'moving lift to top position')) seq.append(SeqDev(self._attached_lift, '4')) # top position seq.append( SeqCall(self.log.info, 'closing the magazin grab and rattling lift')) seq.append(SeqMethod(self._attached_magazineclamp, 'start', 'close')) # rattle a little seq.append(SeqDev(self._attached_lift, '3')) # almost top position seq.append(SeqDev(self._attached_lift, '4')) # top position seq.append(SeqDev(self._attached_lift, '3')) # almost top position seq.append(SeqDev(self._attached_lift, '4')) # top position seq.append(SeqDev(self._attached_lift, '3')) # almost top position seq.append(SeqDev(self._attached_magazineclamp, 'close')) seq.append(SeqMethod(self, 'CheckMagazinSlotUsed', magpos)) seq.append(SeqCall(self.log.info, 'opening lift clamp')) seq.append(SeqMethod(self._attached_liftclamp, 'start', 'open')) seq.append(SeqDev(self._attached_lift, '4')) # top position seq.append(SeqDev(self._attached_lift, '3')) # top position seq.append(SeqDev(self._attached_liftclamp, 'open')) seq.append(SeqCall(self.log.info, 'moving lift to park position')) seq.append(SeqDev(self._attached_lift, '2')) # park position seq.append(SeqCall(self.log.info, 'closing lift clamp')) seq.append(SeqDev(self._attached_liftclamp, 'close')) # move (without mono) to parking position seq.append(SeqSetAttr(self, 'mono_in_lift', 'None')) # Magazin should not contain a mono now seq.append(SeqMethod(self, 'CheckMagazinSlotUsed', magpos)) return seq
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)
def _gen_mag2lift(self, magpos=None): seq = [] if magpos is None: magpos = self._attached_magazine.read(0) else: seq.append(SeqDev(self._attached_magazine, magpos)) # check preconditions seq.append( SeqCall(self.log.info, 'checking preconditions for Magazin2Lift')) seq.append(SeqCheckStatus(self._attached_magazine, status.OK)) seq.append(SeqCheckStatus(self._attached_lift, status.OK)) seq.append(SeqCheckPosition(self._attached_lift, '2')) seq.append(SeqCheckPosition(self._attached_liftclamp, 'close')) seq.append(SeqCheckPosition(self._attached_magazine, magpos)) seq.append(SeqCheckPosition(self._attached_magazineclamp, 'close')) seq.append(SeqMethod(self, 'CheckMagazinSlotUsed', magpos)) seq.append(SeqCheckAttr(self, 'mono_in_lift', 'None')) # transfer mono to lift seq.append( SeqCall(self.log.info, 'transferring mono from magazine to lift')) seq.append(SeqDev(self._attached_liftclamp, 'open')) seq.append(SeqDev(self._attached_lift, '3')) # almost top position seq.append(SeqMethod(self._attached_liftclamp, 'start', 'close')) seq.append(SeqDev(self._attached_lift, '4')) # top position seq.append(SeqDev(self._attached_liftclamp, 'close')) seq.append(SeqMethod(self._attached_magazineclamp, 'start', 'open')) # rattle a little seq.append(SeqCall(self.log.info, 'rattle to release magazine grab')) seq.append(SeqDev(self._attached_lift, '3')) # almost top position seq.append(SeqDev(self._attached_lift, '4')) # top position seq.append(SeqDev(self._attached_lift, '3')) # almost top position seq.append(SeqDev(self._attached_lift, '4')) # top position seq.append(SeqDev(self._attached_magazineclamp, 'open')) seq.append(SeqMethod(self, 'CheckMagazinSlotEmpty', magpos)) # move (with mono) to parking position seq.append( SeqCall(self.log.info, 'moving with mono to parking position')) seq.append( SeqSetAttr(self, 'mono_in_lift', self.monos[self.positions.index(magpos)])) seq.append(SeqDev(self._attached_lift, '2')) # park position seq.append(SeqDev(self._attached_magazineclamp, 'close')) # Magazin should not contain a mono now seq.append(SeqMethod(self, 'CheckMagazinSlotEmpty', magpos)) return seq
def test_seqcall(): # Calling sc = SeqCall(time.sleep, 0.1) assert repr(sc) == 'sleep' a = time.time() sc.check() sc.run() assert sc.isCompleted() is True b = time.time() assert 0.08 - DELTA <= b - a <= 0.15 + DELTA
def _gen_table2lift(self): # XXX TODO drive all foci to 0 and switch of motors.... # XXX TODO move mty/mtx to monospecific abholposition # hier nur das reine abholen vom Monotisch seq = [] # check preconditions seq.append( SeqCall(self.log.info, 'checking preconditions for Table2Lift')) seq.append(SeqCheckStatus(self._attached_tableclamp, status.OK)) seq.append(SeqCheckStatus(self._attached_liftclamp, status.OK)) seq.append(SeqCheckStatus(self._attached_lift, status.OK)) seq.append(SeqCheckPosition(self._attached_lift, '2')) seq.append(SeqCheckPosition(self._attached_liftclamp, 'close')) seq.append(SeqCheckPosition(self._attached_tableclamp, 'close')) # there shall be no mono in the lift, but one on the table seq.append( SeqCall(self.log.info, 'checking if there IS NOT a mono in Lift')) seq.append(SeqCheckAttr(self, 'mono_in_lift', 'None')) seq.append( SeqCheckAttr(self, 'mono_on_table', values=[m for m in self.monos if m != 'None'])) # transfer mono to lift seq.append(SeqCall(self.log.info, 'moving down the lift')) seq.append(SeqDev(self._attached_liftclamp, 'open')) seq.append(SeqDev(self._attached_lift, '1')) # bottom position seq.append(SeqCall(self.log.info, 'grabbing the monochromator')) seq.append(SeqDev(self._attached_liftclamp, 'close')) seq.append(SeqDev(self._attached_tableclamp, 'open')) # move (with mono) to parking position def func(self): self.mono_on_table, self.mono_in_lift = 'None', self.mono_on_table seq.append(SeqCall(func, self)) # seq.append(SeqSetAttr(self, 'mono_on_table', 'None')) # seq.append(SeqSetAttr(self, 'mono_in_lift', self.mono_on_table)) seq.append( SeqCall(self.log.info, 'moving the lift with mono to parking position')) seq.append(SeqDev(self._attached_lift, '2')) # park position seq.append(SeqDev(self._attached_tableclamp, 'close')) return seq
def _gen_lift2table(self): seq = [] # check preconditions seq.append( SeqCall(self.log.info, 'checking preconditions for Lift2Table')) seq.append(SeqCheckStatus(self._attached_tableclamp, status.OK)) seq.append(SeqCheckStatus(self._attached_liftclamp, status.OK)) seq.append(SeqCheckStatus(self._attached_lift, status.OK)) seq.append(SeqCheckPosition(self._attached_lift, '2')) seq.append(SeqCheckPosition(self._attached_liftclamp, 'close')) seq.append(SeqCheckPosition(self._attached_tableclamp, 'close')) # there shall be a mono in the lift! seq.append(SeqCall(self.log.info, 'check if there is a mono in Lift')) seq.append( SeqCheckAttr(self, 'mono_in_lift', values=[m for m in self.monos if m != 'None'])) seq.append(SeqCheckAttr(self, 'mono_on_table', 'None')) seq.append(SeqCall(self.log.info, 'moving down the lift')) # transfer mono to table seq.append(SeqDev(self._attached_tableclamp, 'open')) seq.append(SeqDev(self._attached_lift, '1')) # bottom position seq.append( SeqCall(self.log.info, 'closing table grab and releasing lift clamp')) seq.append(SeqDev(self._attached_tableclamp, 'close')) # move (without mono) to parking position seq.append(SeqDev(self._attached_liftclamp, 'open')) def func(self): self.mono_on_table, self.mono_in_lift = self.mono_in_lift, 'None' seq.append(SeqCall(func, self)) # seq.append(SeqSetAttr(self, 'mono_on_table', self.mono_in_lift)) # seq.append(SeqSetAttr(self, 'mono_in_lift', 'None')) seq.append(SeqCall(self.log.info, 'moving lift to park position')) seq.append(SeqDev(self._attached_lift, '2')) # park position seq.append(SeqDev(self._attached_liftclamp, 'close')) # TODO: change foci alias and reactivate foci return seq