finite-state-machine icon indicating copy to clipboard operation
finite-state-machine copied to clipboard

Add state change logging

Open sdebionne opened this issue 1 year ago • 0 comments

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.

sdebionne avatar Oct 07 '22 12:10 sdebionne