typo fixes
This commit is contained in:
parent
b4978e7df3
commit
7a5c70e753
@ -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,14 @@ 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(
|
uint8_t offset = (((startingRow + fromRow) * columns) + startingColumn) * typeSize;
|
||||||
toDataWithType
|
std::memcpy(typedData + offset, from->readonlyData,
|
||||||
+ (((startingRow + fromRow) * columns)
|
typeSize * from->columns);
|
||||||
+ startingColumn) * typeSize,
|
|
||||||
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