120 lines
4.2 KiB
C++
120 lines
4.2 KiB
C++
#ifndef MISSION_DEVICES_IMTQHANDLER_H_
|
|
#define MISSION_DEVICES_IMTQHANDLER_H_
|
|
|
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
|
#include <mission/devices/devicedefinitions/IMTQHandlerDefinitions.h>
|
|
#include <string.h>
|
|
|
|
/**
|
|
* @brief This is the device handler for the ISIS Magnetorquer iMTQ.
|
|
*
|
|
* @author J. Meier
|
|
*/
|
|
class IMTQHandler: public DeviceHandlerBase {
|
|
public:
|
|
|
|
IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
|
|
virtual ~IMTQHandler();
|
|
|
|
/**
|
|
* @brief Sets mode to MODE_NORMAL. Can be used for debugging.
|
|
*/
|
|
void setModeNormal();
|
|
|
|
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:
|
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER;
|
|
|
|
static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0);
|
|
static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1);
|
|
static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2);
|
|
static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3);
|
|
static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4);
|
|
static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5);
|
|
static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6);
|
|
|
|
|
|
IMTQ::EngHkDataset engHkDataset;
|
|
IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet;
|
|
IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet;
|
|
|
|
uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE];
|
|
|
|
enum class CommunicationStep {
|
|
SELF_TEST,
|
|
GET_ENG_HK_DATA,
|
|
START_MTM_MEASUREMENT,
|
|
GET_CAL_MTM_MEASUREMENT,
|
|
GET_RAW_MTM_MEASUREMENT
|
|
};
|
|
|
|
CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA;
|
|
|
|
/**
|
|
* @brief Each reply contains a status byte giving information about a request. This function
|
|
* parses this byte and returns the associated failure message.
|
|
*
|
|
* @param packet Pointer to the received message containing the status byte.
|
|
*
|
|
* @return The return code derived from the received status byte.
|
|
*/
|
|
ReturnValue_t parseStatusByte(const uint8_t* packet);
|
|
|
|
/**
|
|
* @brief This function fills the engineering housekeeping dataset with the received data.
|
|
|
|
* @param packet Pointer to the received data.
|
|
*
|
|
*/
|
|
void fillEngHkDataset(const uint8_t* packet);
|
|
|
|
/**
|
|
* @brief This function sends a command reply to the requesting queue.
|
|
*
|
|
* @param data Pointer to the data to send.
|
|
* @param dataSize Size of the data to send.
|
|
* @param relplyId Reply id which will be inserted at the beginning of the action message.
|
|
*/
|
|
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
|
|
|
|
/**
|
|
* @brief This function handles the reply containing the commanded dipole.
|
|
*
|
|
* @param packet Pointer to the reply data.
|
|
*/
|
|
void handleGetCommandedDipoleReply(const uint8_t* packet);
|
|
|
|
/**
|
|
* @brief This function parses the reply containing the calibrated MTM measurement and writes
|
|
* the values to the appropriate dataset.
|
|
* @param packet Pointer to the reply data.
|
|
*/
|
|
void fillCalibratedMtmDataset(const uint8_t* packet);
|
|
|
|
/**
|
|
* @brief This function copies the raw MTM measurements to the MTM raw dataset.
|
|
* @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS
|
|
* command.
|
|
*/
|
|
void fillRawMtmDataset(const uint8_t* packet);
|
|
};
|
|
|
|
#endif /* MISSION_DEVICES_IMTQHANDLER_H_ */
|