For details of other assignments and general rules, see this page.
This is an individual assignment. You may not work together.
For deadline see the syllabus.
The following asks you to create state diagrams. You must use Umple with the option 'GraphViz State Diagram' set. Hand in both the Umple code and the resulting diagrams.
Question 1. Draw a state diagram for a car window controller as follows.
The following are the events that can occur when controlling a window:
Up: Causes the window to move up until it hits 'top', or 'obstruction'. Or else until 'release' or 'down' are triggered. Happens when the user pushes up on the control lever, but not very hard. If the window is already moving down, this instead simply stops the window moving.
FullUp: Occurs when the user pushes hard upwards on the control lever. The result is the same as Up, but 'release' is ignored.
Release: Cancels any movement of the window caused by Up or Down. This occurs whenever the user lets go of the control lever.
Down. Inverse of Up. Moves window downwards instead.
FullDown. Inverse of FullUp. But downwards.
Top. Stops window moving when it reaches the normal top of its motion. Only Down and FullDown are then allowed.
Bottom. Inverse of Top.
Obstruction: Window motor is obstructed from moving up or down for some reason (e.g. a jam in the mechanism, someone's finger in the window, etc.) The motor must be stopped. Can occur only when moving up or down. The result is to stop and reverse direction for 1 tenth of a second (to move the window a little in the other direction, e.g. to release a jammed finger).
RepeatObstruction: Obstruction state is entered more than 3 times in 5 seconds. The system then waits 5 seconds before allowing any other motion again. This is a safety mechanism to prevent someone burning out the motor by repeatedly starting it when obstructed.
Question 2. Create a simulation as follows.
Create a main method and other necessary code that runs a simulation of your answer to question 1. Create a trace of the output. Hand in the main method and the trace of output.
Note that you need to call a method that will start and stop the motor in the forward and reverse directions at the appropriate times. In the simulation, this would just print out what has happened to the motor.