Mario Simaremare
/
g3_waterplay
Salinity and temperature sensors are implemented in classes.
Waterplay.cpp
- Committer:
- mariosimaremare
- Date:
- 2016-06-24
- Revision:
- 14:6c24cab82ff0
- Parent:
- 13:142a142a7ac5
- Child:
- 15:e112bab9aa2f
File content as of revision 14:6c24cab82ff0:
/* * G3: WATERPLAY */ #include "Waterplay.h" #include "mbed.h" Waterplay::Waterplay( Printer &printer, TemperatureSensor &temperatureSensor, SalinitySensor &salinitySensor, Thermostat &thermostat, Tank &tank, Flasher &flasher, Flasher &alarm ): _printer(printer), _temperatureSensor(temperatureSensor), _salinitySensor(salinitySensor), _thermostat(thermostat), _tank(tank), _flasher(flasher), _alarm(alarm) { } int Waterplay::control() { int retVal = 1; _temperatureSensor.reload(); _salinitySensor.reload(); _flasher.flash(1); _printer.display( _salinitySensor.getSalinity(), _salinitySensor.getStrStatus(), _temperatureSensor.getTemperature(), _temperatureSensor.getStrStatus() ); _flasher.flash(2); if( _temperatureSensor.getTemperature() > 0.0 && _temperatureSensor.getTemperature() < 100.0 ) { if(_temperatureSensor.getStatus() < 0.0) { _alarm.danger_flash(); } _thermostat.react( _temperatureSensor.getStatus() ); } else { _printer.toBothln("check the temperature sensor"); _alarm.danger_flash_long(); //wait(10.0); } if( _salinitySensor.getSalinity() > 0.25 // avoid interferences. ) { if(_salinitySensor.getStatus() != 0.0){ _alarm.danger_flash(); } _tank.react( _salinitySensor.getStatus() ); } else { _printer.toBothln("check the salinity sensor"); _alarm.danger_flash_long(); //wait(10.0); } _printer.display( _tank.getStrStatus(), _thermostat.getStrStatus() ); return(retVal); }