#PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "testRegionFinalStates_6Python.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() Final = auto() s2 = auto() s3 = auto() class StatusS1S11(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s11 = auto() fState1 = auto() class StatusS1S11S11(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s111 = auto() class StatusS1S11S11S111(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s111 = auto() class StatusS1S12(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s12 = auto() class StatusS1S12S12(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s122 = auto() fState2 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._statusS1S12S12 = None self._statusS1S12 = None self._statusS1S11S11S111 = None self._statusS1S11S11 = None self._statusS1S11 = None self._status = None self.setStatusS1S11(X.StatusS1S11.Null) self.setStatusS1S11S11(X.StatusS1S11S11.Null) self.setStatusS1S11S11S111(X.StatusS1S11S11S111.Null) self.setStatusS1S12(X.StatusS1S12.Null) self.setStatusS1S12S12(X.StatusS1S12S12.Null) self.setStatus(X.Status.s1) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() if self._statusS1S11 != X.StatusS1S11.Null : answer += "." + self._statusS1S11.__str__() if self._statusS1S11S11 != X.StatusS1S11S11.Null : answer += "." + self._statusS1S11S11.__str__() if self._statusS1S11S11S111 != X.StatusS1S11S11S111.Null : answer += "." + self._statusS1S11S11S111.__str__() if self._statusS1S12 != X.StatusS1S12.Null : answer += "." + self._statusS1S12.__str__() if self._statusS1S12S12 != X.StatusS1S12S12.Null : answer += "." + self._statusS1S12S12.__str__() if self._statusS1S11S11S111 != X.StatusS1S11S11S111.Null : answer += "." + self._statusS1S11S11S111.__str__() return answer def getStatus(self): return self._status def getStatusS1S11(self): return self._statusS1S11 def getStatusS1S11S11(self): return self._statusS1S11S11 def getStatusS1S11S11S111(self): return self._statusS1S11S11S111 def getStatusS1S12(self): return self._statusS1S12 def getStatusS1S12S12(self): return self._statusS1S12S12 def e2(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.s1 : self.exitStatus() self.setStatus(X.Status.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e4(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.s2 : self.setStatus(X.Status.Final) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e3(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.s2 : self.setStatus(X.Status.s3) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e(self): wasEventProcessed = False aStatusS1S11S11S111 = self._statusS1S11S11S111 if aStatusS1S11S11S111 == X.StatusS1S11S11.s111 : self.exitStatus() self.setStatus(X.Status.Final) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def d1(self): wasEventProcessed = False aStatusS1S11S11S111 = self._statusS1S11S11S111 if aStatusS1S11S11S111 == X.StatusS1S11S11.s111 : self.exitStatusS1S11() self.setStatusS1S11(X.StatusS1S11.fState1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def d2(self): wasEventProcessed = False aStatusS1S12S12 = self._statusS1S12S12 if aStatusS1S12S12 == X.StatusS1S12S12.s122 : self.exitStatusS1S12S12() self.setStatusS1S12S12(X.StatusS1S12S12.fState2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitStatus(self): if self._status == X.Status.s1 : self.exitStatusS1S11() self.exitStatusS1S12() # line 4 "testRegionFinalStates_6Python.ump" print("t4") def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == X.Status.s1 : if self._statusS1S11 == X.StatusS1S11.Null : self.setStatusS1S11(X.StatusS1S11.s11) if self._statusS1S12 == X.StatusS1S12.Null : self.setStatusS1S12(X.StatusS1S12.s12) elif self._status == X.Status.Final : self.delete() elif self._status == X.Status.s3 : self.delete() def exitStatusS1S11(self): if self._statusS1S11 == X.StatusS1S11.s11 : self.exitStatusS1S11S11() # line 7 "testRegionFinalStates_6Python.ump" print("t3") self.setStatusS1S11(X.StatusS1S11.Null) elif self._statusS1S11 == X.StatusS1S11.fState1 : self.setStatusS1S11(X.StatusS1S11.Null) def setStatusS1S11(self, aStatusS1S11): self._statusS1S11 = aStatusS1S11 if self._status != X.Status.s1 and aStatusS1S11 != X.StatusS1S11.Null : self.setStatus(X.Status.s1) # entry actions and do activities if self._statusS1S11 == X.StatusS1S11.s11 : if self._statusS1S11S11 == X.StatusS1S11S11.Null : self.setStatusS1S11S11(X.StatusS1S11S11.s111) elif self._statusS1S11 == X.StatusS1S11.fState1 : if self._statusS1S12S12 == X.StatusS1S12S12.fState2 : self.delete() def exitStatusS1S11S11(self): if self._statusS1S11S11 == X.StatusS1S11S11.s111 : self.exitStatusS1S11S11S111() # line 9 "testRegionFinalStates_6Python.ump" print("t2") self.setStatusS1S11S11(X.StatusS1S11S11.Null) def setStatusS1S11S11(self, aStatusS1S11S11): self._statusS1S11S11 = aStatusS1S11S11 if self._statusS1S11 != X.StatusS1S11.s11 and aStatusS1S11S11 != X.StatusS1S11S11.Null : self.setStatusS1S11(X.StatusS1S11.s11) # entry actions and do activities if self._statusS1S11S11 == X.StatusS1S11S11.s111 : if self._statusS1S11S11S111 == X.StatusS1S11S11S111.Null : self.setStatusS1S11S11S111(X.StatusS1S11S11S111.s111) def exitStatusS1S11S11S111(self): if self._statusS1S11S11S111 == X.StatusS1S11S11.s111 : # line 11 "testRegionFinalStates_6Python.ump" print("t1") self.setStatusS1S11S11S111(X.StatusS1S11S11S111.Null) def setStatusS1S11S11S111(self, aStatusS1S11S11S111): self._statusS1S11S11S111 = aStatusS1S11S11S111 if self._statusS1S11S11 != X.StatusS1S11S11.s111 and aStatusS1S11S11S111 != X.StatusS1S11S11S111.Null : self.setStatusS1S11S11(X.StatusS1S11S11.s111) def exitStatusS1S12(self): if self._statusS1S12 == X.StatusS1S12.s12 : self.exitStatusS1S12S12() self.setStatusS1S12(X.StatusS1S12.Null) def setStatusS1S12(self, aStatusS1S12): self._statusS1S12 = aStatusS1S12 if self._status != X.Status.s1 and aStatusS1S12 != X.StatusS1S12.Null : self.setStatus(X.Status.s1) # entry actions and do activities if self._statusS1S12 == X.StatusS1S12.s12 : if self._statusS1S12S12 == X.StatusS1S12S12.Null : self.setStatusS1S12S12(X.StatusS1S12S12.s122) def exitStatusS1S12S12(self): if self._statusS1S12S12 == X.StatusS1S12S12.s122 : self.setStatusS1S12S12(X.StatusS1S12S12.Null) elif self._statusS1S12S12 == X.StatusS1S12S12.fState2 : self.setStatusS1S12S12(X.StatusS1S12S12.Null) def setStatusS1S12S12(self, aStatusS1S12S12): self._statusS1S12S12 = aStatusS1S12S12 if self._statusS1S12 != X.StatusS1S12.s12 and aStatusS1S12S12 != X.StatusS1S12S12.Null : self.setStatusS1S12(X.StatusS1S12.s12) # entry actions and do activities if self._statusS1S12S12 == X.StatusS1S12S12.fState2 : if self._statusS1S11 == X.StatusS1S11.fState1 : self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../testTwoParameterGuardPython.ump" from enum import Enum, auto class A_Guard(): #------------------------ # MEMBER VARIABLES #------------------------ #A_Guard State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) S1 = auto() S2 = auto() S3 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(A_Guard.Status.S1) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def e1(self, myB): wasEventProcessed = False aStatus = self._status if aStatus == A_Guard.Status.S1 : if self.checkGuard1(myB) : self.setStatus(A_Guard.Status.S2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e2(self, myB, mySecondB): wasEventProcessed = False aStatus = self._status if aStatus == A_Guard.Status.S2 : if self.checkGuard1(myB) : self.setStatus(A_Guard.Status.S3) wasEventProcessed = True elif aStatus == A_Guard.Status.S3 : if self.checkGuard2(myB, mySecondB) : self.setStatus(A_Guard.Status.S1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass # line 19 "../testTwoParameterGuardPython.ump" def checkGuard1(self, myB): return True # line 22 "../testTwoParameterGuardPython.ump" def checkGuard2(self, myB, mySecondB): return True #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../doActivityNestedStateMachinePython.ump" from enum import Enum, auto from threading import Thread import time class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() class StatusOpen(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() statusOpen = auto() #Course Do Activity Threads #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._doActivityStatusOpenStatusOpenThread = None self._statusOpen = None self._status = None self.setStatusOpen(Course.StatusOpen.Null) self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() if self._statusOpen != Course.StatusOpen.Null : answer += "." + self._statusOpen.__str__() return answer def getStatus(self): return self._status def getStatusOpen(self): return self._statusOpen def exitStatus(self): if self._status == Course.Status.Open : self.exitStatusOpen() def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == Course.Status.Open : if self._statusOpen == Course.StatusOpen.Null : self.setStatusOpen(Course.StatusOpen.statusOpen) def exitStatusOpen(self): if self._statusOpen == Course.StatusOpen.statusOpen : self.setStatusOpen(Course.StatusOpen.Null) if not (self._doActivityStatusOpenStatusOpenThread is None) : self._doActivityStatusOpenStatusOpenThread.interrupt() def setStatusOpen(self, aStatusOpen): self._statusOpen = aStatusOpen if self._status != Course.Status.Open and aStatusOpen != Course.StatusOpen.Null : self.setStatus(Course.Status.Open) # entry actions and do activities if self._statusOpen == Course.StatusOpen.statusOpen : self._doActivityStatusOpenStatusOpenThread = Course.DoActivityThread(self, "doActivityStatusOpenStatusOpen") def doActivityStatusOpenStatusOpen(self): try: keepGoing() except : pass class DoActivityThread(Thread): def __init__(self, aController, aDoActivityMethodName): self._doActivityMethodName = None self._controller = None self._controller = aController self._doActivityMethodName = aDoActivityMethodName # The equivalent of "start();" for starting a python thread super().__init__() self.start() def run(self): if "doActivityStatusOpenStatusOpen" == self._doActivityMethodName : self._controller.doActivityStatusOpenStatusOpen() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 20 "../doActivityPython.ump" from enum import Enum, auto from threading import Thread import time class Lamp(): #------------------------ # MEMBER VARIABLES #------------------------ #Lamp State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) On = auto() Off = auto() #Lamp Do Activity Threads #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._doActivityStatusOffThread = None self._doActivityStatusOnThread = None self._status = None self.setStatus(Lamp.Status.On) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def press(self): wasEventProcessed = False aStatus = self._status if aStatus == Lamp.Status.On : self.exitStatus() self.setStatus(Lamp.Status.Off) wasEventProcessed = True elif aStatus == Lamp.Status.Off : self.exitStatus() self.setStatus(Lamp.Status.On) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitStatus(self): if self._status == Lamp.Status.On : if not (self._doActivityStatusOnThread is None) : self._doActivityStatusOnThread.interrupt() elif self._status == Lamp.Status.Off : if not (self._doActivityStatusOffThread is None) : self._doActivityStatusOffThread.interrupt() def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == Lamp.Status.On : self._doActivityStatusOnThread = Lamp.DoActivityThread(self, "doActivityStatusOn") elif self._status == Lamp.Status.Off : self._doActivityStatusOffThread = Lamp.DoActivityThread(self, "doActivityStatusOff") def doActivityStatusOn(self): try: alsoDo() except : pass def doActivityStatusOff(self): try: keepDoing() except : pass class DoActivityThread(Thread): def __init__(self, aController, aDoActivityMethodName): self._doActivityMethodName = None self._controller = None self._controller = aController self._doActivityMethodName = aDoActivityMethodName # The equivalent of "start();" for starting a python thread super().__init__() self.start() def run(self): if "doActivityStatusOn" == self._doActivityMethodName : self._controller.doActivityStatusOn() elif "doActivityStatusOff" == self._doActivityMethodName : self._controller.doActivityStatusOff() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "checkExternalTransitions_withExitActions_1Python.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) on = auto() off = auto() class SmOn(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s1 = auto() s2 = auto() class SmOnS1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() m1 = auto() m2 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smOnS1 = None self._smOn = None self._sm = None self.setSmOn(X.SmOn.Null) self.setSmOnS1(X.SmOnS1.Null) self.setSm(X.Sm.on) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smOn != X.SmOn.Null : answer += "." + self._smOn.__str__() if self._smOnS1 != X.SmOnS1.Null : answer += "." + self._smOnS1.__str__() return answer def getSm(self): return self._sm def getSmOn(self): return self._smOn def getSmOnS1(self): return self._smOnS1 def e1(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.on : self.exitSm() self.setSm(X.Sm.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e2(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.on : self.exitSm() self.setSm(X.Sm.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e3(self): wasEventProcessed = False aSmOn = self._smOn if aSmOn == X.SmOn.s1 : self.exitSmOn() self.setSmOn(X.SmOn.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e4(self): wasEventProcessed = False aSmOn = self._smOn if aSmOn == X.SmOn.s1 : self.exitSmOn() self.setSmOn(X.SmOn.s1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e5(self): wasEventProcessed = False aSmOn = self._smOn if aSmOn == X.SmOn.s1 : self.exitSm() self.setSm(X.Sm.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e6(self): wasEventProcessed = False aSmOn = self._smOn if aSmOn == X.SmOn.s1 : self.exitSm() self.setSm(X.Sm.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e7(self): wasEventProcessed = False aSmOnS1 = self._smOnS1 if aSmOnS1 == X.SmOnS1.m1 : self.exitSmOnS1() self.setSmOnS1(X.SmOnS1.m2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e8(self): wasEventProcessed = False aSmOnS1 = self._smOnS1 if aSmOnS1 == X.SmOnS1.m1 : self.exitSmOnS1() self.setSmOnS1(X.SmOnS1.m1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e9(self): wasEventProcessed = False aSmOnS1 = self._smOnS1 if aSmOnS1 == X.SmOnS1.m1 : self.exitSmOn() self.setSmOn(X.SmOn.s1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e10(self): wasEventProcessed = False aSmOnS1 = self._smOnS1 if aSmOnS1 == X.SmOnS1.m1 : self.exitSmOn() self.setSmOn(X.SmOn.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e11(self): wasEventProcessed = False aSmOnS1 = self._smOnS1 if aSmOnS1 == X.SmOnS1.m1 : self.exitSm() self.setSm(X.Sm.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e12(self): wasEventProcessed = False aSmOnS1 = self._smOnS1 if aSmOnS1 == X.SmOnS1.m1 : self.exitSm() self.setSm(X.Sm.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.on : self.exitSmOn() # line 4 "checkExternalTransitions_withExitActions_1Python.ump" self.on_exit_action() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.on : if self._smOn == X.SmOn.Null : self.setSmOn(X.SmOn.s1) def exitSmOn(self): if self._smOn == X.SmOn.s1 : self.exitSmOnS1() # line 8 "checkExternalTransitions_withExitActions_1Python.ump" self.s1_exit_action() self.setSmOn(X.SmOn.Null) elif self._smOn == X.SmOn.s2 : self.setSmOn(X.SmOn.Null) def setSmOn(self, aSmOn): self._smOn = aSmOn if self._sm != X.Sm.on and aSmOn != X.SmOn.Null : self.setSm(X.Sm.on) # entry actions and do activities if self._smOn == X.SmOn.s1 : if self._smOnS1 == X.SmOnS1.Null : self.setSmOnS1(X.SmOnS1.m1) def exitSmOnS1(self): if self._smOnS1 == X.SmOnS1.m1 : # line 14 "checkExternalTransitions_withExitActions_1Python.ump" self.m1_exit_action() self.setSmOnS1(X.SmOnS1.Null) elif self._smOnS1 == X.SmOnS1.m2 : self.setSmOnS1(X.SmOnS1.Null) def setSmOnS1(self, aSmOnS1): self._smOnS1 = aSmOnS1 if self._smOn != X.SmOn.s1 and aSmOnS1 != X.SmOnS1.Null : self.setSmOn(X.SmOn.s1) def delete(self): pass # line 28 "checkExternalTransitions_withExitActions_1Python.ump" def on_exit_action(self): print("exited on") # line 29 "checkExternalTransitions_withExitActions_1Python.ump" def s1_exit_action(self): print("exited s1") # line 30 "checkExternalTransitions_withExitActions_1Python.ump" def m1_exit_action(self): print("exited m1") #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "guardNameBothAttributeAndMethod2Python.ump" from enum import Enum, auto class A(): #------------------------ # MEMBER VARIABLES #------------------------ #A Attributes #A State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self._repeatCheck = None self._repeatCheck = False self.setStatus(A.Status.s1) #------------------------ # INTERFACE #------------------------ def setRepeatCheck(self, aRepeatCheck): wasSet = False self._repeatCheck = aRepeatCheck wasSet = True return wasSet def getRepeatCheck(self): return self._repeatCheck # Code from template attribute_IsBoolean def isRepeatCheck(self): return self._repeatCheck def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def __autotransition1__(self): wasEventProcessed = False aStatus = self._status if aStatus == A.Status.s1 : if self.getRepeatCheck() < self.repeatCheck(z) : self.setStatus(A.Status.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == A.Status.s1 : self.__autotransition1__() def delete(self): pass # line 11 "guardNameBothAttributeAndMethod2Python.ump" def repeatCheck(self): return True def __str__(self): return str(super().__str__()) + "[" + "repeatCheck" + ":" + str(self.getRepeatCheck()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "guardNameBothAttributeAndMethod3Python.ump" from enum import Enum, auto class A(): #------------------------ # MEMBER VARIABLES #------------------------ #A Attributes #A State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self._repeatCheck = None self._repeatCheck = False self.setStatus(A.Status.s1) #------------------------ # INTERFACE #------------------------ def setRepeatCheck(self, aRepeatCheck): wasSet = False self._repeatCheck = aRepeatCheck wasSet = True return wasSet def getRepeatCheck(self): return self._repeatCheck # Code from template attribute_IsBoolean def isRepeatCheck(self): return self._repeatCheck def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def __autotransition1__(self): wasEventProcessed = False aStatus = self._status if aStatus == A.Status.s1 : if self.getRepeatCheck() != self.repeatCheck() : self.setStatus(A.Status.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == A.Status.s1 : self.__autotransition1__() def delete(self): pass # line 11 "guardNameBothAttributeAndMethod3Python.ump" def repeatCheck(self): return True def __str__(self): return str(super().__str__()) + "[" + "repeatCheck" + ":" + str(self.getRepeatCheck()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../doActivityMultiPython.ump" from enum import Enum, auto from threading import Thread import time class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() #X Do Activity Threads #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._doActivity1SmS1Thread = None self._doActivity0SmS1Thread = None self._sm = None self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() return answer def getSm(self): return self._sm def e1(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.s1 : self.exitSm() self.setSm(X.Sm.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : if not (self._doActivity0SmS1Thread is None) : self._doActivity0SmS1Thread.interrupt() if not (self._doActivity1SmS1Thread is None) : self._doActivity1SmS1Thread.interrupt() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : self._doActivity0SmS1Thread = X.DoActivityThread(self, "doActivity0SmS1") self._doActivity1SmS1Thread = X.DoActivityThread(self, "doActivity1SmS1") def doActivity0SmS1(self): try: blah1() except : pass def doActivity1SmS1(self): try: blah2() except : pass class DoActivityThread(Thread): def __init__(self, aController, aDoActivityMethodName): self._doActivityMethodName = None self._controller = None self._controller = aController self._doActivityMethodName = aDoActivityMethodName # The equivalent of "start();" for starting a python thread super().__init__() self.start() def run(self): if "doActivity0SmS1" == self._doActivityMethodName : self._controller.doActivity0SmS1() elif "doActivity1SmS1" == self._doActivityMethodName : self._controller.doActivity1SmS1() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../noDefaultEntryMethodGenerated_2Python.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) on = auto() idle = auto() off = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._sm = None self.setSm(X.Sm.on) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() return answer def getSm(self): return self._sm def turnOff(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.on : self.setSm(X.Sm.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goIdle(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.on : self.setSm(X.Sm.idle) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def buttonPressed(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.idle : self.setSm(X.Sm.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def turnOn(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.off : self.setSm(X.Sm.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setSm(self, aSm): self._sm = aSm def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../doActivityNoTransitionsPython.ump" from enum import Enum, auto from threading import Thread import time class LightFixture(): #------------------------ # MEMBER VARIABLES #------------------------ #LightFixture State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) On = auto() Off = auto() #LightFixture Do Activity Threads #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._doActivityBulbOnThread = None self._bulb = None self.setBulb(LightFixture.Bulb.On) #------------------------ # INTERFACE #------------------------ def getBulbFullName(self): answer = self._bulb.__str__() return answer def getBulb(self): return self._bulb def exitBulb(self): if self._bulb == LightFixture.Bulb.On : if not (self._doActivityBulbOnThread is None) : self._doActivityBulbOnThread.interrupt() def setBulb(self, aBulb): self._bulb = aBulb # entry actions and do activities if self._bulb == LightFixture.Bulb.On : self._doActivityBulbOnThread = LightFixture.DoActivityThread(self, "doActivityBulbOn") def doActivityBulbOn(self): try: doActivity() except : pass class DoActivityThread(Thread): def __init__(self, aController, aDoActivityMethodName): self._doActivityMethodName = None self._controller = None self._controller = aController self._doActivityMethodName = aDoActivityMethodName # The equivalent of "start();" for starting a python thread super().__init__() self.start() def run(self): if "doActivityBulbOn" == self._doActivityMethodName : self._controller.doActivityBulbOn() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../activeObjectPython.ump" from enum import Enum, auto from threading import Thread import time class Lamp(): #------------------------ # MEMBER VARIABLES #------------------------ #Lamp Attributes #Lamp State Machines class StateMachine1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) topLevel = auto() class StateMachine1TopLevel(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() thread1 = auto() class StateMachine2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) topLevel = auto() class StateMachine2TopLevel(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() thread1 = auto() #Lamp Do Activity Threads #------------------------ # CONSTRUCTOR #------------------------ def __init__(self, aLog): self._doActivityStateMachine2TopLevelThread1Thread = None self._doActivityStateMachine1TopLevelThread1Thread = None self._stateMachine2TopLevel = None self._stateMachine2 = None self._stateMachine1TopLevel = None self._stateMachine1 = None self._log = None self._log = aLog self.setStateMachine1TopLevel(Lamp.StateMachine1TopLevel.Null) self.setStateMachine1(Lamp.StateMachine1.topLevel) self.setStateMachine2TopLevel(Lamp.StateMachine2TopLevel.Null) self.setStateMachine2(Lamp.StateMachine2.topLevel) #------------------------ # INTERFACE #------------------------ def setLog(self, aLog): wasSet = False self._log = aLog wasSet = True return wasSet def getLog(self): return self._log def getStateMachine1FullName(self): answer = self._stateMachine1.__str__() if self._stateMachine1TopLevel != Lamp.StateMachine1TopLevel.Null : answer += "." + self._stateMachine1TopLevel.__str__() return answer def getStateMachine2FullName(self): answer = self._stateMachine2.__str__() if self._stateMachine2TopLevel != Lamp.StateMachine2TopLevel.Null : answer += "." + self._stateMachine2TopLevel.__str__() return answer def getStateMachine1(self): return self._stateMachine1 def getStateMachine2(self): return self._stateMachine2 def getStateMachine1TopLevel(self): return self._stateMachine1TopLevel def getStateMachine2TopLevel(self): return self._stateMachine2TopLevel def exitStateMachine1(self): if self._stateMachine1 == Lamp.StateMachine1.topLevel : self.exitStateMachine1TopLevel() def setStateMachine1(self, aStateMachine1): self._stateMachine1 = aStateMachine1 # entry actions and do activities if self._stateMachine1 == Lamp.StateMachine1.topLevel : if self._stateMachine1TopLevel == Lamp.StateMachine1TopLevel.Null : self.setStateMachine1TopLevel(Lamp.StateMachine1TopLevel.thread1) def exitStateMachine2(self): if self._stateMachine2 == Lamp.StateMachine1.topLevel : self.exitStateMachine2TopLevel() def setStateMachine2(self, aStateMachine2): self._stateMachine2 = aStateMachine2 # entry actions and do activities if self._stateMachine2 == Lamp.StateMachine1.topLevel : if self._stateMachine2TopLevel == Lamp.StateMachine2TopLevel.Null : self.setStateMachine2TopLevel(Lamp.StateMachine2TopLevel.thread1) def exitStateMachine1TopLevel(self): if self._stateMachine1TopLevel == Lamp.StateMachine1TopLevel.thread1 : self.setStateMachine1TopLevel(Lamp.StateMachine1TopLevel.Null) if not (self._doActivityStateMachine1TopLevelThread1Thread is None) : self._doActivityStateMachine1TopLevelThread1Thread.interrupt() def setStateMachine1TopLevel(self, aStateMachine1TopLevel): self._stateMachine1TopLevel = aStateMachine1TopLevel if self._stateMachine1 != Lamp.StateMachine1.topLevel and aStateMachine1TopLevel != Lamp.StateMachine1TopLevel.Null : self.setStateMachine1(Lamp.StateMachine1.topLevel) # entry actions and do activities if self._stateMachine1TopLevel == Lamp.StateMachine1TopLevel.thread1 : self._doActivityStateMachine1TopLevelThread1Thread = Lamp.DoActivityThread(self, "doActivityStateMachine1TopLevelThread1") def exitStateMachine2TopLevel(self): if self._stateMachine2TopLevel == Lamp.StateMachine1TopLevel.thread1 : self.setStateMachine2TopLevel(Lamp.StateMachine2TopLevel.Null) if not (self._doActivityStateMachine2TopLevelThread1Thread is None) : self._doActivityStateMachine2TopLevelThread1Thread.interrupt() def setStateMachine2TopLevel(self, aStateMachine2TopLevel): self._stateMachine2TopLevel = aStateMachine2TopLevel if self._stateMachine2 != Lamp.StateMachine2.topLevel and aStateMachine2TopLevel != Lamp.StateMachine2TopLevel.Null : self.setStateMachine2(Lamp.StateMachine2.topLevel) # entry actions and do activities if self._stateMachine2TopLevel == Lamp.StateMachine1TopLevel.thread1 : self._doActivityStateMachine2TopLevelThread1Thread = Lamp.DoActivityThread(self, "doActivityStateMachine2TopLevelThread1") def doActivityStateMachine1TopLevelThread1(self): try: log = "Active entry" except : pass def doActivityStateMachine2TopLevelThread1(self): try: log = "Active entry" except : pass class DoActivityThread(Thread): def __init__(self, aController, aDoActivityMethodName): self._doActivityMethodName = None self._controller = None self._controller = aController self._doActivityMethodName = aDoActivityMethodName # The equivalent of "start();" for starting a python thread super().__init__() self.start() def run(self): if "doActivityStateMachine1TopLevelThread1" == self._doActivityMethodName : self._controller.doActivityStateMachine1TopLevelThread1() elif "doActivityStateMachine2TopLevelThread1" == self._doActivityMethodName : self._controller.doActivityStateMachine2TopLevelThread1() def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "log" + ":" + str(self.getLog()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../doActivityPython.ump" from enum import Enum, auto from threading import Thread import time class Switch(): #------------------------ # MEMBER VARIABLES #------------------------ #Switch State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) On = auto() Off = auto() #Switch Do Activity Threads #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._doActivityStatusOffThread = None self._status = None self.setStatus(Switch.Status.On) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def press(self): wasEventProcessed = False aStatus = self._status if aStatus == Switch.Status.On : self.setStatus(Switch.Status.Off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitStatus(self): if self._status == Switch.Status.Off : if not (self._doActivityStatusOffThread is None) : self._doActivityStatusOffThread.interrupt() def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == Switch.Status.Off : self._doActivityStatusOffThread = Switch.DoActivityThread(self, "doActivityStatusOff") def doActivityStatusOff(self): try: keepDoing() except : pass class DoActivityThread(Thread): def __init__(self, aController, aDoActivityMethodName): self._doActivityMethodName = None self._controller = None self._controller = aController self._doActivityMethodName = aDoActivityMethodName # The equivalent of "start();" for starting a python thread super().__init__() self.start() def run(self): if "doActivityStatusOff" == self._doActivityMethodName : self._controller.doActivityStatusOff() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "guardNameBothAttributeAndMethodPython.ump" from enum import Enum, auto class A(): #------------------------ # MEMBER VARIABLES #------------------------ #A Attributes #A State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() s3 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self._repeatCheck = None self._repeatCheck = False self.setStatus(A.Status.s1) #------------------------ # INTERFACE #------------------------ def setRepeatCheck(self, aRepeatCheck): wasSet = False self._repeatCheck = aRepeatCheck wasSet = True return wasSet def getRepeatCheck(self): return self._repeatCheck # Code from template attribute_IsBoolean def isRepeatCheck(self): return self._repeatCheck def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def __autotransition1__(self): wasEventProcessed = False aStatus = self._status if aStatus == A.Status.s1 : if self.repeatCheck() : self.setStatus(A.Status.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == A.Status.s1 : self.__autotransition1__() def delete(self): pass # line 15 "guardNameBothAttributeAndMethodPython.ump" def repeatCheck(self): return True def __str__(self): return str(super().__str__()) + "[" + "repeatCheck" + ":" + str(self.getRepeatCheck()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../doActivityMultiMixinPython.ump" # line 14 "../doActivityMultiMixinPython.ump" from enum import Enum, auto from threading import Thread import time class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() #X Do Activity Threads #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._doActivity1SmS1Thread = None self._doActivity0SmS1Thread = None self._sm = None self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() return answer def getSm(self): return self._sm def e1(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.s1 : self.exitSm() self.setSm(X.Sm.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : if not (self._doActivity0SmS1Thread is None) : self._doActivity0SmS1Thread.interrupt() if not (self._doActivity1SmS1Thread is None) : self._doActivity1SmS1Thread.interrupt() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : self._doActivity0SmS1Thread = X.DoActivityThread(self, "doActivity0SmS1") self._doActivity1SmS1Thread = X.DoActivityThread(self, "doActivity1SmS1") def doActivity0SmS1(self): try: blah1() except : pass def doActivity1SmS1(self): try: blah2() except : pass class DoActivityThread(Thread): def __init__(self, aController, aDoActivityMethodName): self._doActivityMethodName = None self._controller = None self._controller = aController self._doActivityMethodName = aDoActivityMethodName # The equivalent of "start();" for starting a python thread super().__init__() self.start() def run(self): if "doActivity0SmS1" == self._doActivityMethodName : self._controller.doActivity0SmS1() elif "doActivity1SmS1" == self._doActivityMethodName : self._controller.doActivity1SmS1() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "testRegionFinalStates_1.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s4 = auto() class SmS1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2 = auto() s3 = auto() class SmS4(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s5 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS4 = None self._smS1 = None self._sm = None self.setSmS1(X.SmS1.Null) self.setSmS4(X.SmS4.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1 != X.SmS1.Null : answer += "." + self._smS1.__str__() if self._smS4 != X.SmS4.Null : answer += "." + self._smS4.__str__() return answer def getSm(self): return self._sm def getSmS1(self): return self._smS1 def getSmS4(self): return self._smS4 def goToS5(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.s4 : self.exitSmS4() self.setSmS4(X.SmS4.s5) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToS3(self): wasEventProcessed = False aSmS1 = self._smS1 if aSmS1 == X.SmS1.s2 : self.exitSmS1() self.setSmS1(X.SmS1.s3) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToS4(self): wasEventProcessed = False aSmS1 = self._smS1 if aSmS1 == X.SmS1.s2 : self.exitSm() self.setSm(X.Sm.s4) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1() elif self._sm == X.Sm.s4 : self.exitSmS4() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1 == X.SmS1.Null : self.setSmS1(X.SmS1.s2) elif self._sm == X.Sm.s4 : if self._smS4 == X.SmS4.Null : self.setSmS4(X.SmS4.s5) def exitSmS1(self): if self._smS1 == X.SmS1.s2 : self.setSmS1(X.SmS1.Null) elif self._smS1 == X.SmS1.s3 : self.setSmS1(X.SmS1.Null) def setSmS1(self, aSmS1): self._smS1 = aSmS1 if self._sm != X.Sm.s1 and aSmS1 != X.SmS1.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1 == X.SmS1.s3 : self.delete() def exitSmS4(self): if self._smS4 == X.SmS4.s5 : self.setSmS4(X.SmS4.Null) def setSmS4(self, aSmS4): self._smS4 = aSmS4 if self._sm != X.Sm.s4 and aSmS4 != X.SmS4.Null : self.setSm(X.Sm.s4) # entry actions and do activities if self._smS4 == X.SmS4.s5 : self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "testRegionFinalStates_2.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() class SmS1S2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2 = auto() class SmS1S3(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s3 = auto() class SmS1S3S3(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s4 = auto() s5 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS1S3S3 = None self._smS1S3 = None self._smS1S2 = None self._sm = None self.setSmS1S2(X.SmS1S2.Null) self.setSmS1S3(X.SmS1S3.Null) self.setSmS1S3S3(X.SmS1S3S3.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1S2 != X.SmS1S2.Null : answer += "." + self._smS1S2.__str__() if self._smS1S3 != X.SmS1S3.Null : answer += "." + self._smS1S3.__str__() if self._smS1S3S3 != X.SmS1S3S3.Null : answer += "." + self._smS1S3S3.__str__() return answer def getSm(self): return self._sm def getSmS1S2(self): return self._smS1S2 def getSmS1S3(self): return self._smS1S3 def getSmS1S3S3(self): return self._smS1S3S3 def goToS3(self): wasEventProcessed = False aSmS1S2 = self._smS1S2 if aSmS1S2 == X.SmS1S2.s2 : self.exitSmS1S2() self.setSmS1S3(X.SmS1S3.s3) self.setSmS1S2(X.SmS1S2.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToS5(self): wasEventProcessed = False aSmS1S3S3 = self._smS1S3S3 if aSmS1S3S3 == X.SmS1S3S3.s4 : self.exitSmS1S3S3() self.setSmS1S3S3(X.SmS1S3S3.s5) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1S2() self.exitSmS1S3() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1S2 == X.SmS1S2.Null : self.setSmS1S2(X.SmS1S2.s2) if self._smS1S3 == X.SmS1S3.Null : self.setSmS1S3(X.SmS1S3.s3) def exitSmS1S2(self): if self._smS1S2 == X.SmS1S2.s2 : self.setSmS1S2(X.SmS1S2.Null) def setSmS1S2(self, aSmS1S2): self._smS1S2 = aSmS1S2 if self._sm != X.Sm.s1 and aSmS1S2 != X.SmS1S2.Null : self.setSm(X.Sm.s1) def exitSmS1S3(self): if self._smS1S3 == X.SmS1S3.s3 : self.exitSmS1S3S3() self.setSmS1S3(X.SmS1S3.Null) def setSmS1S3(self, aSmS1S3): self._smS1S3 = aSmS1S3 if self._sm != X.Sm.s1 and aSmS1S3 != X.SmS1S3.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1S3 == X.SmS1S3.s3 : if self._smS1S3S3 == X.SmS1S3S3.Null : self.setSmS1S3S3(X.SmS1S3S3.s4) def exitSmS1S3S3(self): if self._smS1S3S3 == X.SmS1S3S3.s4 : self.setSmS1S3S3(X.SmS1S3S3.Null) elif self._smS1S3S3 == X.SmS1S3S3.s5 : self.setSmS1S3S3(X.SmS1S3S3.Null) def setSmS1S3S3(self, aSmS1S3S3): self._smS1S3S3 = aSmS1S3S3 if self._smS1S3 != X.SmS1S3.s3 and aSmS1S3S3 != X.SmS1S3S3.Null : self.setSmS1S3(X.SmS1S3.s3) # entry actions and do activities if self._smS1S3S3 == X.SmS1S3S3.s5 : self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "testRegionFinalStates_3.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() class SmS1S2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2 = auto() class SmS1S2S2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s3 = auto() s4 = auto() class SmS1S5(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s5 = auto() class SmS1S5S5(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s6 = auto() s7 = auto() class SmS1S8(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s8 = auto() class SmS1S8S8(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s9 = auto() s10 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS1S8S8 = None self._smS1S8 = None self._smS1S5S5 = None self._smS1S5 = None self._smS1S2S2 = None self._smS1S2 = None self._sm = None self.setSmS1S2(X.SmS1S2.Null) self.setSmS1S2S2(X.SmS1S2S2.Null) self.setSmS1S5(X.SmS1S5.Null) self.setSmS1S5S5(X.SmS1S5S5.Null) self.setSmS1S8(X.SmS1S8.Null) self.setSmS1S8S8(X.SmS1S8S8.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1S2 != X.SmS1S2.Null : answer += "." + self._smS1S2.__str__() if self._smS1S2S2 != X.SmS1S2S2.Null : answer += "." + self._smS1S2S2.__str__() if self._smS1S5 != X.SmS1S5.Null : answer += "." + self._smS1S5.__str__() if self._smS1S5S5 != X.SmS1S5S5.Null : answer += "." + self._smS1S5S5.__str__() if self._smS1S8 != X.SmS1S8.Null : answer += "." + self._smS1S8.__str__() if self._smS1S8S8 != X.SmS1S8S8.Null : answer += "." + self._smS1S8S8.__str__() return answer def getSm(self): return self._sm def getSmS1S2(self): return self._smS1S2 def getSmS1S2S2(self): return self._smS1S2S2 def getSmS1S5(self): return self._smS1S5 def getSmS1S5S5(self): return self._smS1S5S5 def getSmS1S8(self): return self._smS1S8 def getSmS1S8S8(self): return self._smS1S8S8 def goToS4(self): wasEventProcessed = False aSmS1S2S2 = self._smS1S2S2 if aSmS1S2S2 == X.SmS1S2S2.s3 : self.exitSmS1S2S2() self.setSmS1S2S2(X.SmS1S2S2.s4) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToS7(self): wasEventProcessed = False aSmS1S5S5 = self._smS1S5S5 if aSmS1S5S5 == X.SmS1S5S5.s6 : self.exitSmS1S5S5() self.setSmS1S5S5(X.SmS1S5S5.s7) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToS10(self): wasEventProcessed = False aSmS1S8S8 = self._smS1S8S8 if aSmS1S8S8 == X.SmS1S8S8.s9 : self.exitSmS1S8S8() self.setSmS1S8S8(X.SmS1S8S8.s10) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1S2() self.exitSmS1S5() self.exitSmS1S8() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1S2 == X.SmS1S2.Null : self.setSmS1S2(X.SmS1S2.s2) if self._smS1S5 == X.SmS1S5.Null : self.setSmS1S5(X.SmS1S5.s5) if self._smS1S8 == X.SmS1S8.Null : self.setSmS1S8(X.SmS1S8.s8) def exitSmS1S2(self): if self._smS1S2 == X.SmS1S2.s2 : self.exitSmS1S2S2() self.setSmS1S2(X.SmS1S2.Null) def setSmS1S2(self, aSmS1S2): self._smS1S2 = aSmS1S2 if self._sm != X.Sm.s1 and aSmS1S2 != X.SmS1S2.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1S2 == X.SmS1S2.s2 : if self._smS1S2S2 == X.SmS1S2S2.Null : self.setSmS1S2S2(X.SmS1S2S2.s3) def exitSmS1S2S2(self): if self._smS1S2S2 == X.SmS1S2S2.s3 : self.setSmS1S2S2(X.SmS1S2S2.Null) elif self._smS1S2S2 == X.SmS1S2S2.s4 : self.setSmS1S2S2(X.SmS1S2S2.Null) def setSmS1S2S2(self, aSmS1S2S2): self._smS1S2S2 = aSmS1S2S2 if self._smS1S2 != X.SmS1S2.s2 and aSmS1S2S2 != X.SmS1S2S2.Null : self.setSmS1S2(X.SmS1S2.s2) # entry actions and do activities if self._smS1S2S2 == X.SmS1S2S2.s4 : if self._smS1S5S5 == X.SmS1S5S5.s7 and self._smS1S8S8 == X.SmS1S8S8.s10 : self.delete() def exitSmS1S5(self): if self._smS1S5 == X.SmS1S5.s5 : self.exitSmS1S5S5() self.setSmS1S5(X.SmS1S5.Null) def setSmS1S5(self, aSmS1S5): self._smS1S5 = aSmS1S5 if self._sm != X.Sm.s1 and aSmS1S5 != X.SmS1S5.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1S5 == X.SmS1S5.s5 : if self._smS1S5S5 == X.SmS1S5S5.Null : self.setSmS1S5S5(X.SmS1S5S5.s6) def exitSmS1S5S5(self): if self._smS1S5S5 == X.SmS1S5S5.s6 : self.setSmS1S5S5(X.SmS1S5S5.Null) elif self._smS1S5S5 == X.SmS1S5S5.s7 : self.setSmS1S5S5(X.SmS1S5S5.Null) def setSmS1S5S5(self, aSmS1S5S5): self._smS1S5S5 = aSmS1S5S5 if self._smS1S5 != X.SmS1S5.s5 and aSmS1S5S5 != X.SmS1S5S5.Null : self.setSmS1S5(X.SmS1S5.s5) # entry actions and do activities if self._smS1S5S5 == X.SmS1S5S5.s7 : if self._smS1S2S2 == X.SmS1S2S2.s4 and self._smS1S8S8 == X.SmS1S8S8.s10 : self.delete() def exitSmS1S8(self): if self._smS1S8 == X.SmS1S8.s8 : self.exitSmS1S8S8() self.setSmS1S8(X.SmS1S8.Null) def setSmS1S8(self, aSmS1S8): self._smS1S8 = aSmS1S8 if self._sm != X.Sm.s1 and aSmS1S8 != X.SmS1S8.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1S8 == X.SmS1S8.s8 : if self._smS1S8S8 == X.SmS1S8S8.Null : self.setSmS1S8S8(X.SmS1S8S8.s9) def exitSmS1S8S8(self): if self._smS1S8S8 == X.SmS1S8S8.s9 : self.setSmS1S8S8(X.SmS1S8S8.Null) elif self._smS1S8S8 == X.SmS1S8S8.s10 : self.setSmS1S8S8(X.SmS1S8S8.Null) def setSmS1S8S8(self, aSmS1S8S8): self._smS1S8S8 = aSmS1S8S8 if self._smS1S8 != X.SmS1S8.s8 and aSmS1S8S8 != X.SmS1S8S8.Null : self.setSmS1S8(X.SmS1S8.s8) # entry actions and do activities if self._smS1S8S8 == X.SmS1S8S8.s10 : if self._smS1S2S2 == X.SmS1S2S2.s4 and self._smS1S5S5 == X.SmS1S5S5.s7 : self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "testRegionFinalStates_4.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() Final = auto() s2 = auto() class SmS1O1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() o1 = auto() class SmS1O1O1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() o1Start = auto() o1Final = auto() class SmS1O2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() o2 = auto() class SmS1O2O2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() o2Start = auto() o2Final = auto() class SmS2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2Start = auto() s2Final = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS2 = None self._smS1O2O2 = None self._smS1O2 = None self._smS1O1O1 = None self._smS1O1 = None self._sm = None self.setSmS1O1(X.SmS1O1.Null) self.setSmS1O1O1(X.SmS1O1O1.Null) self.setSmS1O2(X.SmS1O2.Null) self.setSmS1O2O2(X.SmS1O2O2.Null) self.setSmS2(X.SmS2.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1O1 != X.SmS1O1.Null : answer += "." + self._smS1O1.__str__() if self._smS1O1O1 != X.SmS1O1O1.Null : answer += "." + self._smS1O1O1.__str__() if self._smS1O2 != X.SmS1O2.Null : answer += "." + self._smS1O2.__str__() if self._smS1O2O2 != X.SmS1O2O2.Null : answer += "." + self._smS1O2O2.__str__() if self._smS2 != X.SmS2.Null : answer += "." + self._smS2.__str__() return answer def getSm(self): return self._sm def getSmS1O1(self): return self._smS1O1 def getSmS1O1O1(self): return self._smS1O1O1 def getSmS1O2(self): return self._smS1O2 def getSmS1O2O2(self): return self._smS1O2O2 def getSmS2(self): return self._smS2 def goToS2(self): wasEventProcessed = False aSmS1O1 = self._smS1O1 if aSmS1O1 == X.SmS1O1.o1 : self.exitSm() self.setSm(X.Sm.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goBigFinal(self): wasEventProcessed = False aSmS1O1O1 = self._smS1O1O1 if aSmS1O1O1 == X.SmS1O1O1.o1Start : self.exitSm() self.setSm(X.Sm.Final) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def completeO1(self): wasEventProcessed = False aSmS1O1O1 = self._smS1O1O1 if aSmS1O1O1 == X.SmS1O1O1.o1Start : self.exitSmS1O1O1() self.setSmS1O1O1(X.SmS1O1O1.o1Final) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def completeO2(self): wasEventProcessed = False aSmS1O2O2 = self._smS1O2O2 if aSmS1O2O2 == X.SmS1O2O2.o2Start : self.exitSmS1O2O2() self.setSmS1O2O2(X.SmS1O2O2.o2Final) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def completeS2(self): wasEventProcessed = False aSmS2 = self._smS2 if aSmS2 == X.SmS2.s2Start : self.exitSmS2() self.setSmS2(X.SmS2.s2Final) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1O1() self.exitSmS1O2() elif self._sm == X.Sm.s2 : self.exitSmS2() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1O1 == X.SmS1O1.Null : self.setSmS1O1(X.SmS1O1.o1) if self._smS1O2 == X.SmS1O2.Null : self.setSmS1O2(X.SmS1O2.o2) elif self._sm == X.Sm.Final : self.delete() elif self._sm == X.Sm.s2 : if self._smS2 == X.SmS2.Null : self.setSmS2(X.SmS2.s2Start) def exitSmS1O1(self): if self._smS1O1 == X.SmS1O1.o1 : self.exitSmS1O1O1() self.setSmS1O1(X.SmS1O1.Null) def setSmS1O1(self, aSmS1O1): self._smS1O1 = aSmS1O1 if self._sm != X.Sm.s1 and aSmS1O1 != X.SmS1O1.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1O1 == X.SmS1O1.o1 : if self._smS1O1O1 == X.SmS1O1O1.Null : self.setSmS1O1O1(X.SmS1O1O1.o1Start) def exitSmS1O1O1(self): if self._smS1O1O1 == X.SmS1O1O1.o1Start : self.setSmS1O1O1(X.SmS1O1O1.Null) elif self._smS1O1O1 == X.SmS1O1O1.o1Final : self.setSmS1O1O1(X.SmS1O1O1.Null) def setSmS1O1O1(self, aSmS1O1O1): self._smS1O1O1 = aSmS1O1O1 if self._smS1O1 != X.SmS1O1.o1 and aSmS1O1O1 != X.SmS1O1O1.Null : self.setSmS1O1(X.SmS1O1.o1) # entry actions and do activities if self._smS1O1O1 == X.SmS1O1O1.o1Final : if self._smS1O2O2 == X.SmS1O2O2.o2Final : self.delete() def exitSmS1O2(self): if self._smS1O2 == X.SmS1O2.o2 : self.exitSmS1O2O2() self.setSmS1O2(X.SmS1O2.Null) def setSmS1O2(self, aSmS1O2): self._smS1O2 = aSmS1O2 if self._sm != X.Sm.s1 and aSmS1O2 != X.SmS1O2.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1O2 == X.SmS1O2.o2 : if self._smS1O2O2 == X.SmS1O2O2.Null : self.setSmS1O2O2(X.SmS1O2O2.o2Start) def exitSmS1O2O2(self): if self._smS1O2O2 == X.SmS1O2O2.o2Start : self.setSmS1O2O2(X.SmS1O2O2.Null) elif self._smS1O2O2 == X.SmS1O2O2.o2Final : self.setSmS1O2O2(X.SmS1O2O2.Null) def setSmS1O2O2(self, aSmS1O2O2): self._smS1O2O2 = aSmS1O2O2 if self._smS1O2 != X.SmS1O2.o2 and aSmS1O2O2 != X.SmS1O2O2.Null : self.setSmS1O2(X.SmS1O2.o2) # entry actions and do activities if self._smS1O2O2 == X.SmS1O2O2.o2Final : if self._smS1O1O1 == X.SmS1O1O1.o1Final : self.delete() def exitSmS2(self): if self._smS2 == X.SmS2.s2Start : self.setSmS2(X.SmS2.Null) elif self._smS2 == X.SmS2.s2Final : self.setSmS2(X.SmS2.Null) def setSmS2(self, aSmS2): self._smS2 = aSmS2 if self._sm != X.Sm.s2 and aSmS2 != X.SmS2.Null : self.setSm(X.Sm.s2) # entry actions and do activities if self._smS2 == X.SmS2.s2Final : self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "testRegionFinalStates_5.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) o1 = auto() class SmO1S1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s1 = auto() class SmO1S1S2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2 = auto() class SmO1S1S2S2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s3 = auto() s4 = auto() class SmO1S1S5(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s5 = auto() class SmO1S1S5S5(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s6 = auto() class SmO1S7(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s7 = auto() class SmO1S7S7(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s8 = auto() s9 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smO1S7S7 = None self._smO1S7 = None self._smO1S1S5S5 = None self._smO1S1S5 = None self._smO1S1S2S2 = None self._smO1S1S2 = None self._smO1S1 = None self._sm = None self.setSmO1S1(X.SmO1S1.Null) self.setSmO1S1S2(X.SmO1S1S2.Null) self.setSmO1S1S2S2(X.SmO1S1S2S2.Null) self.setSmO1S1S5(X.SmO1S1S5.Null) self.setSmO1S1S5S5(X.SmO1S1S5S5.Null) self.setSmO1S7(X.SmO1S7.Null) self.setSmO1S7S7(X.SmO1S7S7.Null) self.setSm(X.Sm.o1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smO1S1 != X.SmO1S1.Null : answer += "." + self._smO1S1.__str__() if self._smO1S1S2 != X.SmO1S1S2.Null : answer += "." + self._smO1S1S2.__str__() if self._smO1S1S2S2 != X.SmO1S1S2S2.Null : answer += "." + self._smO1S1S2S2.__str__() if self._smO1S1S5 != X.SmO1S1S5.Null : answer += "." + self._smO1S1S5.__str__() if self._smO1S1S5S5 != X.SmO1S1S5S5.Null : answer += "." + self._smO1S1S5S5.__str__() if self._smO1S7 != X.SmO1S7.Null : answer += "." + self._smO1S7.__str__() if self._smO1S7S7 != X.SmO1S7S7.Null : answer += "." + self._smO1S7S7.__str__() if self._smO1S1S2S2 != X.SmO1S1S2S2.Null : answer += "." + self._smO1S1S2S2.__str__() if self._smO1S1S5S5 != X.SmO1S1S5S5.Null : answer += "." + self._smO1S1S5S5.__str__() return answer def getSm(self): return self._sm def getSmO1S1(self): return self._smO1S1 def getSmO1S1S2(self): return self._smO1S1S2 def getSmO1S1S2S2(self): return self._smO1S1S2S2 def getSmO1S1S5(self): return self._smO1S1S5 def getSmO1S1S5S5(self): return self._smO1S1S5S5 def getSmO1S7(self): return self._smO1S7 def getSmO1S7S7(self): return self._smO1S7S7 def goToS4Final(self): wasEventProcessed = False aSmO1S1S2S2 = self._smO1S1S2S2 if aSmO1S1S2S2 == X.SmO1S1S2S2.s3 : self.exitSmO1S1S2S2() self.setSmO1S1S2S2(X.SmO1S1S2S2.s4) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToS9Final(self): wasEventProcessed = False aSmO1S7S7 = self._smO1S7S7 if aSmO1S7S7 == X.SmO1S7S7.s8 : self.exitSmO1S7S7() self.setSmO1S7S7(X.SmO1S7S7.s9) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.o1 : self.exitSmO1S1() self.exitSmO1S7() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.o1 : if self._smO1S1 == X.SmO1S1.Null : self.setSmO1S1(X.SmO1S1.s1) if self._smO1S7 == X.SmO1S7.Null : self.setSmO1S7(X.SmO1S7.s7) def exitSmO1S1(self): if self._smO1S1 == X.SmO1S1.s1 : self.exitSmO1S1S2() self.exitSmO1S1S5() self.setSmO1S1(X.SmO1S1.Null) def setSmO1S1(self, aSmO1S1): self._smO1S1 = aSmO1S1 if self._sm != X.Sm.o1 and aSmO1S1 != X.SmO1S1.Null : self.setSm(X.Sm.o1) # entry actions and do activities if self._smO1S1 == X.SmO1S1.s1 : if self._smO1S1S2 == X.SmO1S1S2.Null : self.setSmO1S1S2(X.SmO1S1S2.s2) if self._smO1S1S5 == X.SmO1S1S5.Null : self.setSmO1S1S5(X.SmO1S1S5.s5) def exitSmO1S1S2(self): if self._smO1S1S2 == X.SmO1S1S2.s2 : self.exitSmO1S1S2S2() self.setSmO1S1S2(X.SmO1S1S2.Null) def setSmO1S1S2(self, aSmO1S1S2): self._smO1S1S2 = aSmO1S1S2 if self._smO1S1 != X.SmO1S1.s1 and aSmO1S1S2 != X.SmO1S1S2.Null : self.setSmO1S1(X.SmO1S1.s1) # entry actions and do activities if self._smO1S1S2 == X.SmO1S1S2.s2 : if self._smO1S1S2S2 == X.SmO1S1S2S2.Null : self.setSmO1S1S2S2(X.SmO1S1S2S2.s3) def exitSmO1S1S2S2(self): if self._smO1S1S2S2 == X.SmO1S1S2S2.s3 : self.setSmO1S1S2S2(X.SmO1S1S2S2.Null) elif self._smO1S1S2S2 == X.SmO1S1S2S2.s4 : self.setSmO1S1S2S2(X.SmO1S1S2S2.Null) def setSmO1S1S2S2(self, aSmO1S1S2S2): self._smO1S1S2S2 = aSmO1S1S2S2 if self._smO1S1S2 != X.SmO1S1S2.s2 and aSmO1S1S2S2 != X.SmO1S1S2S2.Null : self.setSmO1S1S2(X.SmO1S1S2.s2) # entry actions and do activities if self._smO1S1S2S2 == X.SmO1S1S2S2.s4 : if self._smO1S1S5S5 == X.SmO1S1S5S5.s6 and self._smO1S7S7 == X.SmO1S7S7.s9 : self.delete() def exitSmO1S1S5(self): if self._smO1S1S5 == X.SmO1S1S5.s5 : self.exitSmO1S1S5S5() self.setSmO1S1S5(X.SmO1S1S5.Null) def setSmO1S1S5(self, aSmO1S1S5): self._smO1S1S5 = aSmO1S1S5 if self._smO1S1 != X.SmO1S1.s1 and aSmO1S1S5 != X.SmO1S1S5.Null : self.setSmO1S1(X.SmO1S1.s1) # entry actions and do activities if self._smO1S1S5 == X.SmO1S1S5.s5 : if self._smO1S1S5S5 == X.SmO1S1S5S5.Null : self.setSmO1S1S5S5(X.SmO1S1S5S5.s6) def exitSmO1S1S5S5(self): if self._smO1S1S5S5 == X.SmO1S1S5S5.s6 : self.setSmO1S1S5S5(X.SmO1S1S5S5.Null) def setSmO1S1S5S5(self, aSmO1S1S5S5): self._smO1S1S5S5 = aSmO1S1S5S5 if self._smO1S1S5 != X.SmO1S1S5.s5 and aSmO1S1S5S5 != X.SmO1S1S5S5.Null : self.setSmO1S1S5(X.SmO1S1S5.s5) # entry actions and do activities if self._smO1S1S5S5 == X.SmO1S1S5S5.s6 : if self._smO1S1S2S2 == X.SmO1S1S2S2.s4 and self._smO1S7S7 == X.SmO1S7S7.s9 : self.delete() def exitSmO1S7(self): if self._smO1S7 == X.SmO1S7.s7 : self.exitSmO1S7S7() self.setSmO1S7(X.SmO1S7.Null) def setSmO1S7(self, aSmO1S7): self._smO1S7 = aSmO1S7 if self._sm != X.Sm.o1 and aSmO1S7 != X.SmO1S7.Null : self.setSm(X.Sm.o1) # entry actions and do activities if self._smO1S7 == X.SmO1S7.s7 : if self._smO1S7S7 == X.SmO1S7S7.Null : self.setSmO1S7S7(X.SmO1S7S7.s8) def exitSmO1S7S7(self): if self._smO1S7S7 == X.SmO1S7S7.s8 : self.setSmO1S7S7(X.SmO1S7S7.Null) elif self._smO1S7S7 == X.SmO1S7S7.s9 : self.setSmO1S7S7(X.SmO1S7S7.Null) def setSmO1S7S7(self, aSmO1S7S7): self._smO1S7S7 = aSmO1S7S7 if self._smO1S7 != X.SmO1S7.s7 and aSmO1S7S7 != X.SmO1S7S7.Null : self.setSmO1S7(X.SmO1S7.s7) # entry actions and do activities if self._smO1S7S7 == X.SmO1S7S7.s9 : if self._smO1S1S2S2 == X.SmO1S1S2S2.s4 and self._smO1S1S5S5 == X.SmO1S1S5S5.s6 : self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "checkExternalTransitions_noNestedStateMachines.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() s3 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._sm = None self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() return answer def getSm(self): return self._sm def goToS2(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.s1 : self.setSm(X.Sm.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToS3(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.s2 : self.setSm(X.Sm.s3) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setSm(self, aSm): self._sm = aSm def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "stateMachineWithNegativeNumberGuard2.ump" from enum import Enum, auto class stateMachineWithNegativeNumberGuard2(): #------------------------ # MEMBER VARIABLES #------------------------ #stateMachineWithNegativeNumberGuard2 State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) on = auto() off = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(stateMachineWithNegativeNumberGuard2.Status.on) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def turnOff(self, pn): wasEventProcessed = False aStatus = self._status if aStatus == stateMachineWithNegativeNumberGuard2.Status.on : if pn < -1 : self.setStatus(stateMachineWithNegativeNumberGuard2.Status.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def turnOn(self): wasEventProcessed = False aStatus = self._status if aStatus == stateMachineWithNegativeNumberGuard2.Status.off : self.setStatus(stateMachineWithNegativeNumberGuard2.Status.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "parallelSm_diffNamesDiffStates_2.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s0 = auto() s1 = auto() class SmS0T1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t1 = auto() class SmS0T2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t2 = auto() t3 = auto() class SmS1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2 = auto() class SmS1S2T4(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t4 = auto() t5 = auto() class SmS1S2T6(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t6 = auto() t7 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS1S2T6 = None self._smS1S2T4 = None self._smS1 = None self._smS0T2 = None self._smS0T1 = None self._sm = None self.setSmS0T1(X.SmS0T1.Null) self.setSmS0T2(X.SmS0T2.Null) self.setSmS1(X.SmS1.Null) self.setSmS1S2T4(X.SmS1S2T4.Null) self.setSmS1S2T6(X.SmS1S2T6.Null) self.setSm(X.Sm.s0) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS0T1 != X.SmS0T1.Null : answer += "." + self._smS0T1.__str__() if self._smS0T2 != X.SmS0T2.Null : answer += "." + self._smS0T2.__str__() if self._smS1 != X.SmS1.Null : answer += "." + self._smS1.__str__() if self._smS1S2T4 != X.SmS1S2T4.Null : answer += "." + self._smS1S2T4.__str__() if self._smS1S2T6 != X.SmS1S2T6.Null : answer += "." + self._smS1S2T6.__str__() return answer def getSm(self): return self._sm def getSmS0T1(self): return self._smS0T1 def getSmS0T2(self): return self._smS0T2 def getSmS1(self): return self._smS1 def getSmS1S2T4(self): return self._smS1S2T4 def getSmS1S2T6(self): return self._smS1S2T6 def goS1(self): wasEventProcessed = False aSmS0T1 = self._smS0T1 if aSmS0T1 == X.SmS0T1.t1 : self.exitSm() self.setSm(X.Sm.s1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT3(self): wasEventProcessed = False aSmS0T2 = self._smS0T2 if aSmS0T2 == X.SmS0T2.t2 : self.exitSmS0T2() self.setSmS0T2(X.SmS0T2.t3) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT5(self): wasEventProcessed = False aSmS1S2T4 = self._smS1S2T4 if aSmS1S2T4 == X.SmS1S2T4.t4 : self.exitSmS1S2T4() self.setSmS1S2T4(X.SmS1S2T4.t5) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT7(self): wasEventProcessed = False aSmS1S2T6 = self._smS1S2T6 if aSmS1S2T6 == X.SmS1S2T6.t6 : self.exitSmS1S2T6() self.setSmS1S2T6(X.SmS1S2T6.t7) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s0 : self.exitSmS0T1() self.exitSmS0T2() elif self._sm == X.Sm.s1 : self.exitSmS1() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s0 : if self._smS0T1 == X.SmS0T1.Null : self.setSmS0T1(X.SmS0T1.t1) if self._smS0T2 == X.SmS0T2.Null : self.setSmS0T2(X.SmS0T2.t2) elif self._sm == X.Sm.s1 : if self._smS1 == X.SmS1.Null : self.setSmS1(X.SmS1.s2) def exitSmS0T1(self): if self._smS0T1 == X.SmS0T1.t1 : self.setSmS0T1(X.SmS0T1.Null) def setSmS0T1(self, aSmS0T1): self._smS0T1 = aSmS0T1 if self._sm != X.Sm.s0 and aSmS0T1 != X.SmS0T1.Null : self.setSm(X.Sm.s0) def exitSmS0T2(self): if self._smS0T2 == X.SmS0T2.t2 : self.setSmS0T2(X.SmS0T2.Null) elif self._smS0T2 == X.SmS0T2.t3 : self.setSmS0T2(X.SmS0T2.Null) def setSmS0T2(self, aSmS0T2): self._smS0T2 = aSmS0T2 if self._sm != X.Sm.s0 and aSmS0T2 != X.SmS0T2.Null : self.setSm(X.Sm.s0) def exitSmS1(self): if self._smS1 == X.SmS1.s2 : self.exitSmS1S2T4() self.exitSmS1S2T6() self.setSmS1(X.SmS1.Null) def setSmS1(self, aSmS1): self._smS1 = aSmS1 if self._sm != X.Sm.s1 and aSmS1 != X.SmS1.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1 == X.SmS1.s2 : if self._smS1S2T4 == X.SmS1S2T4.Null : self.setSmS1S2T4(X.SmS1S2T4.t4) if self._smS1S2T6 == X.SmS1S2T6.Null : self.setSmS1S2T6(X.SmS1S2T6.t6) def exitSmS1S2T4(self): if self._smS1S2T4 == X.SmS1S2T4.t4 : self.setSmS1S2T4(X.SmS1S2T4.Null) elif self._smS1S2T4 == X.SmS1S2T4.t5 : self.setSmS1S2T4(X.SmS1S2T4.Null) def setSmS1S2T4(self, aSmS1S2T4): self._smS1S2T4 = aSmS1S2T4 if self._smS1 != X.SmS1.s2 and aSmS1S2T4 != X.SmS1S2T4.Null : self.setSmS1(X.SmS1.s2) def exitSmS1S2T6(self): if self._smS1S2T6 == X.SmS1S2T6.t6 : self.setSmS1S2T6(X.SmS1S2T6.Null) elif self._smS1S2T6 == X.SmS1S2T6.t7 : self.setSmS1S2T6(X.SmS1S2T6.Null) def setSmS1S2T6(self, aSmS1S2T6): self._smS1S2T6 = aSmS1S2T6 if self._smS1 != X.SmS1.s2 and aSmS1S2T6 != X.SmS1S2T6.Null : self.setSmS1(X.SmS1.s2) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "testFinalKeyword.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() Final = auto() class SmS1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS1 = None self._sm = None self.setSmS1(X.SmS1.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1 != X.SmS1.Null : answer += "." + self._smS1.__str__() return answer def getSm(self): return self._sm def getSmS1(self): return self._smS1 def goToFinal(self): wasEventProcessed = False aSmS1 = self._smS1 if aSmS1 == X.SmS1.s2 : self.exitSm() self.setSm(X.Sm.Final) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1 == X.SmS1.Null : self.setSmS1(X.SmS1.s2) elif self._sm == X.Sm.Final : self.delete() def exitSmS1(self): if self._smS1 == X.SmS1.s2 : self.setSmS1(X.SmS1.Null) def setSmS1(self, aSmS1): self._smS1 = aSmS1 if self._sm != X.Sm.s1 and aSmS1 != X.SmS1.Null : self.setSm(X.Sm.s1) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../transitionAction.ump" from enum import Enum, auto class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def register(self): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Open : # line 8 "../transitionAction.ump" print("transition") self.setStatus(Course.Status.Open) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "testFinalKeyword_2.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() Final = auto() s3 = auto() class SmS1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2 = auto() class SmS3(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s4 = auto() class SmS3S4(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s5 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS3S4 = None self._smS3 = None self._smS1 = None self._sm = None self.setSmS1(X.SmS1.Null) self.setSmS3(X.SmS3.Null) self.setSmS3S4(X.SmS3S4.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1 != X.SmS1.Null : answer += "." + self._smS1.__str__() if self._smS3 != X.SmS3.Null : answer += "." + self._smS3.__str__() if self._smS3S4 != X.SmS3S4.Null : answer += "." + self._smS3S4.__str__() return answer def getSm(self): return self._sm def getSmS1(self): return self._smS1 def getSmS3(self): return self._smS3 def getSmS3S4(self): return self._smS3S4 def goToS3(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.s1 : self.exitSm() self.setSm(X.Sm.s3) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToFinal(self): wasEventProcessed = False aSmS1 = self._smS1 aSmS3S4 = self._smS3S4 if aSmS1 == X.SmS1.s2 : self.exitSm() self.setSm(X.Sm.Final) wasEventProcessed = True else : # Other states do respond to this event pass if aSmS3S4 == X.SmS3S4.s5 : self.exitSm() self.setSm(X.Sm.Final) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1() elif self._sm == X.Sm.s3 : self.exitSmS3() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1 == X.SmS1.Null : self.setSmS1(X.SmS1.s2) elif self._sm == X.Sm.Final : self.delete() elif self._sm == X.Sm.s3 : if self._smS3 == X.SmS3.Null : self.setSmS3(X.SmS3.s4) def exitSmS1(self): if self._smS1 == X.SmS1.s2 : self.setSmS1(X.SmS1.Null) def setSmS1(self, aSmS1): self._smS1 = aSmS1 if self._sm != X.Sm.s1 and aSmS1 != X.SmS1.Null : self.setSm(X.Sm.s1) def exitSmS3(self): if self._smS3 == X.SmS3.s4 : self.exitSmS3S4() self.setSmS3(X.SmS3.Null) def setSmS3(self, aSmS3): self._smS3 = aSmS3 if self._sm != X.Sm.s3 and aSmS3 != X.SmS3.Null : self.setSm(X.Sm.s3) # entry actions and do activities if self._smS3 == X.SmS3.s4 : if self._smS3S4 == X.SmS3S4.Null : self.setSmS3S4(X.SmS3S4.s5) def exitSmS3S4(self): if self._smS3S4 == X.SmS3S4.s5 : self.setSmS3S4(X.SmS3S4.Null) def setSmS3S4(self, aSmS3S4): self._smS3S4 = aSmS3S4 if self._smS3 != X.SmS3.s4 and aSmS3S4 != X.SmS3S4.Null : self.setSmS3(X.SmS3.s4) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../FinalState.ump" from enum import Enum, auto class Mentor(): #------------------------ # MEMBER VARIABLES #------------------------ #Mentor State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Ok = auto() Final = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Mentor.Status.Ok) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def flip(self): wasEventProcessed = False aStatus = self._status if aStatus == Mentor.Status.Ok : self.setStatus(Mentor.Status.Final) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == Mentor.Status.Final : self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../EventTransitionSpacing.ump" from enum import Enum, auto class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def register(self): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Open : self.setStatus(Course.Status.Open) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "stateMachine_UnspecifiedReception.ump" from enum import Enum, auto class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() Full = auto() error1 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def register(self): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Open : self.setStatus(Course.Status.Full) wasEventProcessed = True else : # Other states do respond to this event wasEventProcessed = self.unspecified(self.getStatus().__str__(), "register") return wasEventProcessed def unspecified(self, state, event): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Open : self.setStatus(Course.Status.error1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def reject(self): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Full : self.setStatus(Course.Status.Full) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def __autotransition1__(self): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.error1 : self.setStatus(Course.Status.Open) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == Course.Status.error1 : self.__autotransition1__() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "eventWithArguments.ump" from enum import Enum, auto class LightFixture(): #------------------------ # MEMBER VARIABLES #------------------------ #LightFixture Attributes #LightFixture State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Off = auto() Dimmed = auto() On = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._bulb = None self._brightness = None self._brightness = 0 self.setBulb(LightFixture.Bulb.Off) #------------------------ # INTERFACE #------------------------ def setBrightness(self, aBrightness): wasSet = False self._brightness = aBrightness wasSet = True return wasSet def getBrightness(self): return self._brightness def getBulbFullName(self): answer = self._bulb.__str__() return answer def getBulb(self): return self._bulb def turnDimmer(self, lightval): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.Off : # line 6 "eventWithArguments.ump" self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True elif aBulb == LightFixture.Bulb.Dimmed : # line 12 "eventWithArguments.ump" self.setBulb(LightFixture.Bulb.Dimmed) wasEventProcessed = True elif aBulb == LightFixture.Bulb.On : # line 16 "eventWithArguments.ump" self.setBulb(LightFixture.Bulb.Dimmed) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def flipSwitch(self): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.Off : self.setBulb(LightFixture.Bulb.Dimmed) wasEventProcessed = True elif aBulb == LightFixture.Bulb.Dimmed : self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True elif aBulb == LightFixture.Bulb.On : self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def entry(self): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.Dimmed : if dimmer > 99 : self.setBulb(LightFixture.Bulb.On) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setBulb(self, aBulb): self._bulb = aBulb def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "brightness" + ":" + str(self.getBrightness()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../entryAction.ump" from enum import Enum, auto class Light(): #------------------------ # MEMBER VARIABLES #------------------------ #Light State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) On = auto() Off = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Light.Status.On) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def flip(self): wasEventProcessed = False aStatus = self._status if aStatus == Light.Status.On : self.setStatus(Light.Status.Off) wasEventProcessed = True elif aStatus == Light.Status.Off : self.setStatus(Light.Status.On) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == Light.Status.On : # line 8 "../entryAction.ump" print("entry") # line 9 "../entryAction.ump" print("entry2") def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../refactorFinalState_invalidElementsInNestedFinalState.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) on = auto() off = auto() FINAL = auto() class StatusFINAL(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() nestedSm = auto() class StatusFINALNestedSm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() nestedFinal = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._statusFINALNestedSm = None self._statusFINAL = None self._status = None self.setStatusFINAL(X.StatusFINAL.Null) self.setStatusFINALNestedSm(X.StatusFINALNestedSm.Null) self.setStatus(X.Status.on) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() if self._statusFINAL != X.StatusFINAL.Null : answer += "." + self._statusFINAL.__str__() if self._statusFINALNestedSm != X.StatusFINALNestedSm.Null : answer += "." + self._statusFINALNestedSm.__str__() return answer def getStatus(self): return self._status def getStatusFINAL(self): return self._statusFINAL def getStatusFINALNestedSm(self): return self._statusFINALNestedSm def turnoff(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.on : self.setStatus(X.Status.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def powerOff(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.on : self.setStatus(X.Status.FINAL) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def turnOn(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.off : self.setStatus(X.Status.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitStatus(self): if self._status == X.Status.FINAL : self.exitStatusFINAL() def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == X.Status.FINAL : if self._statusFINAL == X.StatusFINAL.Null : self.setStatusFINAL(X.StatusFINAL.nestedSm) def exitStatusFINAL(self): if self._statusFINAL == X.StatusFINAL.nestedSm : self.exitStatusFINALNestedSm() self.setStatusFINAL(X.StatusFINAL.Null) def setStatusFINAL(self, aStatusFINAL): self._statusFINAL = aStatusFINAL if self._status != X.Status.FINAL and aStatusFINAL != X.StatusFINAL.Null : self.setStatus(X.Status.FINAL) # entry actions and do activities if self._statusFINAL == X.StatusFINAL.nestedSm : if self._statusFINALNestedSm == X.StatusFINALNestedSm.Null : self.setStatusFINALNestedSm(X.StatusFINALNestedSm.nestedFinal) def exitStatusFINALNestedSm(self): if self._statusFINALNestedSm == X.StatusFINALNestedSm.nestedFinal : self.setStatusFINALNestedSm(X.StatusFINALNestedSm.Null) def setStatusFINALNestedSm(self, aStatusFINALNestedSm): self._statusFINALNestedSm = aStatusFINALNestedSm if self._statusFINAL != X.StatusFINAL.nestedSm and aStatusFINALNestedSm != X.StatusFINALNestedSm.Null : self.setStatusFINAL(X.StatusFINAL.nestedSm) # entry actions and do activities if self._statusFINALNestedSm == X.StatusFINALNestedSm.nestedFinal : # line 15 "../refactorFinalState_invalidElementsInNestedFinalState.ump" entry() self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 12 "nestedStateMachineExtendedByClass.ump" from ThingInWorld import ThingInWorld import os from enum import Enum, auto class Animal(ThingInWorld): #------------------------ # MEMBER VARIABLES #------------------------ #Animal Attributes #Animal State Machines class State(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) alive = auto() dead = auto() class StateAlive(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() normal = auto() zombie = auto() class StateAliveNormal(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() baby = auto() adult = auto() #Animal Associations #------------------------ # CONSTRUCTOR #------------------------ def __init__(self, aIsAlive, aWorld): self._world = None self._drops = None self._stateAliveNormal = None self._stateAlive = None self._state = None self._isAlive = None super().__init__() self._isAlive = aIsAlive self._drops = [] didAddWorld = self.setWorld(aWorld) if not didAddWorld : raise RuntimeError ("Unable to create animal due to world. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html") self.setStateAlive(Animal.StateAlive.Null) self.setStateAliveNormal(Animal.StateAliveNormal.Null) self.setState(Animal.State.alive) #------------------------ # INTERFACE #------------------------ def setIsAlive(self, aIsAlive): wasSet = False self._isAlive = aIsAlive wasSet = True return wasSet def getIsAlive(self): return self._isAlive # Code from template attribute_IsBoolean def isIsAlive(self): return self._isAlive def getStateFullName(self): answer = self._state.__str__() if self._stateAlive != Animal.StateAlive.Null : answer += "." + self._stateAlive.__str__() if self._stateAliveNormal != Animal.StateAliveNormal.Null : answer += "." + self._stateAliveNormal.__str__() return answer def getState(self): return self._state def getStateAlive(self): return self._stateAlive def getStateAliveNormal(self): return self._stateAliveNormal def kill(self): wasEventProcessed = False aState = self._state if aState == Animal.State.alive : self.exitState() self.setState(Animal.State.dead) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def haveBaby(self): wasEventProcessed = False aStateAlive = self._stateAlive if aStateAlive == Animal.StateAlive.zombie : self.exitStateAlive() self.setStateAliveNormal(Animal.StateAliveNormal.adult) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def growUp(self): wasEventProcessed = False aStateAliveNormal = self._stateAliveNormal if aStateAliveNormal == Animal.StateAliveNormal.baby : self.exitStateAliveNormal() self.setStateAliveNormal(Animal.StateAliveNormal.adult) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def zombify(self): wasEventProcessed = False aStateAliveNormal = self._stateAliveNormal if aStateAliveNormal == Animal.StateAliveNormal.adult : self.exitStateAlive() self.setStateAlive(Animal.StateAlive.zombie) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitState(self): if self._state == Animal.State.alive : self.exitStateAlive() def setState(self, aState): self._state = aState # entry actions and do activities if self._state == Animal.State.alive : if self._stateAlive == Animal.StateAlive.Null : self.setStateAlive(Animal.StateAlive.normal) def exitStateAlive(self): if self._stateAlive == Animal.StateAlive.normal : self.exitStateAliveNormal() self.setStateAlive(Animal.StateAlive.Null) elif self._stateAlive == Animal.StateAlive.zombie : self.setStateAlive(Animal.StateAlive.Null) def setStateAlive(self, aStateAlive): self._stateAlive = aStateAlive if self._state != Animal.State.alive and aStateAlive != Animal.StateAlive.Null : self.setState(Animal.State.alive) # entry actions and do activities if self._stateAlive == Animal.StateAlive.normal : if self._stateAliveNormal == Animal.StateAliveNormal.Null : self.setStateAliveNormal(Animal.StateAliveNormal.baby) def exitStateAliveNormal(self): if self._stateAliveNormal == Animal.StateAliveNormal.baby : self.setStateAliveNormal(Animal.StateAliveNormal.Null) elif self._stateAliveNormal == Animal.StateAliveNormal.adult : self.setStateAliveNormal(Animal.StateAliveNormal.Null) def setStateAliveNormal(self, aStateAliveNormal): self._stateAliveNormal = aStateAliveNormal if self._stateAlive != Animal.StateAlive.normal and aStateAliveNormal != Animal.StateAliveNormal.Null : self.setStateAlive(Animal.StateAlive.normal) # Code from template association_GetMany def getDrop(self, index): aDrop = self._drops[index] return aDrop def getDrops(self): newDrops = tuple(self._drops) return newDrops def numberOfDrops(self): number = len(self._drops) return number def hasDrops(self): has = len(self._drops) > 0 return has def indexOfDrop(self, aDrop): index = (-1 if not aDrop in self._drops else self._drops.index(aDrop)) return index # Code from template association_GetOne def getWorld(self): return self._world # Code from template association_MinimumNumberOfMethod @staticmethod def minimumNumberOfDrops(): return 0 # Code from template association_AddManyToManyMethod def addDrop(self, aDrop): wasAdded = False if (aDrop) in self._drops : return False self._drops.append(aDrop) if aDrop.indexOfAnimal(self) != -1 : wasAdded = True else : wasAdded = aDrop.addAnimal(self) if not wasAdded : self._drops.remove(aDrop) return wasAdded # Code from template association_RemoveMany def removeDrop(self, aDrop): wasRemoved = False if not (aDrop) in self._drops : return wasRemoved oldIndex = (-1 if not aDrop in self._drops else self._drops.index(aDrop)) self._drops.remove(oldIndex) if aDrop.indexOfAnimal(self) == -1 : wasRemoved = True else : wasRemoved = aDrop.removeAnimal(self) if not wasRemoved : self._drops.insert(oldIndex, aDrop) return wasRemoved # Code from template association_AddIndexControlFunctions def addDropAt(self, aDrop, index): wasAdded = False if self.addDrop(aDrop) : if index < 0 : index = 0 if index > self.numberOfDrops() : index = self.numberOfDrops() - 1 self._drops.remove(aDrop) self._drops.insert(index, aDrop) wasAdded = True return wasAdded def addOrMoveDropAt(self, aDrop, index): wasAdded = False if (aDrop) in self._drops : if index < 0 : index = 0 if index > self.numberOfDrops() : index = self.numberOfDrops() - 1 self._drops.remove(aDrop) self._drops.insert(index, aDrop) wasAdded = True else : wasAdded = self.addDropAt(aDrop, index) return wasAdded # Code from template association_SetOneToMany def setWorld(self, aWorld): wasSet = False if aWorld is None : return wasSet existingWorld = self._world self._world = aWorld if not (existingWorld is None) and not existingWorld == aWorld : existingWorld.removeAnimal(self) self._world.addAnimal(self) wasSet = True return wasSet def delete(self): copyOfDrops = self._drops.copy() self._drops.clear() for aDrop in copyOfDrops: aDrop.removeAnimal(self) placeholderWorld = self._world self._world = None if not (placeholderWorld is None) : placeholderWorld.removeAnimal(self) super().delete() def __str__(self): return str(super().__str__()) + "[" + "isAlive" + ":" + str(self.getIsAlive()) + "]" + str(os.linesep) + " " + "world = " + ((format(id(self.getWorld()), "x")) if not (self.getWorld() is None) else "null") #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../refactorFinalState_onlyEntryAction.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) on = auto() off = auto() FINAL = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(X.Status.on) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def turnoff(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.on : self.setStatus(X.Status.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def powerOff(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.on : self.setStatus(X.Status.FINAL) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def turnOn(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.off : self.setStatus(X.Status.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == X.Status.FINAL : # line 13 "../refactorFinalState_onlyEntryAction.ump" entry() self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "duplicateTimeoutVariableAndMethod.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() class Sm2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() #Helper Variables #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._sm2_timeouts1Tos2Handler = None self._sm1_timeouts1Tos2Handler = None self._sm2 = None self._sm1 = None self.setSm1(X.Sm1.s1) self.setSm2(X.Sm2.s1) #------------------------ # INTERFACE #------------------------ def getSm1FullName(self): answer = self._sm1.__str__() return answer def getSm2FullName(self): answer = self._sm2.__str__() return answer def getSm1(self): return self._sm1 def getSm2(self): return self._sm2 def timeouts1Tos2(self): wasEventProcessed = False aSm1 = self._sm1 aSm2 = self._sm2 if aSm1 == X.Sm1.s1 : self.exitSm1() self.setSm1(X.Sm1.s2) wasEventProcessed = True else : # Other states do respond to this event pass if aSm2 == X.Sm1.s1 : self.exitSm2() self.setSm2(X.Sm2.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm1(self): if self._sm1 == X.Sm1.s1 : self.stopSm1_timeouts1Tos2Handler() def setSm1(self, aSm1): self._sm1 = aSm1 # entry actions and do activities if self._sm1 == X.Sm1.s1 : self.startSm1_timeouts1Tos2Handler() def exitSm2(self): if self._sm2 == X.Sm1.s1 : self.stopSm2_timeouts1Tos2Handler() def setSm2(self, aSm2): self._sm2 = aSm2 # entry actions and do activities if self._sm2 == X.Sm1.s1 : self.startSm2_timeouts1Tos2Handler() def startSm1_timeouts1Tos2Handler(self): self._sm1_timeouts1Tos2Handler = self.TimedEventHandler(self, "sm1_timeouts1Tos2", 1) def stopSm1_timeouts1Tos2Handler(self): self._sm1_timeouts1Tos2Handler.stop() def startSm2_timeouts1Tos2Handler(self): self._sm2_timeouts1Tos2Handler = self.TimedEventHandler(self, "sm2_timeouts1Tos2", 1) def stopSm2_timeouts1Tos2Handler(self): self._sm2_timeouts1Tos2Handler.stop() class TimedEventHandler(): def __init__(self, aController, aTimeoutMethodName, aHowLongInSeconds): from threading import Timer self._timer = None self._howLongInSeconds = None self._timeoutMethodName = None self._controller = None self._controller = aController self._timeoutMethodName = aTimeoutMethodName self._howLongInSeconds = aHowLongInSeconds self._timer = None self._timer = Timer(self._howLongInSeconds, self.run) self._timer.start() def stop(self): self._timer.cancel() def run(self): if "sm1_timeouts1Tos2" == self._timeoutMethodName : shouldRestart = not self._controller.timeouts1Tos2() if shouldRestart : self._controller.startSm1_timeouts1Tos2Handler() return if "sm2_timeouts1Tos2" == self._timeoutMethodName : shouldRestart = not self._controller.timeouts1Tos2() if shouldRestart : self._controller.startSm2_timeouts1Tos2Handler() return def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../multipleGuardsSameEventWithDefaultNoGuard.ump" from enum import Enum, auto class LightFixture(): #------------------------ # MEMBER VARIABLES #------------------------ #LightFixture Attributes #LightFixture State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) On = auto() Off = auto() Amber = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._bulb = None self._brightness = None self._brightness = 0 self.setBulb(LightFixture.Bulb.On) #------------------------ # INTERFACE #------------------------ def setBrightness(self, aBrightness): wasSet = False self._brightness = aBrightness wasSet = True return wasSet def getBrightness(self): return self._brightness def getBulbFullName(self): answer = self._bulb.__str__() return answer def getBulb(self): return self._bulb def push(self): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.On : if self.getBrightness() < 1 : self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True if self.getBrightness() > 10 : self.setBulb(LightFixture.Bulb.Amber) wasEventProcessed = True self.setBulb(LightFixture.Bulb.On) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setBulb(self, aBulb): self._bulb = aBulb def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "brightness" + ":" + str(self.getBrightness()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../refactorFinalState_empty.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) on = auto() off = auto() FINAL = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(X.Status.on) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def turnoff(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.on : self.setStatus(X.Status.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def powerOff(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.on : self.setStatus(X.Status.FINAL) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def turnOn(self): wasEventProcessed = False aStatus = self._status if aStatus == X.Status.off : self.setStatus(X.Status.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == X.Status.FINAL : self.delete() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 16 "../SimpleStateMachineSpacing.ump" from enum import Enum, auto class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() Full = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def setStatus(self, aStatus): self._status = aStatus return True def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../concurrentStates_normal.ump" from enum import Enum, auto class LightFixture(): #------------------------ # MEMBER VARIABLES #------------------------ #LightFixture State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Off = auto() On = auto() class StatusOnMotorIdle(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() MotorIdle = auto() MotorRunning = auto() class StatusOnFanIdle(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() FanIdle = auto() FanRunning = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._statusOnFanIdle = None self._statusOnMotorIdle = None self._status = None self.setStatusOnMotorIdle(LightFixture.StatusOnMotorIdle.Null) self.setStatusOnFanIdle(LightFixture.StatusOnFanIdle.Null) self.setStatus(LightFixture.Status.Off) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() if self._statusOnMotorIdle != LightFixture.StatusOnMotorIdle.Null : answer += "." + self._statusOnMotorIdle.__str__() if self._statusOnFanIdle != LightFixture.StatusOnFanIdle.Null : answer += "." + self._statusOnFanIdle.__str__() return answer def getStatus(self): return self._status def getStatusOnMotorIdle(self): return self._statusOnMotorIdle def getStatusOnFanIdle(self): return self._statusOnFanIdle def turnOn(self): wasEventProcessed = False aStatus = self._status if aStatus == LightFixture.Status.Off : self.setStatus(LightFixture.Status.On) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def flip(self): wasEventProcessed = False aStatusOnMotorIdle = self._statusOnMotorIdle if aStatusOnMotorIdle == LightFixture.StatusOnMotorIdle.MotorIdle : self.exitStatusOnMotorIdle() self.setStatusOnMotorIdle(LightFixture.StatusOnMotorIdle.MotorRunning) wasEventProcessed = True elif aStatusOnMotorIdle == LightFixture.StatusOnMotorIdle.MotorRunning : self.exitStatusOnMotorIdle() self.setStatusOnMotorIdle(LightFixture.StatusOnMotorIdle.MotorIdle) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def flop(self): wasEventProcessed = False aStatusOnFanIdle = self._statusOnFanIdle if aStatusOnFanIdle == LightFixture.StatusOnFanIdle.FanIdle : self.exitStatusOnFanIdle() self.setStatusOnFanIdle(LightFixture.StatusOnFanIdle.FanRunning) wasEventProcessed = True elif aStatusOnFanIdle == LightFixture.StatusOnFanIdle.FanRunning : self.exitStatusOnFanIdle() self.setStatusOnFanIdle(LightFixture.StatusOnFanIdle.FanIdle) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitStatus(self): if self._status == LightFixture.Status.On : self.exitStatusOnMotorIdle() self.exitStatusOnFanIdle() def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == LightFixture.Status.On : if self._statusOnMotorIdle == LightFixture.StatusOnMotorIdle.Null : self.setStatusOnMotorIdle(LightFixture.StatusOnMotorIdle.MotorIdle) if self._statusOnFanIdle == LightFixture.StatusOnFanIdle.Null : self.setStatusOnFanIdle(LightFixture.StatusOnFanIdle.FanIdle) def exitStatusOnMotorIdle(self): if self._statusOnMotorIdle == LightFixture.StatusOnMotorIdle.MotorIdle : self.setStatusOnMotorIdle(LightFixture.StatusOnMotorIdle.Null) elif self._statusOnMotorIdle == LightFixture.StatusOnMotorIdle.MotorRunning : self.setStatusOnMotorIdle(LightFixture.StatusOnMotorIdle.Null) def setStatusOnMotorIdle(self, aStatusOnMotorIdle): self._statusOnMotorIdle = aStatusOnMotorIdle if self._status != LightFixture.Status.On and aStatusOnMotorIdle != LightFixture.StatusOnMotorIdle.Null : self.setStatus(LightFixture.Status.On) def exitStatusOnFanIdle(self): if self._statusOnFanIdle == LightFixture.StatusOnFanIdle.FanIdle : self.setStatusOnFanIdle(LightFixture.StatusOnFanIdle.Null) elif self._statusOnFanIdle == LightFixture.StatusOnFanIdle.FanRunning : self.setStatusOnFanIdle(LightFixture.StatusOnFanIdle.Null) def setStatusOnFanIdle(self, aStatusOnFanIdle): self._statusOnFanIdle = aStatusOnFanIdle if self._status != LightFixture.Status.On and aStatusOnFanIdle != LightFixture.StatusOnFanIdle.Null : self.setStatus(LightFixture.Status.On) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../EmptyAndNonEmptyStates.ump" from enum import Enum, auto class Light(): #------------------------ # MEMBER VARIABLES #------------------------ #Light State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) On = auto() Off = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Light.Status.On) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def flip(self): wasEventProcessed = False aStatus = self._status if aStatus == Light.Status.On : self.setStatus(Light.Status.Off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../capitalizedStateMachineAttribute.ump" from enum import Enum, auto class Garage(): #------------------------ # MEMBER VARIABLES #------------------------ #Garage State Machines class GarageDoor(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._garageDoor = None #------------------------ # INTERFACE #------------------------ def getGarageDoorFullName(self): answer = self._garageDoor.__str__() return answer def getGarageDoor(self): return self._garageDoor def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "stateMachineWithStringComparisonGuard.ump" from enum import Enum, auto class stateMachineWithStringComparisonGuard(): #------------------------ # MEMBER VARIABLES #------------------------ #stateMachineWithStringComparisonGuard Attributes #stateMachineWithStringComparisonGuard State Machines class CommandControl(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) IDLE = auto() CHECK_AVAILABILITY = auto() COMMAND_VALIDITY = auto() EXECUTION = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._commandControl = None self._cmdString = None self._cmdString = "" self.setCommandControl(stateMachineWithStringComparisonGuard.CommandControl.IDLE) #------------------------ # INTERFACE #------------------------ def setCmdString(self, aCmdString): wasSet = False self._cmdString = aCmdString wasSet = True return wasSet def getCmdString(self): return self._cmdString def getCommandControlFullName(self): answer = self._commandControl.__str__() return answer def getCommandControl(self): return self._commandControl def execute(self): wasEventProcessed = False aCommandControl = self._commandControl if aCommandControl == stateMachineWithStringComparisonGuard.CommandControl.IDLE : self.setCommandControl(stateMachineWithStringComparisonGuard.CommandControl.CHECK_AVAILABILITY) wasEventProcessed = True elif aCommandControl == stateMachineWithStringComparisonGuard.CommandControl.CHECK_AVAILABILITY : if not "" == self.getCmdString() : self.setCommandControl(stateMachineWithStringComparisonGuard.CommandControl.COMMAND_VALIDITY) wasEventProcessed = True elif aCommandControl == stateMachineWithStringComparisonGuard.CommandControl.COMMAND_VALIDITY : if isCommandValid(self.getCmdString()) : self.setCommandControl(stateMachineWithStringComparisonGuard.CommandControl.EXECUTION) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setCommandControl(self, aCommandControl): self._commandControl = aCommandControl def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "cmdString" + ":" + str(self.getCmdString()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "checkExternalTransitions_withExitActions_2.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) on = auto() off = auto() class SmOn(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() m1 = auto() m2 = auto() class SmOnM1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t2 = auto() t3 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smOnM1 = None self._smOn = None self._sm = None self.setSmOn(X.SmOn.Null) self.setSmOnM1(X.SmOnM1.Null) self.setSm(X.Sm.on) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smOn != X.SmOn.Null : answer += "." + self._smOn.__str__() if self._smOnM1 != X.SmOnM1.Null : answer += "." + self._smOnM1.__str__() return answer def getSm(self): return self._sm def getSmOn(self): return self._smOn def getSmOnM1(self): return self._smOnM1 def e1(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.on : self.exitSm() self.setSm(X.Sm.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e2(self): wasEventProcessed = False aSmOn = self._smOn if aSmOn == X.SmOn.m1 : self.exitSmOn() self.setSmOn(X.SmOn.m2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e3(self): wasEventProcessed = False aSmOnM1 = self._smOnM1 if aSmOnM1 == X.SmOnM1.t2 : self.exitSmOnM1() self.setSmOnM1(X.SmOnM1.t3) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.on : self.exitSmOn() # line 4 "checkExternalTransitions_withExitActions_2.ump" on_exit_action() elif self._sm == X.Sm.off : # line 18 "checkExternalTransitions_withExitActions_2.ump" off_exit_action() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.on : if self._smOn == X.SmOn.Null : self.setSmOn(X.SmOn.m1) def exitSmOn(self): if self._smOn == X.SmOn.m1 : self.exitSmOnM1() # line 7 "checkExternalTransitions_withExitActions_2.ump" m1_exit_action() self.setSmOn(X.SmOn.Null) elif self._smOn == X.SmOn.m2 : self.setSmOn(X.SmOn.Null) def setSmOn(self, aSmOn): self._smOn = aSmOn if self._sm != X.Sm.on and aSmOn != X.SmOn.Null : self.setSm(X.Sm.on) # entry actions and do activities if self._smOn == X.SmOn.m1 : if self._smOnM1 == X.SmOnM1.Null : self.setSmOnM1(X.SmOnM1.t2) def exitSmOnM1(self): if self._smOnM1 == X.SmOnM1.t2 : # line 10 "checkExternalTransitions_withExitActions_2.ump" t2_exit_action() self.setSmOnM1(X.SmOnM1.Null) elif self._smOnM1 == X.SmOnM1.t3 : self.setSmOnM1(X.SmOnM1.Null) def setSmOnM1(self, aSmOnM1): self._smOnM1 = aSmOnM1 if self._smOn != X.SmOn.m1 and aSmOnM1 != X.SmOnM1.Null : self.setSmOn(X.SmOn.m1) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "parallelSm_sameNameDiffStates_2.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s0 = auto() s1 = auto() class SmS0T1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t1 = auto() class SmS0T2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t2 = auto() t3 = auto() class SmS1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2 = auto() s3 = auto() class SmS1S2T1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t1 = auto() t4 = auto() class SmS1S2T6(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t6 = auto() class SmS1S2T2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t2 = auto() t5 = auto() class SmS1S3T7(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t7 = auto() t8 = auto() class SmS1S3T6(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t6 = auto() t9 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS1S3T6 = None self._smS1S3T7 = None self._smS1S2T2 = None self._smS1S2T6 = None self._smS1S2T1 = None self._smS1 = None self._smS0T2 = None self._smS0T1 = None self._sm = None self.setSmS0T1(X.SmS0T1.Null) self.setSmS0T2(X.SmS0T2.Null) self.setSmS1(X.SmS1.Null) self.setSmS1S2T1(X.SmS1S2T1.Null) self.setSmS1S2T6(X.SmS1S2T6.Null) self.setSmS1S2T2(X.SmS1S2T2.Null) self.setSmS1S3T7(X.SmS1S3T7.Null) self.setSmS1S3T6(X.SmS1S3T6.Null) self.setSm(X.Sm.s0) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS0T1 != X.SmS0T1.Null : answer += "." + self._smS0T1.__str__() if self._smS0T2 != X.SmS0T2.Null : answer += "." + self._smS0T2.__str__() if self._smS1 != X.SmS1.Null : answer += "." + self._smS1.__str__() if self._smS1S2T1 != X.SmS1S2T1.Null : answer += "." + self._smS1S2T1.__str__() if self._smS1S2T6 != X.SmS1S2T6.Null : answer += "." + self._smS1S2T6.__str__() if self._smS1S2T2 != X.SmS1S2T2.Null : answer += "." + self._smS1S2T2.__str__() if self._smS1S3T7 != X.SmS1S3T7.Null : answer += "." + self._smS1S3T7.__str__() if self._smS1S3T6 != X.SmS1S3T6.Null : answer += "." + self._smS1S3T6.__str__() return answer def getSm(self): return self._sm def getSmS0T1(self): return self._smS0T1 def getSmS0T2(self): return self._smS0T2 def getSmS1(self): return self._smS1 def getSmS1S2T1(self): return self._smS1S2T1 def getSmS1S2T6(self): return self._smS1S2T6 def getSmS1S2T2(self): return self._smS1S2T2 def getSmS1S3T7(self): return self._smS1S3T7 def getSmS1S3T6(self): return self._smS1S3T6 def goS1(self): wasEventProcessed = False aSmS0T1 = self._smS0T1 aSmS0T2 = self._smS0T2 if aSmS0T1 == X.SmS0T1.t1 : self.exitSm() self.setSm(X.Sm.s1) wasEventProcessed = True else : # Other states do respond to this event pass if aSmS0T2 == X.SmS0T2.t2 : self.exitSm() self.setSm(X.Sm.s1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT4(self): wasEventProcessed = False aSmS1S2T1 = self._smS1S2T1 if aSmS1S2T1 == X.SmS0T1.t1 : self.exitSmS1S2T1() self.setSmS1S2T1(X.SmS1S2T1.t4) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT5(self): wasEventProcessed = False aSmS1S2T6 = self._smS1S2T6 aSmS1S2T2 = self._smS1S2T2 if aSmS1S2T6 == X.SmS1S2T6.t6 : self.exitSmS1S2T6() self.setSmS1S2T2(X.SmS1S2T2.t5) self.setSmS1S2T6(X.SmS1S2T6.t6) wasEventProcessed = True else : # Other states do respond to this event pass if aSmS1S2T2 == X.SmS0T2.t2 : self.exitSmS1S2T2() self.setSmS1S2T2(X.SmS1S2T2.t5) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT8(self): wasEventProcessed = False aSmS1S3T7 = self._smS1S3T7 if aSmS1S3T7 == X.SmS1S3T7.t7 : self.exitSmS1S3T7() self.setSmS1S3T7(X.SmS1S3T7.t8) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT9(self): wasEventProcessed = False aSmS1S3T6 = self._smS1S3T6 if aSmS1S3T6 == X.SmS1S2T6.t6 : self.exitSmS1S3T6() self.setSmS1S3T6(X.SmS1S3T6.t9) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s0 : self.exitSmS0T1() self.exitSmS0T2() elif self._sm == X.Sm.s1 : self.exitSmS1() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s0 : if self._smS0T1 == X.SmS0T1.Null : self.setSmS0T1(X.SmS0T1.t1) if self._smS0T2 == X.SmS0T2.Null : self.setSmS0T2(X.SmS0T2.t2) elif self._sm == X.Sm.s1 : if self._smS1 == X.SmS1.Null : self.setSmS1(X.SmS1.s2) def exitSmS0T1(self): if self._smS0T1 == X.SmS0T1.t1 : self.setSmS0T1(X.SmS0T1.Null) def setSmS0T1(self, aSmS0T1): self._smS0T1 = aSmS0T1 if self._sm != X.Sm.s0 and aSmS0T1 != X.SmS0T1.Null : self.setSm(X.Sm.s0) def exitSmS0T2(self): if self._smS0T2 == X.SmS0T2.t2 : self.setSmS0T2(X.SmS0T2.Null) elif self._smS0T2 == X.SmS0T2.t3 : self.setSmS0T2(X.SmS0T2.Null) def setSmS0T2(self, aSmS0T2): self._smS0T2 = aSmS0T2 if self._sm != X.Sm.s0 and aSmS0T2 != X.SmS0T2.Null : self.setSm(X.Sm.s0) def exitSmS1(self): if self._smS1 == X.SmS1.s2 : self.exitSmS1S2T1() self.exitSmS1S2T6() self.exitSmS1S2T2() self.setSmS1(X.SmS1.Null) elif self._smS1 == X.SmS1.s3 : self.exitSmS1S3T7() self.exitSmS1S3T6() self.setSmS1(X.SmS1.Null) def setSmS1(self, aSmS1): self._smS1 = aSmS1 if self._sm != X.Sm.s1 and aSmS1 != X.SmS1.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1 == X.SmS1.s2 : if self._smS1S2T1 == X.SmS1S2T1.Null : self.setSmS1S2T1(X.SmS1S2T1.t1) if self._smS1S2T6 == X.SmS1S2T6.Null : self.setSmS1S2T6(X.SmS1S2T6.t6) if self._smS1S2T2 == X.SmS1S2T2.Null : self.setSmS1S2T2(X.SmS1S2T2.t2) elif self._smS1 == X.SmS1.s3 : if self._smS1S3T7 == X.SmS1S3T7.Null : self.setSmS1S3T7(X.SmS1S3T7.t7) if self._smS1S3T6 == X.SmS1S3T6.Null : self.setSmS1S3T6(X.SmS1S3T6.t6) def exitSmS1S2T1(self): if self._smS1S2T1 == X.SmS0T1.t1 : self.setSmS1S2T1(X.SmS1S2T1.Null) elif self._smS1S2T1 == X.SmS1S2T1.t4 : self.setSmS1S2T1(X.SmS1S2T1.Null) def setSmS1S2T1(self, aSmS1S2T1): self._smS1S2T1 = aSmS1S2T1 if self._smS1 != X.SmS1.s2 and aSmS1S2T1 != X.SmS1S2T1.Null : self.setSmS1(X.SmS1.s2) def exitSmS1S2T6(self): if self._smS1S2T6 == X.SmS1S2T6.t6 : self.setSmS1S2T6(X.SmS1S2T6.Null) def setSmS1S2T6(self, aSmS1S2T6): self._smS1S2T6 = aSmS1S2T6 if self._smS1 != X.SmS1.s2 and aSmS1S2T6 != X.SmS1S2T6.Null : self.setSmS1(X.SmS1.s2) def exitSmS1S2T2(self): if self._smS1S2T2 == X.SmS0T2.t2 : self.setSmS1S2T2(X.SmS1S2T2.Null) elif self._smS1S2T2 == X.SmS1S2T2.t5 : self.setSmS1S2T2(X.SmS1S2T2.Null) def setSmS1S2T2(self, aSmS1S2T2): self._smS1S2T2 = aSmS1S2T2 if self._smS1 != X.SmS1.s2 and aSmS1S2T2 != X.SmS1S2T2.Null : self.setSmS1(X.SmS1.s2) def exitSmS1S3T7(self): if self._smS1S3T7 == X.SmS1S3T7.t7 : self.setSmS1S3T7(X.SmS1S3T7.Null) elif self._smS1S3T7 == X.SmS1S3T7.t8 : self.setSmS1S3T7(X.SmS1S3T7.Null) def setSmS1S3T7(self, aSmS1S3T7): self._smS1S3T7 = aSmS1S3T7 if self._smS1 != X.SmS1.s3 and aSmS1S3T7 != X.SmS1S3T7.Null : self.setSmS1(X.SmS1.s3) def exitSmS1S3T6(self): if self._smS1S3T6 == X.SmS1S2T6.t6 : self.setSmS1S3T6(X.SmS1S3T6.Null) elif self._smS1S3T6 == X.SmS1S3T6.t9 : self.setSmS1S3T6(X.SmS1S3T6.Null) def setSmS1S3T6(self, aSmS1S3T6): self._smS1S3T6 = aSmS1S3T6 if self._smS1 != X.SmS1.s3 and aSmS1S3T6 != X.SmS1S3T6.Null : self.setSmS1(X.SmS1.s3) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 13 "../EventTransitionSpacing.ump" from enum import Enum, auto class Light(): #------------------------ # MEMBER VARIABLES #------------------------ #Light State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Off = auto() On = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._bulb = None self.setBulb(Light.Bulb.Off) #------------------------ # INTERFACE #------------------------ def getBulbFullName(self): answer = self._bulb.__str__() return answer def getBulb(self): return self._bulb def flip(self): wasEventProcessed = False aBulb = self._bulb if aBulb == Light.Bulb.Off : self.setBulb(Light.Bulb.On) wasEventProcessed = True elif aBulb == Light.Bulb.On : self.setBulb(Light.Bulb.Off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setBulb(self, aBulb): self._bulb = aBulb def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "checkExternalTransitions_concurrentStateMachines_2.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s4 = auto() class SmS1S2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2 = auto() class SmS1S2A(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() a = auto() class SmS1S2AA(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t1 = auto() t2 = auto() class SmS1S2B(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() b = auto() class SmS1S2BB(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t3 = auto() t4 = auto() class SmS1S3(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s3 = auto() class SmS1S3S3(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t5 = auto() t6 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS1S3S3 = None self._smS1S3 = None self._smS1S2BB = None self._smS1S2B = None self._smS1S2AA = None self._smS1S2A = None self._smS1S2 = None self._sm = None self.setSmS1S2(X.SmS1S2.Null) self.setSmS1S2A(X.SmS1S2A.Null) self.setSmS1S2AA(X.SmS1S2AA.Null) self.setSmS1S2B(X.SmS1S2B.Null) self.setSmS1S2BB(X.SmS1S2BB.Null) self.setSmS1S3(X.SmS1S3.Null) self.setSmS1S3S3(X.SmS1S3S3.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1S2 != X.SmS1S2.Null : answer += "." + self._smS1S2.__str__() if self._smS1S2A != X.SmS1S2A.Null : answer += "." + self._smS1S2A.__str__() if self._smS1S2AA != X.SmS1S2AA.Null : answer += "." + self._smS1S2AA.__str__() if self._smS1S2B != X.SmS1S2B.Null : answer += "." + self._smS1S2B.__str__() if self._smS1S2BB != X.SmS1S2BB.Null : answer += "." + self._smS1S2BB.__str__() if self._smS1S3 != X.SmS1S3.Null : answer += "." + self._smS1S3.__str__() if self._smS1S3S3 != X.SmS1S3S3.Null : answer += "." + self._smS1S3S3.__str__() if self._smS1S2AA != X.SmS1S2AA.Null : answer += "." + self._smS1S2AA.__str__() if self._smS1S2BB != X.SmS1S2BB.Null : answer += "." + self._smS1S2BB.__str__() return answer def getSm(self): return self._sm def getSmS1S2(self): return self._smS1S2 def getSmS1S2A(self): return self._smS1S2A def getSmS1S2AA(self): return self._smS1S2AA def getSmS1S2B(self): return self._smS1S2B def getSmS1S2BB(self): return self._smS1S2BB def getSmS1S3(self): return self._smS1S3 def getSmS1S3S3(self): return self._smS1S3S3 def goToT2(self): wasEventProcessed = False aSmS1S2AA = self._smS1S2AA if aSmS1S2AA == X.SmS1S2AA.t1 : self.exitSmS1S2AA() self.setSmS1S2AA(X.SmS1S2AA.t2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToT4(self): wasEventProcessed = False aSmS1S2AA = self._smS1S2AA if aSmS1S2AA == X.SmS1S2AA.t2 : self.exitSmS1S2() self.setSmS1S2BB(X.SmS1S2BB.t4) self.setSmS1S2A(X.SmS1S2A.a) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToT5(self): wasEventProcessed = False aSmS1S2BB = self._smS1S2BB if aSmS1S2BB == X.SmS1S2BB.t3 : self.exitSmS1S2() self.setSmS1S3S3(X.SmS1S3S3.t5) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToS4(self): wasEventProcessed = False aSmS1S2BB = self._smS1S2BB if aSmS1S2BB == X.SmS1S2BB.t4 : self.exitSm() self.setSm(X.Sm.s4) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToT6(self): wasEventProcessed = False aSmS1S3S3 = self._smS1S3S3 if aSmS1S3S3 == X.SmS1S3S3.t5 : self.exitSmS1S3S3() self.setSmS1S3S3(X.SmS1S3S3.t6) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToAT2(self): wasEventProcessed = False aSmS1S3S3 = self._smS1S3S3 if aSmS1S3S3 == X.SmS1S3S3.t6 : self.exitSmS1S2() self.setSmS1S2AA(X.SmS1S2AA.t2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1S2() self.exitSmS1S3() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1S2 == X.SmS1S2.Null : self.setSmS1S2(X.SmS1S2.s2) if self._smS1S3 == X.SmS1S3.Null : self.setSmS1S3(X.SmS1S3.s3) def exitSmS1S2(self): if self._smS1S2 == X.SmS1S2.s2 : self.exitSmS1S2A() self.exitSmS1S2B() self.setSmS1S2(X.SmS1S2.Null) def setSmS1S2(self, aSmS1S2): self._smS1S2 = aSmS1S2 if self._sm != X.Sm.s1 and aSmS1S2 != X.SmS1S2.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1S2 == X.SmS1S2.s2 : if self._smS1S2A == X.SmS1S2A.Null : self.setSmS1S2A(X.SmS1S2A.a) if self._smS1S2B == X.SmS1S2B.Null : self.setSmS1S2B(X.SmS1S2B.b) def exitSmS1S2A(self): if self._smS1S2A == X.SmS1S2A.a : self.exitSmS1S2AA() # line 6 "checkExternalTransitions_concurrentStateMachines_2.ump" exit_a_action() self.setSmS1S2A(X.SmS1S2A.Null) def setSmS1S2A(self, aSmS1S2A): self._smS1S2A = aSmS1S2A if self._smS1S2 != X.SmS1S2.s2 and aSmS1S2A != X.SmS1S2A.Null : self.setSmS1S2(X.SmS1S2.s2) # entry actions and do activities if self._smS1S2A == X.SmS1S2A.a : if self._smS1S2AA == X.SmS1S2AA.Null : self.setSmS1S2AA(X.SmS1S2AA.t1) def exitSmS1S2AA(self): if self._smS1S2AA == X.SmS1S2AA.t1 : self.setSmS1S2AA(X.SmS1S2AA.Null) elif self._smS1S2AA == X.SmS1S2AA.t2 : self.setSmS1S2AA(X.SmS1S2AA.Null) def setSmS1S2AA(self, aSmS1S2AA): self._smS1S2AA = aSmS1S2AA if self._smS1S2A != X.SmS1S2A.a and aSmS1S2AA != X.SmS1S2AA.Null : self.setSmS1S2A(X.SmS1S2A.a) def exitSmS1S2B(self): if self._smS1S2B == X.SmS1S2B.b : self.exitSmS1S2BB() # line 16 "checkExternalTransitions_concurrentStateMachines_2.ump" exit_b_action() self.setSmS1S2B(X.SmS1S2B.Null) def setSmS1S2B(self, aSmS1S2B): self._smS1S2B = aSmS1S2B if self._smS1S2 != X.SmS1S2.s2 and aSmS1S2B != X.SmS1S2B.Null : self.setSmS1S2(X.SmS1S2.s2) # entry actions and do activities if self._smS1S2B == X.SmS1S2B.b : if self._smS1S2BB == X.SmS1S2BB.Null : self.setSmS1S2BB(X.SmS1S2BB.t3) def exitSmS1S2BB(self): if self._smS1S2BB == X.SmS1S2BB.t3 : self.setSmS1S2BB(X.SmS1S2BB.Null) elif self._smS1S2BB == X.SmS1S2BB.t4 : self.setSmS1S2BB(X.SmS1S2BB.Null) def setSmS1S2BB(self, aSmS1S2BB): self._smS1S2BB = aSmS1S2BB if self._smS1S2B != X.SmS1S2B.b and aSmS1S2BB != X.SmS1S2BB.Null : self.setSmS1S2B(X.SmS1S2B.b) def exitSmS1S3(self): if self._smS1S3 == X.SmS1S3.s3 : self.exitSmS1S3S3() self.setSmS1S3(X.SmS1S3.Null) def setSmS1S3(self, aSmS1S3): self._smS1S3 = aSmS1S3 if self._sm != X.Sm.s1 and aSmS1S3 != X.SmS1S3.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1S3 == X.SmS1S3.s3 : if self._smS1S3S3 == X.SmS1S3S3.Null : self.setSmS1S3S3(X.SmS1S3S3.t5) def exitSmS1S3S3(self): if self._smS1S3S3 == X.SmS1S3S3.t5 : self.setSmS1S3S3(X.SmS1S3S3.Null) elif self._smS1S3S3 == X.SmS1S3S3.t6 : self.setSmS1S3S3(X.SmS1S3S3.Null) def setSmS1S3S3(self, aSmS1S3S3): self._smS1S3S3 = aSmS1S3S3 if self._smS1S3 != X.SmS1S3.s3 and aSmS1S3S3 != X.SmS1S3S3.Null : self.setSmS1S3(X.SmS1S3.s3) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "nestedStateMachineExtendedByMultipleClasses.ump" from enum import Enum, auto class Animal(): #------------------------ # MEMBER VARIABLES #------------------------ #Animal Attributes #Animal State Machines class State(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) alive = auto() dead = auto() class StateAlive(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() normal = auto() zombie = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self, aIsAlive): self._stateAlive = None self._state = None self._isAlive = None self._isAlive = aIsAlive self.setStateAlive(Animal.StateAlive.Null) self.setState(Animal.State.alive) #------------------------ # INTERFACE #------------------------ def setIsAlive(self, aIsAlive): wasSet = False self._isAlive = aIsAlive wasSet = True return wasSet def getIsAlive(self): return self._isAlive # Code from template attribute_IsBoolean def isIsAlive(self): return self._isAlive def getStateFullName(self): answer = self._state.__str__() if self._stateAlive != Animal.StateAlive.Null : answer += "." + self._stateAlive.__str__() return answer def getState(self): return self._state def getStateAlive(self): return self._stateAlive def kill(self): wasEventProcessed = False aState = self._state if aState == Animal.State.alive : self.exitState() self.setState(Animal.State.dead) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def zombify(self): wasEventProcessed = False aStateAlive = self._stateAlive if aStateAlive == Animal.StateAlive.normal : self.exitStateAlive() self.setStateAlive(Animal.StateAlive.zombie) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def haveBaby(self): wasEventProcessed = False aStateAlive = self._stateAlive if aStateAlive == Animal.StateAlive.zombie : self.exitStateAlive() self.setStateAlive(Animal.StateAlive.normal) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitState(self): if self._state == Animal.State.alive : self.exitStateAlive() def setState(self, aState): self._state = aState # entry actions and do activities if self._state == Animal.State.alive : if self._stateAlive == Animal.StateAlive.Null : self.setStateAlive(Animal.StateAlive.normal) def exitStateAlive(self): if self._stateAlive == Animal.StateAlive.normal : self.setStateAlive(Animal.StateAlive.Null) elif self._stateAlive == Animal.StateAlive.zombie : self.setStateAlive(Animal.StateAlive.Null) def setStateAlive(self, aStateAlive): self._stateAlive = aStateAlive if self._state != Animal.State.alive and aStateAlive != Animal.StateAlive.Null : self.setState(Animal.State.alive) def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "isAlive" + ":" + str(self.getIsAlive()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "eventWithArguments_1.ump" from enum import Enum, auto class LightFixture(): #------------------------ # MEMBER VARIABLES #------------------------ #LightFixture Attributes #LightFixture State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Off = auto() Dimmed = auto() On = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._bulb = None self._brightness = None self._brightness = 0 self.setBulb(LightFixture.Bulb.Off) #------------------------ # INTERFACE #------------------------ def setBrightness(self, aBrightness): wasSet = False self._brightness = aBrightness wasSet = True return wasSet def getBrightness(self): return self._brightness def getBulbFullName(self): answer = self._bulb.__str__() return answer def getBulb(self): return self._bulb def turnDimmer(self, lightval, lightval_1): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.Off : # line 6 "eventWithArguments_1.ump" self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True elif aBulb == LightFixture.Bulb.Dimmed : # line 12 "eventWithArguments_1.ump" self.setBulb(LightFixture.Bulb.Dimmed) wasEventProcessed = True elif aBulb == LightFixture.Bulb.On : # line 16 "eventWithArguments_1.ump" self.setBulb(LightFixture.Bulb.Dimmed) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def flipSwitch(self): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.Off : self.setBulb(LightFixture.Bulb.Dimmed) wasEventProcessed = True elif aBulb == LightFixture.Bulb.Dimmed : self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True elif aBulb == LightFixture.Bulb.On : self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def entry(self): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.Dimmed : if dimmer > 99 : self.setBulb(LightFixture.Bulb.On) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setBulb(self, aBulb): self._bulb = aBulb def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "brightness" + ":" + str(self.getBrightness()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../eventWithArguments_2.ump" from enum import Enum, auto class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def register(self, name, age, grades): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Open : self.setStatus(Course.Status.Open) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../SimpleStateMachineSpacing.ump" from enum import Enum, auto class Mentor(): #------------------------ # MEMBER VARIABLES #------------------------ #Mentor State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "nestedStates_Two_TimedTransition.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() class SmS1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s1a = auto() s1b = auto() class SmS2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s2a = auto() s2b = auto() #Helper Variables #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._timeouts2bTos1bHandler = None self._timeouts1aTos1bHandler = None self._smS2 = None self._smS1 = None self._sm = None self.setSmS1(X.SmS1.Null) self.setSmS2(X.SmS2.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1 != X.SmS1.Null : answer += "." + self._smS1.__str__() if self._smS2 != X.SmS2.Null : answer += "." + self._smS2.__str__() return answer def getSm(self): return self._sm def getSmS1(self): return self._smS1 def getSmS2(self): return self._smS2 def timeouts1aTos1b(self): wasEventProcessed = False aSmS1 = self._smS1 if aSmS1 == X.SmS1.s1a : self.exitSmS1() self.setSmS1(X.SmS1.s1b) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e1(self): wasEventProcessed = False aSmS1 = self._smS1 if aSmS1 == X.SmS1.s1b : self.exitSm() self.setSm(X.Sm.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e2(self): wasEventProcessed = False aSmS2 = self._smS2 if aSmS2 == X.SmS2.s2a : self.exitSm() self.setSm(X.Sm.s1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def timeouts2bTos1b(self): wasEventProcessed = False aSmS2 = self._smS2 if aSmS2 == X.SmS2.s2b : self.exitSm() self.setSmS1(X.SmS1.s1b) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1() elif self._sm == X.Sm.s2 : self.exitSmS2() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1 == X.SmS1.Null : self.setSmS1(X.SmS1.s1a) elif self._sm == X.Sm.s2 : if self._smS2 == X.SmS2.Null : self.setSmS2(X.SmS2.s2a) def exitSmS1(self): if self._smS1 == X.SmS1.s1a : self.setSmS1(X.SmS1.Null) self.stopTimeouts1aTos1bHandler() elif self._smS1 == X.SmS1.s1b : self.setSmS1(X.SmS1.Null) def setSmS1(self, aSmS1): self._smS1 = aSmS1 if self._sm != X.Sm.s1 and aSmS1 != X.SmS1.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1 == X.SmS1.s1a : self.startTimeouts1aTos1bHandler() def exitSmS2(self): if self._smS2 == X.SmS2.s2a : self.setSmS2(X.SmS2.Null) elif self._smS2 == X.SmS2.s2b : self.setSmS2(X.SmS2.Null) self.stopTimeouts2bTos1bHandler() def setSmS2(self, aSmS2): self._smS2 = aSmS2 if self._sm != X.Sm.s2 and aSmS2 != X.SmS2.Null : self.setSm(X.Sm.s2) # entry actions and do activities if self._smS2 == X.SmS2.s2b : self.startTimeouts2bTos1bHandler() def startTimeouts1aTos1bHandler(self): self._timeouts1aTos1bHandler = self.TimedEventHandler(self, "timeouts1aTos1b", 2) def stopTimeouts1aTos1bHandler(self): self._timeouts1aTos1bHandler.stop() def startTimeouts2bTos1bHandler(self): self._timeouts2bTos1bHandler = self.TimedEventHandler(self, "timeouts2bTos1b", 3) def stopTimeouts2bTos1bHandler(self): self._timeouts2bTos1bHandler.stop() class TimedEventHandler(): def __init__(self, aController, aTimeoutMethodName, aHowLongInSeconds): from threading import Timer self._timer = None self._howLongInSeconds = None self._timeoutMethodName = None self._controller = None self._controller = aController self._timeoutMethodName = aTimeoutMethodName self._howLongInSeconds = aHowLongInSeconds self._timer = None self._timer = Timer(self._howLongInSeconds, self.run) self._timer.start() def stop(self): self._timer.cancel() def run(self): if "timeouts1aTos1b" == self._timeoutMethodName : shouldRestart = not self._controller.timeouts1aTos1b() if shouldRestart : self._controller.startTimeouts1aTos1bHandler() return if "timeouts2bTos1b" == self._timeoutMethodName : shouldRestart = not self._controller.timeouts2bTos1b() if shouldRestart : self._controller.startTimeouts2bTos1bHandler() return def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "parallelSm_sameNameDiffStates.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s0 = auto() s1 = auto() class SmS0T1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t1 = auto() class SmS0T2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t2 = auto() t3 = auto() class SmS1T1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t1 = auto() t4 = auto() class SmS1T2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t2 = auto() t5 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS1T2 = None self._smS1T1 = None self._smS0T2 = None self._smS0T1 = None self._sm = None self.setSmS0T1(X.SmS0T1.Null) self.setSmS0T2(X.SmS0T2.Null) self.setSmS1T1(X.SmS1T1.Null) self.setSmS1T2(X.SmS1T2.Null) self.setSm(X.Sm.s0) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS0T1 != X.SmS0T1.Null : answer += "." + self._smS0T1.__str__() if self._smS0T2 != X.SmS0T2.Null : answer += "." + self._smS0T2.__str__() if self._smS1T1 != X.SmS1T1.Null : answer += "." + self._smS1T1.__str__() if self._smS1T2 != X.SmS1T2.Null : answer += "." + self._smS1T2.__str__() return answer def getSm(self): return self._sm def getSmS0T1(self): return self._smS0T1 def getSmS0T2(self): return self._smS0T2 def getSmS1T1(self): return self._smS1T1 def getSmS1T2(self): return self._smS1T2 def goS1(self): wasEventProcessed = False aSmS0T1 = self._smS0T1 if aSmS0T1 == X.SmS0T1.t1 : self.exitSm() self.setSm(X.Sm.s1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT3(self): wasEventProcessed = False aSmS0T2 = self._smS0T2 if aSmS0T2 == X.SmS0T2.t2 : self.exitSmS0T2() self.setSmS0T2(X.SmS0T2.t3) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT4(self): wasEventProcessed = False aSmS1T1 = self._smS1T1 if aSmS1T1 == X.SmS0T1.t1 : self.exitSmS1T1() self.setSmS1T1(X.SmS1T1.t4) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT5(self): wasEventProcessed = False aSmS1T2 = self._smS1T2 if aSmS1T2 == X.SmS0T2.t2 : self.exitSmS1T2() self.setSmS1T2(X.SmS1T2.t5) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s0 : self.exitSmS0T1() self.exitSmS0T2() elif self._sm == X.Sm.s1 : self.exitSmS1T1() self.exitSmS1T2() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s0 : if self._smS0T1 == X.SmS0T1.Null : self.setSmS0T1(X.SmS0T1.t1) if self._smS0T2 == X.SmS0T2.Null : self.setSmS0T2(X.SmS0T2.t2) elif self._sm == X.Sm.s1 : if self._smS1T1 == X.SmS1T1.Null : self.setSmS1T1(X.SmS1T1.t1) if self._smS1T2 == X.SmS1T2.Null : self.setSmS1T2(X.SmS1T2.t2) def exitSmS0T1(self): if self._smS0T1 == X.SmS0T1.t1 : self.setSmS0T1(X.SmS0T1.Null) def setSmS0T1(self, aSmS0T1): self._smS0T1 = aSmS0T1 if self._sm != X.Sm.s0 and aSmS0T1 != X.SmS0T1.Null : self.setSm(X.Sm.s0) def exitSmS0T2(self): if self._smS0T2 == X.SmS0T2.t2 : self.setSmS0T2(X.SmS0T2.Null) elif self._smS0T2 == X.SmS0T2.t3 : self.setSmS0T2(X.SmS0T2.Null) def setSmS0T2(self, aSmS0T2): self._smS0T2 = aSmS0T2 if self._sm != X.Sm.s0 and aSmS0T2 != X.SmS0T2.Null : self.setSm(X.Sm.s0) def exitSmS1T1(self): if self._smS1T1 == X.SmS0T1.t1 : self.setSmS1T1(X.SmS1T1.Null) elif self._smS1T1 == X.SmS1T1.t4 : self.setSmS1T1(X.SmS1T1.Null) def setSmS1T1(self, aSmS1T1): self._smS1T1 = aSmS1T1 if self._sm != X.Sm.s1 and aSmS1T1 != X.SmS1T1.Null : self.setSm(X.Sm.s1) def exitSmS1T2(self): if self._smS1T2 == X.SmS0T2.t2 : self.setSmS1T2(X.SmS1T2.Null) elif self._smS1T2 == X.SmS1T2.t5 : self.setSmS1T2(X.SmS1T2.Null) def setSmS1T2(self, aSmS1T2): self._smS1T2 = aSmS1T2 if self._sm != X.Sm.s1 and aSmS1T2 != X.SmS1T2.Null : self.setSm(X.Sm.s1) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 13 "../EventTransition.ump" from enum import Enum, auto class Light(): #------------------------ # MEMBER VARIABLES #------------------------ #Light State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Off = auto() On = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._bulb = None self.setBulb(Light.Bulb.Off) #------------------------ # INTERFACE #------------------------ def getBulbFullName(self): answer = self._bulb.__str__() return answer def getBulb(self): return self._bulb def flip(self): wasEventProcessed = False aBulb = self._bulb if aBulb == Light.Bulb.Off : self.setBulb(Light.Bulb.On) wasEventProcessed = True elif aBulb == Light.Bulb.On : self.setBulb(Light.Bulb.Off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setBulb(self, aBulb): self._bulb = aBulb def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "stateMachineWithNegativeNumberGuard.ump" from enum import Enum, auto class stateMachineWithNegativeNumberGuard(): #------------------------ # MEMBER VARIABLES #------------------------ #stateMachineWithNegativeNumberGuard State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) on = auto() off = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(stateMachineWithNegativeNumberGuard.Status.on) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def turnOff(self, pn): wasEventProcessed = False aStatus = self._status if aStatus == stateMachineWithNegativeNumberGuard.Status.on : if pn > -1 : self.setStatus(stateMachineWithNegativeNumberGuard.Status.off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def turnOn(self): wasEventProcessed = False aStatus = self._status if aStatus == stateMachineWithNegativeNumberGuard.Status.off : self.setStatus(stateMachineWithNegativeNumberGuard.Status.on) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../twoEventsWithArguments.ump" from enum import Enum, auto class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() Full = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def register(self, name, age, grades): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Open : self.setStatus(Course.Status.Open) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def reject(self, firstName): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Full : self.setStatus(Course.Status.Full) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../SimpleStateMachine.ump" from enum import Enum, auto class Mentor(): #------------------------ # MEMBER VARIABLES #------------------------ #Mentor State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "nestedStates_timedTransition.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() class SmS1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() s1a = auto() s1b = auto() #Helper Variables #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._timeouts1aTos1bHandler = None self._smS1 = None self._sm = None self.setSmS1(X.SmS1.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1 != X.SmS1.Null : answer += "." + self._smS1.__str__() return answer def getSm(self): return self._sm def getSmS1(self): return self._smS1 def e2(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.s2 : self.setSm(X.Sm.s1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def timeouts1aTos1b(self): wasEventProcessed = False aSmS1 = self._smS1 if aSmS1 == X.SmS1.s1a : self.exitSmS1() self.setSmS1(X.SmS1.s1b) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e1(self): wasEventProcessed = False aSmS1 = self._smS1 if aSmS1 == X.SmS1.s1b : self.exitSm() self.setSm(X.Sm.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1 == X.SmS1.Null : self.setSmS1(X.SmS1.s1a) def exitSmS1(self): if self._smS1 == X.SmS1.s1a : self.setSmS1(X.SmS1.Null) self.stopTimeouts1aTos1bHandler() elif self._smS1 == X.SmS1.s1b : self.setSmS1(X.SmS1.Null) def setSmS1(self, aSmS1): self._smS1 = aSmS1 if self._sm != X.Sm.s1 and aSmS1 != X.SmS1.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1 == X.SmS1.s1a : self.startTimeouts1aTos1bHandler() def startTimeouts1aTos1bHandler(self): self._timeouts1aTos1bHandler = self.TimedEventHandler(self, "timeouts1aTos1b", 2) def stopTimeouts1aTos1bHandler(self): self._timeouts1aTos1bHandler.stop() class TimedEventHandler(): def __init__(self, aController, aTimeoutMethodName, aHowLongInSeconds): from threading import Timer self._timer = None self._howLongInSeconds = None self._timeoutMethodName = None self._controller = None self._controller = aController self._timeoutMethodName = aTimeoutMethodName self._howLongInSeconds = aHowLongInSeconds self._timer = None self._timer = Timer(self._howLongInSeconds, self.run) self._timer.start() def stop(self): self._timer.cancel() def run(self): if "timeouts1aTos1b" == self._timeoutMethodName : shouldRestart = not self._controller.timeouts1aTos1b() if shouldRestart : self._controller.startTimeouts1aTos1bHandler() return def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../nestedStates_UnspecifiedReception.ump" from enum import Enum, auto class NestedStatesWthSameEventNames(): #------------------------ # MEMBER VARIABLES #------------------------ #NestedStatesWthSameEventNames State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) nestedState1 = auto() nestedState2 = auto() state5 = auto() class SmNestedState1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() state1 = auto() state2 = auto() class SmNestedState2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() state3 = auto() state4 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smNestedState2 = None self._smNestedState1 = None self._sm = None self.setSmNestedState1(NestedStatesWthSameEventNames.SmNestedState1.Null) self.setSmNestedState2(NestedStatesWthSameEventNames.SmNestedState2.Null) self.setSm(NestedStatesWthSameEventNames.Sm.nestedState1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smNestedState1 != NestedStatesWthSameEventNames.SmNestedState1.Null : answer += "." + self._smNestedState1.__str__() if self._smNestedState2 != NestedStatesWthSameEventNames.SmNestedState2.Null : answer += "." + self._smNestedState2.__str__() return answer def getSm(self): return self._sm def getSmNestedState1(self): return self._smNestedState1 def getSmNestedState2(self): return self._smNestedState2 def e1(self): wasEventProcessed = False aSmNestedState1 = self._smNestedState1 if aSmNestedState1 == NestedStatesWthSameEventNames.SmNestedState1.state1 : self.exitSmNestedState1() self.setSmNestedState1(NestedStatesWthSameEventNames.SmNestedState1.state2) wasEventProcessed = True else : # Other states do respond to this event wasEventProcessed = self.unspecified(self.getSmNestedState1().__str__(), "e1") return wasEventProcessed def unspecified(self, state, event): wasEventProcessed = False aSmNestedState1 = self._smNestedState1 aSmNestedState2 = self._smNestedState2 if aSmNestedState1 == NestedStatesWthSameEventNames.SmNestedState1.state1 : self.exitSmNestedState1() self.setSmNestedState1(NestedStatesWthSameEventNames.SmNestedState1.state1) wasEventProcessed = True else : # Other states do respond to this event pass if aSmNestedState2 == NestedStatesWthSameEventNames.SmNestedState2.state4 : self.exitSm() self.setSm(NestedStatesWthSameEventNames.Sm.nestedState2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e2(self): wasEventProcessed = False aSmNestedState1 = self._smNestedState1 if aSmNestedState1 == NestedStatesWthSameEventNames.SmNestedState1.state2 : self.exitSm() self.setSm(NestedStatesWthSameEventNames.Sm.state5) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def e4(self): wasEventProcessed = False aSmNestedState2 = self._smNestedState2 if aSmNestedState2 == NestedStatesWthSameEventNames.SmNestedState2.state4 : self.exitSm() self.setSm(NestedStatesWthSameEventNames.Sm.state5) wasEventProcessed = True else : # Other states do respond to this event wasEventProcessed = self.unspecified(self.getSmNestedState2().__str__(), "e4") return wasEventProcessed def exitSm(self): if self._sm == NestedStatesWthSameEventNames.Sm.nestedState1 : self.exitSmNestedState1() elif self._sm == NestedStatesWthSameEventNames.Sm.nestedState2 : self.exitSmNestedState2() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == NestedStatesWthSameEventNames.Sm.nestedState1 : if self._smNestedState1 == NestedStatesWthSameEventNames.SmNestedState1.Null : self.setSmNestedState1(NestedStatesWthSameEventNames.SmNestedState1.state1) elif self._sm == NestedStatesWthSameEventNames.Sm.nestedState2 : if self._smNestedState2 == NestedStatesWthSameEventNames.SmNestedState2.Null : self.setSmNestedState2(NestedStatesWthSameEventNames.SmNestedState2.state3) def exitSmNestedState1(self): if self._smNestedState1 == NestedStatesWthSameEventNames.SmNestedState1.state1 : self.setSmNestedState1(NestedStatesWthSameEventNames.SmNestedState1.Null) elif self._smNestedState1 == NestedStatesWthSameEventNames.SmNestedState1.state2 : self.setSmNestedState1(NestedStatesWthSameEventNames.SmNestedState1.Null) def setSmNestedState1(self, aSmNestedState1): self._smNestedState1 = aSmNestedState1 if self._sm != NestedStatesWthSameEventNames.Sm.nestedState1 and aSmNestedState1 != NestedStatesWthSameEventNames.SmNestedState1.Null : self.setSm(NestedStatesWthSameEventNames.Sm.nestedState1) def exitSmNestedState2(self): if self._smNestedState2 == NestedStatesWthSameEventNames.SmNestedState2.state3 : self.setSmNestedState2(NestedStatesWthSameEventNames.SmNestedState2.Null) elif self._smNestedState2 == NestedStatesWthSameEventNames.SmNestedState2.state4 : self.setSmNestedState2(NestedStatesWthSameEventNames.SmNestedState2.Null) def setSmNestedState2(self, aSmNestedState2): self._smNestedState2 = aSmNestedState2 if self._sm != NestedStatesWthSameEventNames.Sm.nestedState2 and aSmNestedState2 != NestedStatesWthSameEventNames.SmNestedState2.Null : self.setSm(NestedStatesWthSameEventNames.Sm.nestedState2) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../nestedStates.ump" from enum import Enum, auto class LightFixture(): #------------------------ # MEMBER VARIABLES #------------------------ #LightFixture State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Off = auto() On = auto() class BulbOn(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() Normal = auto() Dimmed = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._bulbOn = None self._bulb = None self.setBulbOn(LightFixture.BulbOn.Null) self.setBulb(LightFixture.Bulb.Off) #------------------------ # INTERFACE #------------------------ def getBulbFullName(self): answer = self._bulb.__str__() if self._bulbOn != LightFixture.BulbOn.Null : answer += "." + self._bulbOn.__str__() return answer def getBulb(self): return self._bulb def getBulbOn(self): return self._bulbOn def flip(self): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.Off : self.setBulb(LightFixture.Bulb.On) wasEventProcessed = True elif aBulb == LightFixture.Bulb.On : self.exitBulb() self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def touch(self): wasEventProcessed = False aBulbOn = self._bulbOn if aBulbOn == LightFixture.BulbOn.Normal : self.exitBulbOn() self.setBulbOn(LightFixture.BulbOn.Dimmed) wasEventProcessed = True elif aBulbOn == LightFixture.BulbOn.Dimmed : self.exitBulb() self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitBulb(self): if self._bulb == LightFixture.Bulb.On : self.exitBulbOn() def setBulb(self, aBulb): self._bulb = aBulb # entry actions and do activities if self._bulb == LightFixture.Bulb.On : if self._bulbOn == LightFixture.BulbOn.Null : self.setBulbOn(LightFixture.BulbOn.Normal) def exitBulbOn(self): if self._bulbOn == LightFixture.BulbOn.Normal : self.setBulbOn(LightFixture.BulbOn.Null) elif self._bulbOn == LightFixture.BulbOn.Dimmed : self.setBulbOn(LightFixture.BulbOn.Null) def setBulbOn(self, aBulbOn): self._bulbOn = aBulbOn if self._bulb != LightFixture.Bulb.On and aBulbOn != LightFixture.BulbOn.Null : self.setBulb(LightFixture.Bulb.On) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../BeforeAndAfter_StateMachineSet.ump" from enum import Enum, auto class LightFixture(): #------------------------ # MEMBER VARIABLES #------------------------ #LightFixture State Machines class Light(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) On = auto() Off = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._light = None self.setLight(LightFixture.Light.On) #------------------------ # INTERFACE #------------------------ def getLightFullName(self): answer = self._light.__str__() return answer def getLight(self): return self._light def flip(self): wasEventProcessed = False aLight = self._light if aLight == LightFixture.Light.On : self.setLight(LightFixture.Light.Off) wasEventProcessed = True elif aLight == LightFixture.Light.Off : self.setLight(LightFixture.Light.On) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setLight(self, aLight): # line 16 "../BeforeAndAfter_StateMachineSet.ump" print("About to flip") # END OF UMPLE BEFORE INJECTION self._light = aLight # line 12 "../BeforeAndAfter_StateMachineSet.ump" print("Just flipped") # END OF UMPLE AFTER INJECTION def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../multipleGuardsSameEvent.ump" from enum import Enum, auto class LightFixture(): #------------------------ # MEMBER VARIABLES #------------------------ #LightFixture Attributes #LightFixture State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) On = auto() Off = auto() Amber = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._bulb = None self._brightness = None self._brightness = 0 self.setBulb(LightFixture.Bulb.On) #------------------------ # INTERFACE #------------------------ def setBrightness(self, aBrightness): wasSet = False self._brightness = aBrightness wasSet = True return wasSet def getBrightness(self): return self._brightness def getBulbFullName(self): answer = self._bulb.__str__() return answer def getBulb(self): return self._bulb def push(self): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.On : if self.getBrightness() < 1 : self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True if self.getBrightness() > 10 : self.setBulb(LightFixture.Bulb.Amber) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setBulb(self, aBulb): self._bulb = aBulb def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "brightness" + ":" + str(self.getBrightness()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../externalStateMachine.ump" from enum import Enum, auto class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() Closed = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def register(self): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Open : self.setStatus(Course.Status.Closed) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def deregister(self): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Closed : self.setStatus(Course.Status.Open) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../guardSpacing.ump" from enum import Enum, auto class Garage(): #------------------------ # MEMBER VARIABLES #------------------------ #Garage Attributes #Garage State Machines class GarageDoor(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() Closing = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self, aEntranceClear): self._garageDoor = None self._entranceClear = None self._entranceClear = aEntranceClear self.setGarageDoor(Garage.GarageDoor.Open) #------------------------ # INTERFACE #------------------------ def setEntranceClear(self, aEntranceClear): wasSet = False self._entranceClear = aEntranceClear wasSet = True return wasSet def getEntranceClear(self): return self._entranceClear # Code from template attribute_IsBoolean def isEntranceClear(self): return self._entranceClear def getGarageDoorFullName(self): answer = self._garageDoor.__str__() return answer def getGarageDoor(self): return self._garageDoor def pressButton(self): wasEventProcessed = False aGarageDoor = self._garageDoor if aGarageDoor == Garage.GarageDoor.Open : if self.getEntranceClear() : self.setGarageDoor(Garage.GarageDoor.Closing) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setGarageDoor(self, aGarageDoor): self._garageDoor = aGarageDoor def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "entranceClear" + ":" + str(self.getEntranceClear()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 9 "../SimpleStateMachineSpacing.ump" from enum import Enum, auto class Student(): #------------------------ # MEMBER VARIABLES #------------------------ #Student State Machines class Grade(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Pass = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._grade = None self.setGrade(Student.Grade.Pass) #------------------------ # INTERFACE #------------------------ def getGradeFullName(self): answer = self._grade.__str__() return answer def getGrade(self): return self._grade def setGrade(self, aGrade): self._grade = aGrade return True def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../stateMachineSpacing1.ump" from enum import Enum, auto class Garage(): #------------------------ # MEMBER VARIABLES #------------------------ #Garage State Machines class GarageDoor(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Closed = auto() Opening = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._garageDoor = None self.setGarageDoor(Garage.GarageDoor.Closed) #------------------------ # INTERFACE #------------------------ def getGarageDoorFullName(self): answer = self._garageDoor.__str__() return answer def getGarageDoor(self): return self._garageDoor def pressButton(self): wasEventProcessed = False aGarageDoor = self._garageDoor if aGarageDoor == Garage.GarageDoor.Closed : # line 7 "../stateMachineSpacing1.ump" turnLightOn() self.setGarageDoor(Garage.GarageDoor.Opening) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setGarageDoor(self, aGarageDoor): self._garageDoor = aGarageDoor def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../stateMachineSpacing2.ump" from enum import Enum, auto class Garage(): #------------------------ # MEMBER VARIABLES #------------------------ #Garage State Machines class GarageDoor(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Closed = auto() Opening = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._garageDoor = None self.setGarageDoor(Garage.GarageDoor.Closed) #------------------------ # INTERFACE #------------------------ def getGarageDoorFullName(self): answer = self._garageDoor.__str__() return answer def getGarageDoor(self): return self._garageDoor def pressButton(self): wasEventProcessed = False aGarageDoor = self._garageDoor if aGarageDoor == Garage.GarageDoor.Closed : # line 7 "../stateMachineSpacing2.ump" turnLightOn() self.setGarageDoor(Garage.GarageDoor.Opening) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setGarageDoor(self, aGarageDoor): self._garageDoor = aGarageDoor def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "parallelSm_diffNamesDiffStates.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s0 = auto() s1 = auto() class SmS0T1(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t1 = auto() class SmS0T2(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t2 = auto() t3 = auto() class SmS1T4(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t4 = auto() t5 = auto() class SmS1T6(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t6 = auto() t7 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS1T6 = None self._smS1T4 = None self._smS0T2 = None self._smS0T1 = None self._sm = None self.setSmS0T1(X.SmS0T1.Null) self.setSmS0T2(X.SmS0T2.Null) self.setSmS1T4(X.SmS1T4.Null) self.setSmS1T6(X.SmS1T6.Null) self.setSm(X.Sm.s0) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS0T1 != X.SmS0T1.Null : answer += "." + self._smS0T1.__str__() if self._smS0T2 != X.SmS0T2.Null : answer += "." + self._smS0T2.__str__() if self._smS1T4 != X.SmS1T4.Null : answer += "." + self._smS1T4.__str__() if self._smS1T6 != X.SmS1T6.Null : answer += "." + self._smS1T6.__str__() return answer def getSm(self): return self._sm def getSmS0T1(self): return self._smS0T1 def getSmS0T2(self): return self._smS0T2 def getSmS1T4(self): return self._smS1T4 def getSmS1T6(self): return self._smS1T6 def goS1(self): wasEventProcessed = False aSmS0T1 = self._smS0T1 if aSmS0T1 == X.SmS0T1.t1 : self.exitSm() self.setSm(X.Sm.s1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT3(self): wasEventProcessed = False aSmS0T2 = self._smS0T2 if aSmS0T2 == X.SmS0T2.t2 : self.exitSmS0T2() self.setSmS0T2(X.SmS0T2.t3) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT5(self): wasEventProcessed = False aSmS1T4 = self._smS1T4 if aSmS1T4 == X.SmS1T4.t4 : self.exitSmS1T4() self.setSmS1T4(X.SmS1T4.t5) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goT7(self): wasEventProcessed = False aSmS1T6 = self._smS1T6 if aSmS1T6 == X.SmS1T6.t6 : self.exitSmS1T6() self.setSmS1T6(X.SmS1T6.t7) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s0 : self.exitSmS0T1() self.exitSmS0T2() elif self._sm == X.Sm.s1 : self.exitSmS1T4() self.exitSmS1T6() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s0 : if self._smS0T1 == X.SmS0T1.Null : self.setSmS0T1(X.SmS0T1.t1) if self._smS0T2 == X.SmS0T2.Null : self.setSmS0T2(X.SmS0T2.t2) elif self._sm == X.Sm.s1 : if self._smS1T4 == X.SmS1T4.Null : self.setSmS1T4(X.SmS1T4.t4) if self._smS1T6 == X.SmS1T6.Null : self.setSmS1T6(X.SmS1T6.t6) def exitSmS0T1(self): if self._smS0T1 == X.SmS0T1.t1 : self.setSmS0T1(X.SmS0T1.Null) def setSmS0T1(self, aSmS0T1): self._smS0T1 = aSmS0T1 if self._sm != X.Sm.s0 and aSmS0T1 != X.SmS0T1.Null : self.setSm(X.Sm.s0) def exitSmS0T2(self): if self._smS0T2 == X.SmS0T2.t2 : self.setSmS0T2(X.SmS0T2.Null) elif self._smS0T2 == X.SmS0T2.t3 : self.setSmS0T2(X.SmS0T2.Null) def setSmS0T2(self, aSmS0T2): self._smS0T2 = aSmS0T2 if self._sm != X.Sm.s0 and aSmS0T2 != X.SmS0T2.Null : self.setSm(X.Sm.s0) def exitSmS1T4(self): if self._smS1T4 == X.SmS1T4.t4 : self.setSmS1T4(X.SmS1T4.Null) elif self._smS1T4 == X.SmS1T4.t5 : self.setSmS1T4(X.SmS1T4.Null) def setSmS1T4(self, aSmS1T4): self._smS1T4 = aSmS1T4 if self._sm != X.Sm.s1 and aSmS1T4 != X.SmS1T4.Null : self.setSm(X.Sm.s1) def exitSmS1T6(self): if self._smS1T6 == X.SmS1T6.t6 : self.setSmS1T6(X.SmS1T6.Null) elif self._smS1T6 == X.SmS1T6.t7 : self.setSmS1T6(X.SmS1T6.Null) def setSmS1T6(self, aSmS1T6): self._smS1T6 = aSmS1T6 if self._sm != X.Sm.s1 and aSmS1T6 != X.SmS1T6.Null : self.setSm(X.Sm.s1) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../timedEvent.ump" from enum import Enum, auto class Mentor(): #------------------------ # MEMBER VARIABLES #------------------------ #Mentor Attributes #Mentor State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Ok = auto() NotOkay = auto() NotOk = auto() #Helper Variables #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._timeoutNotOkayToOkHandler = None self._timeoutOkToNotOkHandler = None self._status = None self._howLongUntilOk = None self._howLongUntilOk = 3 self.setStatus(Mentor.Status.Ok) #------------------------ # INTERFACE #------------------------ def setHowLongUntilOk(self, aHowLongUntilOk): wasSet = False self._howLongUntilOk = aHowLongUntilOk wasSet = True return wasSet def getHowLongUntilOk(self): return self._howLongUntilOk def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def timeoutOkToNotOk(self): wasEventProcessed = False aStatus = self._status if aStatus == Mentor.Status.Ok : self.exitStatus() self.setStatus(Mentor.Status.NotOk) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def timeoutNotOkayToOk(self): wasEventProcessed = False aStatus = self._status if aStatus == Mentor.Status.NotOkay : self.exitStatus() self.setStatus(Mentor.Status.Ok) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitStatus(self): if self._status == Mentor.Status.Ok : self.stopTimeoutOkToNotOkHandler() elif self._status == Mentor.Status.NotOkay : self.stopTimeoutNotOkayToOkHandler() def setStatus(self, aStatus): self._status = aStatus # entry actions and do activities if self._status == Mentor.Status.Ok : self.startTimeoutOkToNotOkHandler() elif self._status == Mentor.Status.NotOkay : self.startTimeoutNotOkayToOkHandler() def startTimeoutOkToNotOkHandler(self): self._timeoutOkToNotOkHandler = self.TimedEventHandler(self, "timeoutOkToNotOk", 4) def stopTimeoutOkToNotOkHandler(self): self._timeoutOkToNotOkHandler.stop() def startTimeoutNotOkayToOkHandler(self): self._timeoutNotOkayToOkHandler = self.TimedEventHandler(self, "timeoutNotOkayToOk", self._howLongUntilOk) def stopTimeoutNotOkayToOkHandler(self): self._timeoutNotOkayToOkHandler.stop() class TimedEventHandler(): def __init__(self, aController, aTimeoutMethodName, aHowLongInSeconds): from threading import Timer self._timer = None self._howLongInSeconds = None self._timeoutMethodName = None self._controller = None self._controller = aController self._timeoutMethodName = aTimeoutMethodName self._howLongInSeconds = aHowLongInSeconds self._timer = None self._timer = Timer(self._howLongInSeconds, self.run) self._timer.start() def stop(self): self._timer.cancel() def run(self): if "timeoutOkToNotOk" == self._timeoutMethodName : shouldRestart = not self._controller.timeoutOkToNotOk() if shouldRestart : self._controller.startTimeoutOkToNotOkHandler() return if "timeoutNotOkayToOk" == self._timeoutMethodName : shouldRestart = not self._controller.timeoutNotOkayToOk() if shouldRestart : self._controller.startTimeoutNotOkayToOkHandler() return def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "howLongUntilOk" + ":" + str(self.getHowLongUntilOk()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "1600_guardsOnEntryAndExit.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._sm = None self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() return answer def getSm(self): return self._sm def hh(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.s1 : self.exitSm() self.setSm(X.Sm.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def hhh(self): wasEventProcessed = False aSm = self._sm if aSm == X.Sm.s2 : self.exitSm() self.setSm(X.Sm.s1) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : # line 8 "1600_guardsOnEntryAndExit.ump" if not condition2 : print("s1 exit!") elif self._sm == X.Sm.s2 : # line 17 "1600_guardsOnEntryAndExit.ump" if condition4 : print("s2 exit!") def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : # line 4 "1600_guardsOnEntryAndExit.ump" if condition : print("s1 entry!") elif self._sm == X.Sm.s2 : # line 13 "1600_guardsOnEntryAndExit.ump" if condition3 : print("s2 entry!") def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 1 "checkExternalTransitions_concurrentStateMachines.ump" from enum import Enum, auto class X(): #------------------------ # MEMBER VARIABLES #------------------------ #X State Machines class Sm(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) s1 = auto() s2 = auto() class SmS1A(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() a = auto() class SmS1AA(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t1 = auto() t2 = auto() class SmS1B(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() b = auto() class SmS1BB(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Null = auto() t3 = auto() t4 = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._smS1BB = None self._smS1B = None self._smS1AA = None self._smS1A = None self._sm = None self.setSmS1A(X.SmS1A.Null) self.setSmS1AA(X.SmS1AA.Null) self.setSmS1B(X.SmS1B.Null) self.setSmS1BB(X.SmS1BB.Null) self.setSm(X.Sm.s1) #------------------------ # INTERFACE #------------------------ def getSmFullName(self): answer = self._sm.__str__() if self._smS1A != X.SmS1A.Null : answer += "." + self._smS1A.__str__() if self._smS1AA != X.SmS1AA.Null : answer += "." + self._smS1AA.__str__() if self._smS1B != X.SmS1B.Null : answer += "." + self._smS1B.__str__() if self._smS1BB != X.SmS1BB.Null : answer += "." + self._smS1BB.__str__() return answer def getSm(self): return self._sm def getSmS1A(self): return self._smS1A def getSmS1AA(self): return self._smS1AA def getSmS1B(self): return self._smS1B def getSmS1BB(self): return self._smS1BB def goToT2(self): wasEventProcessed = False aSmS1AA = self._smS1AA if aSmS1AA == X.SmS1AA.t1 : self.exitSmS1AA() self.setSmS1AA(X.SmS1AA.t2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToT4(self): wasEventProcessed = False aSmS1AA = self._smS1AA if aSmS1AA == X.SmS1AA.t2 : self.exitSmS1A() self.setSmS1BB(X.SmS1BB.t4) self.setSmS1A(X.SmS1A.a) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def goToS2(self): wasEventProcessed = False aSmS1BB = self._smS1BB if aSmS1BB == X.SmS1BB.t4 : self.exitSm() self.setSm(X.Sm.s2) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def exitSm(self): if self._sm == X.Sm.s1 : self.exitSmS1A() self.exitSmS1B() def setSm(self, aSm): self._sm = aSm # entry actions and do activities if self._sm == X.Sm.s1 : if self._smS1A == X.SmS1A.Null : self.setSmS1A(X.SmS1A.a) if self._smS1B == X.SmS1B.Null : self.setSmS1B(X.SmS1B.b) def exitSmS1A(self): if self._smS1A == X.SmS1A.a : self.exitSmS1AA() # line 5 "checkExternalTransitions_concurrentStateMachines.ump" exit_a_action() self.setSmS1A(X.SmS1A.Null) def setSmS1A(self, aSmS1A): self._smS1A = aSmS1A if self._sm != X.Sm.s1 and aSmS1A != X.SmS1A.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1A == X.SmS1A.a : if self._smS1AA == X.SmS1AA.Null : self.setSmS1AA(X.SmS1AA.t1) def exitSmS1AA(self): if self._smS1AA == X.SmS1AA.t1 : self.setSmS1AA(X.SmS1AA.Null) elif self._smS1AA == X.SmS1AA.t2 : self.setSmS1AA(X.SmS1AA.Null) def setSmS1AA(self, aSmS1AA): self._smS1AA = aSmS1AA if self._smS1A != X.SmS1A.a and aSmS1AA != X.SmS1AA.Null : self.setSmS1A(X.SmS1A.a) def exitSmS1B(self): if self._smS1B == X.SmS1B.b : self.exitSmS1BB() # line 15 "checkExternalTransitions_concurrentStateMachines.ump" exit_b_action() self.setSmS1B(X.SmS1B.Null) def setSmS1B(self, aSmS1B): self._smS1B = aSmS1B if self._sm != X.Sm.s1 and aSmS1B != X.SmS1B.Null : self.setSm(X.Sm.s1) # entry actions and do activities if self._smS1B == X.SmS1B.b : if self._smS1BB == X.SmS1BB.Null : self.setSmS1BB(X.SmS1BB.t3) def exitSmS1BB(self): if self._smS1BB == X.SmS1BB.t3 : self.setSmS1BB(X.SmS1BB.Null) elif self._smS1BB == X.SmS1BB.t4 : self.setSmS1BB(X.SmS1BB.Null) def setSmS1BB(self, aSmS1BB): self._smS1BB = aSmS1BB if self._smS1B != X.SmS1B.b and aSmS1BB != X.SmS1BB.Null : self.setSmS1B(X.SmS1B.b) def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../AutoEventTransition.ump" from enum import Enum, auto class Light(): #------------------------ # MEMBER VARIABLES #------------------------ #Light State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Off = auto() On = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._bulb = None self.setBulb(Light.Bulb.Off) #------------------------ # INTERFACE #------------------------ def getBulbFullName(self): answer = self._bulb.__str__() return answer def getBulb(self): return self._bulb def __autotransition1__(self): wasEventProcessed = False aBulb = self._bulb if aBulb == Light.Bulb.Off : self.setBulb(Light.Bulb.On) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setBulb(self, aBulb): self._bulb = aBulb # entry actions and do activities if self._bulb == Light.Bulb.Off : self.__autotransition1__() def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 20 "../SimpleStateMachine.ump" from enum import Enum, auto class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() Full = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def setStatus(self, aStatus): self._status = aStatus return True def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../oneGuard.ump" from enum import Enum, auto class LightFixture(): #------------------------ # MEMBER VARIABLES #------------------------ #LightFixture Attributes #LightFixture State Machines class Bulb(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) On = auto() Off = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._bulb = None self._brightness = None self._brightness = 0 self.setBulb(LightFixture.Bulb.On) #------------------------ # INTERFACE #------------------------ def setBrightness(self, aBrightness): wasSet = False self._brightness = aBrightness wasSet = True return wasSet def getBrightness(self): return self._brightness def getBulbFullName(self): answer = self._bulb.__str__() return answer def getBulb(self): return self._bulb def push(self): wasEventProcessed = False aBulb = self._bulb if aBulb == LightFixture.Bulb.On : if self.getBrightness() < 1 : self.setBulb(LightFixture.Bulb.Off) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setBulb(self, aBulb): self._bulb = aBulb def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "brightness" + ":" + str(self.getBrightness()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 12 "../SimpleStateMachine.ump" from enum import Enum, auto class Student(): #------------------------ # MEMBER VARIABLES #------------------------ #Student State Machines class Grade(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Pass = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._grade = None self.setGrade(Student.Grade.Pass) #------------------------ # INTERFACE #------------------------ def getGradeFullName(self): answer = self._grade.__str__() return answer def getGrade(self): return self._grade def setGrade(self, aGrade): self._grade = aGrade return True def delete(self): pass #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 4 "../EventTransition.ump" from enum import Enum, auto class Course(): #------------------------ # MEMBER VARIABLES #------------------------ #Course State Machines class Status(Enum): def _generate_next_value_(name, start, count, last_values): return name def __str__(self): return str(self.value) Open = auto() #------------------------ # CONSTRUCTOR #------------------------ def __init__(self): self._status = None self.setStatus(Course.Status.Open) #------------------------ # INTERFACE #------------------------ def getStatusFullName(self): answer = self._status.__str__() return answer def getStatus(self): return self._status def register(self): wasEventProcessed = False aStatus = self._status if aStatus == Course.Status.Open : self.setStatus(Course.Status.Open) wasEventProcessed = True else : # Other states do respond to this event pass return wasEventProcessed def setStatus(self, aStatus): self._status = aStatus def delete(self): pass