2022-05-16 11:10:35 +02:00
|
|
|
#include "DeviceHandlerCommander.h"
|
2022-06-06 11:55:42 +02:00
|
|
|
|
2022-06-05 12:52:55 +02:00
|
|
|
#include <fsfw/ipc/QueueFactory.h>
|
2022-05-16 11:10:35 +02:00
|
|
|
|
|
|
|
DeviceHandlerCommander::DeviceHandlerCommander(object_id_t objectId)
|
|
|
|
: SystemObject(objectId), commandActionHelper(this) {
|
|
|
|
auto mqArgs = MqArgs(this->getObjectId());
|
|
|
|
commandQueue = QueueFactory::instance()->createMessageQueue(
|
|
|
|
QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceHandlerCommander::~DeviceHandlerCommander() {}
|
|
|
|
|
|
|
|
ReturnValue_t DeviceHandlerCommander::performOperation(uint8_t operationCode) {
|
|
|
|
readCommandQueue();
|
2022-06-05 12:52:55 +02:00
|
|
|
return RETURN_OK;
|
2022-05-16 11:10:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t DeviceHandlerCommander::initialize() {
|
|
|
|
ReturnValue_t result = commandActionHelper.initialize();
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueueIF* DeviceHandlerCommander::getCommandQueuePtr() { return commandQueue; }
|
|
|
|
|
|
|
|
void DeviceHandlerCommander::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {}
|
|
|
|
|
|
|
|
void DeviceHandlerCommander::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
|
|
|
ReturnValue_t returnCode) {}
|
|
|
|
|
|
|
|
void DeviceHandlerCommander::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceHandlerCommander::completionSuccessfulReceived(ActionId_t actionId) {
|
|
|
|
lastReplyReturnCode = RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceHandlerCommander::completionFailedReceived(ActionId_t actionId,
|
|
|
|
ReturnValue_t returnCode) {
|
|
|
|
lastReplyReturnCode = returnCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceHandlerCommander::readCommandQueue() {
|
|
|
|
CommandMessage message;
|
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
|
|
|
for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK;
|
|
|
|
result = commandQueue->receiveMessage(&message)) {
|
|
|
|
result = commandActionHelper.handleReply(&message);
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t DeviceHandlerCommander::sendCommand(object_id_t target, ActionId_t actionId) {
|
|
|
|
return commandActionHelper.commandAction(target, actionId, nullptr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t DeviceHandlerCommander::getReplyReturnCode() { return lastReplyReturnCode; }
|
|
|
|
|
2022-06-06 11:55:42 +02:00
|
|
|
void DeviceHandlerCommander::resetReplyReturnCode() { lastReplyReturnCode = RETURN_FAILED; }
|