diff --git a/OtherDevices/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.cpp b/OtherDevices/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.cpp index 25c91a3..b5c3b8b 100644 --- a/OtherDevices/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.cpp +++ b/OtherDevices/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.cpp @@ -3,3 +3,41 @@ // #include "../../../include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h" +#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h" + +DigitalActuatorElectrovanne::DigitalActuatorElectrovanne(int temps, float thresholdHigh, float thresholdLow) : DigitalActuator(temps), + thresholdHigh(thresholdHigh), thresholdLow(thresholdLow) {} + +void DigitalActuatorElectrovanne::activate() { + DigitalDevice::state = HIGH; +} + +void DigitalActuatorElectrovanne::run() { + int previousState = LOW; + while (1){ + state = *ptrmem; + if ((state != previousState)&&(state == HIGH)){ + AnalogSensorManometre::setAlea(1); + previousState = HIGH; + } else if((state != previousState)&&(state == LOW)) { + AnalogSensorManometre::setAlea(-1); + previousState = LOW; + } + } +} + +float DigitalActuatorElectrovanne::getThresholdLow() const { + return thresholdLow; +} + +void DigitalActuatorElectrovanne::setThresholdLow(float thresholdLow) { + DigitalActuatorElectrovanne::thresholdLow = thresholdLow; +} + +float DigitalActuatorElectrovanne::getThresholdHigh() const { + return thresholdHigh; +} + +void DigitalActuatorElectrovanne::setThresholdHigh(float threshold) { + DigitalActuatorElectrovanne::thresholdHigh = threshold; +} diff --git a/include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h b/include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h index 7223364..6d79ce5 100644 --- a/include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h +++ b/include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h @@ -6,8 +6,24 @@ #define PROJET_VICTORAVECUNK_DIGITALACTUATORELECTROVANNE_H -class DigitalActuatorElectrovanne { +#include "../DigitalDevice.h" +class DigitalActuatorElectrovanne : public DigitalActuator{ + private: + float thresholdHigh, thresholdLow; + + public: + DigitalActuatorElectrovanne(int temps, float threshold, float thresholdLow); + + float getThresholdHigh() const; + void setThresholdHigh(float threshold); + + float getThresholdLow() const; + + void setThresholdLow(float thresholdLow); + + void activate(); + void run(); };