Merge branch 'master' into mueller_FIFO_static_normal
This commit is contained in:
commit
02cfa8bcd5
@ -8,13 +8,16 @@
|
|||||||
const uint16_t EventManager::POOL_SIZES[N_POOLS] = {
|
const uint16_t EventManager::POOL_SIZES[N_POOLS] = {
|
||||||
sizeof(EventMatchTree::Node), sizeof(EventIdRangeMatcher),
|
sizeof(EventMatchTree::Node), sizeof(EventIdRangeMatcher),
|
||||||
sizeof(ReporterRangeMatcher) };
|
sizeof(ReporterRangeMatcher) };
|
||||||
//If one checks registerListener calls, there are around 40 (to max 50) objects registering for certain events.
|
// If one checks registerListener calls, there are around 40 (to max 50)
|
||||||
//Each listener requires 1 or 2 EventIdMatcher and 1 or 2 ReportRangeMatcher. So a good guess is 75 to a max of 100 pools required for each, which fits well.
|
// objects registering for certain events.
|
||||||
|
// Each listener requires 1 or 2 EventIdMatcher and 1 or 2 ReportRangeMatcher.
|
||||||
|
// So a good guess is 75 to a max of 100 pools required for each, which fits well.
|
||||||
|
// SHOULDDO: Shouldn't this be in the config folder and passed via ctor?
|
||||||
const uint16_t EventManager::N_ELEMENTS[N_POOLS] = { 240, 120, 120 };
|
const uint16_t EventManager::N_ELEMENTS[N_POOLS] = { 240, 120, 120 };
|
||||||
|
|
||||||
EventManager::EventManager(object_id_t setObjectId) :
|
EventManager::EventManager(object_id_t setObjectId) :
|
||||||
SystemObject(setObjectId), eventReportQueue(NULL), mutex(NULL), factoryBackend(
|
SystemObject(setObjectId),
|
||||||
0, POOL_SIZES, N_ELEMENTS, false, true) {
|
factoryBackend(0, POOL_SIZES, N_ELEMENTS, false, true) {
|
||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
eventReportQueue = QueueFactory::instance()->createMessageQueue(
|
eventReportQueue = QueueFactory::instance()->createMessageQueue(
|
||||||
MAX_EVENTS_PER_CYCLE, EventMessage::EVENT_MESSAGE_SIZE);
|
MAX_EVENTS_PER_CYCLE, EventMessage::EVENT_MESSAGE_SIZE);
|
||||||
@ -108,41 +111,45 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener,
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
//forward declaration, should be implemented by mission
|
|
||||||
const char* translateObject(object_id_t object);
|
|
||||||
const char * translateEvents(Event event);
|
|
||||||
|
|
||||||
void EventManager::printEvent(EventMessage* message) {
|
void EventManager::printEvent(EventMessage* message) {
|
||||||
const char *string = 0;
|
const char *string = 0;
|
||||||
switch (message->getSeverity()) {
|
switch (message->getSeverity()) {
|
||||||
case SEVERITY::INFO:
|
case SEVERITY::INFO:
|
||||||
// string = translateObject(message->getReporter());
|
#ifdef DEBUG_INFO_EVENT
|
||||||
// sif::info << "EVENT: ";
|
|
||||||
// if (string != 0) {
|
|
||||||
// sif::info << string;
|
|
||||||
// } else {
|
|
||||||
// sif::info << "0x" << std::hex << message->getReporter() << std::dec;
|
|
||||||
// }
|
|
||||||
// sif::info << " reported " << translateEvents(message->getEvent()) << " ("
|
|
||||||
// << std::dec << message->getEventId() << std::hex << ") P1: 0x"
|
|
||||||
// << message->getParameter1() << " P2: 0x"
|
|
||||||
// << message->getParameter2() << std::dec << std::endl;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
string = translateObject(message->getReporter());
|
string = translateObject(message->getReporter());
|
||||||
sif::error << "EVENT: ";
|
sif::info << "EVENT: ";
|
||||||
if (string != 0) {
|
if (string != 0) {
|
||||||
sif::error << string;
|
sif::info << string;
|
||||||
} else {
|
} else {
|
||||||
sif::error << "0x" << std::hex << message->getReporter() << std::dec;
|
sif::info << "0x" << std::hex << message->getReporter() << std::dec;
|
||||||
}
|
}
|
||||||
sif::error << " reported " << translateEvents(message->getEvent()) << " ("
|
sif::info << " reported " << translateEvents(message->getEvent()) << " ("
|
||||||
<< std::dec << message->getEventId() << std::hex << ") P1: 0x"
|
<< std::dec << message->getEventId() << std::hex << ") P1: 0x"
|
||||||
<< message->getParameter1() << " P2: 0x"
|
<< message->getParameter1() << " P2: 0x"
|
||||||
<< message->getParameter2() << std::dec << std::endl;
|
<< message->getParameter2() << std::dec << std::endl;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
string = translateObject(message->getReporter());
|
||||||
|
sif::debug << "EventManager: ";
|
||||||
|
if (string != 0) {
|
||||||
|
sif::debug << string;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sif::debug << "0x" << std::hex << message->getReporter() << std::dec;
|
||||||
|
}
|
||||||
|
sif::debug << " reported " << translateEvents(message->getEvent())
|
||||||
|
<< " (" << std::dec << message->getEventId() << ") "
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1()
|
||||||
|
<< ", P1 Dec: " << std::dec << message->getParameter1()
|
||||||
|
<< std::endl;
|
||||||
|
sif::debug << std::hex << "P2 Hex: 0x" << message->getParameter2()
|
||||||
|
<< ", P2 Dec: " << std::dec << message->getParameter2()
|
||||||
|
<< std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -10,6 +10,12 @@
|
|||||||
#include "../ipc/MutexIF.h"
|
#include "../ipc/MutexIF.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
// forward declaration, should be implemented by mission
|
||||||
|
extern const char* translateObject(object_id_t object);
|
||||||
|
extern const char* translateEvents(Event event);
|
||||||
|
#endif
|
||||||
|
|
||||||
class EventManager: public EventManagerIF,
|
class EventManager: public EventManagerIF,
|
||||||
public ExecutableObjectIF,
|
public ExecutableObjectIF,
|
||||||
public SystemObject {
|
public SystemObject {
|
||||||
@ -36,11 +42,11 @@ public:
|
|||||||
ReturnValue_t performOperation(uint8_t opCode);
|
ReturnValue_t performOperation(uint8_t opCode);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
MessageQueueIF* eventReportQueue;
|
MessageQueueIF* eventReportQueue = nullptr;
|
||||||
|
|
||||||
std::map<MessageQueueId_t, EventMatchTree> listenerList;
|
std::map<MessageQueueId_t, EventMatchTree> listenerList;
|
||||||
|
|
||||||
MutexIF* mutex;
|
MutexIF* mutex = nullptr;
|
||||||
|
|
||||||
static const uint8_t N_POOLS = 3;
|
static const uint8_t N_POOLS = 3;
|
||||||
LocalPool<N_POOLS> factoryBackend;
|
LocalPool<N_POOLS> factoryBackend;
|
||||||
|
@ -1,12 +1,27 @@
|
|||||||
#ifndef HASPARAMETERSIF_H_
|
#ifndef FSFW_PARAMETERS_HASPARAMETERSIF_H_
|
||||||
#define HASPARAMETERSIF_H_
|
#define FSFW_PARAMETERS_HASPARAMETERSIF_H_
|
||||||
|
|
||||||
#include "ParameterWrapper.h"
|
#include "../parameters/ParameterWrapper.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/** Each parameter is identified with a unique parameter ID */
|
||||||
typedef uint32_t ParameterId_t;
|
typedef uint32_t ParameterId_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This interface is used by components which have modifiable
|
||||||
|
* parameters, e.g. atittude controllers
|
||||||
|
* @details
|
||||||
|
* Each parameter has a unique parameter ID. The first byte of the parameter
|
||||||
|
* ID is the domain ID which can be used to identify unqiue spacecraft domains
|
||||||
|
* (e.g. control and sensor domain in the AOCS controller).
|
||||||
|
*
|
||||||
|
* The second and third byte represent the matrix ID, which can represent
|
||||||
|
* a 8-bit row and column number and the last byte...
|
||||||
|
*
|
||||||
|
* Yeah, it it matrix ID oder parameter ID now and is index a 16 bit number
|
||||||
|
* of a 8 bit number now?
|
||||||
|
*/
|
||||||
class HasParametersIF {
|
class HasParametersIF {
|
||||||
public:
|
public:
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_PARAMETERS_IF;
|
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_PARAMETERS_IF;
|
||||||
@ -32,13 +47,11 @@ public:
|
|||||||
return (domainId << 24) + (parameterId << 8) + index;
|
return (domainId << 24) + (parameterId << 8) + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~HasParametersIF() {
|
virtual ~HasParametersIF() {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always set parameter before checking newValues!
|
* Always set parameter before checking newValues!
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param domainId
|
* @param domainId
|
||||||
* @param parameterId
|
* @param parameterId
|
||||||
* @param parameterWrapper
|
* @param parameterWrapper
|
||||||
@ -51,4 +64,4 @@ public:
|
|||||||
const ParameterWrapper *newValues, uint16_t startAtIndex) = 0;
|
const ParameterWrapper *newValues, uint16_t startAtIndex) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* HASPARAMETERSIF_H_ */
|
#endif /* FSFW_PARAMETERS_HASPARAMETERSIF_H_ */
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
#include "../objectmanager/ObjectManagerIF.h"
|
|
||||||
#include "ParameterHelper.h"
|
#include "ParameterHelper.h"
|
||||||
#include "ParameterMessage.h"
|
#include "ParameterMessage.h"
|
||||||
|
#include "../objectmanager/ObjectManagerIF.h"
|
||||||
|
|
||||||
ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner) :
|
ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner) :
|
||||||
owner(owner), storage(NULL) {
|
owner(owner) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ParameterHelper::~ParameterHelper() {
|
ParameterHelper::~ParameterHelper() {
|
||||||
}
|
}
|
||||||
@ -28,7 +26,6 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ParameterMessage::CMD_PARAMETER_LOAD: {
|
case ParameterMessage::CMD_PARAMETER_LOAD: {
|
||||||
|
|
||||||
uint8_t domain = HasParametersIF::getDomain(
|
uint8_t domain = HasParametersIF::getDomain(
|
||||||
ParameterMessage::getParameterId(message));
|
ParameterMessage::getParameterId(message));
|
||||||
uint16_t parameterId = HasParametersIF::getMatrixId(
|
uint16_t parameterId = HasParametersIF::getMatrixId(
|
||||||
@ -36,12 +33,14 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
|
|||||||
uint8_t index = HasParametersIF::getIndex(
|
uint8_t index = HasParametersIF::getIndex(
|
||||||
ParameterMessage::getParameterId(message));
|
ParameterMessage::getParameterId(message));
|
||||||
|
|
||||||
const uint8_t *storedStream;
|
const uint8_t *storedStream = nullptr;
|
||||||
size_t storedStreamSize;
|
size_t storedStreamSize = 0;
|
||||||
result = storage->getData(
|
result = storage->getData(
|
||||||
ParameterMessage::getStoreId(message), &storedStream,
|
ParameterMessage::getStoreId(message), &storedStream,
|
||||||
&storedStreamSize);
|
&storedStreamSize);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "ParameterHelper::handleParameterMessage: Getting"
|
||||||
|
" store data failed for load command." << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +124,8 @@ ReturnValue_t ParameterHelper::initialize() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason, Command_t initialCommand) {
|
void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
||||||
|
Command_t initialCommand) {
|
||||||
CommandMessage reply;
|
CommandMessage reply;
|
||||||
reply.setReplyRejected(reason, initialCommand);
|
reply.setReplyRejected(reason, initialCommand);
|
||||||
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
#ifndef PARAMETERHELPER_H_
|
#ifndef FSFW_PARAMETERS_PARAMETERHELPER_H_
|
||||||
#define PARAMETERHELPER_H_
|
#define FSFW_PARAMETERS_PARAMETERHELPER_H_
|
||||||
|
|
||||||
#include "ParameterMessage.h"
|
#include "ParameterMessage.h"
|
||||||
#include "ReceivesParameterMessagesIF.h"
|
#include "ReceivesParameterMessagesIF.h"
|
||||||
|
#include "../ipc/MessageQueueIF.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Helper class to handle parameter messages.
|
||||||
|
* @details
|
||||||
|
* This class simplfies handling of parameter messages, which are sent
|
||||||
|
* to a class which implements ReceivesParameterMessagesIF.
|
||||||
|
*/
|
||||||
class ParameterHelper {
|
class ParameterHelper {
|
||||||
public:
|
public:
|
||||||
ParameterHelper(ReceivesParameterMessagesIF *owner);
|
ParameterHelper(ReceivesParameterMessagesIF *owner);
|
||||||
@ -15,13 +22,15 @@ public:
|
|||||||
private:
|
private:
|
||||||
ReceivesParameterMessagesIF *owner;
|
ReceivesParameterMessagesIF *owner;
|
||||||
|
|
||||||
MessageQueueId_t ownerQueueId;
|
MessageQueueId_t ownerQueueId = MessageQueueIF::NO_QUEUE;
|
||||||
|
|
||||||
StorageManagerIF *storage;
|
StorageManagerIF *storage = nullptr;
|
||||||
|
|
||||||
ReturnValue_t sendParameter(MessageQueueId_t to, uint32_t id, const ParameterWrapper *description);
|
ReturnValue_t sendParameter(MessageQueueId_t to, uint32_t id,
|
||||||
|
const ParameterWrapper *description);
|
||||||
|
|
||||||
void rejectCommand(MessageQueueId_t to, ReturnValue_t reason, Command_t initialCommand);
|
void rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
||||||
|
Command_t initialCommand);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PARAMETERHELPER_H_ */
|
#endif /* FSFW_PARAMETERS_PARAMETERHELPER_H_ */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "ParameterMessage.h"
|
#include "../parameters/ParameterMessage.h"
|
||||||
#include "../objectmanager/ObjectManagerIF.h"
|
#include "../objectmanager/ObjectManagerIF.h"
|
||||||
|
|
||||||
ParameterId_t ParameterMessage::getParameterId(const CommandMessage* message) {
|
ParameterId_t ParameterMessage::getParameterId(const CommandMessage* message) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef PARAMETERMESSAGE_H_
|
#ifndef FSFW_PARAMETERS_PARAMETERMESSAGE_H_
|
||||||
#define PARAMETERMESSAGE_H_
|
#define FSFW_PARAMETERS_PARAMETERMESSAGE_H_
|
||||||
|
|
||||||
#include "../ipc/CommandMessage.h"
|
|
||||||
#include "HasParametersIF.h"
|
#include "HasParametersIF.h"
|
||||||
|
#include "../ipc/CommandMessage.h"
|
||||||
#include "../storagemanager/StorageManagerIF.h"
|
#include "../storagemanager/StorageManagerIF.h"
|
||||||
|
|
||||||
class ParameterMessage {
|
class ParameterMessage {
|
||||||
@ -26,4 +26,4 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PARAMETERMESSAGE_H_ */
|
#endif /* FSFW_PARAMETERS_PARAMETERMESSAGE_H_ */
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
#include "ParameterWrapper.h"
|
#include "ParameterWrapper.h"
|
||||||
|
|
||||||
ParameterWrapper::ParameterWrapper() :
|
ParameterWrapper::ParameterWrapper() :
|
||||||
pointsToStream(false), type(Type::UNKNOWN_TYPE), rows(0), columns(0), data(
|
pointsToStream(false), type(Type::UNKNOWN_TYPE) {
|
||||||
NULL), readonlyData(NULL) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterWrapper::ParameterWrapper(Type type, uint8_t rows, uint8_t columns,
|
ParameterWrapper::ParameterWrapper(Type type, uint8_t rows, uint8_t columns,
|
||||||
void *data) :
|
void *data) :
|
||||||
pointsToStream(false), type(type), rows(rows), columns(columns), data(
|
pointsToStream(false), type(type), rows(rows), columns(columns),
|
||||||
data), readonlyData(data) {
|
data(data), readonlyData(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterWrapper::ParameterWrapper(Type type, uint8_t rows, uint8_t columns,
|
ParameterWrapper::ParameterWrapper(Type type, uint8_t rows, uint8_t columns,
|
||||||
const void *data) :
|
const void *data) :
|
||||||
pointsToStream(false), type(type), rows(rows), columns(columns), data(
|
pointsToStream(false), type(type), rows(rows), columns(columns),
|
||||||
NULL), readonlyData(data) {
|
data(nullptr), readonlyData(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterWrapper::~ParameterWrapper() {
|
ParameterWrapper::~ParameterWrapper() {
|
||||||
@ -141,6 +140,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t ParameterWrapper::deSerialize(const uint8_t **buffer,
|
ReturnValue_t ParameterWrapper::deSerialize(const uint8_t **buffer,
|
||||||
size_t *size, Endianness streamEndianness) {
|
size_t *size, Endianness streamEndianness) {
|
||||||
return deSerialize(buffer, size, streamEndianness, 0);
|
return deSerialize(buffer, size, streamEndianness, 0);
|
||||||
@ -184,16 +184,16 @@ ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize,
|
|||||||
return SerializeIF::STREAM_TOO_SHORT;
|
return SerializeIF::STREAM_TOO_SHORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = NULL;
|
data = nullptr;
|
||||||
readonlyData = stream;
|
readonlyData = stream;
|
||||||
pointsToStream = true;
|
pointsToStream = true;
|
||||||
|
|
||||||
stream += dataSize;
|
stream += dataSize;
|
||||||
if (remainingStream != NULL) {
|
if (remainingStream != nullptr) {
|
||||||
*remainingStream = stream;
|
*remainingStream = stream;
|
||||||
}
|
}
|
||||||
streamSize -= dataSize;
|
streamSize -= dataSize;
|
||||||
if (remainingSize != NULL) {
|
if (remainingSize != nullptr) {
|
||||||
*remainingSize = streamSize;
|
*remainingSize = streamSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,15 +265,15 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
|
|||||||
result = UNKNOW_DATATYPE;
|
result = UNKNOW_DATATYPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
//need a type to do arithmetic
|
//need a type to do arithmetic
|
||||||
uint8_t *toDataWithType = (uint8_t*) data;
|
uint8_t* typedData = static_cast<uint8_t*>(data);
|
||||||
for (uint8_t fromRow = 0; fromRow < from->rows; fromRow++) {
|
for (uint8_t fromRow = 0; fromRow < from->rows; fromRow++) {
|
||||||
memcpy(
|
size_t offset = (((startingRow + fromRow) * columns) +
|
||||||
toDataWithType
|
startingColumn) * typeSize;
|
||||||
+ (((startingRow + fromRow) * columns)
|
std::memcpy(typedData + offset, from->readonlyData,
|
||||||
+ startingColumn) * typeSize,
|
typeSize * from->columns);
|
||||||
from->readonlyData, typeSize * from->columns);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#ifndef PARAMETERWRAPPER_H_
|
#ifndef FSFW_PARAMETERS_PARAMETERWRAPPER_H_
|
||||||
#define PARAMETERWRAPPER_H_
|
#define FSFW_PARAMETERS_PARAMETERWRAPPER_H_
|
||||||
|
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../serialize/SerializeAdapter.h"
|
#include "../serialize/SerializeAdapter.h"
|
||||||
#include "../serialize/SerializeIF.h"
|
#include "../serialize/SerializeIF.h"
|
||||||
#include <stddef.h>
|
|
||||||
#include "../globalfunctions/Type.h"
|
#include "../globalfunctions/Type.h"
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @details
|
||||||
|
*/
|
||||||
class ParameterWrapper: public SerializeIF {
|
class ParameterWrapper: public SerializeIF {
|
||||||
friend class DataPoolParameterWrapper;
|
friend class DataPoolParameterWrapper;
|
||||||
public:
|
public:
|
||||||
@ -36,32 +40,21 @@ public:
|
|||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness, uint16_t startWritingAtIndex = 0);
|
Endianness streamEndianness, uint16_t startWritingAtIndex = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific parameter value by supplying the row and the column.
|
||||||
|
* @tparam T Type of target data
|
||||||
|
* @param value [out] Pointer to storage location
|
||||||
|
* @param row
|
||||||
|
* @param column
|
||||||
|
* @return
|
||||||
|
* -@c RETURN_OK if element was retrieved successfully
|
||||||
|
* -@c NOT_SET data has not been set yet
|
||||||
|
* -@c DATATYPE_MISSMATCH Invalid supplied type
|
||||||
|
* -@c OUT_OF_BOUNDS Invalid row and/or column.
|
||||||
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ReturnValue_t getElement(T *value, uint8_t row = 0, uint8_t column = 0) const {
|
ReturnValue_t getElement(T *value, uint8_t row = 0,
|
||||||
if (readonlyData == NULL){
|
uint8_t column = 0) const;
|
||||||
return NOT_SET;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PodTypeConversion<T>::type != type) {
|
|
||||||
return DATATYPE_MISSMATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((row >= rows) || (column >= columns)) {
|
|
||||||
return OUT_OF_BOUNDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pointsToStream) {
|
|
||||||
const uint8_t *streamWithtype = (const uint8_t *) readonlyData;
|
|
||||||
streamWithtype += (row * columns + column) * type.getSize();
|
|
||||||
int32_t size = type.getSize();
|
|
||||||
return SerializeAdapter::deSerialize(value, &streamWithtype,
|
|
||||||
&size, true);
|
|
||||||
} else {
|
|
||||||
const T *dataWithType = (const T *) readonlyData;
|
|
||||||
*value = dataWithType[row * columns + column];
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void set(T *data, uint8_t rows, uint8_t columns) {
|
void set(T *data, uint8_t rows, uint8_t columns) {
|
||||||
@ -111,21 +104,22 @@ public:
|
|||||||
void setMatrix(const T& member) {
|
void setMatrix(const T& member) {
|
||||||
this->set(member[0], sizeof(member)/sizeof(member[0]), sizeof(member[0])/sizeof(member[0][0]));
|
this->set(member[0], sizeof(member)/sizeof(member[0]), sizeof(member[0])/sizeof(member[0][0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t set(const uint8_t *stream, size_t streamSize,
|
ReturnValue_t set(const uint8_t *stream, size_t streamSize,
|
||||||
const uint8_t **remainingStream = NULL, size_t *remainingSize =
|
const uint8_t **remainingStream = nullptr,
|
||||||
NULL);
|
size_t *remainingSize = nullptr);
|
||||||
|
|
||||||
ReturnValue_t copyFrom(const ParameterWrapper *from,
|
ReturnValue_t copyFrom(const ParameterWrapper *from,
|
||||||
uint16_t startWritingAtIndex);
|
uint16_t startWritingAtIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool pointsToStream;
|
bool pointsToStream = false;
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
uint8_t rows;
|
uint8_t rows = 0;
|
||||||
uint8_t columns;
|
uint8_t columns = 0;
|
||||||
void *data;
|
void *data = nullptr;
|
||||||
const void *readonlyData;
|
const void *readonlyData = nullptr;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ReturnValue_t serializeData(uint8_t** buffer, size_t* size,
|
ReturnValue_t serializeData(uint8_t** buffer, size_t* size,
|
||||||
@ -136,4 +130,33 @@ private:
|
|||||||
const void *from, uint8_t fromRows, uint8_t fromColumns);
|
const void *from, uint8_t fromRows, uint8_t fromColumns);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PARAMETERWRAPPER_H_ */
|
template <typename T>
|
||||||
|
inline ReturnValue_t ParameterWrapper::getElement(T *value, uint8_t row,
|
||||||
|
uint8_t column) const {
|
||||||
|
if (readonlyData == nullptr){
|
||||||
|
return NOT_SET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PodTypeConversion<T>::type != type) {
|
||||||
|
return DATATYPE_MISSMATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((row >= rows) or (column >= columns)) {
|
||||||
|
return OUT_OF_BOUNDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pointsToStream) {
|
||||||
|
const uint8_t *streamWithType = static_cast<const uint8_t*>(readonlyData);
|
||||||
|
streamWithType += (row * columns + column) * type.getSize();
|
||||||
|
int32_t size = type.getSize();
|
||||||
|
return SerializeAdapter::deSerialize(value, &streamWithType,
|
||||||
|
&size, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const T *dataWithType = static_cast<const T*>(readonlyData);
|
||||||
|
*value = dataWithType[row * columns + column];
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FSFW_PARAMETERS_PARAMETERWRAPPER_H_ */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef RECEIVESPARAMETERMESSAGESIF_H_
|
#ifndef FSFW_PARAMETERS_RECEIVESPARAMETERMESSAGESIF_H_
|
||||||
#define RECEIVESPARAMETERMESSAGESIF_H_
|
#define FSFW_PARAMETERS_RECEIVESPARAMETERMESSAGESIF_H_
|
||||||
|
|
||||||
|
|
||||||
#include "HasParametersIF.h"
|
#include "HasParametersIF.h"
|
||||||
@ -16,4 +16,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* RECEIVESPARAMETERMESSAGESIF_H_ */
|
#endif /* FSFW_PARAMETERS_RECEIVESPARAMETERMESSAGESIF_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user