diff --git a/eco/bernina/config.py b/eco/bernina/config.py index cfbc636..c2740a5 100755 --- a/eco/bernina/config.py +++ b/eco/bernina/config.py @@ -226,7 +226,7 @@ components = [ "name": "las", "z_und": 142, "desc": "Experiment laser optics", - "type": "eco.loptics.bernina_experiment_dev:Laser_Exp", + "type": "eco.loptics.bernina_experiment:Laser_Exp", "kwargs": {"Id":"SLAAR21-LMOT"}, }, { diff --git a/eco/devices_general/delay_stage.py b/eco/devices_general/delay_stage.py index 56d941a..7760b20 100755 --- a/eco/devices_general/delay_stage.py +++ b/eco/devices_general/delay_stage.py @@ -1,5 +1,6 @@ from ..devices_general.utilities import Changer from epics import PV +from ..aliases import Alias _status_messages = { @@ -20,10 +21,14 @@ _status_messages = { class DelayStage: - def __init__(self, stage): + + + + def __init__(self, stage, name=None): self._stage = stage self.delay_stage_offset = 0.0 - self.name = self._stage.name + self.name = name + self.alias = Alias(name) self.Id = self._stage.Id self._elog = self._stage._elog diff --git a/eco/devices_general/smaract.py b/eco/devices_general/smaract.py index d7f2cbb..33b93c3 100644 --- a/eco/devices_general/smaract.py +++ b/eco/devices_general/smaract.py @@ -10,6 +10,24 @@ from ..aliases import Alias _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 cpmfirmed", + 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) @@ -64,7 +82,8 @@ class SmarActRecord: self._rbv = SmarAct(Id+':MOTRBV') self._hlm = SmarAct(Id+':HLM') self._llm = SmarAct(Id+':LLM') - self._status = SmarAct(Id+':STATUS') + self._statusstg = SmarAct(Id+':STATUS') + self._status = [] self._set_pos = SmarAct(Id+':SET_POS') self._stop = SmarAct(Id+':STOP') self._hold = SmarAct(Id+':HOLD') @@ -75,7 +94,7 @@ class SmarActRecord: self.alias = Alias(name) for an, af in alias_fields.items(): self.alias.append( - Alias(an, channel=".".join([pvname, af]), channeltype="CA" + Alias(an, channel=".".join([self.Id, af]), channeltype="CA" )) @@ -84,13 +103,18 @@ class SmarActRecord: def changeTo(self, value, hold=False, check=True): """ Adjustable convention""" - mover = lambda value: self.move(\ - value, ignore_limits=(not check), - wait=True) + def changer(value): + self._status = self.move(value, ignore_limits=(not check), wait=True) + self._status_message = _status_messages[self._status] + if not self._status == 0: + print(self._status_message) + #mover = lambda value: self.move(\ + # value, ignore_limits=(not check), + # wait=True) return Changer( target=value, parent=self, - mover=mover, + changer=changer, hold=hold, stopper=self._stop.put('PROC', 1)) @@ -160,7 +184,7 @@ class SmarActRecord: return TIMEOUT if 1 == stat: - s0 = self._status.get('VAL') + s0 = self._statusstg.get('VAL') s1 = s0 t0 = time.time() t1 = t0 + min(10.0, timeout) # should be moving by now @@ -169,15 +193,15 @@ class SmarActRecord: if wait or confirm_move: while time.time() <= thold and s1 == 3: ca.poll(evt=1.e-2) - s1 = self._status.get('VAL') + s1 = self._statusstg.get('VAL') while time.time() <= t1 and s1 == 0: ca.poll(evt=1.e-2) - s1 = self._status.get('VAL') + s1 = self._statusstg.get('VAL') if s1 == 4: if wait: while time.time() <= tout and s1 == 4: ca.poll(evt=1.e-2) - s1 = self._status.get('VAL') + s1 = self._statusstg.get('VAL') if s1 == 3 or s1 == 4: if time.time() > tout: return TIMEOUT diff --git a/eco/loptics/bernina_experiment.py b/eco/loptics/bernina_experiment.py index 8339315..7e5172b 100755 --- a/eco/loptics/bernina_experiment.py +++ b/eco/loptics/bernina_experiment.py @@ -1,3 +1,4 @@ +from ..aliases import Alias from ..devices_general.motors import MotorRecord from ..devices_general.smaract import SmarActRecord @@ -5,100 +6,143 @@ from epics import PV from ..devices_general.delay_stage import DelayStage from ..devices_general.user_to_motor import User_to_motor +def addMotorRecordToSelf(self, Id=None, name=None): + self.__dict__[name] = MotorRecord(Id, name=name) + self.alias.append(self.__dict__[name].alias) + +def addSmarActRecordToSelf(self, Id=None, name=None): + self.__dict__[name] = SmarActRecord(Id, name=name) + self.alias.append(self.__dict__[name].alias) + +def addDelayStageToSelf(self, stage=None, name=None): + self.__dict__[name] = DelayStage(stage, name=name) + self.alias.append(self.__dict__[name].alias) class Laser_Exp: - def __init__(self, Id): + def __init__(self, Id=None, name=None): self.Id = Id - - try: - self.lensx = MotorRecord("SARES20-EXP:MOT_DIODE") + self.IdExp1 = 'SARES20-EXP' + self.IdSA = 'SARES23' + self.name=name + self.alias=Alias(name) + + #Waveplate and Delay stage + addMotorRecordToSelf(self, self.Id+'-M534:MOT', name="wp") + try: + addMotorRecordToSelf(self, Id=self.Id+'-M521:MOTOR_1', name="_eos_delay") + addDelayStageToSelf(self,stage=self.__dict__["_eos_delay"], name="eos_delay") except: - print("No owis lens x motor") + print('No eos delay stage') + pass + try: + addMotorRecordToSelf(self, Id=self.Id+'-M522:MOTOR_1', name="_thz_delaystg") + addDelayStageToSelf(self,self.__dict__["_thz_delaystg"], name="spatialenc_delay") + #addDelayStageToSelf(self,self.__dict__["_thz_delaystg"], name="thz_delay") + except: + print('No thz delay stage') pass - # Waveplate and Delay stage - self.wp = MotorRecord(Id + "-M534:MOT") + #compressor + addMotorRecordToSelf(self, Id=self.Id+'-M532:MOT', name="compressor") + #self.compressor = MotorRecord(Id+'-M532:MOT') - self._pump_delayStg = MotorRecord(self.Id + "-M521:MOTOR_1") - self.pump_delay = DelayStage(self._pump_delayStg) + #LAM delay stages + addSmarActRecordToSelf(self, Id='SLAAR21-LMTS-LAM11', name="_lam_delay_smarstg") + addDelayStageToSelf(self,self.__dict__["_lam_delay_smarstg"], name="lam_delay_smar") + #self._lam_delayStg_Smar = SmarActRecord('SLAAR21-LMTS-LAM11') + #self.lam_delay_Smar = DelayStage(self._lam_delayStg_Smar) - # LAM delay stages - self._lam_delayStg_Smar = SmarActRecord("SLAAR21-LMTS-LAM11") - self.lam_delay_Smar = DelayStage(self._lam_delayStg_Smar) + addMotorRecordToSelf(self, Id=self.Id+'-M548:MOT', name="_lam_delaystg") + addDelayStageToSelf(self,self.__dict__["_lam_delaystg"], name="lam_delay") + #self._lam_delayStg = MotorRecord(self.Id+'-M548:MOT') + #self.lam_delay = DelayStage(self._lam_delayStg) - self._lam_delayStg = MotorRecord(self.Id + "-M548:MOT") - self.lam_delay = DelayStage(self._lam_delayStg) + #PALM delay stages + addMotorRecordToSelf(self, Id=self.Id+'-M552:MOT', name="_palm_delaystg") + addDelayStageToSelf(self,self.__dict__["_palm_delaystg"], name="palm_delay") + #self._palm_delayStg = MotorRecord(self.Id+'-M552:MOT') + #self.palm_delay = DelayStage(self._palm_delayStg) - # PALM delay stages - self._palm_delayStg = MotorRecord(self.Id + "-M552:MOT") - self.palm_delay = DelayStage(self._palm_delayStg) + #PSEN delay stages + #self._psen_delayStg = MotorRecord(self.Id+'') + #self.psen_delay = DelayStage(self._pump_delayStg) - # PSEN delay stages - # self._psen_delayStg = MotorRecord(self.Id+'') - # self.psen_delay = DelayStage(self._pump_delayStg) - - # SmarAct ID - self.IdSA = "SARES23" - - ### Mirrors used in the expeirment ### + #SmarAct ID + ### Mirrors used in the experiment ### try: - self.eos_rot = SmarActRecord(self.IdSA + "-ESB18") + addSmarActRecordToSelf(self, Id=self.IdSA+'-ESB18', name="spatialenc_rot") + #self._eos_rot = SmarActRecord(self.IdSA+'-ESB18') + #self.eos_rot = User_to_motor(self._eos_rot,180./35.7,0.) except: - print("No Smaract EOSrot") + print('No Smaract EOSrot') pass try: - self.eos_gonio = SmarActRecord(self.IdSA + "-ESB3") + addSmarActRecordToSelf(self, Id=self.IdSA+'-ESB2', name="eos_gonio") except: - print("No Smaract EOSGonio") + print('No Smaract EOSGonio') pass try: - self._pump_rot = SmarActRecord(self.IdSA + "-ESB16") - self.pump_rot = User_to_motor(self._pump_rot, 180.0 / 35.7, 0.0) + addSmarActRecordToSelf(self, Id=self.IdSA+'-ESB1', name="eos_x") except: - print("No Smaract THzrot") + print('No Smaract EOSx') pass try: - self.pump_gonio = SmarActRecord(self.IdSA + "-ESB2") + addSmarActRecordToSelf(self, Id=self.IdSA+'-ESB16', name="thz_rot") + #self.thz_rot = User_to_motor(self._thz_rot,180./35.7,0.) except: - print("No Smaract THzGonio") + print('No Smaract THzrot') pass try: - self.pump_x = SmarActRecord(self.IdSA + "-ESB1") + addSmarActRecordToSelf(self, Id=self.IdSA+'-ESB5', name="thz_gonio") except: - print("No Smaract THzZ") + print('No Smaract THzGonio') + pass + + try: + addSmarActRecordToSelf(self, Id=self.IdSA+'-ESB4', name="tar_t") + #self.thz_z = SmarActRecord(self.IdSA+'-ESB4') + except: + print('No Smaract THzZ') pass try: - self.par_x = SmarActRecord(self.IdSA + "-ESB5") + addSmarActRecordToSelf(self, Id=self.IdSA+'-ESB6', name="spatialenc_gon") + #self.par_x = SmarActRecord(self.IdSA+'-ESB6') except: - print("No Smaract ParX") + print('No Smaract ParX') pass try: - self.par_z = SmarActRecord(self.IdSA + "-ESB4") + addSmarActRecordToSelf(self, Id=self.IdSA+'-ESB3', name="par_z") except: - print("No Smaract ParZ") + print('No Smaract ParZ') pass + + ### Motors on EXP1 deltatau + try: + addMotorRecordToSelf(self, Id=self.IdExp1+':MOT_VT80', name="tar_y") + #self.par_y = MotorRecord(self.IdExp1+':MOT_VT80') + except: + print('No Smaract ParY') + pass + + def get_adjustable_positions_str(self): - ostr = "*****SmarAct motor positions******\n" + ostr = '*****Laser motor positions******\n' - for tkey, item in self.__dict__.items(): - if hasattr(item, "get_current_value"): + for tkey,item in self.__dict__.items(): + if hasattr(item,'get_current_value'): pos = item.get_current_value() - ostr += " " + tkey.ljust(10) + " : % 14g\n" % pos + ostr += ' ' + tkey.ljust(17) + ' : % 14g\n'%pos return ostr + + - # def pos(self): - # s = [] - # for i in sorted(self.__dict__.keys()): - # s.append[i] - # for n, mo^tor in enumerate (s): - # s[n] += ': ' + str(self.__dict__[motor]) - # return s def __repr__(self): return self.get_adjustable_positions_str() + diff --git a/eco/timing/event_timing.py b/eco/timing/event_timing.py index a7a5440..fd93503 100644 --- a/eco/timing/event_timing.py +++ b/eco/timing/event_timing.py @@ -2,6 +2,47 @@ from epics import PV from ..aliases import Alias from ..utilities.lazy_proxy import Proxy +#EVR output mapping +evr_mapping = { + 0: "Pulser 0", + 1: "Pulser 1", + 2: "Pulser 2", + 3: "Pulser 3", + 4: "Pulser 4", + 5: "Pulser 5", + 6: "Pulser 6", + 7: "Pulser 7", + 8: "Pulser 8", + 9: "Pulser 9", + 10: "Pulser 10", + 11: "Pulser 11", + 12: "Pulser 12", + 13: "Pulser 13", + 14: "Pulser 14", + 15: "Pulser 15", + 16: "Pulser 16", + 17: "Pulser 17", + 18: "Pulser 18", + 19: "Pulser 19", + 20: "Pulser 20", + 21: "Pulser 21", + 22: "Pulser 22", + 23: "Pulser 23", + 32: "Distributed bus bit 0", + 33: "Distributed bus bit 1", + 34: "Distributed bus bit 2", + 35: "Distributed bus bit 3", + 36: "Distributed bus bit 4", + 37: "Distributed bus bit 5", + 38: "Distributed bus bit 6", + 39: "Distributed bus bit 7", + 40: "Prescaler 0", + 41: "Prescaler 1", + 42: "Prescaler 2", + 62: "Logic High", + 63: "Logic low" + } + # temporary mapping of Ids to codes, be aware of changes! eventcodes = [1, 2, 3, 4, 5, 0, 6, 7, 8, 12, 0, 11, 9, 10, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]