fsfw/src/fsfw/cfdp/FaultHandlerBase.h

56 lines
2.2 KiB
C
Raw Normal View History

2022-08-09 14:05:43 +02:00
#ifndef FSFW_CFDP_FAULTHANDLERBASE_H
#define FSFW_CFDP_FAULTHANDLERBASE_H
#include <etl/flat_map.h>
#include "definitions.h"
2022-08-09 14:55:08 +02:00
namespace cfdp {
class FaultHandlerBase {
2022-08-09 14:05:43 +02:00
public:
2022-08-09 14:55:08 +02:00
virtual ~FaultHandlerBase();
FaultHandlerBase();
2022-08-09 14:05:43 +02:00
2022-08-09 14:39:03 +02:00
/**
* Get the fault handler code for the given condition code
* @param code
* @param handler [out] Will be set to the approrpiate handler for the condition code if
* it is valid
* @return
* - true if the condition code is valid
* - false otherwise
*/
bool getFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes& handler) const;
bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes handler);
2022-08-09 15:09:43 +02:00
bool reportFault(cfdp::ConditionCode code);
2022-08-09 14:39:03 +02:00
virtual void noticeOfSuspensionCb(cfdp::ConditionCode code) = 0;
virtual void noticeOfCancellationCb(cfdp::ConditionCode code) = 0;
virtual void abandonCb(cfdp::ConditionCode code) = 0;
virtual void ignoreCb(cfdp::ConditionCode code) = 0;
2022-08-09 14:05:43 +02:00
private:
2022-08-09 15:09:43 +02:00
etl::flat_map<cfdp::ConditionCode, cfdp::FaultHandlerCodes, 10> faultHandlerMap = {
2022-08-09 14:05:43 +02:00
etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::INVALID_TRANSMISSION_MODE,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::FILE_SIZE_ERROR, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE,
2022-08-09 15:09:43 +02:00
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::FILESTORE_REJECTION, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}};
2022-08-09 14:05:43 +02:00
};
2022-08-09 14:55:08 +02:00
} // namespace cfdp
2022-08-09 14:05:43 +02:00
#endif // FSFW_CFDP_FAULTHANDLERBASE_H