1st comit

Dependencies:   lib_Transmission SEN0169 DS1820

Committer:
jsanchez
Date:
Tue Jan 11 15:04:26 2022 +0000
Revision:
0:851e1c7a4454
1st commit :)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jsanchez 0:851e1c7a4454 1 #include "main.h"
jsanchez 0:851e1c7a4454 2
jsanchez 0:851e1c7a4454 3 int main(void)
jsanchez 0:851e1c7a4454 4 {
jsanchez 0:851e1c7a4454 5 if (T_anode.begin()&&T_cathode.begin()) {
jsanchez 0:851e1c7a4454 6 transmission.send(processing("*IDN?"),com);
jsanchez 0:851e1c7a4454 7 while(1) {
jsanchez 0:851e1c7a4454 8 T_anode.startConversion();
jsanchez 0:851e1c7a4454 9 T_cathode.startConversion();
jsanchez 0:851e1c7a4454 10 ThisThread::sleep_for(1s);
jsanchez 0:851e1c7a4454 11 T_anode.read(temperature_anode);
jsanchez 0:851e1c7a4454 12 T_cathode.read(temperature_cathode);
jsanchez 0:851e1c7a4454 13 ph_anode = PH_anode.read_ph();
jsanchez 0:851e1c7a4454 14 ph_cathode = PH_cathode.read_ph();
jsanchez 0:851e1c7a4454 15 }
jsanchez 0:851e1c7a4454 16 }
jsanchez 0:851e1c7a4454 17 }
jsanchez 0:851e1c7a4454 18
jsanchez 0:851e1c7a4454 19 string processing(string cmd)
jsanchez 0:851e1c7a4454 20 {
jsanchez 0:851e1c7a4454 21 ostringstream ssend;
jsanchez 0:851e1c7a4454 22 ssend << fixed;
jsanchez 0:851e1c7a4454 23 ssend.precision(2);
jsanchez 0:851e1c7a4454 24 if(cmd.empty());
jsanchez 0:851e1c7a4454 25 else if(cmd == "*IDN?") {
jsanchez 0:851e1c7a4454 26 ssend << MBED_PROJECT << ", Mbed OS " << MBED_VERSION << ", Version dated, " << __DATE__ << ", " << __TIME__;
jsanchez 0:851e1c7a4454 27 } else if(cmd == "MESURES?") {
jsanchez 0:851e1c7a4454 28 ssend << temperature_anode << " ; " << temperature_cathode << " ; " << ph_anode << " ; " << ph_cathode;
jsanchez 0:851e1c7a4454 29
jsanchez 0:851e1c7a4454 30 } else if(cmd == "ANODE:INFOS?") {
jsanchez 0:851e1c7a4454 31 float* parameters = PH_anode.get_parameters();
jsanchez 0:851e1c7a4454 32 ssend << parameters[0] << " ; " << parameters[1] << " ; " << parameters[2] << " ; " << parameters[3] << " ; " << parameters[4];
jsanchez 0:851e1c7a4454 33
jsanchez 0:851e1c7a4454 34 } else if(cmd == "CATHODE:INFOS?") {
jsanchez 0:851e1c7a4454 35 float* parameters = PH_anode.get_parameters();
jsanchez 0:851e1c7a4454 36 ssend << parameters[0] << " ; " << parameters[1] << " ; " << parameters[2] << " ; " << parameters[3] << " ; " << parameters[4];
jsanchez 0:851e1c7a4454 37
jsanchez 0:851e1c7a4454 38 } else if(cmd.find("ANODE:CALIB: ") != string::npos) {
jsanchez 0:851e1c7a4454 39 stringstream param(cmd.substr(cmd.find(' ')+1));
jsanchez 0:851e1c7a4454 40 int tampon;
jsanchez 0:851e1c7a4454 41 param >> tampon;
jsanchez 0:851e1c7a4454 42 PH_anode.calibration(tampon);
jsanchez 0:851e1c7a4454 43
jsanchez 0:851e1c7a4454 44 } else if(cmd.find("CATHODE:CALIB: ") != string::npos) {
jsanchez 0:851e1c7a4454 45 stringstream param(cmd.substr(cmd.find(' ')+1));
jsanchez 0:851e1c7a4454 46 int tampon;
jsanchez 0:851e1c7a4454 47 param >> tampon;
jsanchez 0:851e1c7a4454 48 PH_cathode.calibration(tampon);
jsanchez 0:851e1c7a4454 49
jsanchez 0:851e1c7a4454 50 } else if(cmd[cmd.size()-1] == '?')
jsanchez 0:851e1c7a4454 51 ssend << "incorrect requeste [" << cmd << "]";
jsanchez 0:851e1c7a4454 52
jsanchez 0:851e1c7a4454 53 return ssend.str();
jsanchez 0:851e1c7a4454 54 }