[PDF version of this document]| [HV Home]

Statecharts model of a CD player

Statecharts model of a CD player

   



The assignment

Draw (in your preferred drawing tool) and explain (in plain English), by means of a model in the Statechart formalism, the design of the dynamics of a CD Player software application. The application consists of three main parts: the static GUI part (widgets), the dynamic part (Statechart), and the hardware part (which has a given software interface). This assignment is about the Statechart part which will obviously have links with the other two parts.

Application Requirements

  1. The application shall be closed by closing its window (no explicit Quit button).
  2. There shall be seven buttons named: Play/Pause, Stop, Previous, Next, Forward, Reverse, and Eject.
  3. There shall be a Time text field to display time information.
  4. There shall be a Track text field to display the current track.
  5. When there is no disc in the CD player or when the CD player drawer is open, the system shall be in a state named No CD Loaded.
  6. When the CD player drawer is closed and a CD is in the CD player, the system shall be in one of three possible states: CD stopped, CD Playing, or CD Paused.
  7. When in the No CD Loaded state, with the drawer open and a CD in the drawer, pressing the Eject button shall cause the drawer of the CD player to close and the system shall enter the CD Stopped State.
  8. When in the No CD Loaded state, with the drawer open and no CD in the drawer, pressing the Eject button shall cause the drawer of the CD player to close and the system shall remain in the No CD Loaded state.
  9. When in the No CD Loaded state, pressing the Play/Pause, Stop, Previous, Next, Forward and Reverse buttons shall have no effect.
  10. The CD Playing State is entered from the CD Stopped state by a user clicking the Play/Pause button.
  11. The CD Stopped State is entered from the CD Playing state by a user clicking the Stop button.
  12. The CD Paused State is entered from the CD Playing state by a user clicking the Play/Pause button.
  13. The CD Playing State is entered from the CD Paused state by a user clicking the Play/Pause button.
  14. When in the CD Stopped state, the Time field shall display 00:00 and the Track field shall display [track 1].
  15. When in the CD Stopped state, the Stop button shall be disabled.
  16. When in the CD Stopped, CD Playing or CD Paused states, clicking the Next button when the current track is not the last track on the CD will cause the CD player to move to the next track, the Time field will display 00:00 and the Track field shall display the track number.
  17. When in the CD Stopped, CD Playing or CD Paused states, clicking the Next button when the current track is the last track on the CD will cause the CD player to move to the first track, the Time field will display 00:00 and the Track field shall display [track 1] and the CD Stopped state will be entered.
  18. When in the CD Stopped, CD Playing or CD Paused states, clicking the Previous button when the current track is not the first track on the CD will cause the CD player to move to the previous track, the Time field will display 00:00 and the Track field shall display the track number.
  19. When in the CD Stopped, CD Playing or CD Paused states, clicking the Previous button when the current track is the first track on the CD will cause the CD player to move to the start of the first track, the Time field will display 00:00 and the Track field shall display [track 1].
  20. When in the CD Stopped, CD Playing, or CD Paused states, pressing the Forward button will cause the CD to stop playing and the CD to step forwards in one-second intervals. Each step will take (in real-time) no more than 0.1 seconds. Fore each step, the Time field will display the current track time and the Track field will display the current track number. The application will stop stepping through the CD when the user stops holding down the Forward button, or the end of the CD is reached. If the end of the CD is reached, the CD stopped state will be entered, the Time field will display 00:00 and the Track field shall display [track 1].
  21. When in the CD Stopped, CD Playing, or CD Paused states, pressing the Reverse button will cause the CD to stop playing and the CD to step backwards in one-second intervals. Each step will take (in real-time) no more than 0.1 seconds. Fore each step, the Time field will display the current track time and the Track field will display the current track number. The application will stop stepping through the CD when the user stops holding down the Reverse button, or the start of the CD is reached.
  22. While in the CD Playing state, the Time field shall be updated every second with the elapsed playing time of the current track and the Track field shapll display the current track number N as [track N].
  23. When in the CD Paused state, the values in the Time and Track fields will be displayed initially and then after one second will be hidden (blank). After another second, they will be displayed again. This displaying/hiding cycle will continue as long as the system is in the CD Paused state.

You may need to add/modify requirements as you construct the statechart model. This may be due to the under-specification or even inconsistencies in the requirements.

A possible concrete User Interface (static part, consisting of a collection of widgets) may look like below.

CDGUI.png

It is assumed that appropriate events are generated by the widgets. For example, pressing the Eject button will generate an Eject event. You must explicitly link these mappings between the static part of the model (the widgets) and your Statechart. At an implementation level, this is often called ``binding'' of GUI widget events to callbacks implementing the dynamics (here described in the form of a Statechart).

Similarly, it assumed the Statechart has access to the widgets. For example, the Statechart is able to ``disable'' a button by invoking an appropriate method of such a button. You must explicitly list the methods of graphical entities you presume are present.

Software interaface to CD player hardware




Translated from TEX by TTH, version 3.02 (minor customizations by HV). On 29 Oct 2002, 20:21.