def _generateSequence(self, target): seq = [] current = [int(dev.read(0)) for dev in self._attached_ephvs] if all(v == 0 for v in target): # shut down without ramp via capacitors subseq = [] for (i, dev) in enumerate(self._attached_ephvs): if current[i] <= 10: continue subseq.append(SeqMethod(dev, 'start', 0)) if subseq: seq.append(subseq) seq.append(SeqMethod(self, '_wait_for_shutdown')) else: while True: subseq = [] for (i, dev) in enumerate(self._attached_ephvs): if target[i] - 5 <= current[i] <= target[i] + 10: continue if target[i] > current[i]: setval = min(current[i] + self.voltagestep, target[i]) elif target[i] < current[i]: setval = max(current[i] - self.voltagestep, target[i]) subseq.append(SeqMethod(dev, 'start', setval)) current[i] = setval if not subseq: break seq.extend(subseq) seq.append(SeqSleep(self.stepsettle)) # final settle if seq: seq.append(SeqSleep(self.finalsettle)) return seq
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
def _generateSequence(self, target): seq = [] if not self.isAtTarget(self.read(0)): # self.reset() # session.delay(2) # switch on hardware if True or self.autoonoff: # ask why on/off automatic is needed seq.append(SeqDev(self._attached_a2_powvalunit, 1)) seq.append(SeqSleep(2)) seq.append(SeqDev(self._attached_a2_lgon, 1)) seq.append(SeqSleep(2)) # necessary for initialisation of logo seq.append(SeqDev(self._attached_a2_press, 1)) seq.append(SeqSleep(2)) seq.append(SeqMethod(self, '_checkpower', 1)) # we have to make a case differentiation because # the order of execution is important ! if target == 'cover': seq.append(SeqDev(self._attached_frame, 'out')) seq.append(SeqDev(self._attached_cover, 'in')) elif target == 'frame': seq.append(SeqDev(self._attached_cover, 'out')) seq.append(SeqDev(self._attached_frame, 'in')) elif target == 'open': seq.append(SeqDev(self._attached_cover, 'out')) seq.append(SeqDev(self._attached_frame, 'out')) if self.autoonoff: # and self.doStatus(0)[0] == status.OK seq.append(SeqDev(self._attached_a2_powvalunit, 0)) seq.append(SeqDev(self._attached_a2_lgon, 0)) seq.append(SeqDev(self._attached_a2_press, 0)) seq.append(SeqSleep(self.chkmotiontime)) seq.append(SeqMethod(self, '_checkpower', 0)) return 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): 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
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
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, 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
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)
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
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 = [] if target == '+': seq.append((SeqDev(self._attached_pom, 0.8), SeqDev(self._attached_pmag, -2.5))) seq.append(SeqSleep(4.)) seq.append(SeqDev(self._attached_pmag, .15)) elif target == '-': seq.append((SeqDev(self._attached_pom, 0.8), SeqDev(self._attached_pmag, 2.5))) seq.append(SeqSleep(4.)) seq.append(SeqDev(self._attached_pmag, 1.)) elif target == '0': seq.append((SeqDev(self._attached_pom, 3), SeqDev(self._attached_pmag, 0))) else: raise ProgrammingError('Invalid value requested') return seq
def _generateSequence(self, target): seq = [] seq.append(SeqMethod(self, '_HW_wait_while_BUSY')) seq.append(SeqMethod(self, '_HW_wait_while_HOT')) seq.append( SeqMethod(self, '_writeDestination', self._phys2steps(target))) seq.append(SeqMethod(self, '_HW_start')) seq.append(SeqSleep(1.1)) seq.append(SeqMethod(self, '_check_start_status')) seq.append(SeqMethod(self, '_HW_wait_while_BUSY')) self.log.debug('BeckhoffMotorBase Seq generated') return seq
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
def test_seqsleep(session): # pylint:disable=unused-argument # Sleeping?? sw = SeqSleep(0.1) assert repr(sw).startswith('0.1') a = time.time() sw.check() sw.run() while not sw.isCompleted(): pass b = time.time() assert 0.08 - DELTA <= b - a <= 0.15 + DELTA
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
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