Java Reference
In-Depth Information
while ( true ) {
Thread.sleep(SAMPLING);
tankLevel # tank.getLevel();
// states transitions
if (tankState.equals(EMPTY) && tankLevel > MINIMUM) {
tankState # NOTEMPTY;
}
else if (tankState.equals(NOTEMPTY)
&& tankLevel > MEDIUM) {
tankState # NOTFULL;
if (automatic) {
// opens the input pump in order to fill the tank
pumpA.setOutputFlow(50);
console.pumpASlider.setValue(50);
}
}
else if (tankState.equals(NOTFULL)
&& tankLevel > MAXIMUM) {
tankState # FULL;
// closes the input pump
pumpA.setOutputFlow(0);
console.pumpASlider.setValue(0);
}
else if (tankState.equals(FULL)
&& tankLevel < # MAXIMUM) {
tankState # NOTFULL;
}
else if (tankState.equals(NOTFULL)
&& tankLevel < # MEDIUM) {
tankState # NOTEMPTY;
if (automatic) {
// opens the input pump in order to fill the tank
pumpA.setOutputFlow(50);
console.pumpASlider.setValue(50);
}
}
else if (tankState.equals(NOTEMPTY)
&& tankLevel < # MINIMUM) {
tankState # EMPTY;
if (automatic)
{ // opens the input pump (maximum flow)
// in order to fill the tank
pumpA.setOutputFlow(100);
console.pumpASlider.setValue(100);
}
}
}
Search WWH ::




Custom Search