Polytech school project. RICM4 students, see http://air.imag.fr/index.php/Projets-2016-2017-Station_de_pompage_connect%C3%A9e for more information

Dependencies:   SX1272Lib mbed WakeUp

Fork of SX1272PingPong by Semtech

Revision:
17:cce0eada6d82
Parent:
15:79a78f997f18
diff -r 85fb5e37def7 -r cce0eada6d82 ordre.cpp
--- a/ordre.cpp	Fri Mar 03 13:42:44 2017 +0000
+++ b/ordre.cpp	Sat Apr 01 12:29:59 2017 +0000
@@ -2,9 +2,7 @@
 #include "ordre.h"
 #include "debug.h"
 
-Ordre::Ordre(char id, char idR, char niveau){
-    //TODO   
-}
+#define TEMPS_ATTENTE_REMPLISSAGE 10
 
 char getiemebit1(char c, int i)
 {
@@ -15,7 +13,8 @@
     idEmetteur = trameRecu[1];
     idRecepteur = trameRecu[0];
     niveauCuve = trameRecu[2]>>3;
-    debug("idEmetteur = ");
+    ordreAFaire = (trameRecu[2]&0x4)>>2;
+    /*debug("idEmetteur = ");
     for(int i=0; i < 8; i++){
         if(getiemebit1(trameRecu[1], i)){
             debug("1");
@@ -35,25 +34,37 @@
     }
     debug("\r\n niveauCuve = ");
     for(int i=0; i < 8; i++){
-        if(getiemebit1(trameRecu[2], i)){
+        if(getiemebit1(niveauCuve, i)){
+            debug("1");
+        }
+        else{
+            debug("0");
+        }
+    }
+    debug("\r\n ordreAfaire = ");
+    for(int i=0; i < 8; i++){
+        if(getiemebit1(ordreAFaire, i)){
             debug("1");
         }
         else{
             debug("0");
         }
     }
-}
-char* Ordre::creerTrame(){
-    //TODO
-    return NULL;
+    debug("\r\n");*/
 }
-void Ordre::mettreAJourNiveauCuve(){
-    //TODO
-}
-void Ordre::executerOrdre(Pompe p, Niveau n){
+
+void Ordre::executerOrdre(Pompe p, Niveau n, char niveauCible){
     //TODO
     debug("Execution de l'ordre 10s \r\n");
-    wait(10);
+    //wait(10);
+    if(n.getNiveauCuve() < niveauCible){
+        p.activerPompe();
+    }
+    while(n.getNiveauCuve() < niveauCible){
+        wait(TEMPS_ATTENTE_REMPLISSAGE);
+    }
+    
+    p.arreterPompe();
     debug("Fin execution ordre\r\n");
 }
 
@@ -65,4 +76,7 @@
 }
 char Ordre::getNiveauCuve(){
     return niveauCuve;
+}
+char Ordre::getOrdreAFaire(){
+    return ordreAFaire;
 }
\ No newline at end of file