Browse Source

*** empty log message ***

Joe Shochet 25 years ago
parent
commit
47d099866b
2 changed files with 18 additions and 4 deletions
  1. 14 4
      direct/src/fsm/FSM.py
  2. 4 0
      direct/src/tkpanels/FSMInspector.py

+ 14 - 4
direct/src/fsm/FSM.py

@@ -31,6 +31,8 @@ class FSM(DirectObject):
         self.setInitialState(initialStateName)
         self.setInitialState(initialStateName)
         self.setFinalState(finalStateName)
         self.setFinalState(finalStateName)
 
 
+        # Flag to see if we are inspecting
+        self.inspecting = 0
 
 
         # Enter the initial state.
         # Enter the initial state.
         # It is assumed that the initial state takes no arguments.
         # It is assumed that the initial state takes no arguments.
@@ -124,8 +126,12 @@ class FSM(DirectObject):
         FSM.notify.debug("[%s]: exiting %s" % (self.__name,
         FSM.notify.debug("[%s]: exiting %s" % (self.__name,
                                                self.__currentState.getName()))
                                                self.__currentState.getName()))
         self.__currentState.exit(argList)
         self.__currentState.exit(argList)
-        messenger.send(self.getName() + '_' +
-                       self.__currentState.getName() + '_exited')
+        # Only send the state change event if we are inspecting it
+        # If this event turns out to be generally useful, we can
+        # turn it on all the time, but for now nobody else is using it
+        if self.inspecting:
+            messenger.send(self.getName() + '_' +
+                           self.__currentState.getName() + '_exited')
         self.__currentState = None
         self.__currentState = None
                     
                     
     def __enter(self, aState, argList=[]):
     def __enter(self, aState, argList=[]):
@@ -135,8 +141,12 @@ class FSM(DirectObject):
             FSM.notify.debug("[%s]: entering %s" % (self.__name,
             FSM.notify.debug("[%s]: entering %s" % (self.__name,
                                                     aState.getName()))
                                                     aState.getName()))
             self.__currentState = aState
             self.__currentState = aState
-            messenger.send(self.getName() + '_' +
-                           aState.getName() + '_entered')
+            # Only send the state change event if we are inspecting it
+            # If this event turns out to be generally useful, we can
+            # turn it on all the time, but for now nobody else is using it
+            if self.inspecting:
+                messenger.send(self.getName() + '_' +
+                               aState.getName() + '_entered')
             aState.enter(argList)
             aState.enter(argList)
         else:
         else:
             FSM.notify.error("[%s]: enter: no such state" % self.__name)
             FSM.notify.error("[%s]: enter: no such state" % self.__name)

+ 4 - 0
direct/src/tkpanels/FSMInspector.py

@@ -26,6 +26,9 @@ class FSMInspector(AppShell):
         self.defineoptions(kw, optiondefs)
         self.defineoptions(kw, optiondefs)
 
 
         self.fsm = fsm
         self.fsm = fsm
+        # Tell the fsm we are inspecting it so it will send events
+        # when it changes state
+        self.fsm.inspecting = 1
 
 
         AppShell.__init__(self)
         AppShell.__init__(self)
 
 
@@ -281,6 +284,7 @@ class FSMInspector(AppShell):
             
             
     def onDestroy(self, event):
     def onDestroy(self, event):
         """ Called on FSM Panel shutdown """
         """ Called on FSM Panel shutdown """
+        self.fsm.inspecting = 0
         for si in self.stateInspectorDict.values():
         for si in self.stateInspectorDict.values():
             self.ignore(self.name + '_' + si.getName() + '_entered')
             self.ignore(self.name + '_' + si.getName() + '_entered')
             self.ignore(self.name + '_' + si.getName() + '_exited')
             self.ignore(self.name + '_' + si.getName() + '_exited')