1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-09-28 22:15:23 +08:00

add a reset function to states, call it when the state machine resets

This commit is contained in:
Joel Bender 2015-08-05 23:28:23 -04:00
parent f01c0cab17
commit a8149cd5dc

View File

@ -140,13 +140,20 @@ class State:
self.is_success_state = False
self.is_fail_state = False
# list of send and receive transitions
# empty lists of send and receive transitions
self.send_transitions = []
self.receive_transitions = []
# timeout transition
self.timeout_transition = None
def reset(self):
"""Override this method in a derived class if the state maintains
counters or other information. Called when the associated state
machine is reset.
"""
if _debug: State._debug("reset")
def doc(self, doc_string):
"""Change the documentation string (label) for the state. The state
is returned for method chaining.
@ -438,6 +445,10 @@ class StateMachine:
# we are not starting up
self._startup_flag = False
# give all the states a chance to reset
for state in self.states:
state.reset()
def run(self):
if _debug: StateMachine._debug("run")