Beverage vending machine |
© Franck.Barbier@FranckBarbier.com |
Beverage vending machine is a software case study, which is implemented in PauWare. PauWare is a Java engine for executing Harel's Statecharts in general.
Application Programming Interface -API-: Javadoc.
This case study aims at illustrating the use of timer events in PauWare.
The simple approach is inheriting from com.pauware.pauware_engine.Core.Timer_monitor
.
Timer activation and inactivation may typically be assigned to a state as follows (one-shot timer event):
_Service.set_entryAction(this, "to_be_set", new Object[]{Long.valueOf(1000L)});
_Service.set_exitAction(this, "to_be_killed");
The state machine must accordingly provide an implementation for the time_out
(time_out_error
as well) abstract methods inherited from com.pauware.pauware_engine.Core.Timer_monitor
:
public void time_out(long delay, com.pauware.pauware_engine.Core.AbstractState context) throws com.pauware.pauware_engine.Exceptions.State_exception {
assert (delay == 1000L); // Check for what delay the timer event is received...
assert (context.name().equals("Service"));
_BVM_state_machine.run_to_completion("time_out");
}
Beverage_vending_machine.java
what follows:
_BVM_state_machine = new com.pauware.pauware_engine.Core.StateMachine(… /*, new com.pauware.pauware2web.PauWare2Web_client()*/);