This commit is contained in:
+51
-96
@@ -246,62 +246,24 @@ for dev in ["eiger", "id", "chopper", "LEEM2000", "diag"]:
|
||||
|
||||
|
||||
###################################################################################################
|
||||
#ID and Machine status
|
||||
#Beamline and Machine status
|
||||
###################################################################################################
|
||||
|
||||
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")
|
||||
|
||||
|
||||
def get_id_control(id):
|
||||
#0 = SLS control, 1 = experiment
|
||||
if id<1 or id>2: raise Exception("Invalid id")
|
||||
return caget("X11MA-ID1-GAP:SCTRL" if id==1 else "X11MA-ID2-GAP:SCTRL")
|
||||
|
||||
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 caget("ACOAU-ACCU:OP-MODE", 'i')
|
||||
|
||||
|
||||
|
||||
|
||||
def assert_machine_ok(wait = True):
|
||||
print "Checking machine..."
|
||||
ID1status=get_id_control(1)
|
||||
ID2status=get_id_control(2)
|
||||
Ringstatus=get_ring_status()
|
||||
|
||||
oldRingstatus=Ringstatus
|
||||
if get_dry_run():
|
||||
return
|
||||
|
||||
ring_status=get_ring_status()
|
||||
old_ring_status=ring_status
|
||||
checkRing=0
|
||||
|
||||
if Ringstatus==5:
|
||||
if ring_status==5:
|
||||
log ("FB off")
|
||||
#checkRing=1
|
||||
if Ringstatus==0:
|
||||
if ring_status==0:
|
||||
log ("Machine down")
|
||||
checkRing=2
|
||||
|
||||
@@ -309,83 +271,76 @@ def assert_machine_ok(wait = True):
|
||||
status=False
|
||||
|
||||
while not status:
|
||||
ID1status=get_id_control(1)
|
||||
ID2status=get_id_control(2)
|
||||
Ringstatus=get_ring_status()
|
||||
if oldRingstatus != Ringstatus:
|
||||
if Ringstatus == 0:
|
||||
id1_status=get_id_control(1)
|
||||
id2_status=get_id_control(2)
|
||||
ring_status=get_ring_status()
|
||||
if old_ring_status != ring_status:
|
||||
if ring_status == 0:
|
||||
log("Machine down")
|
||||
checkRing=2
|
||||
oldRingstatus=Ringstatus
|
||||
elif Ringstatus == 1:
|
||||
elif ring_status == 1:
|
||||
log("Inj. Stopped")
|
||||
checkRing=2
|
||||
oldRingstatus=Ringstatus
|
||||
elif Ringstatus == 2:
|
||||
elif ring_status == 2:
|
||||
log("Accumulating.")
|
||||
checkRing=2
|
||||
oldRingstatus=Ringstatus
|
||||
elif Ringstatus == 3:
|
||||
elif ring_status == 3:
|
||||
log("Accumulating")
|
||||
checkRing=2
|
||||
oldRingstatus=Ringstatus
|
||||
elif Ringstatus == 4:
|
||||
elif ring_status == 4:
|
||||
log("Top-up ready, Gap still open")
|
||||
checkRing=2
|
||||
oldRingstatus=Ringstatus
|
||||
elif Ringstatus == 5:
|
||||
elif ring_status == 5:
|
||||
log("Light-Available, no OFB")
|
||||
checkRing=2
|
||||
oldRingstatus=Ringstatus
|
||||
elif Ringstatus == 6:
|
||||
elif ring_status == 6:
|
||||
log("Light Available")
|
||||
checkRing=2
|
||||
oldRingstatus=Ringstatus
|
||||
status= (Ringstatus ==6) and (ID1status==1) and (ID2status==1)
|
||||
old_ring_status=ring_status
|
||||
status= (ring_status ==6) and (id1_status==1) and (id2_status==1)
|
||||
if not wait:
|
||||
raise Exception ("Ring error: " + str(Ringstatus))
|
||||
raise Exception ("Ring error: " + str(ring_status))
|
||||
time.sleep(1)
|
||||
if checkRing==2:
|
||||
log("wait 120 s")
|
||||
time.sleep(120)
|
||||
log("continue")
|
||||
elif checkRing==2:
|
||||
log("wait 10 s")
|
||||
time.sleep(10)
|
||||
log("continue")
|
||||
print "Machine ok"
|
||||
|
||||
|
||||
def assert_bemline_ok():
|
||||
def assert_beamline_ok():
|
||||
print "Checking beamline..."
|
||||
if get_dry_run():
|
||||
return
|
||||
|
||||
checkbeamline=0
|
||||
message=[ "PLC error","Encoder error", "Feedforward error","Operator control", "Moving timeout", "Interlock"]
|
||||
|
||||
ID = get_setting("ID")
|
||||
if ID == "ID1":
|
||||
ID1status=get_id_status(1)
|
||||
ID2status=0
|
||||
id1_status=get_id_status(1)
|
||||
id2_status=0
|
||||
elif ID == "ID2":
|
||||
ID1status=0
|
||||
ID2status=get_id_status(2)
|
||||
id1_status=0
|
||||
id2_status=get_id_status(2)
|
||||
if ID == "ID1_ID2":
|
||||
ID1status=get_id_status(1)
|
||||
ID2status=get_id_status(2)
|
||||
if ID1status >= 1:
|
||||
ID1error=get_id_error(1)
|
||||
id1_status=get_id_status(1)
|
||||
id2_status=get_id_status(2)
|
||||
if id1_status >= 1:
|
||||
id1_error=get_id_error(1)
|
||||
for bit in range (5,-1, -1):
|
||||
if ID1error & (2**bit):
|
||||
if id1_error & (2**bit):
|
||||
log ("ID1 "+ str(message[bit]))
|
||||
ID1error=ID1error-(2**bit)
|
||||
if ID2status >= 1:
|
||||
ID2error=get_id_error(2)
|
||||
id1_error=id1_error-(2**bit)
|
||||
if id2_status >= 1:
|
||||
id2_error=get_id_error(2)
|
||||
for bit in range (5,-1, -1):
|
||||
if ID2error & (2**bit):
|
||||
if id2_error & (2**bit):
|
||||
log ("ID2 "+ str(message[bit]))
|
||||
ID2error=ID2error-(2**bit)
|
||||
if ID1status >= 1:
|
||||
raise Exception("ID1 error")
|
||||
if ID2status >= 1:
|
||||
raise Exception("ID2 error")
|
||||
id2_error=id2_error-(2**bit)
|
||||
if id1_status >= 1:
|
||||
raise Exception("ID1 error: " + str(id1_status))
|
||||
if id2_status >= 1:
|
||||
raise Exception("ID2 error: "+ str(id2_status))
|
||||
|
||||
def assert_status_ok(wait = True):
|
||||
assert_machine_ok(wait)
|
||||
assert_beamline_ok()
|
||||
|
||||
###################################################################################################
|
||||
#Manual log file
|
||||
@@ -438,7 +393,7 @@ def change_energy(v):
|
||||
if v<91 or v>2500:
|
||||
raise Exception ("Invalid energy: " + str(v))
|
||||
print "Setting energy: " + str(v)
|
||||
if DRY_RUN:
|
||||
if get_dry_run():
|
||||
return
|
||||
put_energy(v)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user