diff --git a/acquisition/scan.py b/acquisition/scan.py index 2983410..2e45456 100755 --- a/acquisition/scan.py +++ b/acquisition/scan.py @@ -3,6 +3,7 @@ import os import json import numpy as np from time import sleep +import traceback class ScanSimple: def __init__(self,adjustables,values,counterCallers,fina,Npulses=100,basepath='',scan_info_dir='',checker=None): @@ -22,6 +23,7 @@ class ScanSimple: 'name':[ta.name for ta in adjustables ], 'Id':[ta.Id for ta in adjustables] }, + 'scan_values_all':values, 'scan_values':[], 'scan_readbacks':[], 'scan_files':[], @@ -102,7 +104,7 @@ class ScanSimple: except: tb = traceback.format_exc() else: - tb = "No error" + tb = "Ended all steps without interruption." finally: print(tb) diff --git a/devices_general/motors.py b/devices_general/motors.py index 3c6f0dd..e033c0b 100755 --- a/devices_general/motors.py +++ b/devices_general/motors.py @@ -2,12 +2,31 @@ from ..eco_epics.motor import Motor as _Motor import subprocess from threading import Thread from epics import PV +from .utilities import Changer _MotorRocordStandardProperties = \ {} _posTypes = ['user','dial','raw'] _guiTypes = ['xdm'] + +_status_messages = { + -13 : 'invalid value (cannot convert to float). Move not attempted.', + -12 : 'target value outside soft limits. Move not attempted.', + -11 : 'drive PV is not connected: Move not attempted.', + -8 : 'move started, but timed-out.', + -7 : 'move started, timed-out, but appears done.', + -5 : 'move started, unexpected return value from PV.put()', + -4 : 'move-with-wait finished, soft limit violation seen', + -3 : 'move-with-wait finished, hard limit violation seen', + 0 : 'move-with-wait finish OK.', + 0 : 'move-without-wait executed, not comfirmed', + 1 : 'move-without-wait executed, move confirmed' , + 3 : 'move-without-wait finished, hard limit violation seen', + 4 : 'move-without-wait finished, soft limit violation seen', +} + + def _keywordChecker(kw_key_list_tups): for tkw,tkey,tlist in kw_key_list_tups: assert tkey in tlist, "Keyword %s should be one of %s"%(tkw,tlist) @@ -18,19 +37,28 @@ class MotorRecord: self._motor = _Motor(pvname) self._elog = elog self.name = name + self._currentChange = None # Conventional methods and properties for all Adjustable objects def changeTo(self, value, hold=False, check=True): """ Adjustable convention""" - mover = lambda value: self._motor.move(\ + def changer(value): + self._status = self._motor.move(\ value, ignore_limits=(not check), wait=True) + self._status_message = _status_messages[self._status] + if not self._status==0: + print(self._status_message) + +# changer = lambda value: self._motor.move(\ +# value, ignore_limits=(not check), +# wait=True) return Changer( target=value, parent=self, - mover=mover, + changer=changer, hold=hold, stopper=self._motor.stop) def stop(self): @@ -154,7 +182,7 @@ class MotorRecord: -class Changer: +class ChangerOld: def __init__(self, target=None, parent=None, mover=None, hold=True, stopper=None): self.target = target self._mover = mover diff --git a/devices_general/utilities.py b/devices_general/utilities.py index 1c965b4..369a38d 100644 --- a/devices_general/utilities.py +++ b/devices_general/utilities.py @@ -20,7 +20,7 @@ class Changer: if self._thread.ident is None: return 'waiting' else: - if self.thread.isAlive: + if self._thread.isAlive: return 'changing' else: return 'done' diff --git a/loptics/bernina_experiment.py b/loptics/bernina_experiment.py index dc24a3e..5040f3a 100755 --- a/loptics/bernina_experiment.py +++ b/loptics/bernina_experiment.py @@ -1,13 +1,13 @@ from ..devices_general.motors import MotorRecord from epics import PV - +from .delay_stage import DelayStageCA class Laser_Exp: def __init__(self,Id): self.Id = Id self.delay_stage_offset =160. - + self.deltest = DelayStageCA(Id+'-M521:MOTOR_1') ### Mirrors used in the expeirment ### try: @@ -46,4 +46,4 @@ class Laser_Exp: self.delay_stage.mv(motor_pos) return (delay, motor_pos) - + diff --git a/timing/lasertiming.py b/timing/lasertiming.py index 9e8d843..02e4ccc 100644 --- a/timing/lasertiming.py +++ b/timing/lasertiming.py @@ -120,7 +120,7 @@ _OSCILLATOR_PERIOD = 1/71.368704e6 class Phase_shifter(PV): """ this class is needed to store the offset in files and read in ps """ - def __init__(self,pv_basename="SLAAR01-TSPL-EPL",dial_max=14.0056e-9,precision=100e-15): + def __init__(self,pv_basename="SLAAR02-TSPL-EPL",dial_max=14.0056e-9,precision=100e-15): pvname = pv_basename+":CURR_DELTA_T" PV.__init__(self,pvname) self._filename = os.path.join(_basefolder,pvname) @@ -171,20 +171,21 @@ class Phase_shifter(PV): return "Phase Shifter: user,dial = %s , %s"%(user,dial) -_slicer_gate = Pockels_trigger("SLAAR-LTIM01-EVR0:Pul2-Delay") -_sdg1 = Pockels_trigger("SLAAR-LTIM01-EVR0:Pul3-Delay") -_phase_shifter = Phase_shifter("SLAAR01-TSPL-EPL") +_slicer_gate = Pockels_trigger("SLAAR-LTIM02-EVR0:Pul3-Delay") +_sdg1 = Pockels_trigger("SLAAR-LTIM02-EVR0:Pul2-Delay") +_phase_shifter = Phase_shifter("SLAAR02-TSPL-EPL") _POCKELS_CELL_RESOLUTION = 7e-9 class Lxt(object): - def __init__(self): + def __init__(self,accuracy_poly=[100e-15,1e-7]): self.sdg1 = _sdg1 self.slicer_gate = _slicer_gate self.phase_shifter = _phase_shifter - self.Id = 'SLAAR01-TSPL-EPL' + self.Id = 'SLAAR02-TSPL-EPL' self.name = 'lxt' self.elog = None + self.accuracy_poly = accuracy_poly def move_sdg(self,value): self.sdg1.move(value) @@ -192,6 +193,8 @@ class Lxt(object): def move(self,value,accuracy=None): self.sdg1.move(-value) self.slicer_gate.move(-value) + if not accuracy: + accuracy = np.abs(value)*self.accuracy_poly[1]+self.accuracy_poly[0] self.phase_shifter.move(value,accuracy=accuracy) def set(self,value):