simplified SA Depl init
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2022-10-12 13:56:25 +02:00
parent ea82748496
commit 09c0afbe7f
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 116 additions and 131 deletions

View File

@ -539,7 +539,8 @@ void ObjectFactory::createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwi
pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V);
}
void ObjectFactory::createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitcher) {
void ObjectFactory::createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitcher,
GpioIF& gpioIF) {
using namespace gpio;
GpioCookie* solarArrayDeplCookie = new GpioCookie;
GpiodRegularByLineName* gpio = nullptr;
@ -552,10 +553,12 @@ void ObjectFactory::createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitc
gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), Direction::OUT,
Levels::LOW);
solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio);
ReturnValue_t result = gpioIF.addGpios(solarArrayDeplCookie);
if (result != returnvalue::OK) {
sif::error << "Adding Solar Array Deployment GPIO cookie failed" << std::endl;
}
// TODO: Find out burn time. For now set to 1000 ms.
new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF,
solarArrayDeplCookie, pwrSwitcher,
new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, gpioIF, pwrSwitcher,
pcdu::Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V,
gpioIds::DEPLSA1, gpioIds::DEPLSA2);
}

View File

@ -33,7 +33,7 @@ void createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwitcher, HealthTa
void createImtqComponents(PowerSwitchIF* pwrSwitcher);
void createBpxBatteryComponent();
void createStrComponents(PowerSwitchIF* pwrSwitcher);
void createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitcher);
void createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitcher, GpioIF& gpioIF);
void createSyrlinksComponents(PowerSwitchIF* pwrSwitcher);
void createPayloadComponents(LinuxLibgpioIF* gpioComIF);
void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher);

View File

@ -35,7 +35,7 @@ void ObjectFactory::produce(void* args) {
createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher);
#endif
createHeaterComponents(gpioComIF, pwrSwitcher, healthTable);
createSolarArrayDeploymentComponents(*pwrSwitcher);
createSolarArrayDeploymentComponents(*pwrSwitcher, *gpioComIF);
createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher);
#if OBSW_ADD_SYRLINKS == 1
createSyrlinksComponents(pwrSwitcher);

View File

