diff --git a/inc/Services/Parameter.hpp b/inc/Services/Parameter.hpp index a00b402181dd26e3d8e642c93a0c3d9e20f24b3f..b75bdff538cae5668a7227bc631543a8fb29658b 100644 --- a/inc/Services/Parameter.hpp +++ b/inc/Services/Parameter.hpp @@ -26,6 +26,9 @@ class Parameter { // Various flags (TBD which. Ideas: update with priority, do not poll, etc.) public: + ValueType currentValue = 0; // Last good value of the parameter. TODO: Find a way to store arbitrary types + + Parameter() = default; Parameter(uint8_t new_ptc, uint8_t new_pfc, uint32_t initialValue = 0, UpdatePtr new_ptr = nullptr) { ptc = new_ptc; pfc = new_pfc; @@ -38,9 +41,6 @@ class Parameter { currentValue = initialValue; } } - - ValueType currentValue = 0; // Last good value of the parameter. TODO: Find a way to store arbitrary types (w/out - // templates preferred) }; diff --git a/inc/Services/ParameterService.hpp b/inc/Services/ParameterService.hpp index cc2e5713e37fe37954f31014b810b4b40d11bba4..83e0b61e00d48bbb5a29452046021fc3ef5a16ee 100644 --- a/inc/Services/ParameterService.hpp +++ b/inc/Services/ParameterService.hpp @@ -28,7 +28,7 @@ class ParameterService : public Service { private: - static etl::map<ParamId, Parameter, MAX_PARAMS> paramsList; + etl::map<ParamId, Parameter, MAX_PARAMS> paramsList; uint16_t numOfValidIds(Message idMsg); // count the valid ids in a given TC[20, 1] public: @@ -39,9 +39,9 @@ public: /** * Adds a new parameter. If the parameter has not been added (either because the map is full or because it already - * exists in it) then returns true. + * exists in it) then returns false. */ - static bool addParameter(uint8_t ptc, uint8_t pfc, uint32_t initialValue = 0, UpdatePtr ptr = nullptr); + bool addNewParameter(uint8_t ptc, uint8_t pfc, uint32_t initial_value = 0, UpdatePtr ptr = nullptr); /** * This function receives a TC[20, 1] packet and returns a TM[20, 2] packet diff --git a/src/Services/ParameterService.cpp b/src/Services/ParameterService.cpp index dcbeaa44bd510595942e8e102982f3fe5e29a8b2..e09b1a070b7d2392b59ba951479b2282803737f8 100644 --- a/src/Services/ParameterService.cpp +++ b/src/Services/ParameterService.cpp @@ -3,8 +3,8 @@ ParameterService::ParameterService() { - addParameter(3, 14); - addParameter(3, 14); + addNewParameter(3, 14); + addNewParameter(3, 14); // // Test code, setting up some of the parameter fields // @@ -33,9 +33,9 @@ ParameterService::ParameterService() { //#endif } -bool ParameterService::addParameter(uint8_t ptc, uint8_t pfc, uint32_t initial_value, UpdatePtr ptr) { +bool ParameterService::addNewParameter(uint8_t ptc, uint8_t pfc, uint32_t initial_value, UpdatePtr ptr) { Parameter param = Parameter(ptc, pfc, initial_value, ptr); - return paramsList.insert(std::make_pair(0, param)).second; + return paramsList.insert(std::make_pair(paramsList.size() + 1, param)).second; // second element of the returned std::pair is whether the given item was inserted or not }