BondSM_sm.py
Go to the documentation of this file.
00001 # ex: set ro:
00002 # DO NOT EDIT.
00003 # generated by smc (http://smc.sourceforge.net/)
00004 # from file : BondSM_sm.sm
00005 
00006 from smclib import statemap
00007 
00008 
00009 class BondSMState(statemap.State):
00010 
00011     def Entry(self, fsm):
00012         pass
00013 
00014     def Exit(self, fsm):
00015         pass
00016 
00017     def ConnectTimeout(self, fsm):
00018         self.Default(fsm)
00019 
00020     def Die(self, fsm):
00021         self.Default(fsm)
00022 
00023     def DisconnectTimeout(self, fsm):
00024         self.Default(fsm)
00025 
00026     def HeartbeatTimeout(self, fsm):
00027         self.Default(fsm)
00028 
00029     def SisterAlive(self, fsm):
00030         self.Default(fsm)
00031 
00032     def SisterDead(self, fsm):
00033         self.Default(fsm)
00034 
00035     def Default(self, fsm):
00036         msg = "\n\tState: %s\n\tTransition: %s" % (
00037             fsm.getState().getName(), fsm.getTransition())
00038         raise statemap.TransitionUndefinedException(msg)
00039 
00040 
00041 class SM_Default(BondSMState):
00042     pass
00043 
00044 
00045 class SM_WaitingForSister(SM_Default):
00046 
00047     def ConnectTimeout(self, fsm):
00048         ctxt = fsm.getOwner()
00049         fsm.getState().Exit(fsm)
00050         fsm.clearState()
00051         try:
00052             ctxt.Death()
00053         finally:
00054             fsm.setState(SM.Dead)
00055             fsm.getState().Entry(fsm)
00056 
00057     def Die(self, fsm):
00058         ctxt = fsm.getOwner()
00059         fsm.getState().Exit(fsm)
00060         fsm.clearState()
00061         try:
00062             ctxt.Death()
00063         finally:
00064             fsm.setState(SM.Dead)
00065             fsm.getState().Entry(fsm)
00066 
00067     def SisterAlive(self, fsm):
00068         ctxt = fsm.getOwner()
00069         fsm.getState().Exit(fsm)
00070         fsm.clearState()
00071         try:
00072             ctxt.Connected()
00073         finally:
00074             fsm.setState(SM.Alive)
00075             fsm.getState().Entry(fsm)
00076 
00077 
00078 class SM_Alive(SM_Default):
00079 
00080     def Die(self, fsm):
00081         ctxt = fsm.getOwner()
00082         fsm.getState().Exit(fsm)
00083         fsm.clearState()
00084         try:
00085             ctxt.StartDying()
00086         finally:
00087             fsm.setState(SM.AwaitSisterDeath)
00088             fsm.getState().Entry(fsm)
00089 
00090     def HeartbeatTimeout(self, fsm):
00091         ctxt = fsm.getOwner()
00092         fsm.getState().Exit(fsm)
00093         fsm.clearState()
00094         try:
00095             ctxt.Death()
00096         finally:
00097             fsm.setState(SM.Dead)
00098             fsm.getState().Entry(fsm)
00099 
00100     def SisterAlive(self, fsm):
00101         ctxt = fsm.getOwner()
00102         fsm.getState().Exit(fsm)
00103         fsm.clearState()
00104         try:
00105             ctxt.Heartbeat()
00106         finally:
00107             fsm.setState(SM.Alive)
00108             fsm.getState().Entry(fsm)
00109 
00110     def SisterDead(self, fsm):
00111         ctxt = fsm.getOwner()
00112         fsm.getState().Exit(fsm)
00113         fsm.clearState()
00114         try:
00115             ctxt.SisterDied()
00116             ctxt.Death()
00117         finally:
00118             fsm.setState(SM.Dead)
00119             fsm.getState().Entry(fsm)
00120 
00121 
00122 class SM_AwaitSisterDeath(SM_Default):
00123 
00124     def DisconnectTimeout(self, fsm):
00125         ctxt = fsm.getOwner()
00126         fsm.getState().Exit(fsm)
00127         fsm.clearState()
00128         try:
00129             ctxt.Death()
00130         finally:
00131             fsm.setState(SM.Dead)
00132             fsm.getState().Entry(fsm)
00133 
00134     def HeartbeatTimeout(self, fsm):
00135         fsm.getState().Exit(fsm)
00136         fsm.setState(SM.AwaitSisterDeath)
00137         fsm.getState().Entry(fsm)
00138 
00139     def SisterAlive(self, fsm):
00140         fsm.getState().Exit(fsm)
00141         fsm.setState(SM.AwaitSisterDeath)
00142         fsm.getState().Entry(fsm)
00143 
00144     def SisterDead(self, fsm):
00145         ctxt = fsm.getOwner()
00146         fsm.getState().Exit(fsm)
00147         fsm.clearState()
00148         try:
00149             ctxt.Death()
00150         finally:
00151             fsm.setState(SM.Dead)
00152             fsm.getState().Entry(fsm)
00153 
00154 
00155 class SM_Dead(SM_Default):
00156 
00157     def ConnectTimeout(self, fsm):
00158         fsm.getState().Exit(fsm)
00159         fsm.setState(SM.Dead)
00160         fsm.getState().Entry(fsm)
00161 
00162     def Die(self, fsm):
00163         fsm.getState().Exit(fsm)
00164         fsm.setState(SM.Dead)
00165         fsm.getState().Entry(fsm)
00166 
00167     def DisconnectTimeout(self, fsm):
00168         fsm.getState().Exit(fsm)
00169         fsm.setState(SM.Dead)
00170         fsm.getState().Entry(fsm)
00171 
00172     def HeartbeatTimeout(self, fsm):
00173         fsm.getState().Exit(fsm)
00174         fsm.setState(SM.Dead)
00175         fsm.getState().Entry(fsm)
00176 
00177     def SisterDead(self, fsm):
00178         fsm.getState().Exit(fsm)
00179         fsm.setState(SM.Dead)
00180         fsm.getState().Entry(fsm)
00181 
00182 
00183 class SM(object):
00184 
00185     WaitingForSister = SM_WaitingForSister('SM.WaitingForSister', 0)
00186     Alive = SM_Alive('SM.Alive', 1)
00187     AwaitSisterDeath = SM_AwaitSisterDeath('SM.AwaitSisterDeath', 2)
00188     Dead = SM_Dead('SM.Dead', 3)
00189     Default = SM_Default('SM.Default', -1)
00190 
00191 
00192 class BondSM_sm(statemap.FSMContext):
00193 
00194     def __init__(self, owner):
00195         statemap.FSMContext.__init__(self, SM.WaitingForSister)
00196         self._owner = owner
00197 
00198     def __getattr__(self, attrib):
00199         def trans_sm(*arglist):
00200             self._transition = attrib
00201             getattr(self.getState(), attrib)(self, *arglist)
00202             self._transition = None
00203         return trans_sm
00204 
00205     def enterStartState(self):
00206         self._state.Entry(self)
00207 
00208     def getOwner(self):
00209         return self._owner
00210 
00211 # Local variables:
00212 #  buffer-read-only: t
00213 # End:


test_bond
Author(s): Stuart Glaser
autogenerated on Thu Jun 6 2019 20:40:42