Java Reference
In-Depth Information
public int getOutputFlow() { return outputFlow; }
// this method transfers a micro-volume of paint from the
// upstream tank to the downstream tank
public void flush( int DT) { // interval in milliseconds
int microVol; // volume in millilitres
if (outputFlow ## 0 ||
(upstreamTank ## null && downstreamTank ## null ))
return ;
else if (upstreamTank ! # null && downstreamTank ! # null ) {
// the case of a pump connecting an upstream tank and a
// downstream tank: the output quantity is equal to the
// minimum of the current level of upstream tank, the
// residue of the downstream tank and the output volume
microVol # ( int ) Math.min( upstreamTank.getLevel(),
downstreamTank.getResidue() );
microVol # ( int )Math.min(microVol,
DT * outputFlow / 1000);
upstreamTank.pull(microVol);
downstreamTank.push(microVol, upstreamTank.getColor());
outputFlow # microVol * 1000 / DT;
}
else if (upstreamTank ! # null ) {
// this is the case of a pump that doesn't have a
// downstream tank (e.g. the spray pump and the drain
// pump of the mixture tank)
microVol # ( int ) Math.min( upstreamTank.getLevel(),
DT * outputFlow / 1000);
upstreamTank.pull(microVol);
outputFlow # microVol * 1000 / DT;
}
else {
// this is the case of a pump that doesn't have an
// upstream tank (e.g. the input pump of the colour
// tanks)
microVol #
( int ) Math.min( downstreamTank.getResidue(),
DT*outputFlow/1000 );
downstreamTank.push(microVol, null );
outputFlow # microVol * 1000 / DT;
}
}
}
Class Simulator implements the main application class of the car painting
work cell simulator. It has two main functionalities:
It creates the tank and pump components, initializes their interconnec-
tions, and creates a thread object that invokes the flush method of each
pump every 100 milliseconds.
Search WWH ::




Custom Search