Java Reference
In-Depth Information
thread.sleep(1000);
working # false ;
this .repaint();
// notifies the Client that the task has been completed
this .notifyObservers("WORKDONE");
}
catch (InterruptedException ie) { ie.printStackTrace(); }
}
}
Class Client extends class EventProcess . It holds a reference to the server
object and implements the run() method. Every 1500 milliseconds the client
sends a request to the Server to execute a task and visualizes string
DOSERVICE in the graphical user interface.
package parking;
public class Client extends EventProcess {
Server server; // a reference to the Server object
public Client(String name, Server server) {
super (name);
this .server # server;
this .attachTo(server); // attaches itself to the event
// raised by the Server
}
// this method implements the client's behaviour
public void run() {
while (alive)
try {
server.doService();
this .waitEvent(server, "WORKDONE");
thread.sleep(1500);
}
catch (InterruptedException ie) { ie.printStackTrace(); }
}
}
11.5
Prototype 2: Graphical animation
The second prototype simulates the behaviour of the physical devices, the
controller and the car and animates them in a graphical user interface.
11.5.1
Analysis
Let's consider the dynamic of each subsystem. Figure 11.4 depicts the finite
state automata of PhotoCell , TicketDispenser and StoppingBar respectively.
Ovals represent states, while rectangles represent state transitions. State
names are in bold upper case. Two labels describe state transitions. The
 
Search WWH ::




Custom Search