diff --git a/script/scan_guard.py b/script/scan_guard.py index 6893dbb6..3302df80 100644 --- a/script/scan_guard.py +++ b/script/scan_guard.py @@ -684,6 +684,8 @@ class GlobalFlag(ControlledDevice): def __init__(self): ControlledDevice.__init__(self,"Global Flag") + global beam_ok + beam_ok = True def pause(self): """ @@ -862,6 +864,7 @@ class ScanGuard(object): logging.warning("beam down") self.pause() time.sleep(1.0) + def check_beam(self): beam_ok = self.beam_ok if self.test: @@ -898,28 +901,25 @@ class ScanGuard(object): device.resume() -##### main frame ##### +##### main ##### -def main(args): - nll = getattr(logging, args.loglevel.upper(), None) +def main(): + nll = logging.INFO logging.basicConfig(format="%(asctime)s %(levelname)s: %(message)s", level=nll) logging.info("PEARL Scan Guard") - logging.info("version 1.1.1") + logging.info("version 1.1.2") guard = ScanGuard() - guard.ringcurrent_trip_lo = args.riculo - logging.debug(guard.ringcurrent_trip_lo) - if args.ricuhi >= args.riculo: - guard.ringcurrent_dead_band = 1 #args.ricuhi - guard.ringcurrent_trip_lo - else: - raise ValueError("invalid ring current trip arguments") - logging.debug(guard.ringcurrent_trip_hi) - guard.controls_active = args.controls_active - logging.debug(guard.controls_active) - guard.unattended_only = not args.attended - logging.debug(guard.unattended_only) - guard.test = args.test - logging.debug(guard.test) + guard.ringcurrent_trip_lo = 390.0 + guard.ringcurrent_trip_hi = 410.0 + guard.ringcurrent_dead_band = 1.0 + # True = offline mode is interpreted as beam down + guard.unattended_only = True + # True = block acquisition while beam is down, False = do not block (e.g. for He lamp measurements) + guard.controls_active = True + # True = simulate beam down after a few seconds, False = normal operation + guard.test = False + guard.connect() try: pass @@ -929,58 +929,8 @@ def main(args): except: print sys.exc_info()[1] - -def test(): - """ - ad-hoc test function - """ - logging.basicConfig(format="%(asctime)s %(levelname)s: %(message)s", level=logging.DEBUG) - sh = StationShutter("X03DA-OP-ST1:") - sh.connect() - sh.ShutterRbv.pend_io() - sh.set_monitors() - return sh - - -def operate(): - """ - execute the scan guard in normal operation - - this is the normal entry point of a stable version in normal operation. - the function parameters should be stable. - do not modify the parameters for tests, use the test() function instead. - """ - args.controls_active = True - args.loglevel = logging.INFO - main(args) - -##### command line ##### - -import argparse - #This is to dispose created channels - otherwise, if channel is off, old channels remain and CPU consumption goes 100%. import _ca _ca.initialize() -if True: #__name__ == '__main__': - parser = argparse.ArgumentParser( - description="Pause the measurements (scan records, Scienta detector) for beam loss") - parser.add_argument("-o", "--ring-current-lo", type=float, default=390, dest="riculo", - help="beam loss is triggered if ring current (mA) falls below this level") - parser.add_argument("-i", "--ring-current-hi", type=float, default=400, dest="ricuhi", - help="beam is restored if ring current (mA) rises above this level") - parser.add_argument("-a", "--attended", action="store_true", dest="attended", - help="guard beam during attended operation (default: unattended only)") - parser.add_argument("-p", "--passive", action="store_false", dest="controls_active", - help="check beam conditions but do not send out commands") - parser.add_argument("-t", "--test", action="store_true", dest="test", - help="test controls (simulate beam loss after 15 seconds)") - parser.add_argument("-l", "--loglevel", dest="loglevel", default="INFO", - choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]) - args = parser.parse_args() - #args.loglevel = "DEBUG" - - args.attended = False - main(args) - - +main()