Beverage vending machine

Preamble

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.

Goal

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
Installation requirements
_BVM_state_machine = new com.pauware.pauware_engine.Core.StateMachine(… /*, new com.pauware.pauware2web.PauWare2Web_client()*/);
Specification (statechart) as full-size SVG image
Beverage_vending_machineServiceentry/ Beverage_vending_machine.to_be_set(Long)exit/ Beverage_vending_machine.to_be_killedCoin_insertionPick_uptime_out/Beverage_vending_machine.give_change;Beverage_vending_machine.take_beveragechoose[Beverage_vending_machine.required]/Beverage_vending_machine.please_wait_for_beverage;Beverage_vending_machine.decrease_totalcancel/Beverage_vending_machine.give_changecoin_insertion/Beverage_vending_machine.increase_total(Integer)pick_up