I have to agree with the person who made the comment "use it incorrectly."
The entire finite machine is a black box in which events accumulate, and which cause certain things based on these events (including state transitions). Events themselves should not generally depend on the current state of the machine.
I cannot foresee a situation in which an event should change depending on the current state (but feel free to educate me if you have any).
An event will always be what it is. If it needs to be processed differently depending on the current state, this is a problem for the state machine itself, and not for event pumps.
In fact, the whole idea of changing an event based on the current state flies before encapsulation.
The best state cars have a very simple form:
+------+ | | state V | transitions +---------------+ | events --> | | --+ | state machine | effects <-- | | +---------------+
In other words, events are somehow pumped up (regardless of state) and have certain effects based on its state and events. And he maintains his own condition.
As for updating your question, in which you would like to handle the output differently depending on whether the last reading was good or a formula based on the previous ones, I would just put this in the effects section. Have a state machine to display the current value plus an indication of whether it was from a sensor or calculated.
Then your code that processes effects can do what it likes with this information. This effectively gives you the necessary information and does not violate the growth of the black box.
paxdiablo
source share