Beverage vending machine is a software case study,
which is implemented in PauWare.
PauWare is a Java engine for executing
Harel Statecharts ☛ in general.
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");
}
Resources
Java SE application as a Maven project
Beverage_vending_machine.PauWare2Web.zip
Installation requirements
This application has been designed and tested by means of PauWare ver. 2.0 (a.k.a. PauWare2, Sept. 2021).
This application also reuses PauWare2Web, a PauWare2 add-on, which allows the dynamic simulation of Harel's Statecharts in a Web browser.
While PauWare2 is based on Java 9,
PauWare2Web requires Java 11.
After downloading Beverage_vending_machine.PauWare2Web.zip,
PauWare2PauWare2.zip
and PauWare2WebPauWare2Web.zip
must be made accessible as Maven dependencies.
PauWare2Web itself requires third-party libraries that are downloaded by Maven: