import com.pauware.pauware_engine._Core.*; import com.pauware.pauware_engine._Exception.*; import com.pauware.pauware_engine._Java_EE.*; public class VoitureStateMachine { // State Machine protected AbstractStatechart_monitor State_Machine; // States protected AbstractStatechart Stop; protected AbstractStatechart Marche; protected AbstractStatechart Maximum; protected AbstractStatechart Normale; // Business object associated with the SM protected Voiture bo; private void initialize_SM() throws Statechart_exception { bo = new Voiture(); Stop = new Statechart("Stop"); Stop.inputState(); Stop.set_entryAction(bo, "stop", null, AbstractStatechart.Reentrance); Maximum = new Statechart("Maximum"); Normale = new Statechart("Normale"); Normale.inputState(); Marche = (Maximum.xor(Normale)).name("Marche"); State_Machine = new Statechart_monitor((Stop.xor(Marche)), "State_Machine", AbstractStatechart_monitor.Show_on_system_out); } public void start() throws Statechart_exception { State_Machine.fires("accelerer", Stop, Marche, true, bo, "accelerer"); State_Machine.fires("ralentir", Marche, Stop, bo, "vitesseDix"); State_Machine.fires("ralentir", Marche, Normale, bo, "vitesseSupDix", bo, "decelerer"); State_Machine.fires("accelerer", Marche, Normale, bo, "vitesseInf90", bo, "accelerer"); State_Machine.fires("accelerer", Marche, Maximum, bo, "vitesse90", bo, "accelerer"); State_Machine.start(); } public void stop() throws Statechart_exception { State_Machine.stop(); } public VoitureStateMachine() throws Statechart_exception { initialize_SM(); } // Events public void accelerer() throws Statechart_exception { State_Machine.run_to_completion("accelerer"); System.out.println(bo); } public void ralentir() throws Statechart_exception { State_Machine.run_to_completion("ralentir", AbstractStatechart_monitor.Compute_invariants); System.out.println(bo); } }