@ -5,13 +5,13 @@
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw_hal/common/gpio/GpioCookie.h>
SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(
object_id_t setObjectId_, object_id_t gpioDriverId_, CookieIF* gpioCookie_,
PowerSwitchIF& mainLineSwitcher_, pcdu::Switches mainLineSwitch_, gpioId_t deplSA1,
gpioId_t deplSA2)
SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_,
GpioIF& gpioInterface,
PowerSwitchIF& mainLineSwitcher_,
pcdu::Switches mainLineSwitch_,
gpioId_t deplSA1, gpioId_t deplSA2)
: SystemObject(setObjectId_),
gpioDriverId(gpioDriverId_),
gpioCookie(gpioCookie_),
gpioInterface(gpioInterface),
deplSA1(deplSA1),
deplSA2(deplSA2),
mainLineSwitcher(mainLineSwitcher_),
@ -38,19 +38,6 @@ ReturnValue_t SolarArrayDeploymentHandler::initialize() {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
gpioInterface = ObjectManager::instance()->get<GpioIF>(gpioDriverId);
if (gpioInterface == nullptr) {
sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = gpioInterface->addGpios(dynamic_cast<GpioCookie*>(gpioCookie));
if (result != returnvalue::OK) {
sif::error << "SolarArrayDeploymentHandler::initialize: Failed to initialize Gpio interface"
<< std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = actionHelper.initialize(commandQueue);
if (result != returnvalue::OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
@ -60,83 +47,85 @@ ReturnValue_t SolarArrayDeploymentHandler::initialize() {
}
void SolarArrayDeploymentHandler::handleStateMachine() {
// switch (stateMachine) {
// case WAIT_ON_DELOYMENT_COMMAND:
// readCommandQueue();
// break;
// case SWITCH_8V_ON:
// mainLineSwitcher.sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON);
// mainSwitchCountdown.setTimeout(mainLineSwitcher.getSwitchDelayMs());
// stateMachine = WAIT_ON_8V_SWITCH;
// break;
// case WAIT_ON_8V_SWITCH:
// performWaitOn8VActions();
// break;
// case SWITCH_DEPL_GPIOS:
// deploymentTransistorsOn();
// break;
//// case WAIT_ON_DEPLOYMENT_FINISH:
//// handleDeploymentFinish();
//// break;
// case WAIT_FOR_MAIN_SWITCH_OFF:
// if (mainLineSwitcher.getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) {
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// } else if (mainSwitchCountdown.hasTimedOut()) {
// triggerEvent(MAIN_SWITCH_OFF_TIMEOUT);
// sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main"
// << " switch off" << std::endl;
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// }
// break;
// default:
// sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" << std::endl;
// break;
// }
// switch (stateMachine) {
// case WAIT_ON_DELOYMENT_COMMAND:
// readCommandQueue();
// break;
// case SWITCH_8V_ON:
// mainLineSwitcher.sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON);
// mainSwitchCountdown.setTimeout(mainLineSwitcher.getSwitchDelayMs());
// stateMachine = WAIT_ON_8V_SWITCH;
// break;
// case WAIT_ON_8V_SWITCH:
// performWaitOn8VActions();
// break;
// case SWITCH_DEPL_GPIOS:
// deploymentTransistorsOn();
// break;
//// case WAIT_ON_DEPLOYMENT_FINISH:
//// handleDeploymentFinish();
//// break;
// case WAIT_FOR_MAIN_SWITCH_OFF:
// if (mainLineSwitcher.getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) {
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// } else if (mainSwitchCountdown.hasTimedOut()) {
// triggerEvent(MAIN_SWITCH_OFF_TIMEOUT);
// sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main"
// << " switch off" << std::endl;
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// }
// break;
// default:
// sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" <<
// std::endl; break;
// }
}
void SolarArrayDeploymentHandler::performWaitOn8VActions() {
// if (mainLineSwitcher.getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) {
// stateMachine = SWITCH_DEPL_GPIOS;
// } else {
// if (mainSwitchCountdown.hasTimedOut()) {
// triggerEvent(MAIN_SWITCH_ON_TIMEOUT);
// actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS,
// MAIN_SWITCH_TIMEOUT_FAILURE);
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// }
// }
// if (mainLineSwitcher.getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) {
// stateMachine = SWITCH_DEPL_GPIOS;
// } else {
// if (mainSwitchCountdown.hasTimedOut()) {
// triggerEvent(MAIN_SWITCH_ON_TIMEOUT);
// actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS,
// MAIN_SWITCH_TIMEOUT_FAILURE);
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// }
// }
}
void SolarArrayDeploymentHandler::deploymentTransistorsOn() {
// ReturnValue_t result = returnvalue::OK;
// result = gpioInterface->pullHigh(deplSA1);
// if (result != returnvalue::OK) {
// sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
// " array deployment switch 1 high "
// << std::endl;
// /* If gpio switch high failed, state machine is reset to wait for a command reinitiating
// * the deployment sequence. */
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED);
// actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED);
// mainLineSwitcher.sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
// }
// result = gpioInterface->pullHigh(deplSA2);
// if (result != returnvalue::OK) {
// sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
// " array deployment switch 2 high "
// << std::endl;
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED);
// actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED);
// mainLineSwitcher.sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
// }
//deploymentCountdown.setTimeout(burnTimeMs);
//stateMachine = WAIT_ON_DEPLOYMENT_FINISH;
// ReturnValue_t result = returnvalue::OK;
// result = gpioInterface->pullHigh(deplSA1);
// if (result != returnvalue::OK) {
// sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
// " array deployment switch 1 high "
// << std::endl;
// /* If gpio switch high failed, state machine is reset to wait for a command reinitiating
// * the deployment sequence. */
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED);
// actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS,
// SWITCHING_DEPL_SA2_FAILED); mainLineSwitcher.sendSwitchCommand(mainLineSwitch,
// PowerSwitchIF::SWITCH_OFF);
// }
// result = gpioInterface->pullHigh(deplSA2);
// if (result != returnvalue::OK) {
// sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
// " array deployment switch 2 high "
// << std::endl;
// stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED);
// actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS,
// SWITCHING_DEPL_SA2_FAILED); mainLineSwitcher.sendSwitchCommand(mainLineSwitch,
// PowerSwitchIF::SWITCH_OFF);
// }
// deploymentCountdown.setTimeout(burnTimeMs);
// stateMachine = WAIT_ON_DEPLOYMENT_FINISH;
}
//void SolarArrayDeploymentHandler::handleDeploymentFinish() {
// ReturnValue_t result = returnvalue::OK;
// void SolarArrayDeploymentHandler::handleDeploymentFinish() {
// ReturnValue_t result = returnvalue::OK;
//// if (deploymentCountdown.hasTimedOut()) {
//// actionHelper.finish(true, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, returnvalue::OK);
//// result = gpioInterface->pullLow(deplSA1);
@ -174,20 +163,20 @@ ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) {
ReturnValue_t result;
// if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) {
// sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in"
// << "waiting-on-command-state" << std::endl;
// return DEPLOYMENT_ALREADY_EXECUTING;
// }
// if (actionId != DEPLOY_SOLAR_ARRAYS) {
// sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command"
// << std::endl;
// result = COMMAND_NOT_SUPPORTED;
// } else {
// stateMachine = SWITCH_8V_ON;
// rememberCommanderId = commandedBy;
// result = returnvalue::OK;
// }
// if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) {
// sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in"
// << "waiting-on-command-state" << std::endl;
// return DEPLOYMENT_ALREADY_EXECUTING;
// }
// if (actionId != DEPLOY_SOLAR_ARRAYS) {
// sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command"
// << std::endl;
// result = COMMAND_NOT_SUPPORTED;
// } else {
// stateMachine = SWITCH_8V_ON;
// rememberCommanderId = commandedBy;
// result = returnvalue::OK;
// }
return result;
}

