struct heaterStates and more
This commit is contained in:
@@ -1344,102 +1344,31 @@ void ThermalController::ctrlScexBoard() {
|
||||
}
|
||||
|
||||
void ThermalController::performThermalModuleCtrl() {
|
||||
ctrlAcsBoard();
|
||||
ctrlMgt();
|
||||
ctrlRw();
|
||||
ctrlStr();
|
||||
ctrlIfBoard();
|
||||
ctrlTcsBoard();
|
||||
ctrlObc();
|
||||
ctrlObcIfBoard();
|
||||
ctrlSBandTransceiver();
|
||||
ctrlPcduP60Board();
|
||||
ctrlPcduAcu();
|
||||
ctrlPcduPdu();
|
||||
ctrlPlPcduBoard();
|
||||
ctrlPlocMissionBoard();
|
||||
ctrlPlocProcessingBoard();
|
||||
ctrlDac();
|
||||
// ctrlAcsBoard();
|
||||
// ctrlMgt();
|
||||
// ctrlRw();
|
||||
// ctrlStr();
|
||||
// ctrlIfBoard();
|
||||
// ctrlTcsBoard();
|
||||
// ctrlObc();
|
||||
// ctrlObcIfBoard();
|
||||
// ctrlSBandTransceiver();
|
||||
// ctrlPcduP60Board();
|
||||
// ctrlPcduAcu();
|
||||
// ctrlPcduPdu();
|
||||
// ctrlPlPcduBoard();
|
||||
// ctrlPlocMissionBoard();
|
||||
// ctrlPlocProcessingBoard();
|
||||
// ctrlDac();
|
||||
ctrlCameraBody();
|
||||
ctrlDro();
|
||||
ctrlX8();
|
||||
ctrlHpa();
|
||||
ctrlTx();
|
||||
ctrlMpa();
|
||||
ctrlScexBoard();
|
||||
// ctrlDro();
|
||||
// ctrlX8();
|
||||
// ctrlHpa();
|
||||
// ctrlTx();
|
||||
// ctrlMpa();
|
||||
// ctrlScexBoard();
|
||||
// heaterTransitionControl();
|
||||
}
|
||||
|
||||
void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr,
|
||||
struct TempLimits& tempLimit) {
|
||||
componentAboveCutOffLimit = false;
|
||||
// Heater off
|
||||
if (not heaterHandler.checkSwitchState(switchNr) and not thermalStates[thermalComponent].heating) {
|
||||
if (sensorTemp < tempLimit.opLowerLimit) {
|
||||
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON);
|
||||
sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " ON" << std::endl;
|
||||
thermalStates[thermalComponent].heating = true;
|
||||
//TODO: EVENT
|
||||
//TODO: merken wenn an oder ausgeschaltet und erst nach drei zyklen wieder checken? wenn in transition dann paar mal skippen mit transitionboolean; bool switchOnTransition und bool switchOffTasnition, counter 3 zyklen dabei checken ob tansition erfolgreich, bool clearen, falls drei erreicht heaterControlErrorCounter global zählen
|
||||
}
|
||||
// Heater on
|
||||
} else if (heaterHandler.checkSwitchState(switchNr) and thermalStates[thermalComponent].heating) {
|
||||
if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) {
|
||||
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
|
||||
sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; //TODO: array mit struct enthält infos
|
||||
thermalStates[thermalComponent].heating = false;
|
||||
|
||||
}
|
||||
} else if (redSwitchNrInUse) {
|
||||
if (heaterHandler.checkSwitchState(redSwitchNr)) {
|
||||
if (sensorTemp >= tempLimit.cutOffLimit) {
|
||||
componentAboveCutOffLimit = true;
|
||||
heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF);
|
||||
sif::info << "ThermalController::ctrlHeater: Heater" << redSwitchNr << " OFF" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr) {
|
||||
bool heaterAvailable = true;
|
||||
|
||||
if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) {
|
||||
if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) {
|
||||
switchNr = redSwitchNr;
|
||||
redSwitchNrInUse = true;
|
||||
} else {
|
||||
heaterAvailable = false;
|
||||
triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr);
|
||||
}
|
||||
} else {
|
||||
redSwitchNrInUse = false;
|
||||
}
|
||||
return heaterAvailable;
|
||||
}
|
||||
|
||||
bool ThermalController::selectAndReadSensorTemp() {
|
||||
for (unsigned i = 0; i < numSensors; i++) {
|
||||
if (sensors[i].first and sensors[i].second != INVALID_TEMPERATURE) {
|
||||
sensorTemp = sensors[i].second;
|
||||
thermalStates[thermalComponent].errorCounter = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
thermalStates[thermalComponent].errorCounter ++;
|
||||
if(thermalComponent != rw and thermalComponent != acsBoard){
|
||||
if (thermalStates[thermalComponent].errorCounter <= 3){
|
||||
triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent);
|
||||
}
|
||||
}else{
|
||||
if (thermalStates[thermalComponent].errorCounter <= 8){
|
||||
triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr,
|
||||
heater::Switchers redSwitchNr,
|
||||
TempLimits& tempLimit) {
|
||||
@@ -1458,12 +1387,116 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr,
|
||||
}
|
||||
resetSensorsArray();
|
||||
}
|
||||
bool ThermalController::selectAndReadSensorTemp() {
|
||||
for (unsigned i = 0; i < numSensors; i++) {
|
||||
if (sensors[i].first and sensors[i].second != INVALID_TEMPERATURE) {
|
||||
sensorTemp = sensors[i].second;
|
||||
thermalStates[thermalComponent].errorCounter = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
thermalStates[thermalComponent].errorCounter++;
|
||||
if (thermalComponent != rw and thermalComponent != acsBoard) {
|
||||
if (thermalStates[thermalComponent].errorCounter <= 3) {
|
||||
triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent);
|
||||
}
|
||||
} else {
|
||||
if (thermalStates[thermalComponent].errorCounter <= 8) {
|
||||
triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr) {
|
||||
bool heaterAvailable = true;
|
||||
|
||||
if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) {
|
||||
if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) {
|
||||
switchNr = redSwitchNr;
|
||||
redSwitchNrInUse = true;
|
||||
} else {
|
||||
heaterAvailable = false;
|
||||
triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr);
|
||||
}
|
||||
} else {
|
||||
redSwitchNrInUse = false;
|
||||
}
|
||||
return heaterAvailable;
|
||||
}
|
||||
void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr,
|
||||
struct TempLimits& tempLimit) {
|
||||
componentAboveCutOffLimit = false;
|
||||
// if Heater off
|
||||
if (not heaterStates[switchNr].switchOnTransition and
|
||||
not heaterStates[switchNr].switchOffTransition) {
|
||||
if (not heaterHandler.checkSwitchState(switchNr) and
|
||||
not thermalStates[thermalComponent].heating) {
|
||||
if (sensorTemp < tempLimit.opLowerLimit) {
|
||||
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON);
|
||||
heaterStates[switchNr].switchOnTransition = true;
|
||||
sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " ON"
|
||||
<< std::endl;
|
||||
thermalStates[thermalComponent].heating = true;
|
||||
// TODO: EVENT; aber heaterHandler erstellt schon event
|
||||
// TODO: merken wenn an oder ausgeschaltet und erst nach drei zyklen wieder checken? wenn in
|
||||
// transition dann paar mal skippen; bool switchOnTransition und bool
|
||||
// switchOffTasnition, counter 3 zyklen dabei checken ob tansition erfolgreich, bool
|
||||
// clearen, falls drei erreicht heaterControlErrorCounter global zählen
|
||||
}
|
||||
|
||||
// if Heater on
|
||||
} else if (heaterHandler.checkSwitchState(switchNr)) {
|
||||
if (thermalStates[thermalComponent].heating) {
|
||||
if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) {
|
||||
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
|
||||
sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " OFF"
|
||||
<< std::endl;
|
||||
heaterStates[switchNr].switchOffTransition = true;
|
||||
thermalStates[thermalComponent].heating = false;
|
||||
}
|
||||
} else {
|
||||
if (sensorTemp >= tempLimit.cutOffLimit) {
|
||||
componentAboveCutOffLimit = true;
|
||||
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
|
||||
sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: Heater "
|
||||
<< thermalComponent << " OFF" << std::endl;
|
||||
heaterStates[switchNr].switchOffTransition = true;
|
||||
if (heaterHandler.checkSwitchState(redSwitchNr)) {
|
||||
heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF);
|
||||
sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: RedundantHeater "
|
||||
<< thermalComponent << " OFF" << std::endl;
|
||||
heaterStates[redSwitchNr].switchOffTransition = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void ThermalController::resetSensorsArray() {
|
||||
// TODO: müssen auch andere Variablen resettet werden? senstemp?
|
||||
for (auto& validValuePair : sensors) {
|
||||
validValuePair.first = false;
|
||||
validValuePair.second = INVALID_TEMPERATURE;
|
||||
}
|
||||
thermalComponent = NONE;
|
||||
}
|
||||
void ThermalController::heaterTransitionControl() {
|
||||
for (unsigned i = 0; i < 7; i++) {
|
||||
if (heaterStates[i].switchOffTransition) {
|
||||
if (heaterStates[i].heaterSwitchOffControlErrorCounter > 3) {
|
||||
heaterStates[i].switchOffTransition = false;
|
||||
heaterStates[i].heaterSwitchOffControlErrorCounter = 0;
|
||||
}
|
||||
heaterStates[i].heaterSwitchOffControlErrorCounter++;
|
||||
}
|
||||
|
||||
if (heaterStates[i].switchOnTransition) {
|
||||
if (heaterStates[i].heaterSwitchOnControlErrorCounter > 3) {
|
||||
heaterStates[i].switchOnTransition = false;
|
||||
heaterStates[i].heaterSwitchOnControlErrorCounter = 0;
|
||||
}
|
||||
heaterStates[i].heaterSwitchOnControlErrorCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user