1st comit
Dependencies: lib_Transmission SEN0169 DS1820
Diff: main.cpp
- Revision:
- 0:851e1c7a4454
diff -r 000000000000 -r 851e1c7a4454 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 11 15:04:26 2022 +0000 @@ -0,0 +1,54 @@ +#include "main.h" + +int main(void) +{ + if (T_anode.begin()&&T_cathode.begin()) { + transmission.send(processing("*IDN?"),com); + while(1) { + T_anode.startConversion(); + T_cathode.startConversion(); + ThisThread::sleep_for(1s); + T_anode.read(temperature_anode); + T_cathode.read(temperature_cathode); + ph_anode = PH_anode.read_ph(); + ph_cathode = PH_cathode.read_ph(); + } + } +} + +string processing(string cmd) +{ + ostringstream ssend; + ssend << fixed; + ssend.precision(2); + if(cmd.empty()); + else if(cmd == "*IDN?") { + ssend << MBED_PROJECT << ", Mbed OS " << MBED_VERSION << ", Version dated, " << __DATE__ << ", " << __TIME__; + } else if(cmd == "MESURES?") { + ssend << temperature_anode << " ; " << temperature_cathode << " ; " << ph_anode << " ; " << ph_cathode; + + } else if(cmd == "ANODE:INFOS?") { + float* parameters = PH_anode.get_parameters(); + ssend << parameters[0] << " ; " << parameters[1] << " ; " << parameters[2] << " ; " << parameters[3] << " ; " << parameters[4]; + + } else if(cmd == "CATHODE:INFOS?") { + float* parameters = PH_anode.get_parameters(); + ssend << parameters[0] << " ; " << parameters[1] << " ; " << parameters[2] << " ; " << parameters[3] << " ; " << parameters[4]; + + } else if(cmd.find("ANODE:CALIB: ") != string::npos) { + stringstream param(cmd.substr(cmd.find(' ')+1)); + int tampon; + param >> tampon; + PH_anode.calibration(tampon); + + } else if(cmd.find("CATHODE:CALIB: ") != string::npos) { + stringstream param(cmd.substr(cmd.find(' ')+1)); + int tampon; + param >> tampon; + PH_cathode.calibration(tampon); + + } else if(cmd[cmd.size()-1] == '?') + ssend << "incorrect requeste [" << cmd << "]"; + + return ssend.str(); +} \ No newline at end of file