finite-state-machine
finite-state-machine copied to clipboard
Add state change logging
StateMachine
may implement a state change logger (on_state_change
method) as shown in the log example
class TurnstileWithLog(Turnstile):
def __init__(self):
super().__init__()
self.history = [self.state]
def on_state_change(self, source, target):
if source != target:
self.history.append(target)
that keeps an history of the distinct state changes.
I will had some documentation if the feature is accepted.