Mario Simaremare
/
g3_waterplay
Salinity and temperature sensors are implemented in classes.
Tank.cpp@3:7c648d1d8802, 2016-06-16 (annotated)
- Committer:
- mariosimaremare
- Date:
- Thu Jun 16 11:28:59 2016 +0000
- Revision:
- 3:7c648d1d8802
- Child:
- 4:d8914369bf82
Spread the code into classes.; Median is implemented.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mariosimaremare | 3:7c648d1d8802 | 1 | /* |
mariosimaremare | 3:7c648d1d8802 | 2 | * G3: WATERPLAY |
mariosimaremare | 3:7c648d1d8802 | 3 | */ |
mariosimaremare | 3:7c648d1d8802 | 4 | |
mariosimaremare | 3:7c648d1d8802 | 5 | #include "Tank.h" |
mariosimaremare | 3:7c648d1d8802 | 6 | #include "mbed.h" |
mariosimaremare | 3:7c648d1d8802 | 7 | |
mariosimaremare | 3:7c648d1d8802 | 8 | Tank::Tank( |
mariosimaremare | 3:7c648d1d8802 | 9 | mbed::Serial &serial, |
mariosimaremare | 3:7c648d1d8802 | 10 | double initialVolume, // in ml |
mariosimaremare | 3:7c648d1d8802 | 11 | double initialSalinity, // in ppt |
mariosimaremare | 3:7c648d1d8802 | 12 | double maxVolume, |
mariosimaremare | 3:7c648d1d8802 | 13 | double alertVolume, |
mariosimaremare | 3:7c648d1d8802 | 14 | double consentration // in ppt |
mariosimaremare | 3:7c648d1d8802 | 15 | ): |
mariosimaremare | 3:7c648d1d8802 | 16 | _serial(serial), |
mariosimaremare | 3:7c648d1d8802 | 17 | _volume(initialVolume), |
mariosimaremare | 3:7c648d1d8802 | 18 | _initialSalinity(initialSalinity), |
mariosimaremare | 3:7c648d1d8802 | 19 | _maxVolume(maxVolume), |
mariosimaremare | 3:7c648d1d8802 | 20 | _alertVolume(alertVolume), |
mariosimaremare | 3:7c648d1d8802 | 21 | _consentration(consentration), |
mariosimaremare | 3:7c648d1d8802 | 22 | _status(0) |
mariosimaremare | 3:7c648d1d8802 | 23 | { |
mariosimaremare | 3:7c648d1d8802 | 24 | } |
mariosimaremare | 3:7c648d1d8802 | 25 | void Tank::addSalineSolution(double addedSalineSolution) |
mariosimaremare | 3:7c648d1d8802 | 26 | { |
mariosimaremare | 3:7c648d1d8802 | 27 | _serial.printf( |
mariosimaremare | 3:7c648d1d8802 | 28 | "\taddSalineSolution( )\n\r" |
mariosimaremare | 3:7c648d1d8802 | 29 | ); |
mariosimaremare | 3:7c648d1d8802 | 30 | } |
mariosimaremare | 3:7c648d1d8802 | 31 | void Tank::addPureWater(double addedPureWater) { |
mariosimaremare | 3:7c648d1d8802 | 32 | _serial.printf( |
mariosimaremare | 3:7c648d1d8802 | 33 | "\taddPureWater( )\n\r" |
mariosimaremare | 3:7c648d1d8802 | 34 | ); |
mariosimaremare | 3:7c648d1d8802 | 35 | } |
mariosimaremare | 3:7c648d1d8802 | 36 | double Tank::getVolume() { |
mariosimaremare | 3:7c648d1d8802 | 37 | double retVal = 0.0; |
mariosimaremare | 3:7c648d1d8802 | 38 | _serial.printf( |
mariosimaremare | 3:7c648d1d8802 | 39 | "\tgetVolume( )\n\r" |
mariosimaremare | 3:7c648d1d8802 | 40 | ); |
mariosimaremare | 3:7c648d1d8802 | 41 | |
mariosimaremare | 3:7c648d1d8802 | 42 | return(retVal); |
mariosimaremare | 3:7c648d1d8802 | 43 | } |
mariosimaremare | 3:7c648d1d8802 | 44 | |
mariosimaremare | 3:7c648d1d8802 | 45 | double Tank::getSalinity() { |
mariosimaremare | 3:7c648d1d8802 | 46 | double retVal = 0.0; |
mariosimaremare | 3:7c648d1d8802 | 47 | _serial.printf( |
mariosimaremare | 3:7c648d1d8802 | 48 | "\tgetSalinity( )\n\r" |
mariosimaremare | 3:7c648d1d8802 | 49 | ); |
mariosimaremare | 3:7c648d1d8802 | 50 | |
mariosimaremare | 3:7c648d1d8802 | 51 | return(retVal); |
mariosimaremare | 3:7c648d1d8802 | 52 | } |
mariosimaremare | 3:7c648d1d8802 | 53 | |
mariosimaremare | 3:7c648d1d8802 | 54 | int Tank::getStatus() { |
mariosimaremare | 3:7c648d1d8802 | 55 | int retVal = 0; |
mariosimaremare | 3:7c648d1d8802 | 56 | _serial.printf( |
mariosimaremare | 3:7c648d1d8802 | 57 | "\tgetStatus( )\n\r" |
mariosimaremare | 3:7c648d1d8802 | 58 | ); |
mariosimaremare | 3:7c648d1d8802 | 59 | |
mariosimaremare | 3:7c648d1d8802 | 60 | return(retVal); |
mariosimaremare | 3:7c648d1d8802 | 61 | } |