|
dbelan2(à)cs.mcgill.ca |
hchen19(à)cs.mcgill.ca |
Events
Components
Door
Models the state of the CD tray. It is either opened or closed. It can be opened by the eject button only when in state stop. If it is playing or paused, it is stopped then an opendoor is broadcast.
CDin / CDout
The CDin state means that a CD is in the player and ready to play. The NoCD state means that there is no CD in the player (a CD might be on the tray, but the tray is opened). The cdin/cdout event involved any work necessary to add/remove a CD. For example, if there is no CD in the player, then opening the door, adding the CD and closing the door caused one cdin event.
Display
Displays the time and track number.
The initial time is 0, reflected by the state zero that resets the timer to 0. When a CD starts playing, it goes to the timeupdate state. In the timeupdate state, the time is automagically updated every seconds. If the CD player is paused then the timer goes in the timepause state where it keeps its value. When it returns to timeupdate it continues counting the time from where it left. A prevB and nextB events zeros the timer. A play event is broadcast from the control panel if they were generated when the CD was playing. The play event will start the timer after the previous/next track button is clicked. We are assuming that fast forward and rewind do not go over the next/previous track when the end/beginning is reached.
Initially (when there is no CD), no track number is displayed. Inserting a CD, will set the track number to 1. Then tracks can get change with the prev/next track buttons and also end_of_track event (when a song is done, go to the next one).
Controls
This part models the state of a CD. It is either playing, paused or stopped. In the stop state and pause state, when the play button is clicked, a play event is broadcast. This signals other components to change state.