pass comn if to handler

This commit is contained in:
Robin Müller 2022-02-10 16:55:06 +01:00
parent 00f411eaca
commit 513c907962
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 53 additions and 14 deletions

View File

@ -1082,7 +1082,8 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF*
q7s::SPI_DEFAULT_DEV, plpcdu::MAX_ADC_REPLY_SIZE, spi::DEFAULT_MAX_1227_MODE, q7s::SPI_DEFAULT_DEV, plpcdu::MAX_ADC_REPLY_SIZE, spi::DEFAULT_MAX_1227_MODE,
spi::DEFAULT_MAX_1227_SPEED); spi::DEFAULT_MAX_1227_SPEED);
// Create device handler components // Create device handler components
auto plPcduHandler = PayloadPcduHandler(objects::PLPCDU_HANDLER, objects::SPI_COM_IF, spiCookie); auto plPcduHandler = PayloadPcduHandler(objects::PLPCDU_HANDLER, objects::SPI_COM_IF, spiCookie,
gpioComIF);
} }
void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {

View File

@ -1,24 +1,54 @@
#include "PayloadPcduHandler.h" #include "PayloadPcduHandler.h"
PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie) #include "devices/gpioIds.h"
: DeviceHandlerBase(objectId, comIF, cookie), state(States::ON) {}
PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie,
GpioIF* gpioIF)
: DeviceHandlerBase(objectId, comIF, cookie), state(States::ADC_OFF_PL_OFF), gpioIF(gpioIF) {}
void PayloadPcduHandler::doStartUp() { void PayloadPcduHandler::doStartUp() {
switch(state) { switch(state) {
case(States::ADC_OFF_PL_OFF): { case(States::ADC_OFF_PL_OFF): {
// Switch on relays here
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0);
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1);
state = States::SWITCH_ON_RELAY_TRANSITION;
break; break;
} }
case(States::SWITCH_ON_RELAY): { case(States::SWITCH_ON_RELAY_TRANSITION): {
// If necessary, check whether a certain amount of time has elapaed // If necessary, check whether a certain amount of time has elapsed
state = States::ADC_OFF_PL_OFF;
break; break;
} }
case(States::ADC_OFF_PL_OFF): { default:
break; // Config error
} sif::error << "PayloadPcduHandler::doStartUp: Invalid state" << std::endl;
case(States::SWITCH_ON_HPA): {
// If necessary, check whether a certain amount of time has elapaed
break;
} }
}
void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
if(mode == _MODE_TO_NORMAL) {
switch(state) {
case(States::ADC_OFF_PL_OFF): {
// Switch on HPA here
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO);
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA);
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX);
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_X8);
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA);
state = States::SWITCH_ON_HPA_TRANSITION;
break;
}
case(States::SWITCH_ON_HPA_TRANSITION): {
// If necessary, check whether a certain amount of time has elapsed
state = States::ADC_ON_PL_ON;
setMode(MODE_NORMAL);
break;
}
default:
// Config error
sif::error << "PayloadPcduHandler::doTransition: Invalid state" << std::endl;
}
} }
} }
@ -52,6 +82,8 @@ ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
uint32_t PayloadPcduHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; } uint32_t PayloadPcduHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; }
ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) { LocalDataPoolManager& poolManager) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;

View File

@ -2,21 +2,27 @@
#define LINUX_DEVICES_PLPCDUHANDLER_H_ #define LINUX_DEVICES_PLPCDUHANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include "fsfw_hal/common/gpio/GpioIF.h"
class PayloadPcduHandler : DeviceHandlerBase { class PayloadPcduHandler : DeviceHandlerBase {
public: public:
PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie); PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF);
private: private:
enum class States { enum class States {
ADC_OFF_PL_OFF, ADC_OFF_PL_OFF,
SWITCH_ON_RELAY, SWITCH_ON_RELAY_TRANSITION,
// In this mode, the handler can start polling the ADC. This is the ON mode
ADC_ON_PL_OFF, ADC_ON_PL_OFF,
SWITCH_ON_HPA, SWITCH_ON_HPA_TRANSITION,
// Now the ADC is actually spitting out sensible values. This is the normal mode with the
// experiment being on.
ADC_ON_PL_ON ADC_ON_PL_ON
}; };
States state; States state;
GpioIF* gpioIF;
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
void doStartUp() override; void doStartUp() override;
void doShutDown() override; void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;