Small fixes

This commit is contained in:
Ulrich Mohr 2022-08-17 17:55:21 +02:00
parent ef40db7fe4
commit a91393b4b4
4 changed files with 41 additions and 19 deletions

View File

@ -104,13 +104,11 @@ void HeaterHandler::readCommandQueue() {
} while (result == RETURN_OK);
}
ReturnValue_t HeaterHandler::executeAction(Action* action) {
return action->handle();
}
ReturnValue_t HeaterHandler::executeAction(Action* action) { return action->handle(); }
ReturnValue_t HeaterHandler::handleAction(SetHeaterAction *heaterAction){
auto& heater = heaterVec.at(heaterAction->switchNr);
auto action = heaterAction->switchAction;
ReturnValue_t HeaterHandler::handleAction(SetHeaterAction* heaterAction) {
auto& heater = heaterVec.at(heaterAction->switchNr);
auto action = heaterAction->switchAction;
// Always accepts OFF commands
if (action == SetHeaterAction::SwitchAction::SET_SWITCH_ON) {
HasHealthIF::HealthState health = heater.healthDevice->getHealth();
@ -119,7 +117,8 @@ ReturnValue_t HeaterHandler::executeAction(Action* action) {
return HasHealthIF::OBJECT_NOT_HEALTHY;
}
auto cmdSource = heaterAction->cmdSource;
if (health == HasHealthIF::EXTERNAL_CONTROL and cmdSource == SetHeaterAction::CmdSourceParam::INTERNAL) {
if (health == HasHealthIF::EXTERNAL_CONTROL and
cmdSource == SetHeaterAction::CmdSourceParam::INTERNAL) {
return HasHealthIF::IS_EXTERNALLY_CONTROLLED;
}
}
@ -131,7 +130,7 @@ ReturnValue_t HeaterHandler::executeAction(Action* action) {
heater.cmdActive = true;
heater.replyQueue = heaterAction->commandedBy;
return RETURN_OK;
}
}
ReturnValue_t HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) {
ReturnValue_t result;
@ -157,7 +156,8 @@ ReturnValue_t HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t o
result = ipcStore->addData(&storeAddress, commandData, sizeof(commandData));
if (result == RETURN_OK) {
CommandMessage message;
ActionMessage::setCommand(&message, static_cast<ActionId_t>(HeaterCommands::SWITCH_HEATER), storeAddress);
ActionMessage::setCommand(&message, static_cast<ActionId_t>(HeaterCommands::SWITCH_HEATER),
storeAddress);
/* Send heater command to own command queue */
result = commandQueue->sendMessage(commandQueue->getId(), &message, 0);
if (result != RETURN_OK) {
@ -211,7 +211,8 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) {
heater.cmdActive = false;
heater.waitMainSwitchOn = false;
if (heater.replyQueue != commandQueue->getId()) {
actionHelper.finish(false, heater.replyQueue, static_cast<ActionId_t>(heater.action), MAIN_SWITCH_SET_TIMEOUT);
actionHelper.finish(false, heater.replyQueue, static_cast<ActionId_t>(heater.action),
MAIN_SWITCH_SET_TIMEOUT);
}
return;
}
@ -237,9 +238,11 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) {
// HeaterHandler itself
if (heater.replyQueue != commandQueue->getId()) {
if (result == RETURN_OK) {
actionHelper.finish(true, heater.replyQueue, static_cast<ActionId_t>(heater.action), result);
actionHelper.finish(true, heater.replyQueue, static_cast<ActionId_t>(heater.action),
result);
} else {
actionHelper.finish(false, heater.replyQueue, static_cast<ActionId_t>(heater.action), result);
actionHelper.finish(false, heater.replyQueue, static_cast<ActionId_t>(heater.action),
result);
}
}
heater.cmdActive = false;
@ -255,7 +258,8 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) {
sif::debug << "HeaterHandler::handleSwitchHandling: Failed to get state of"
<< " main line switch" << std::endl;
if (heater.replyQueue != commandQueue->getId()) {
actionHelper.finish(false, heater.replyQueue, static_cast<ActionId_t>(heater.action), mainSwitchState);
actionHelper.finish(false, heater.replyQueue, static_cast<ActionId_t>(heater.action),
mainSwitchState);
}
heater.cmdActive = false;
}
@ -316,6 +320,8 @@ bool HeaterHandler::allSwitchesOff() {
MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->getId(); }
ActionHelper* HeaterHandler::getActionHelper() { return &actionHelper; }
ReturnValue_t HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) { return RETURN_OK; }
ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const {

View File

@ -66,8 +66,10 @@ class HeaterHandler : public ExecutableObjectIF,
uint32_t getSwitchDelayMs(void) const override;
MessageQueueId_t getCommandQueue() const override;
ActionHelper* getActionHelper() override;
ReturnValue_t executeAction(Action* action) override;
ReturnValue_t handleAction(SetHeaterAction *heaterAction);
ReturnValue_t initialize() override;
private:

View File

@ -111,8 +111,10 @@ void SolarArrayDeploymentHandler::performWaitOn8VActions() {
} else {
if (mainSwitchCountdown.hasTimedOut()) {
triggerEvent(MAIN_SWITCH_ON_TIMEOUT);
actionHelper.finish(false, rememberCommanderId, static_cast<DeviceCommandId_t>(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS),
MAIN_SWITCH_TIMEOUT_FAILURE);
actionHelper.finish(
false, rememberCommanderId,
static_cast<DeviceCommandId_t>(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS),
MAIN_SWITCH_TIMEOUT_FAILURE);
stateMachine = WAIT_ON_DELOYMENT_COMMAND;
}
}
@ -129,7 +131,10 @@ void SolarArrayDeploymentHandler::switchDeploymentTransistors() {
* the deployment sequence. */
stateMachine = WAIT_ON_DELOYMENT_COMMAND;
triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED);
actionHelper.finish(false, rememberCommanderId, static_cast<DeviceCommandId_t>(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), SWITCHING_DEPL_SA1_FAILED);
actionHelper.finish(
false, rememberCommanderId,
static_cast<DeviceCommandId_t>(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS),
SWITCHING_DEPL_SA1_FAILED);
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
}
result = gpioInterface->pullHigh(deplSA2);
@ -139,7 +144,10 @@ void SolarArrayDeploymentHandler::switchDeploymentTransistors() {
<< std::endl;
stateMachine = WAIT_ON_DELOYMENT_COMMAND;
triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED);
actionHelper.finish(false, rememberCommanderId, static_cast<DeviceCommandId_t>(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), SWITCHING_DEPL_SA2_FAILED);
actionHelper.finish(
false, rememberCommanderId,
static_cast<DeviceCommandId_t>(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS),
SWITCHING_DEPL_SA2_FAILED);
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
}
deploymentCountdown.setTimeout(burnTimeMs);
@ -149,7 +157,10 @@ void SolarArrayDeploymentHandler::switchDeploymentTransistors() {
void SolarArrayDeploymentHandler::handleDeploymentFinish() {
ReturnValue_t result = RETURN_OK;
if (deploymentCountdown.hasTimedOut()) {
actionHelper.finish(true, rememberCommanderId, static_cast<DeviceCommandId_t>(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), RETURN_OK);
actionHelper.finish(
true, rememberCommanderId,
static_cast<DeviceCommandId_t>(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS),
RETURN_OK);
result = gpioInterface->pullLow(deplSA1);
if (result != RETURN_OK) {
sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
@ -187,7 +198,7 @@ ReturnValue_t SolarArrayDeploymentHandler::executeAction(Action* action) {
<< "waiting-on-command-state" << std::endl;
return DEPLOYMENT_ALREADY_EXECUTING;
}
//delegates to SolarArrayDeploymentHandler::handleAction()
// delegates to SolarArrayDeploymentHandler::handleAction()
return action->handle();
}
@ -200,3 +211,5 @@ ReturnValue_t SolarArrayDeploymentHandler::handleAction(SolarArrayDeploymentActi
MessageQueueId_t SolarArrayDeploymentHandler::getCommandQueue() const {
return commandQueue->getId();
}
ActionHelper* SolarArrayDeploymentHandler::getActionHelper() { return &actionHelper; }

View File

@ -50,6 +50,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual MessageQueueId_t getCommandQueue() const override;
virtual ActionHelper *getActionHelper() override;
virtual ReturnValue_t executeAction(Action* action) override;
ReturnValue_t handleAction(SolarArrayDeploymentAction* action);
virtual ReturnValue_t initialize() override;