Projet_VictorAvecUnK/OtherDevices/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.cpp

43 lines
1.4 KiB
C++

//
// Created by camer on 16/05/2020.
//
#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;
}