fsfw/src/fsfw/datapool/HkSwitchHelper.cpp

68 lines
2.2 KiB
C++
Raw Normal View History

2021-07-13 20:22:54 +02:00
#include "fsfw/datapool/HkSwitchHelper.h"
2022-02-02 10:29:30 +01:00
2021-07-13 20:22:54 +02:00
#include "fsfw/ipc/QueueFactory.h"
2022-02-02 10:29:30 +01:00
HkSwitchHelper::HkSwitchHelper(EventReportingProxyIF* eventProxy)
: commandActionHelper(this), eventProxy(eventProxy) {
actionQueue = QueueFactory::instance()->createMessageQueue();
}
2022-02-02 10:29:30 +01:00
HkSwitchHelper::~HkSwitchHelper() { QueueFactory::instance()->deleteMessageQueue(actionQueue); }
ReturnValue_t HkSwitchHelper::initialize() {
2022-02-02 10:29:30 +01:00
ReturnValue_t result = commandActionHelper.initialize();
2022-02-02 10:29:30 +01:00
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
2022-02-02 10:29:30 +01:00
return result;
}
ReturnValue_t HkSwitchHelper::performOperation(uint8_t operationCode) {
2022-02-02 10:29:30 +01:00
CommandMessage command;
while (actionQueue->receiveMessage(&command) == HasReturnvaluesIF::RETURN_OK) {
ReturnValue_t result = commandActionHelper.handleReply(&command);
if (result == HasReturnvaluesIF::RETURN_OK) {
continue;
}
command.setToUnknownCommand();
actionQueue->reply(&command);
}
2022-02-02 10:29:30 +01:00
return HasReturnvaluesIF::RETURN_OK;
}
2022-02-02 10:29:30 +01:00
void HkSwitchHelper::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {}
void HkSwitchHelper::stepFailedReceived(ActionId_t actionId, uint8_t step,
2022-02-02 10:29:30 +01:00
ReturnValue_t returnCode) {
eventProxy->forwardEvent(SWITCHING_TM_FAILED, returnCode, actionId);
}
2022-02-02 10:29:30 +01:00
void HkSwitchHelper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {}
2022-02-02 10:29:30 +01:00
void HkSwitchHelper::completionSuccessfulReceived(ActionId_t actionId) {}
2022-02-02 10:29:30 +01:00
void HkSwitchHelper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
eventProxy->forwardEvent(SWITCHING_TM_FAILED, returnCode, actionId);
}
ReturnValue_t HkSwitchHelper::switchHK(SerializeIF* sids, bool enable) {
2022-02-02 10:29:30 +01:00
// ActionId_t action = HKService::DISABLE_HK;
// if (enable) {
// action = HKService::ENABLE_HK;
// }
//
// ReturnValue_t result = commandActionHelper.commandAction(
// objects::PUS_HK_SERVICE, action, sids);
//
// if (result != HasReturnvaluesIF::RETURN_OK) {
// eventProxy->forwardEvent(SWITCHING_TM_FAILED, result);
// }
// return result;
return HasReturnvaluesIF::RETURN_OK;
}
2022-02-02 10:29:30 +01:00
MessageQueueIF* HkSwitchHelper::getCommandQueuePtr() { return actionQueue; }