Qt Lab #3 : Statecharts

Eric Lecolinet - Télécom Paris - Dept. INFRES

Useful links

Goal

The goal of this Lab is to implement the presentation and interaction parts of the control panel of an (actual) microwave oven.

      

Step 1: Design the Statechart

Draw (on a sheet of paper [think about taking a picture]) or using a computer tool) the Statechart implementing the desired behaviour.

The buttons on the microwave panel are:

Note that, when a setting sequence is started, no other button is active, except the Stop button, which cancels any operation. For instance:

The Start button can be clicked:

The display panel shows different information depending on currently active state. For instance:

Finally:

Step 2: Create the graphical interface using QtCreator

You can now create the graphical objects GUI, either by using Qt Designor (which is part of Qt Creator) or by programming them directly. Think about giving intelligible names to your widgets to make programming easier in the following questions.

Notes:

Step 3: Implement the Statechart and link it to the GUI

You can now implement the QtStateMachine, its states and its transitions. This should typically this be done in the constructor of the MainWindow (or in a method called by the constructor). The Transitions.h header may help the writing the Statechart.

We will take care of temporal aspects (for displaying the current time on the clock and stopping the oven) in the next question. As said before, the display panel should show appropriate info depending on the selected state.

Once the implementation is completed, do some testing to verify that the behavior is consistent with the specification set out in the previous question.

Step 4: Clock and cooking duration

The goal is now to make 1) the clock to work properly (it should be updated every second) and 2) the oven to stop cooking when the cooking duration has expired. For this purpose you'll need using QTimers (QTimer can send a signal when a lapse of time has elapsed). As said before, be careful to update the display only in the appropriate states.

Last Step: Improving the GUI

Give free rein to your imagination... :-)

Exercice Report

Please follow the following instructions to avoid mistakes and undesirable problems:



Eric Lecolinet - http://www.telecom-paristech.fr/~elc - Telecom ParisTech