View File

@ -43,9 +43,9 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
* @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor.
* @param burnTimeMs Time duration the power will be applied to the burn wires.
*/
SolarArrayDeploymentHandler(object_id_t setObjectId, object_id_t gpioDriverId,
CookieIF* gpioCookie, PowerSwitchIF& mainLineSwitcher,
pcdu::Switches mainLineSwitch, gpioId_t deplSA1, gpioId_t deplSA2);
SolarArrayDeploymentHandler(object_id_t setObjectId, GpioIF& gpio,
PowerSwitchIF& mainLineSwitcher, pcdu::Switches mainLineSwitch,
gpioId_t deplSA1, gpioId_t deplSA2);
virtual ~SolarArrayDeploymentHandler();
@ -71,16 +71,16 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH);
static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH);
// enum StateMachine {
// WAIT_ON_DELOYMENT_COMMAND,
// SWITCH_8V_ON,
// WAIT_ON_8V_SWITCH,
// SWITCH_DEPL_GPIOS,
// WAIT_ON_DEPLOYMENT_FINISH,
// WAIT_FOR_MAIN_SWITCH_OFF
// };
//
// StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND;
// enum StateMachine {
// WAIT_ON_DELOYMENT_COMMAND,
// SWITCH_8V_ON,
// WAIT_ON_8V_SWITCH,
// SWITCH_DEPL_GPIOS,
// WAIT_ON_DEPLOYMENT_FINISH,
// WAIT_FOR_MAIN_SWITCH_OFF
// };
//
// StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND;
/**
* This countdown is used to check if the PCDU sets the 8V line on in the intended time.
@ -90,7 +90,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
/**
* This countdown is used to wait for the burn wire being successful cut.
*/
//Countdown deploymentCountdown;
// Countdown deploymentCountdown;
/**
* The message queue id of the component commanding an action will be stored in this variable.
@ -100,17 +100,10 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
/** Size of command queue */
size_t cmdQueueSize = 20;
/** The object ID of the GPIO driver which switches the deployment transistors */
object_id_t gpioDriverId;
CookieIF* gpioCookie;
GpioIF& gpioInterface;
gpioId_t deplSA1;
gpioId_t deplSA2;
GpioIF* gpioInterface = nullptr;
/** Queue to receive messages from other objects. */
MessageQueueIF* commandQueue = nullptr;
@ -146,7 +139,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
* @brief This function performs actions to finish the deployment. Essentially switches
* are turned of after the burn time has expired.
*/
//void handleDeploymentFinish();
// void handleDeploymentFinish();
};
#endif /* MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ */