This commit is contained in:
gac-x11ma
2020-12-15 15:20:00 +01:00
parent caccd1e648
commit b707f89f2b
9 changed files with 277 additions and 210 deletions
+54 -19
View File
@@ -1,27 +1,59 @@
POL_IDS={ "Circ_Plus": 1, "Circ_Minus": 2, "Lin_Hor":3, "Lin_Ver": 4, "Lin": 5}
channel_id1_status=Channel("X11MA-ID1-USER:STATUS", 'i', monitored=True)
channel_id2_status=Channel("X11MA-ID2-USER:STATUS", 'i', monitored=True)
channel_id1_error=Channel("X11MA-ID1-USER:ERROR-SOURCE", 'i', monitored=True)
channel_id2_error=Channel("X11MA-ID2-USER:ERROR-SOURCE", 'i', monitored=True)
channel_id1_control=Channel("X11MA-ID1-GAP:SCTRL", 'i', monitored=True)
channel_id2_control=Channel("X11MA-ID2-GAP:SCTRL", 'i', monitored=True)
channel_ring_status=Channel("ACOAU-ACCU:OP-MODE", 'i', monitored=True)
def get_id_status(id):
# 0 = ok
# 1 = Warning
# 2 = Error
# 3 = Not available
if id<1 or id>2: raise Exception("Invalid id")
return caget("X11MA-ID1-USER:STATUS" if (id==1) else "X11MA-ID2-USER:STATUS")
def get_id_error(id):
# B0 (1) = PLC (Taper, Motor controller, Limitswitch....)
# B1 (2) = Encoders (cabel, not referenced)
# B2 (4) = FeedForward (PS off, PS defect, FF ausgeschaltet)
# B3 (8) = Operator COntrol
# B4 (16)= Moving Timeout (moving longer then 120 sec)
# B5 (32)= Interlock (Orbit, Temperature...)\
if id<1 or id>2:
raise Exception("Invalid id")
return caget("X11MA-ID1-USER:ERROR-SOURCE" if (id==1) else "X11MA-ID2-USER:ERROR-SOURCE")
return channel_id1_status.get() if (id==1) else channel_id2_status.get()
def get_id_error(id):
# B0 (1) = PLC (Taper, Motor controller, Limitswitch....)
# B1 (2) = Encoders (cabel, not referenced)
# B2 (4) = FeedForward (PS off, PS defect, FF ausgeschaltet)
# B3 (8) = Operator COntrol
# B4 (16)= Moving Timeout (moving longer then 120 sec)
# B5 (32)= Interlock (Orbit, Temperature...)\
if id<1 or id>2:
raise Exception("Invalid id")
return channel_id1_error.get() if (id==1)else channel_id2_error.get()
def get_id_control(id):
#0 = SLS control, 1 = experiment
if id<1 or id>2: raise Exception("Invalid id")
return channel_id1_control.get() if (id==1) else channel_id2_control.get()
def get_ring_status():
#ACOAU-ACCU:OP-MODE kann Werte zwischen 0 und 5 annehmen:
# rule from 24.8.04
#If (PCT beam current <0.09) -> State 0: "Machine Down"
#Else If (GUN Trigger OFF) -> State 1: "Inj. Stopped"
#Else If (INJ_MODE == Normal) -> State 2: "Accumulating."
#Else If !(reached Top-Up Current) -> State 3: "Accumulating"
#Else If (OP-READY == Wait) -> State 4: "Top-up ready"
#Else If (OFB off) -> State 5: "Light-Available" (former State 4)
#Else -> State 6: "Light Available" (former State 5)
return channel_ring_status.get()
def get_pol_as_string(pol):
for (k,v) in POL_IDS.items():
if v==pol:
return k
return "Unknown"
def get_id_pol(id, as_string=False):
@@ -49,10 +81,7 @@ def get_id_pol(id, as_string=False):
else:
ret = -1
if as_string:
for (k,v) in POL_IDS.items():
if v==ret:
return k
return "Unknown"
return get_pol_as_string(ret)
return ret
def get_alpha_id(id):
@@ -84,6 +113,9 @@ def put_id_pol(id, pol, alpha=None):
if id<1 or id>2:
raise Exception("Invalid id")
if get_dry_run():
return
mode_dev = id1_mode if (id==1) else id2_mode
alpha_dev = id1_alpha if (id==1) else id2_alpha
@@ -114,6 +146,9 @@ def put_id_pol(id, pol, alpha=None):
def tune_detune(active_id):
if get_dry_run():
return
offset_1 = float(get_setting("OFFSET_ID_1"))
offset_2 = float(get_setting("OFFSET_ID_2"))
@@ -196,6 +231,8 @@ def init_pol_switch(switching_type, sid = None, pol_id1=None, pol_id2=None):
else:
if _switching_id == "ID1_ID2":
put_id_pol(2, _switching_current_pol) #Force both IDs to same polarization
if get_dry_run():
return
wait_channel("X11PHS:alldone", 1)
@@ -216,10 +253,8 @@ def nextpol():
def switch_pol():
global _switching_type, _switching_active_id, _switching_current_pol, _switching_pol_id1, _switching_pol_id2, _switching_id
if DRY_RUN:
return
newpol=nextpol()
print "Switch pol: ", newpol
print "Switch pol: ", get_pol_as_string(newpol)
if _switching_id == "ID1":
put_id_pol(1,newpol)
elif _switching_id == "ID2":