Heater Handling #325

Merged
muellerr merged 78 commits from heater_handling into develop 2023-02-08 21:35:05 +01:00
4 changed files with 22 additions and 16 deletions
Showing only changes of commit 868ba0cd03 - Show all commits

View File

@ -105,23 +105,25 @@ void ThermalController::performControlOperation() {
}
// TODO: Heater control
//TODO: Hysterese offset
if(heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == HeaterHandler::SwitchState::OFF){
if(sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) {
// TODO: Hysterese offset
if (heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState ==
HeaterHandler::SwitchState::OFF) {
if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) {
heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true;
heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_ON;
heaterHandler.handleSwitchOnCommand(heater::HEATER_4_CAMERA);
heater4Countdown.resetTimer();
}
}else if(heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == HeaterHandler::SwitchState::ON){
if(sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit){
if(heater4Countdown.hasTimedOut()){
} else if (heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState ==
HeaterHandler::SwitchState::ON) {
if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) {
if (heater4Countdown.hasTimedOut()) {
heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true;
heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_OFF;
//triggerEvent(HEATER_TIMEOUT, heater::HEATER_4_CAMERA);
// triggerEvent(HEATER_TIMEOUT, heater::HEATER_4_CAMERA);
heaterHandler.handleSwitchOffCommand(heater::HEATER_4_CAMERA);
}
}else {
} else {
heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true;
heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_OFF;
heaterHandler.handleSwitchOffCommand(heater::HEATER_4_CAMERA);

View File

@ -53,11 +53,10 @@ class ThermalController : public ExtendedControllerBase {
private:
static const uint32_t DELAY = 500;
static const uint32_t OP_TIME = 1000; //TODO to be changed
static const uint32_t OP_TIME = 1000; // TODO to be changed
enum class InternalState { STARTUP, INITIAL_DELAY, READY };
InternalState internalState = InternalState::STARTUP;
HeaterHandler& heaterHandler;

View File

@ -321,8 +321,13 @@ HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers swi
return heaterVec.at(switchNr).switchState;
}
ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, ReturnValue_t onOff) {
return sendSwitchCommand(heater, onOff);
ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, SwitchState switchState) {
if (switchState == SwitchState::ON) {
return sendSwitchCommand(heater, PowerSwitchIF::SWITCH_ON);
} else if (switchState == SwitchState::OFF) {
return sendSwitchCommand(heater, PowerSwitchIF::SWITCH_OFF);
}
return returnvalue::FAILED;
}
bool HeaterHandler::allSwitchesOff() {

View File

@ -64,7 +64,10 @@ class HeaterHandler : public ExecutableObjectIF,
virtual ~HeaterHandler();
protected:
ReturnValue_t switchHeater(heater::Switchers heater, ReturnValue_t onOff);
enum SwitchState : bool { ON = true, OFF = false };
enum SwitchAction : uint8_t { SET_SWITCH_OFF, SET_SWITCH_ON, NONE };
ReturnValue_t switchHeater(heater::Switchers heater, SwitchState switchState);
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override;
@ -96,9 +99,6 @@ class HeaterHandler : public ExecutableObjectIF,
static const MessageQueueId_t NO_COMMANDER = 0;
enum SwitchState : bool { ON = true, OFF = false };
enum SwitchAction : uint8_t { SET_SWITCH_OFF, SET_SWITCH_ON, NONE };
/**
* @brief Struct holding information about a heater command to execute.
*