LPS JS / Mbed OS 2022_TICE_Electrolyse

Dependencies:   lib_Transmission SEN0169 DS1820

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "main.h"
00002 
00003 int main(void)
00004 {
00005     if (T_anode.begin()&&T_cathode.begin()) {
00006         transmission.send(processing("*IDN?"),com);
00007         while(1) {
00008             T_anode.startConversion();
00009             T_cathode.startConversion();
00010             ThisThread::sleep_for(1s);
00011             T_anode.read(temperature_anode);
00012             T_cathode.read(temperature_cathode);
00013             ph_anode = PH_anode.read_ph();
00014             ph_cathode = PH_cathode.read_ph();
00015         }
00016     }
00017 }
00018 
00019 string processing(string cmd)
00020 {
00021     ostringstream ssend;
00022     ssend << fixed;
00023     ssend.precision(2);
00024     if(cmd.empty());
00025     else if(cmd == "*IDN?") {
00026         ssend << MBED_PROJECT << ", Mbed OS " << MBED_VERSION << ", Version dated, " << __DATE__ << ", " << __TIME__;
00027     } else if(cmd == "MESURES?") {
00028         ssend << temperature_anode << " ; " << temperature_cathode << " ; " << ph_anode << " ; " << ph_cathode;
00029 
00030     } else if(cmd == "ANODE:INFOS?") {
00031         float* parameters = PH_anode.get_parameters();
00032         ssend << parameters[0] << " ; " << parameters[1] << " ; " << parameters[2] << " ; " << parameters[3] << " ; " << parameters[4];
00033 
00034     } else if(cmd == "CATHODE:INFOS?") {
00035         float* parameters = PH_anode.get_parameters();
00036         ssend << parameters[0] << " ; " << parameters[1] << " ; " << parameters[2] << " ; " << parameters[3] << " ; " << parameters[4];
00037 
00038     } else if(cmd.find("ANODE:CALIB: ") != string::npos) {
00039         stringstream param(cmd.substr(cmd.find(' ')+1));
00040         int tampon;
00041         param >> tampon;
00042         PH_anode.calibration(tampon);
00043 
00044     } else if(cmd.find("CATHODE:CALIB: ") != string::npos) {
00045         stringstream param(cmd.substr(cmd.find(' ')+1));
00046         int tampon;
00047         param >> tampon;
00048         PH_cathode.calibration(tampon);
00049 
00050     } else if(cmd[cmd.size()-1] == '?')
00051         ssend << "incorrect requeste [" << cmd << "]";
00052 
00053     return ssend.str();
00054 }