This commit is contained in:
+163
-1
@@ -7,9 +7,171 @@
|
||||
###################################################################################################
|
||||
# Device initialization
|
||||
###################################################################################################
|
||||
class Energy(PositionerBase):
|
||||
def __init__(self, name, config):
|
||||
ControlledVariableBase.__init__(self, name, photon_energy.config)
|
||||
self.setReadback(photon_energy.getReadback())
|
||||
|
||||
def doRead(self):
|
||||
return photon_energy.read()
|
||||
|
||||
def doWrite(self, val):
|
||||
if not photon_energy.isInPosition(val):
|
||||
change_photon_pars(_photon_energy=val)
|
||||
|
||||
def getMinValue(self):
|
||||
er=get_energy_range()
|
||||
return er[0] if er is not None else sys.maxint
|
||||
|
||||
def getMaxValue(self):
|
||||
er=get_energy_range()
|
||||
return er[1] if er is not None else -sys.maxint
|
||||
add_device(Energy("energy", None), True)
|
||||
|
||||
def get_energy_range():
|
||||
md,gr = id_mode.read(), grating.read()
|
||||
if gr.startswith("G1"):
|
||||
if md in ["CIRC+", "CIRC-", "LH"]:
|
||||
return (20,360)
|
||||
if md in ["LV"]:
|
||||
return (200,360)
|
||||
if md in ["LV low E"]:
|
||||
return (40,120)
|
||||
if md in ["LHQ"]:
|
||||
return (20,200)
|
||||
if md in ["OFF"]:
|
||||
return (20,50)
|
||||
elif gr.startswith("G2"):
|
||||
if md in ["CIRC+", "CIRC-", "LH"]:
|
||||
return (80,800)
|
||||
if md in ["LV"]:
|
||||
return (200,800)
|
||||
if md in ["LV low E"]:
|
||||
return (80,120)
|
||||
if md in ["LHQ"]:
|
||||
return (80,200)
|
||||
elif gr.startswith("NIM"):
|
||||
if md in ["CIRC+", "CIRC-"]:
|
||||
return (20,30)
|
||||
if md in ["LH", "LHQ"]:
|
||||
return (10,30)
|
||||
return None
|
||||
|
||||
|
||||
#scienta.getDataArray().setMonitored(True)
|
||||
class Cff(PositionerBase):
|
||||
def __init__(self, name, config):
|
||||
ControlledVariableBase.__init__(self, name, pgm_cff.config)
|
||||
self.setReadback(pgm_cff.getReadback())
|
||||
|
||||
def doRead(self):
|
||||
return pgm_cff.read()
|
||||
|
||||
def doWrite(self, val):
|
||||
if not pgm_cff.isInPosition(val):
|
||||
change_photon_pars(_cff=val)
|
||||
|
||||
def getMinValue(self):
|
||||
return pgm_cff.getMinValue()
|
||||
|
||||
def getMaxValue(self):
|
||||
return pgm_cff.getMaxValue()
|
||||
|
||||
add_device(Cff("cff", None), True)
|
||||
|
||||
class FeSettlingCondition(SettlingCondition):
|
||||
def doWait(self):
|
||||
time.sleep(0.5)
|
||||
cawait("X09LA-FE-SV1:TR1.DMOV", 1)
|
||||
cawait("X09LA-FE-SV1:TR2.DMOV", 1)
|
||||
cawait("X09LA-FE-SH1:TR1.DMOV", 1)
|
||||
cawait("X09LA-FE-SH1:TR2.DMOV", 1)
|
||||
|
||||
class IdSettlingCondition(SettlingCondition):
|
||||
def doWait(self):
|
||||
time.sleep(0.5)
|
||||
id_status.waitValue("done", -1)
|
||||
|
||||
class GrSettlingCondition(SettlingCondition):
|
||||
def doWait(self):
|
||||
time.sleep(0.5)
|
||||
cawait("X09LA:m4.DMOV", 1)
|
||||
|
||||
class CffSettlingCondition(SettlingCondition):
|
||||
def doWait(self):
|
||||
caput("X09LA-PGM:setE.PROC",1)
|
||||
time.sleep(0.5)
|
||||
cawait("X09LA:m1.DMOV", 1)
|
||||
cawait("X09LA:m2.DMOV", 1)
|
||||
|
||||
|
||||
#fe_state.getSetpoint().setBlockingWrite(True)
|
||||
fe_state.setSettlingCondition(FeSettlingCondition())
|
||||
oper_mode.getSetpoint().setBlockingWrite(True)
|
||||
photon_energy.setSettlingCondition(IdSettlingCondition())
|
||||
id_mode.setSettlingCondition(IdSettlingCondition())
|
||||
grating.setSettlingCondition(GrSettlingCondition())
|
||||
pgm_cff.setSettlingCondition(CffSettlingCondition())
|
||||
|
||||
|
||||
def change_photon_pars(_photon_energy=None, _id_mode=None, _grating=None, _cff=None):
|
||||
if (_photon_energy is not None) and (photon_energy.isInPosition(_photon_energy)):
|
||||
_photon_energy = None
|
||||
if _id_mode == id_mode.read():
|
||||
_id_mode=None
|
||||
if _grating == grating.read():
|
||||
_grating=None
|
||||
if _cff == pgm_cff.read():
|
||||
_cff=None
|
||||
if _photon_energy == _id_mode == _grating == _cff == None:
|
||||
return
|
||||
log("Changing photon parameters: photon_energy=" + str(_photon_energy) + " id_mode=" + str(_id_mode) + " grating=" + str(_grating) + " cff=" + str(_cff))
|
||||
|
||||
initial_fe_state = fe_state.read()
|
||||
initial_oper_mode = oper_mode.read()
|
||||
initial_v = fe_vert_width.read();
|
||||
initial_h = fe_horiz_width.read()
|
||||
|
||||
try:
|
||||
#Set front end to “Closed” state
|
||||
fe_state.move("Closed")
|
||||
|
||||
#Set operation mode to “PGM”
|
||||
oper_mode.move("PGM")
|
||||
|
||||
|
||||
if _id_mode is not None:
|
||||
#Set polarization mode
|
||||
print "Setting id_mode="+str(_id_mode)
|
||||
id_mode.move("OFF")
|
||||
id_mode.move(_id_mode)
|
||||
|
||||
if _grating is not None:
|
||||
#Set grating
|
||||
print "Setting grating="+str(_grating)
|
||||
grating.move(_grating)
|
||||
|
||||
if _photon_energy is not None:
|
||||
#Set insertion device energy
|
||||
print "Setting photon_energy="+str(_photon_energy)
|
||||
photon_energy.move(_photon_energy)
|
||||
|
||||
if _cff is not None:
|
||||
#Set cff
|
||||
print "Setting cff="+str(_cff)
|
||||
pgm_cff.move(_cff)
|
||||
|
||||
finally:
|
||||
#Return operation mode to original value (e.g. “PGM+ID”)
|
||||
oper_mode.move(initial_oper_mode)
|
||||
|
||||
#Return front end to original state (e.g. “2x2”)
|
||||
fe_state.move(initial_fe_state)
|
||||
#IF (initial_h, initial_v) does not correspond to a predefined setting
|
||||
if (initial_h!=initial_v) or \
|
||||
not initial_h in [-15.0,0.0,0.25,0.5,1.0,1.5,2.0]:
|
||||
fe_vert_width.write(initial_v);
|
||||
fe_horiz_width.write(initial_h);
|
||||
fe_settling_condition.waitSettled()
|
||||
|
||||
class AcquisitionMode(Readable.ReadableString):
|
||||
def read(self):
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"PASSES" : 1,
|
||||
"STOP" : [ 50.0 ],
|
||||
"DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ],
|
||||
"PRE_ACTIONS" : {
|
||||
"id_mode" : "CIRC+",
|
||||
"grating" : "G2 1200"
|
||||
},
|
||||
"COMPRESSION" : true,
|
||||
"SENSORS" : [ "scienta.dataMatrix" ],
|
||||
"ZIGZAG" : false,
|
||||
"SETTLING_TIME" : 0.0,
|
||||
"MONITORS" : [ "current" ],
|
||||
"START" : [ 21.0 ],
|
||||
"RANGE" : [ null, null, null, null ],
|
||||
"POSITIONERS" : [ "energy" ],
|
||||
"STEPS" : [ 9 ],
|
||||
"SNAPS" : [ "acmi", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "photon_energy", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ]
|
||||
}
|
||||
@@ -41,6 +41,16 @@ passes = int(PASSES)
|
||||
zigzag = bool(ZIGZAG)
|
||||
|
||||
|
||||
#Change photon parameters
|
||||
_id_mode=_grating=None
|
||||
if "id_mode" in PRE_ACTIONS.keys():
|
||||
_id_mode=PRE_ACTIONS.pop("id_mode")
|
||||
if "grating" in PRE_ACTIONS.keys():
|
||||
_grating=PRE_ACTIONS.pop("grating")
|
||||
if (_id_mode is not None) or (_grating is not None):
|
||||
print _id_mode, _grating
|
||||
change_photon_pars(_id_mode=_id_mode, _grating=_grating)
|
||||
1/0
|
||||
#Execute pre-actions
|
||||
for key in PRE_ACTIONS.keys():
|
||||
if key=="eval":
|
||||
@@ -78,5 +88,6 @@ try:
|
||||
snaps=SNAPS, diags=DIAGS, monitors=MONITORS)
|
||||
finally:
|
||||
scienta.zeroSupplies()
|
||||
pass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user