00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2002 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 __facility__ = "Online" 00011 __abstract__ = "GLAST LAT Finite State Machine class for Online Run Control" 00012 __author__ = "R. Claus <Claus@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online" 00013 __date__ = "11/13/2002" 00014 __version__ = "$Revision: 2.2 $" 00015 __credits__ = "SLAC" 00016 00017 import LATTE.copyright_SLAC 00018 00019 import logging as log 00020 from FSM import FSM 00021 00022 00023 class RunControlFSM(FSM): 00024 def __init__(self, app): 00025 FSM.__init__(self, 'RESET', None) 00026 self.set_default_transition( self.error, None ) 00027 self.add_transition ('SETUP', 'RESET', self.setup, 'STOPPED') 00028 self.add_transition ('TEARDOWN', 'STOPPED', self.teardown,'RESET' ) 00029 self.add_transition ('START_RUN', 'STOPPED', self.startRun,'RUNNING') 00030 self.add_transition ('STOP_RUN', 'RUNNING', self.stopRun, 'STOPPED') 00031 self.add_transition ('PAUSE', 'RUNNING', self.pause, 'PAUSED' ) 00032 self.add_transition ('RESUME', 'PAUSED', self.resume, 'RUNNING') 00033 self.add_transition ('STOP', 'PAUSED', self.stop, 'STOPPED') 00034 self.__app = app 00035 00036 00037 def error(self): 00038 log.error(self.__class__.__name__ + "Undefined transition: (%s, %s)" % \ 00039 (str(self.input_symbol), str(self.current_state))) 00040 00041 def setup(self): 00042 return self.__app.rcSetup() 00043 00044 def teardown(self): 00045 return self.__app.rcTeardown() 00046 00047 def startRun(self): 00048 return self.__app.rcStartRun() 00049 00050 def stopRun(self): 00051 return self.__app.rcStopRun() 00052 00053 def pause(self): 00054 return self.__app.rcPause() 00055 00056 def resume(self): 00057 return self.__app.rcResume() 00058 00059 def stop(self): 00060 return self.__app.rcStop()