2021-05-02 13:48:39 +02:00
|
|
|
#ifndef MISSION_DEVICES_RADIATIONSENSORHANDLER_H_
|
|
|
|
#define MISSION_DEVICES_RADIATIONSENSORHANDLER_H_
|
2021-04-29 10:40:11 +02:00
|
|
|
|
|
|
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
2021-05-02 13:48:39 +02:00
|
|
|
#include <mission/devices/devicedefinitions/RadSensorDefinitions.h>
|
2021-04-29 10:40:11 +02:00
|
|
|
|
|
|
|
/**
|
2021-05-02 13:48:39 +02:00
|
|
|
* @brief This is the device handler class for radiation sensor on the OBC IF Board. The sensor
|
|
|
|
* is based on the MAX1227 ADC converter.
|
2021-04-29 10:40:11 +02:00
|
|
|
*
|
2021-05-02 13:48:39 +02:00
|
|
|
* @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf
|
2021-04-29 10:40:11 +02:00
|
|
|
*
|
|
|
|
* @author J. Meier
|
|
|
|
*/
|
2021-05-02 13:48:39 +02:00
|
|
|
class RadiationSensorHandler: public DeviceHandlerBase {
|
2021-04-29 10:40:11 +02:00
|
|
|
public:
|
|
|
|
|
2021-05-02 13:48:39 +02:00
|
|
|
RadiationSensorHandler(object_id_t objectId, object_id_t comIF,
|
2021-04-29 10:40:11 +02:00
|
|
|
CookieIF * comCookie);
|
2021-05-02 13:48:39 +02:00
|
|
|
virtual ~RadiationSensorHandler();
|
2021-04-29 10:40:11 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
void setNormalDatapoolEntriesInvalid() override;
|
|
|
|
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
|
|
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
|
|
|
LocalDataPoolManager& poolManager) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
enum class CommunicationStep {
|
2021-05-02 13:48:39 +02:00
|
|
|
START_CONVERSION,
|
|
|
|
READ_CONVERSIONS
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class InternalState {
|
|
|
|
SETUP,
|
|
|
|
CONFIGURED
|
2021-04-29 10:40:11 +02:00
|
|
|
};
|
|
|
|
|
2021-05-02 13:48:39 +02:00
|
|
|
RAD_SENSOR::RadSensorDataset dataset;
|
2021-04-29 10:40:11 +02:00
|
|
|
|
2021-05-02 13:48:39 +02:00
|
|
|
static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE;
|
2021-04-29 10:40:11 +02:00
|
|
|
|
|
|
|
uint8_t cmdBuffer[MAX_CMD_LEN];
|
2021-05-02 13:48:39 +02:00
|
|
|
InternalState internalState = InternalState::SETUP;
|
|
|
|
CommunicationStep communicationStep = CommunicationStep::START_CONVERSION;
|
2021-04-29 10:40:11 +02:00
|
|
|
};
|
|
|
|
|
2021-05-02 13:48:39 +02:00
|
|
|
#endif /* MISSION_DEVICES_RADIATIONSENSORHANDLER_H_ */
|