eive-obsw/mission/payload/RadiationSensorHandler.h
Robin Mueller a4a5800cba
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
EIVE/eive-obsw/pipeline/pr-main This commit looks good
that should do the job
2023-07-18 11:01:53 +02:00

61 lines
2.5 KiB
C++

#ifndef MISSION_PAYLOAD_RADIATIONSENSORHANDLER_H_
#define MISSION_PAYLOAD_RADIATIONSENSORHANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw_hal/common/gpio/GpioIF.h>
#include <mission/payload/radSensorDefinitions.h>
#include <mission/system/objects/Stack5VHandler.h>
/**
* @brief This is the device handler class for radiation sensor on the OBC IF Board. The
* sensor is based on the MAX1227 ADC converter.
*
* @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf
*
* @author J. Meier
*/
class RadiationSensorHandler : public DeviceHandlerBase {
public:
RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
GpioIF *gpioIF, Stack5VHandler &handler);
virtual ~RadiationSensorHandler();
void setToGoToNormalModeImmediately();
void enablePeriodicDataPrint(bool enable);
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
private:
static constexpr uint32_t DEFAULT_MEASUREMENT_CD_MS = 30 * 60 * 1000;
enum class CommunicationStep { START_CONVERSION, READ_CONVERSIONS };
enum class InternalState { OFF, POWER_SWITCHING, SETUP, CONFIGURED };
bool printPeriodicData = false;
radSens::RadSensorDataset dataset;
Countdown measurementCd = Countdown(DEFAULT_MEASUREMENT_CD_MS);
static const uint8_t MAX_CMD_LEN = radSens::READ_SIZE;
GpioIF *gpioIF = nullptr;
Stack5VHandler &stackHandler;
bool goToNormalMode = false;
uint8_t cmdBuffer[MAX_CMD_LEN];
InternalState internalState = InternalState::OFF;
CommunicationStep communicationStep = CommunicationStep::START_CONVERSION;
};
#endif /* MISSION_PAYLOAD_RADIATIONSENSORHANDLER_H_ */