diff --git a/src/Subsystems/Compressor.cpp b/src/Subsystems/Compressor.cpp index 08bd189..7098d6c 100644 --- a/src/Subsystems/Compressor.cpp +++ b/src/Subsystems/Compressor.cpp @@ -3,6 +3,7 @@ HHCompressor::HHCompressor(){ compressor=new Compressor(COMPRESSOR_GAUGE_SIDECAR, COMPRESSOR_GAUGE, COMPRESSOR_RELAY_SIDECAR, COMPRESSOR_RELAY); solenoid1=new Solenoid(COMPRESSOR_SOLENOID_ONE); solenoid2=new Solenoid(COMPRESSOR_SOLENOID_TWO); + time(&t); } void HHCompressor::CompressorSystemPeriodic(){ switch(e_CollectorSolenoidState){ @@ -19,12 +20,18 @@ void HHCompressor::CompressorSystemPeriodic(){ default: break; } - e_CollectorSolenoidState=IDLE; - if(compressor->GetPressureSwitchValue()==1){ - compressor->Start(); - }else{ - compressor->Stop(); + time_t f; + time(&f); + printf("%f",difftime(t,f)); + if(difftime(t,f)>1.0f){ + if(compressor->GetPressureSwitchValue()==1){ + compressor->Start(); + }else{ + compressor->Stop(); + } + t=clock(); } + e_CollectorSolenoidState=IDLE; } void HHCompressor::ExtendCollector(){ e_CollectorSolenoidState=EXTENDED; diff --git a/src/Subsystems/Compressor.h b/src/Subsystems/Compressor.h index 20040c2..c82a3f5 100644 --- a/src/Subsystems/Compressor.h +++ b/src/Subsystems/Compressor.h @@ -1,9 +1,11 @@ #include #include "../Definitions.h" +#include class HHCompressor{ private: Compressor *compressor; Solenoid *solenoid1, *solenoid2; + time_t t; public: enum{ EXTENDED,