Java Reference
In-Depth Information
this .maxRate # rate / 60000;
attachTo("LOADED", this );
// it listens to its LOADED event
long lifetime # Math.round( (1.0 ! 0.5*Math.random()) /
// activates the first event
activateEvent("LOADED", lifetime, pieceType);
protected void notifyEvent(DiscreteEvent event) {
// when a "LOADED" event is notified, it activates
//the next "LOADED" event.
if ("LOADED")) {
numPieces !! ;
long lifetime # Math.round( (1.0 ! 0.5*Math.random()) /
this .activateEvent("LOADED", lifetime, pieceType);
Class WorkCell creates two processes that generate nut and screw pieces.
package workcell;
public class WorkCell{
PieceSource nutSource;
// a reference to the source of pieces for nuts
PieceSource screwSource;
// a reference to the source of pieces for screws
public WorkCell(String name, DiscreteClock clock) {
nutSource # new PieceSource("NutSource","Nut",clock,30);
screwSource # new PieceSource("ScrewSource", "Screw",
clock, 50);
The test case consists in the visualization of the sequence of events that the
nut source and the screw source generate during the simulation. The
maximum rate of generated pieces is set to 30 for the nut source and to 50
for the screw source.
We consider two situations:
The lifetime of a LOADED event (e.g. the delay between two generated
pieces) is constant and proportional to the maximum rate. Accordingly,
the delay between two nut pieces is equal to 2000 milliseconds, while the
delay between two screw pieces is equal to 1200 milliseconds. Table 9.2
(left side) lists the sequence of events corresponding to the generation of
nut and screw pieces.
Search WWH ::

Custom Search