Java Reference
In-Depth Information
if (outputBuffer.size() ## outputSize) {
// if the output buffer is full the machine is
// not working
outputFull # true ;
working # false ;
}
else if (inputBuffer.size() > 0) {
// the input buffer is not empty, thus the machine
// starts a new operation
working # true ;
inputBuffer.remove(0);
long processingTime # Math.round( (1.0 !
0.5 * Math.random()) / maxRate);
this .activateEvent("WORKDONE", processingTime,
this .name);
if (inputFull && inputBuffer.size() < inputSize-2) {
// notifies the NOTFULL event only if it notified
// the FULL event before
inputFull # false ;
activateEvent("NOTFULL", 0, null );
}
}
else
// the input buffer is empty
working # false ;
}
else if (event.name.equals("UNLOADED") &&
event.value.equals( this .name)) {
// a piece has been unloaded from the output buffer
// of this machine
outputBuffer.remove(0);
// the buffer is not full any more
outputFull # false ;
if (! working && inputBuffer.size() > 0) {
// if the machine is not working and the input buffer
// is not full it starts a new manufacturing operation
working # true ;
inputBuffer.remove(0);
long processingTime # Math.round( (1.0 !
0.5 * Math.random()) / maxRate);
this .activateEvent("WORKDONE", processingTime,
this .name);
if (inputFull && inputBuffer.size() < inputSize-2) {
// notifies the NOTFULL event only if it notified
// the FULL event before
inputFull # false ;
Search WWH ::




Custom Search