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] = {
|
||||
sizeof(EventMatchTree::Node), sizeof(EventIdRangeMatcher),
|
||||
sizeof(ReporterRangeMatcher) };
|
||||
//If one checks registerListener calls, there are around 40 (to max 50) 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.
|
||||
// If one checks registerListener calls, there are around 40 (to max 50)
|
||||
// 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 };
|
||||
|
||||
EventManager::EventManager(object_id_t setObjectId) :
|
||||
SystemObject(setObjectId), eventReportQueue(NULL), mutex(NULL), factoryBackend(
|
||||
0, POOL_SIZES, N_ELEMENTS, false, true) {
|
||||
SystemObject(setObjectId),
|
||||
factoryBackend(0, POOL_SIZES, N_ELEMENTS, false, true) {
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
eventReportQueue = QueueFactory::instance()->createMessageQueue(
|
||||
MAX_EVENTS_PER_CYCLE, EventMessage::EVENT_MESSAGE_SIZE);
|
||||
@ -108,41 +111,45 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener,
|
||||
|
||||
#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) {
|
||||
const char *string = 0;
|
||||
switch (message->getSeverity()) {
|
||||
case SEVERITY::INFO:
|
||||
// string = translateObject(message->getReporter());
|
||||
// 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:
|
||||
#ifdef DEBUG_INFO_EVENT
|
||||
string = translateObject(message->getReporter());
|
||||
sif::error << "EVENT: ";
|
||||
sif::info << "EVENT: ";
|
||||
if (string != 0) {
|
||||
sif::error << string;
|
||||
sif::info << string;
|
||||
} 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"
|
||||
<< message->getParameter1() << " P2: 0x"
|
||||
<< 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;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -10,6 +10,12 @@
|
||||
#include "../ipc/MutexIF.h"
|
||||
#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,
|
||||
public ExecutableObjectIF,
|
||||
public SystemObject {
|
||||
@ -36,11 +42,11 @@ public:
|
||||
ReturnValue_t performOperation(uint8_t opCode);
|
||||
protected:
|
||||
|
||||
MessageQueueIF* eventReportQueue;
|
||||
MessageQueueIF* eventReportQueue = nullptr;
|
||||
|
||||
std::map<MessageQueueId_t, EventMatchTree> listenerList;
|
||||
|
||||
MutexIF* mutex;
|
||||
MutexIF* mutex = nullptr;
|
||||
|
||||
static const uint8_t N_POOLS = 3;
|
||||
LocalPool<N_POOLS> factoryBackend;
|
||||
|
@ -1,12 +1,27 @@
|
||||
#ifndef HASPARAMETERSIF_H_
|
||||
#define HASPARAMETERSIF_H_
|
||||
#ifndef FSFW_PARAMETERS_HASPARAMETERSIF_H_
|
||||
#define FSFW_PARAMETERS_HASPARAMETERSIF_H_
|
||||
|
||||
#include "ParameterWrapper.h"
|
||||
#include "../parameters/ParameterWrapper.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/** Each parameter is identified with a unique parameter ID */
|
||||
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 {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_PARAMETERS_IF;
|
||||
@ -32,13 +47,11 @@ public:
|
||||
return (domainId << 24) + (parameterId << 8) + index;
|
||||
}
|
||||
|
||||
virtual ~HasParametersIF() {
|
||||
}
|
||||
virtual ~HasParametersIF() {}
|
||||
|
||||
/**
|
||||
* Always set parameter before checking newValues!
|
||||
*
|
||||
*
|
||||
* @param domainId
|
||||
* @param parameterId
|
||||
* @param parameterWrapper
|
||||
@ -51,4 +64,4 @@ public:
|
||||
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 "ParameterMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner) :
|
||||
owner(owner), storage(NULL) {
|
||||
|
||||
}
|
||||
owner(owner) {}
|
||||
|
||||
ParameterHelper::~ParameterHelper() {
|
||||
}
|
||||
@ -28,7 +26,6 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
|
||||
}
|
||||
break;
|
||||
case ParameterMessage::CMD_PARAMETER_LOAD: {
|
||||
|
||||
uint8_t domain = HasParametersIF::getDomain(
|
||||
ParameterMessage::getParameterId(message));
|
||||
uint16_t parameterId = HasParametersIF::getMatrixId(
|
||||
@ -36,12 +33,14 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
|
||||
uint8_t index = HasParametersIF::getIndex(
|
||||
ParameterMessage::getParameterId(message));
|
||||
|
||||
const uint8_t *storedStream;
|
||||
size_t storedStreamSize;
|
||||
const uint8_t *storedStream = nullptr;
|
||||
size_t storedStreamSize = 0;
|
||||
result = storage->getData(
|
||||
ParameterMessage::getStoreId(message), &storedStream,
|
||||
&storedStreamSize);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "ParameterHelper::handleParameterMessage: Getting"
|
||||
" store data failed for load command." << std::endl;
|
||||
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;
|
||||
reply.setReplyRejected(reason, initialCommand);
|
||||
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
||||
|
@ -1,9 +1,16 @@
|
||||
#ifndef PARAMETERHELPER_H_
|
||||
#define PARAMETERHELPER_H_
|
||||
#ifndef FSFW_PARAMETERS_PARAMETERHELPER_H_
|
||||
#define FSFW_PARAMETERS_PARAMETERHELPER_H_
|
||||
|
||||
#include "ParameterMessage.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 {
|
||||
public:
|
||||
ParameterHelper(ReceivesParameterMessagesIF *owner);
|
||||
@ -15,13 +22,15 @@ public:
|
||||
private:
|
||||
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"
|
||||
|
||||
ParameterId_t ParameterMessage::getParameterId(const CommandMessage* message) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef PARAMETERMESSAGE_H_
|
||||
#define PARAMETERMESSAGE_H_
|
||||
#ifndef FSFW_PARAMETERS_PARAMETERMESSAGE_H_
|
||||
#define FSFW_PARAMETERS_PARAMETERMESSAGE_H_
|
||||
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "HasParametersIF.h"
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
class ParameterMessage {
|
||||
@ -26,4 +26,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif /* PARAMETERMESSAGE_H_ */
|
||||
#endif /* FSFW_PARAMETERS_PARAMETERMESSAGE_H_ */
|
||||
|
@ -1,20 +1,19 @@
|
||||
#include "ParameterWrapper.h"
|
||||
|
||||
ParameterWrapper::ParameterWrapper() :
|
||||
pointsToStream(false), type(Type::UNKNOWN_TYPE), rows(0), columns(0), data(
|
||||
NULL), readonlyData(NULL) {
|
||||
pointsToStream(false), type(Type::UNKNOWN_TYPE) {
|
||||
}
|
||||
|
||||
ParameterWrapper::ParameterWrapper(Type type, uint8_t rows, uint8_t columns,
|
||||
void *data) :
|
||||
pointsToStream(false), type(type), rows(rows), columns(columns), data(
|
||||
data), readonlyData(data) {
|
||||
pointsToStream(false), type(type), rows(rows), columns(columns),
|
||||
data(data), readonlyData(data) {
|
||||
}
|
||||
|
||||
ParameterWrapper::ParameterWrapper(Type type, uint8_t rows, uint8_t columns,
|
||||
const void *data) :
|
||||
pointsToStream(false), type(type), rows(rows), columns(columns), data(
|
||||
NULL), readonlyData(data) {
|
||||
pointsToStream(false), type(type), rows(rows), columns(columns),
|
||||
data(nullptr), readonlyData(data) {
|
||||
}
|
||||
|
||||
ParameterWrapper::~ParameterWrapper() {
|
||||
@ -141,6 +140,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow,
|
||||
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t ParameterWrapper::deSerialize(const uint8_t **buffer,
|
||||
size_t *size, Endianness streamEndianness) {
|
||||
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;
|
||||
}
|
||||
|
||||
data = NULL;
|
||||
data = nullptr;
|
||||
readonlyData = stream;
|
||||
pointsToStream = true;
|
||||
|
||||
stream += dataSize;
|
||||
if (remainingStream != NULL) {
|
||||
if (remainingStream != nullptr) {
|
||||
*remainingStream = stream;
|
||||
}
|
||||
streamSize -= dataSize;
|
||||
if (remainingSize != NULL) {
|
||||
if (remainingSize != nullptr) {
|
||||
*remainingSize = streamSize;
|
||||
}
|
||||
|
||||
@ -265,15 +265,15 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
|
||||
result = UNKNOW_DATATYPE;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//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++) {
|
||||
memcpy(
|
||||
toDataWithType
|
||||
+ (((startingRow + fromRow) * columns)
|
||||
+ startingColumn) * typeSize,
|
||||
from->readonlyData, typeSize * from->columns);
|
||||
size_t offset = (((startingRow + fromRow) * columns) +
|
||||
startingColumn) * typeSize;
|
||||
std::memcpy(typedData + offset, from->readonlyData,
|
||||
typeSize * from->columns);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,16 @@
|
||||
#ifndef PARAMETERWRAPPER_H_
|
||||
#define PARAMETERWRAPPER_H_
|
||||
#ifndef FSFW_PARAMETERS_PARAMETERWRAPPER_H_
|
||||
#define FSFW_PARAMETERS_PARAMETERWRAPPER_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
#include <stddef.h>
|
||||
#include "../globalfunctions/Type.h"
|
||||
#include <cstddef>
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @details
|
||||
*/
|
||||
class ParameterWrapper: public SerializeIF {
|
||||
friend class DataPoolParameterWrapper;
|
||||
public:
|
||||
@ -36,32 +40,21 @@ public:
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
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>
|
||||
ReturnValue_t getElement(T *value, uint8_t row = 0, uint8_t column = 0) const {
|
||||
if (readonlyData == NULL){
|
||||
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;
|
||||
}
|
||||
}
|
||||
ReturnValue_t getElement(T *value, uint8_t row = 0,
|
||||
uint8_t column = 0) const;
|
||||
|
||||
template<typename T>
|
||||
void set(T *data, uint8_t rows, uint8_t columns) {
|
||||
@ -111,21 +104,22 @@ public:
|
||||
void setMatrix(const T& member) {
|
||||
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,
|
||||
const uint8_t **remainingStream = NULL, size_t *remainingSize =
|
||||
NULL);
|
||||
const uint8_t **remainingStream = nullptr,
|
||||
size_t *remainingSize = nullptr);
|
||||
|
||||
ReturnValue_t copyFrom(const ParameterWrapper *from,
|
||||
uint16_t startWritingAtIndex);
|
||||
|
||||
private:
|
||||
bool pointsToStream;
|
||||
bool pointsToStream = false;
|
||||
|
||||
Type type;
|
||||
uint8_t rows;
|
||||
uint8_t columns;
|
||||
void *data;
|
||||
const void *readonlyData;
|
||||
uint8_t rows = 0;
|
||||
uint8_t columns = 0;
|
||||
void *data = nullptr;
|
||||
const void *readonlyData = nullptr;
|
||||
|
||||
template<typename T>
|
||||
ReturnValue_t serializeData(uint8_t** buffer, size_t* size,
|
||||
@ -136,4 +130,33 @@ private:
|
||||
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_
|
||||
#define RECEIVESPARAMETERMESSAGESIF_H_
|
||||
#ifndef FSFW_PARAMETERS_RECEIVESPARAMETERMESSAGESIF_H_
|
||||
#define FSFW_PARAMETERS_RECEIVESPARAMETERMESSAGESIF_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