Java Reference
In-Depth Information
private boolean mixing # false ;
// true when mixing is in process
private int redColorFlow # 0;
private int greenColorFlow # 0;
private int blueColorFlow # 0;
public void setColor( int rc, int gc, int bc){
try {
// closes the output pumps of the colour tanks
redController.openPump("PumpB", 0);
greenController.openPump("PumpB", 0);
blueController.openPump("PumpB", 0);
// closes the spray pump
pumpA.setOutputFlow(0);
console.pumpASlider.setValue(0);
// opens the drain pump
pumpB.setOutputFlow(100);
console.pumpBSlider.setValue(100);
// evaluates the needed paint flows from the colour
// tanks
redColorFlow # ( int ) Math.round(rc*100.0 / 255.0);
greenColorFlow # ( int ) Math.round(gc*100.0 / 255.0);
blueColorFlow # ( int ) Math.round(bc*100.0 / 255.0);
// the drain pump is open
mixing # true ;
} catch (RemoteException re) {re.printStackTrace();}
}
// return false only if the drain pump is open
public boolean colorReady() { return ! mixing; }
// implements the finite state automaton
public void run() {
try { . . .
while ( true ) { ... // states transitions
if (tankState.equals(EMPTY)
&& tankLevel > MINIMUM) {...}
else if (tankState.equals(NOTEMPTY)
&& tankLevel > MEDIUM) {
tankState # NOTFULL;
// the superviswory console is now allowed
// to open the spray pump
if (mixing) mixing # false ;
}
else if (tankState.equals(NOTFULL)
&& tankLevel > MAXIMUM) {
...
}
Search WWH ::




Custom Search