def test_group_creation(self): # group creation mymot1 = get_axis("mymot1") mymot2 = get_axis("mymot2") mygrp = Group(mymot1, mymot2) self.assertTrue(mygrp)
def _simultaneous_rmove(self, *args): axis_list = [] targets = [] for axis, target in grouped(args, 2): axis_list.append(axis) targets.append(axis.position() + target) g = Group(*axis_list) g.move(dict(zip(axis_list, targets)))
def test_group_get_position(self): # group creation mymot1 = get_axis("mymot1") mymot2 = get_axis("mymot2") mygrp = Group(mymot1, mymot2) #mymot1.controller.log_level(3) pos_list = mygrp.position() #mymot1.controller.log_level(3) for axis in pos_list: self.assertEqual(axis.position(), pos_list[axis])
def test_group_move(self): # group creation mymot1 = get_axis("mymot1") mymot2 = get_axis("mymot2") mygrp = Group(mymot1, mymot2) pos_list = mygrp.position() pos_list[mymot1] += 0.1 # waits for the end of motions mygrp.move(pos_list) self.assertEqual(mygrp.state(), "READY")
def test_group_stop(self): # group creation mymot1 = get_axis("mymot1") mymot2 = get_axis("mymot2") mygrp = Group(mymot1, mymot2) pos_list = mygrp.position() pos_list[mymot1] -= 0.1 # non blocking call mygrp.move(pos_list, wait=False) # waits for the end of motions mygrp.stop() self.assertEqual(mygrp.state(), "READY")
def _simultaneous_move(self, *args): axis_list = [] for axis, target in grouped(args, 2): axis_list.append(axis) g = Group(*axis_list) g.move(*args)
def helical_oscil(self, start_ang, stop_ang, helical_pos, exp_time, save_diagnostic=True, operate_shutter=True): def oscil_cleanup(omega_v=self.omega.velocity(from_config=True), omega_a=self.omega.acceleration(from_config=True), phiy_v=self.phiy.velocity(from_config=True), phiy_a=self.phiy.acceleration(from_config=True), sampx_v=self.sampx.velocity(from_config=True), sampx_a=self.sampx.acceleration(from_config=True), sampy_v=self.sampy.velocity(from_config=True), sampy_a=self.sampy.acceleration(from_config=True)): for motor_name in ("omega", "phiy", "sampx", "sampy"): getattr(self, motor_name).velocity(locals()[motor_name + "_v"]) getattr(self, motor_name).acceleration(locals()[motor_name + "_a"]) helical = self._helical_calc(helical_pos, exp_time) d, calc_velocity, acc_time, acc_ang = self._oscil_calc( start_ang, stop_ang, exp_time) encoder_step_size = -self.omega.steps_per_unit pixel_detector_trigger_steps = encoder_step_size * start_ang shutter_predelay_steps = math.fabs( float(self.shutter_predelay * calc_velocity * encoder_step_size)) shutter_postdelay_steps = math.fabs( float(self.shutter_postdelay * calc_velocity * encoder_step_size)) omega_prep_time = self.shutter_predelay * float(calc_velocity) oscil_start = start_ang - d * ( acc_ang + shutter_predelay_steps / encoder_step_size) oscil_final = stop_ang + d * acc_ang with cleanup(oscil_cleanup): self.fshut.close() moves = [] for motor_name, helical_info in helical.iteritems(): motor = helical_info["motor"] start = helical_info["start"] v = helical_info["velocity"] dd = helical_info["d"] step_size = abs(motor.steps_per_unit) prep_distance = (v * (omega_prep_time - (acc_time / 2.0))) / float(step_size) deceleration_distance = ( (acc_time * v) / 2.0) / float(step_size) helical_info[ "distance"] += prep_distance + deceleration_distance #logging.info("relative move for motor %s of: %f, prep_dist=%f", motor_name, start-motor.position()-dd*prep_distance, dd*prep_distance) moves += [motor, start - dd * prep_distance] self._simultaneous_move(self.omega, oscil_start, *moves) self.omega.velocity(calc_velocity) self.omega.acctime(acc_time) for motor_name, helical_info in helical.iteritems(): v = helical_info["velocity"] m = helical_info["motor"] if v > 0: #print 'setting velocity and acctime for motor %s to:' % motor_name, v, acc_time if v > 0.4: raise RuntimeError( "Wrong parameter for helical, velocity is too high; hint: increase number of images or exposure time and reduce transmission." ) m.velocity(v) m.acctime(acc_time) e1 = oscil_start * encoder_step_size + 5 e2 = oscil_final * encoder_step_size - 5 esh1 = start_ang * encoder_step_size - d * shutter_predelay_steps esh2 = stop_ang * encoder_step_size - d * shutter_postdelay_steps if (esh1 < esh2 and esh1 < e1) or (esh1 > esh2 and esh1 > e1): raise RuntimeError("acc_margin too small") if operate_shutter: self._musst_prepare(e1, e2, esh1, esh2, pixel_detector_trigger_steps) moves = dict() for motor_name, helical_info in helical.iteritems(): m = helical_info["motor"] moves[m] = m.position( ) + helical_info["d"] * helical_info["distance"] axes_group = Group(self.phiy, self.sampx, self.sampy) def abort_all(): self.omega.stop() axes_group.stop() self.musst.putget("#ABORT") with error_cleanup(abort_all): self.omega.move(oscil_final, wait=False) axes_group.move(moves) self.omega.wait_move() if save_diagnostic: self.save_diagnostic(wait=False)