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
ordre.cpp@15:79a78f997f18, 2017-02-28 (annotated)
- Committer:
- chevamax
- Date:
- Tue Feb 28 13:40:13 2017 +0000
- Revision:
- 15:79a78f997f18
- Child:
- 17:cce0eada6d82
Application de test.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chevamax | 15:79a78f997f18 | 1 | #include "mbed.h" |
chevamax | 15:79a78f997f18 | 2 | #include "ordre.h" |
chevamax | 15:79a78f997f18 | 3 | #include "debug.h" |
chevamax | 15:79a78f997f18 | 4 | |
chevamax | 15:79a78f997f18 | 5 | Ordre::Ordre(char id, char idR, char niveau){ |
chevamax | 15:79a78f997f18 | 6 | //TODO |
chevamax | 15:79a78f997f18 | 7 | } |
chevamax | 15:79a78f997f18 | 8 | |
chevamax | 15:79a78f997f18 | 9 | char getiemebit1(char c, int i) |
chevamax | 15:79a78f997f18 | 10 | { |
chevamax | 15:79a78f997f18 | 11 | return ((c>>(7-i)) & 1); |
chevamax | 15:79a78f997f18 | 12 | } |
chevamax | 15:79a78f997f18 | 13 | |
chevamax | 15:79a78f997f18 | 14 | Ordre::Ordre(char* trameRecu){ |
chevamax | 15:79a78f997f18 | 15 | idEmetteur = trameRecu[1]; |
chevamax | 15:79a78f997f18 | 16 | idRecepteur = trameRecu[0]; |
chevamax | 15:79a78f997f18 | 17 | niveauCuve = trameRecu[2]>>3; |
chevamax | 15:79a78f997f18 | 18 | debug("idEmetteur = "); |
chevamax | 15:79a78f997f18 | 19 | for(int i=0; i < 8; i++){ |
chevamax | 15:79a78f997f18 | 20 | if(getiemebit1(trameRecu[1], i)){ |
chevamax | 15:79a78f997f18 | 21 | debug("1"); |
chevamax | 15:79a78f997f18 | 22 | } |
chevamax | 15:79a78f997f18 | 23 | else{ |
chevamax | 15:79a78f997f18 | 24 | debug("0"); |
chevamax | 15:79a78f997f18 | 25 | } |
chevamax | 15:79a78f997f18 | 26 | } |
chevamax | 15:79a78f997f18 | 27 | debug("\r\n idRecepteur = "); |
chevamax | 15:79a78f997f18 | 28 | for(int i=0; i < 8; i++){ |
chevamax | 15:79a78f997f18 | 29 | if(getiemebit1(trameRecu[0], i)){ |
chevamax | 15:79a78f997f18 | 30 | debug("1"); |
chevamax | 15:79a78f997f18 | 31 | } |
chevamax | 15:79a78f997f18 | 32 | else{ |
chevamax | 15:79a78f997f18 | 33 | debug("0"); |
chevamax | 15:79a78f997f18 | 34 | } |
chevamax | 15:79a78f997f18 | 35 | } |
chevamax | 15:79a78f997f18 | 36 | debug("\r\n niveauCuve = "); |
chevamax | 15:79a78f997f18 | 37 | for(int i=0; i < 8; i++){ |
chevamax | 15:79a78f997f18 | 38 | if(getiemebit1(trameRecu[2], i)){ |
chevamax | 15:79a78f997f18 | 39 | debug("1"); |
chevamax | 15:79a78f997f18 | 40 | } |
chevamax | 15:79a78f997f18 | 41 | else{ |
chevamax | 15:79a78f997f18 | 42 | debug("0"); |
chevamax | 15:79a78f997f18 | 43 | } |
chevamax | 15:79a78f997f18 | 44 | } |
chevamax | 15:79a78f997f18 | 45 | } |
chevamax | 15:79a78f997f18 | 46 | char* Ordre::creerTrame(){ |
chevamax | 15:79a78f997f18 | 47 | //TODO |
chevamax | 15:79a78f997f18 | 48 | return NULL; |
chevamax | 15:79a78f997f18 | 49 | } |
chevamax | 15:79a78f997f18 | 50 | void Ordre::mettreAJourNiveauCuve(){ |
chevamax | 15:79a78f997f18 | 51 | //TODO |
chevamax | 15:79a78f997f18 | 52 | } |
chevamax | 15:79a78f997f18 | 53 | void Ordre::executerOrdre(Pompe p, Niveau n){ |
chevamax | 15:79a78f997f18 | 54 | //TODO |
chevamax | 15:79a78f997f18 | 55 | debug("Execution de l'ordre 10s \r\n"); |
chevamax | 15:79a78f997f18 | 56 | wait(10); |
chevamax | 15:79a78f997f18 | 57 | debug("Fin execution ordre\r\n"); |
chevamax | 15:79a78f997f18 | 58 | } |
chevamax | 15:79a78f997f18 | 59 | |
chevamax | 15:79a78f997f18 | 60 | char Ordre::getIdEmetteur(){ |
chevamax | 15:79a78f997f18 | 61 | return idEmetteur; |
chevamax | 15:79a78f997f18 | 62 | } |
chevamax | 15:79a78f997f18 | 63 | char Ordre::getIdRecepteur(){ |
chevamax | 15:79a78f997f18 | 64 | return idRecepteur; |
chevamax | 15:79a78f997f18 | 65 | } |
chevamax | 15:79a78f997f18 | 66 | char Ordre::getNiveauCuve(){ |
chevamax | 15:79a78f997f18 | 67 | return niveauCuve; |
chevamax | 15:79a78f997f18 | 68 | } |