diff --git a/inc/Parameters/Parameters.hpp b/inc/Parameters/Parameters.hpp index d225fbfa48775709fd93fe333f9557ac4607a819..220edac7ff040306bc838668555f2c55dd04c552 100644 --- a/inc/Parameters/Parameters.hpp +++ b/inc/Parameters/Parameters.hpp @@ -1,5 +1,19 @@ #include "Services/Parameter.hpp" - +#include "etl/vector.h" namespace SystemParameters { - // initialize all system parameters here -} \ No newline at end of file + + // initialize all system parameters here + Parameter<u_int8_t> parameter1(5); + Parameter<char> parameter2('a'); + Parameter<int> parameter3('b'); + Parameter<u_int8_t> parameter4(5); + Parameter<u_int8_t> parameter5(5); + etl::vector<ParameterBase*, ECSS_ST_20_MAX_PARAMETERS> arr; + arr.push_back(paramter1) + /**= { + parameter1, + parameter2, + parameter3, + parameter4, + parameter5};**/ +} diff --git a/inc/Services/Parameter.hpp b/inc/Services/Parameter.hpp index dc9f791014a93bb471792389043d4547d0562c86..5c61854e3d6ae063e761e9c2ed80f66e6d481d99 100644 --- a/inc/Services/Parameter.hpp +++ b/inc/Services/Parameter.hpp @@ -86,14 +86,15 @@ public: template <typename DataType> class Parameter : public ParameterBase { +private: DataType currentValue; void (* updateFunction)(DataType*); public: Parameter(DataType initialValue, void (* updateFunction)(DataType*) = nullptr) { - this.updateFunction = updateFunction; + this->updateFunction = updateFunction; - if (this.updateFunction != nullptr) { + if (this->updateFunction != nullptr) { (*updateFunction)(¤tValue); } else { diff --git a/inc/Services/ParameterService.hpp b/inc/Services/ParameterService.hpp index e2f4be64e451503d23f7b6e98a642cfef6c7b749..d6695688b8d2dc89879c9c37fc2b7b4da4cdf5ce 100644 --- a/inc/Services/ParameterService.hpp +++ b/inc/Services/ParameterService.hpp @@ -5,7 +5,6 @@ #include "Service.hpp" #include "ErrorHandler.hpp" #include "Parameter.hpp" -#include "etl/map.h" #include "etl/vector.h" /** @@ -26,14 +25,11 @@ class ParameterService : public Service { -private: - etl::map<ParamId, ParameterBase*, ECSS_ST_20_MAX_PARAMETERS> paramsList; - public: /** * @brief Initializes the parameter list. */ - ParameterService(); + ParameterService() = default; /** * @brief Adds a new parameter. Emits an InternalError::MapFull if an attempt is made to insert diff --git a/src/Services/ParameterService.cpp b/src/Services/ParameterService.cpp index a20b5b80f15dbc3fc0322d598a78aa688800c03d..ec1977dfe5027322af8dab532577c42b512bcd97 100644 --- a/src/Services/ParameterService.cpp +++ b/src/Services/ParameterService.cpp @@ -4,24 +4,11 @@ #include "Services/ParameterService.hpp" #include "Services/Parameter.hpp" -ParameterService::ParameterService() { - // test addings -// addNewParameter(3, 14); -// addNewParameter(3, 14); -} - void ParameterService::addNewParameter(uint16_t id, ParameterBase* param) { - if (paramsList.full()) { - ErrorHandler::reportInternalError(ErrorHandler::InternalErrorType::MapFull); - } - else { - if (paramsList.find(id) == paramsList.end()) { - paramsList.insert(std::make_pair(id, param)); - } - else { - ErrorHandler::reportInternalError(ErrorHandler::InternalErrorType::ExistingParameterId); - } - } + ErrorHandler::reportInternalError(ErrorHandler::InternalErrorType::MapFull); + ErrorHandler::reportInternalError(ErrorHandler::InternalErrorType::ExistingParameterId); + etl::vector<ParameterBase*, ECSS_ST_20_MAX_PARAMETERS> arr; + } void ParameterService::reportParameterIds(Message& paramIds) { @@ -47,7 +34,7 @@ void ParameterService::reportParameterIds(Message& paramIds) { for (uint16_t i = 0; i < numOfIds; i++) { uint16_t currId = paramIds.readUint16(); - +/** if (paramsList.find(currId) != paramsList.end()) { std::pair<uint16_t, String<ECSS_ST_20_MAX_STRING_LENGTH>> p = std::make_pair(currId, paramsList.at(currId) ->getValueAsString()); @@ -58,7 +45,7 @@ void ParameterService::reportParameterIds(Message& paramIds) { else { ErrorHandler::reportError(paramIds, ErrorHandler::ExecutionStartErrorType::UnknownExecutionStartError); continue; // generate failed start of execution notification & ignore - } + }**/ } reqParam.appendUint16(validIds); // append the number of valid IDs @@ -87,7 +74,7 @@ void ParameterService::setParameterIds(Message& newParamValues) { for (uint16_t i = 0; i < numOfIds; i++) { uint16_t currId = newParamValues.readUint16(); // the parameter is checked for read-only status and manual update availability - if (paramsList.find(currId) != paramsList.end()) { +/** if (paramsList.find(currId) != paramsList.end()) { // WARNING! SETTING WORKS ONLY WITH UINT32_T INPUT! // I need a way to know the input's type! @@ -97,7 +84,7 @@ void ParameterService::setParameterIds(Message& newParamValues) { ErrorHandler::reportError(newParamValues, ErrorHandler::ExecutionStartErrorType::UnknownExecutionStartError); continue; // generate failed start of execution notification & ignore - } + }**/ } }