web server load-drive and reading sensors based on LPC1768
Dependencies: DHT22 EthernetNetIf HTTPServer mbed
Diff: Atuadores/Atuadores.cpp
- Revision:
- 0:3125f39d20b4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Atuadores/Atuadores.cpp Mon Dec 07 14:06:24 2015 +0000 @@ -0,0 +1,113 @@ +#include "Atuadores.h" +#include "Leitura.h" +#include "mbed.h" + +DigitalOut Carregador(p28); +DigitalOut ArCond(p29); + +float saidaCarr; +float saidaAr; + +int CarregadorB; +int ArCondB; +int EstadoCarr; +int EstadoAr; +int Trava2 = 0; +int Trava3 = 0; +int TravaAuto1 = 0; +int TravaAuto2 = 0; +bool complemento = false; +int x9 = 0; +int x92 = 0; + +void Atuadores::AtuadorCarr() + { + saidaCarr = atof(TensCC); + if ((saidaCarr <=12.2) && (TravaAuto1 == 0)){ + Carregador = 1; + TravaAuto1 = 1; + + } + if (CarregadorB == 1 && Trava2 == 0){ + if (Carregador == 0){ Carregador = 1; x9 = 1;} + else{ Carregador = 0; x9 = 2;} + Trava2 = 1; + + } + else if (CarregadorB == 0 && Trava2 == 1){ + if (Carregador == 0){ Carregador = 1; x9 = 1;} + else { Carregador = 0; x9 = 2;} + // if (saidaCarr >= 12.8){ complemento = true;} + Trava2 = 0; + } + EstadoCarr = Carregador; +// if (complemento == true){x9 = 0;} + } + +void Atuadores::AtuadorAr() + { + saidaAr = szTemp; + if ((saidaAr >= 22) && (TravaAuto2 == 0)){ + ArCond = 1; + TravaAuto2 = 1; + } + else if(ArCondB == 1 && Trava3 == 0){ + if( ArCond == 0){ArCond = 1; x92 = 1;} + else { ArCond = 0; x92 = 2; } + Trava3 = 1; + TravaAuto2 = 1; + } + else if (ArCondB == 0 && Trava3 == 1 ){ + if( ArCond == 0){ArCond = 1; x92 = 1;} + else {ArCond = 0; x92 = 2;} + Trava3 = 0; + TravaAuto2 = 1; + } + EstadoAr = ArCond; + // if((saidaAr >= 22) && (x92 == 1)) {x92 = 0;} + } + + +void Atuadores::Desliga() +{ + if (Carregador == 1) + { + Carregador = 0; + CarregadorB = 0; + TravaAuto1 = 0; + Trava2 = 0; + x9 = 0; + + } + if (ArCond == 1) + { + ArCond = 0; + ArCondB = 0; + TravaAuto2 = 0; + Trava3 = 0; + x92 = 0; + } +} + +void Atuadores::Religa() +{ + if (Carregador == 0) + { + Carregador = 1; + CarregadorB = 0; + TravaAuto1 = 1; + Trava2 = 0; + // x9 = 0; + + } + if (ArCond == 0) + { + ArCond = 1; + ArCondB = 0; + TravaAuto2 = 1; + Trava3 = 0; + // x92 = 0; + } +} + + \ No newline at end of file