From 47d099866b47d9f1347565fc15e8cb5ff51c8485 Mon Sep 17 00:00:00 2001 From: Joe Shochet Date: Thu, 29 Mar 2001 21:36:56 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/fsm/FSM.py | 18 ++++++++++++++---- direct/src/tkpanels/FSMInspector.py | 4 ++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/direct/src/fsm/FSM.py b/direct/src/fsm/FSM.py index f91d225121..8cdc9f5c53 100644 --- a/direct/src/fsm/FSM.py +++ b/direct/src/fsm/FSM.py @@ -31,6 +31,8 @@ class FSM(DirectObject): self.setInitialState(initialStateName) self.setFinalState(finalStateName) + # Flag to see if we are inspecting + self.inspecting = 0 # Enter the initial state. # 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, self.__currentState.getName())) 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 def __enter(self, aState, argList=[]): @@ -135,8 +141,12 @@ class FSM(DirectObject): FSM.notify.debug("[%s]: entering %s" % (self.__name, aState.getName())) 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) else: FSM.notify.error("[%s]: enter: no such state" % self.__name) diff --git a/direct/src/tkpanels/FSMInspector.py b/direct/src/tkpanels/FSMInspector.py index 546fda22e2..1fb2b53854 100644 --- a/direct/src/tkpanels/FSMInspector.py +++ b/direct/src/tkpanels/FSMInspector.py @@ -26,6 +26,9 @@ class FSMInspector(AppShell): self.defineoptions(kw, optiondefs) 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) @@ -281,6 +284,7 @@ class FSMInspector(AppShell): def onDestroy(self, event): """ Called on FSM Panel shutdown """ + self.fsm.inspecting = 0 for si in self.stateInspectorDict.values(): self.ignore(self.name + '_' + si.getName() + '_entered') self.ignore(self.name + '_' + si.getName() + '_exited')