2020-08-28 18:46:47 +02:00
|
|
|
#ifndef FSFW_PARAMETERS_HASPARAMETERSIF_H_
|
|
|
|
#define FSFW_PARAMETERS_HASPARAMETERSIF_H_
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-10-29 17:57:27 +01:00
|
|
|
#include "ParameterWrapper.h"
|
2020-11-10 11:00:13 +01:00
|
|
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
2020-10-29 17:57:27 +01:00
|
|
|
#include <cstdint>
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-10-29 17:57:27 +01:00
|
|
|
/**
|
|
|
|
* Each parameter is identified with a unique parameter ID
|
|
|
|
* The first byte of the parameter ID will denote the domain ID.
|
|
|
|
* The second and third byte will be the unique identifier number.
|
|
|
|
*/
|
|
|
|
using ParameterId_t = uint32_t;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-08-28 18:46:47 +02:00
|
|
|
/**
|
|
|
|
* @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).
|
|
|
|
*
|
2020-11-10 11:00:13 +01:00
|
|
|
* The second byte is a unique identfier ID.
|
2020-08-28 18:46:47 +02:00
|
|
|
*
|
2020-11-10 11:00:13 +01:00
|
|
|
* The third and fourth byte can be used as a linear index for matrix or array
|
|
|
|
* parameter entries.
|
2020-08-28 18:46:47 +02:00
|
|
|
*/
|
2016-06-15 23:48:41 +02:00
|
|
|
class HasParametersIF {
|
|
|
|
public:
|
2018-07-12 16:29:32 +02:00
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_PARAMETERS_IF;
|
2020-10-29 17:57:27 +01:00
|
|
|
static const ReturnValue_t INVALID_IDENTIFIER_ID = MAKE_RETURN_CODE(0x01);
|
2016-06-15 23:48:41 +02:00
|
|
|
static const ReturnValue_t INVALID_DOMAIN_ID = MAKE_RETURN_CODE(0x02);
|
|
|
|
static const ReturnValue_t INVALID_VALUE = MAKE_RETURN_CODE(0x03);
|
2018-07-12 16:29:32 +02:00
|
|
|
static const ReturnValue_t READ_ONLY = MAKE_RETURN_CODE(0x05);
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
static uint8_t getDomain(ParameterId_t id) {
|
2016-06-15 23:48:41 +02:00
|
|
|
return id >> 24;
|
|
|
|
}
|
|
|
|
|
2020-10-29 17:57:27 +01:00
|
|
|
static uint8_t getUniqueIdentifierId(ParameterId_t id) {
|
|
|
|
return id >> 16;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
2020-10-29 17:57:27 +01:00
|
|
|
/**
|
|
|
|
* Get the index of a parameter. Please note that the index is always a
|
|
|
|
* linear index. For a vector, this is straightforward.
|
|
|
|
* For a matrix, the linear indexing run from left to right, top to bottom.
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
static uint16_t getIndex(ParameterId_t id) {
|
2016-06-15 23:48:41 +02:00
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2021-01-29 22:45:53 +01:00
|
|
|
static uint32_t getFullParameterId(uint8_t domainId, uint8_t uniqueId, uint16_t linearIndex) {
|
|
|
|
return (domainId << 24) + (uniqueId << 16) + linearIndex;
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-08-28 18:46:47 +02:00
|
|
|
virtual ~HasParametersIF() {}
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
/**
|
2020-11-10 11:00:13 +01:00
|
|
|
* This is the generic function overriden by child classes to set
|
|
|
|
* parameters. To set a parameter, the parameter wrapper is used with
|
|
|
|
* a variety of set functions. The provided values can be checked with
|
|
|
|
* newValues.
|
2016-06-15 23:48:41 +02:00
|
|
|
* Always set parameter before checking newValues!
|
|
|
|
*
|
|
|
|
* @param domainId
|
|
|
|
* @param parameterId
|
|
|
|
* @param parameterWrapper
|
|
|
|
* @param newValues
|
2020-10-29 17:57:27 +01:00
|
|
|
* @param startAtIndex Linear index, runs left to right, top to bottom for
|
|
|
|
* matrix indexes.
|
2016-06-15 23:48:41 +02:00
|
|
|
* @return
|
|
|
|
*/
|
2021-01-29 22:45:53 +01:00
|
|
|
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
|
|
|
|
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
|
|
|
|
uint16_t startAtIndex) = 0;
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
2020-08-28 18:46:47 +02:00
|
|
|
#endif /* FSFW_PARAMETERS_HASPARAMETERSIF_H_ */
|