From f99ea9a83da2a30316d07c2b2dfeaefbf58f64db Mon Sep 17 00:00:00 2001 From: victorleroch Date: Wed, 20 May 2020 11:05:57 +0200 Subject: [PATCH] =?UTF-8?q?electrovanne=20declar=C3=A9,=20je=20pense=20ca?= =?UTF-8?q?=20marche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DigitalActuatorElectrovanne.cpp | 38 +++++++++++++++++++ .../DigitalActuatorElectrovanne.h | 18 ++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) 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(); };