Java Reference
In-Depth Information
protected void notifyEvent(DiscreteEvent event) {
if ("LOADED")) {
numPieces !! ;
if (working) {
// the inventory can prepare a new piece to be
// loaded in the input buffer
long lifetime # Math.round((1.0 ! 0.5*Math.random()) /
this .activateEvent("LOADED", lifetime, pieceType);
else if ("FULL")) {
// the machine's input buffer is full (only one
// place available)
working # false ;
else if ("NOTFULL")) {
// the machine's input buffer is not full
working # true ;
long lifetime # Math.round( (1.0 ! 0.5*Math.random()) /
this .activateEvent("LOADED", lifetime, pieceType);
Class Machine extends the DiscreteProcess class and implements the state
transitions triggered by the events LOADED , WORKDONE and UNLOADED .
The current state is represented by three Boolean variables working ,
inputFull and outputFull and by the current number of pieces in the input
buffer. Both the drill and the cutter listen to the UNLOADED event that the
AGV raises when it unloads a piece from their output buffers. In order to
distinguish whether the AGV is unloading a piece from the drill or from the
cutter, the UNLOADED event carries a datum (the value field) that records
the name of the machine. The machine activates the events FULL and
NOTFULL that PieceSource is listening to and the event WORKDONE that the
machine itself is listening to.
package workcell;
import java.util.ArrayList;
public class Machine extends DiscreteProcess {
ArrayList inputBuffer # new ArrayList();
ArrayList outputBuffer # new ArrayList();
double maxRate; // maximum number of pieces per
// minute (in milliseconds)
int inputSize; // the size of the input buffer
int outputSize; // the size of the output buffer
Search WWH ::

Custom Search