Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed BLE_API X_NUCLEO_IDB0XA1 MODSERIAL
Event.cpp
00001 #include "Event.h" 00002 #include "Logger.h" 00003 #include <stdlib.h> 00004 static Logger *Ordi = Logger::Instance(); 00005 event::event() 00006 { 00007 created=true; 00008 J_active=false; 00009 R_active=false; 00010 B_active=false; 00011 J_val=0; 00012 R_val=0; 00013 B_val='0'; 00014 } 00015 event::~event() 00016 { 00017 ; 00018 } 00019 event * event::Instance() 00020 { 00021 if(created)return _instance(); 00022 else { 00023 _instance= new event(); 00024 return _instance; 00025 } 00026 } 00027 float event::deduce_val() 00028 { 00029 float nval; 00030 char tmp_num[2]; 00031 //ont pull le numeros de la string 00032 for(int i=0; i<2; i++) { 00033 tmp_num[i]=pull_c(); 00034 } 00035 //verifiacation de negatif 00036 nval= atof(nval); 00037 nval = nval/10;//pour ce permetre plus de precision ont divise par 10 00038 if(pull_c()=='T') { //le nombre est negatif 00039 nval= -navl; 00040 } 00041 Ordi->log("event::deduce_val Valheur de val rendu :"); 00042 Ordi->log(nval); 00043 return nval; 00044 } 00045 bool event::has_new_event() 00046 { 00047 return(J_active|R_active|B_active|T_active); 00048 } 00049 char event::pull_c() 00050 { 00051 char t; 00052 if(!tmp.empty()) { 00053 t = tmp.front(); 00054 tmp.pop(); 00055 } else t='X'; 00056 return t; 00057 } 00058 void event::give_event(std::queue<char> vnt) 00059 { 00060 char c; 00061 if(!vnt.empty()) { 00062 tmp = vnt; 00063 while(!tmp.empty()) { 00064 c=pull_c(); 00065 switch(c) { 00066 case 'B' : 00067 B_active=true; 00068 c=pull_c(); 00069 B_val = c; 00070 break; 00071 case 'J' : 00072 c= pull_c(); 00073 if(c == 'R') { 00074 R_active =true; 00075 R_val=deduce_val(); 00076 } 00077 if( c== 'L') { 00078 J_active =true; 00079 J_val=deduce_val(); 00080 } 00081 if( c == 'T') 00082 { 00083 T_active = true; 00084 T_val = deduce_val(); 00085 } 00086 break; 00087 } 00088 } 00089 } else Ordi->log("event::give_event Error empty queue ... God that still sounds wrong ..."); 00090 00091 } 00092 //Quand ces fonctions sont appeler nous savons que l'event est en court de traitement donc nous le desactivons 00093 char event::get_val_B() 00094 { B_avtive = false; 00095 return B_val; 00096 } 00097 float event::get_val_J() 00098 { 00099 J_active= false; 00100 return J_val; 00101 } 00102 float event::get_val_T() 00103 { 00104 T_active = false; 00105 return T_val; 00106 } 00107 float event::get_val_R() 00108 { 00109 R_active= false; 00110 return R_val; 00111 }
Generated on Thu Jul 14 2022 17:21:51 by
1.7.2