From 3a433915f14732c6e25d098f4b29c811ed6f908a Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Wed, 12 Jul 2023 12:52:07 +0200 Subject: [PATCH] moved action parameters to a generic place to use them for HK TM --- src/fsfw/action/Action.h | 6 +++--- src/fsfw/housekeeping/HousekeepingEntryIF.h | 5 ----- src/fsfw/housekeeping/HousekeepingSet.cpp | 7 +++++++ src/fsfw/housekeeping/HousekeepingSet.h | 13 ++++++++----- src/fsfw/introspection/HasTmTcParametersIF.h | 12 ++++++++++++ .../{action => introspection}/MinMaxParameter.h | 0 src/fsfw/{action => introspection}/Parameter.h | 10 +++++----- src/fsfw/{action => introspection}/ParameterIF.h | 0 src/fsfw/introspection/Types.h | 1 + src/fsfw/introspection/TypesHelper.h | 2 +- 10 files changed, 37 insertions(+), 19 deletions(-) delete mode 100644 src/fsfw/housekeeping/HousekeepingEntryIF.h create mode 100644 src/fsfw/introspection/HasTmTcParametersIF.h rename src/fsfw/{action => introspection}/MinMaxParameter.h (100%) rename src/fsfw/{action => introspection}/Parameter.h (90%) rename src/fsfw/{action => introspection}/ParameterIF.h (100%) diff --git a/src/fsfw/action/Action.h b/src/fsfw/action/Action.h index 661983931..f0ca4cc7c 100644 --- a/src/fsfw/action/Action.h +++ b/src/fsfw/action/Action.h @@ -6,7 +6,7 @@ #include #include "ActionMessage.h" -#include "ParameterIF.h" +#include #ifdef FSFW_INTROSPECTION @@ -15,7 +15,7 @@ //TODO ActionId_t -class Action: public SerializeIF { +class Action: public SerializeIF, public HasTmTcParametersIF { public: #ifdef FSFW_INTROSPECTION Action(); @@ -30,7 +30,7 @@ class Action: public SerializeIF { [[nodiscard]] virtual ReturnValue_t handle() = 0; - void registerParameter(ParameterIF *parameter); + void registerParameter(ParameterIF *parameter) override; std::vector const *getParameters() const; diff --git a/src/fsfw/housekeeping/HousekeepingEntryIF.h b/src/fsfw/housekeeping/HousekeepingEntryIF.h deleted file mode 100644 index e27005921..000000000 --- a/src/fsfw/housekeeping/HousekeepingEntryIF.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -class HousekeepingEntryIF { - -}; \ No newline at end of file diff --git a/src/fsfw/housekeeping/HousekeepingSet.cpp b/src/fsfw/housekeeping/HousekeepingSet.cpp index 9e895edd2..9a5f7468a 100644 --- a/src/fsfw/housekeeping/HousekeepingSet.cpp +++ b/src/fsfw/housekeeping/HousekeepingSet.cpp @@ -16,3 +16,10 @@ HousekeepingSet::HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSet owner->getHelper()->registerSet(this); } #endif + +void HousekeepingSet::registerParameter(ParameterIF* parameter) { + parameterList.push_back(parameter); +} + + +std::vector const* HousekeepingSet::getParameters() { return ¶meterList; } diff --git a/src/fsfw/housekeeping/HousekeepingSet.h b/src/fsfw/housekeeping/HousekeepingSet.h index 5cc51930b..6ed9788dd 100644 --- a/src/fsfw/housekeeping/HousekeepingSet.h +++ b/src/fsfw/housekeeping/HousekeepingSet.h @@ -2,34 +2,37 @@ #include #include +#include +#include #include -#include "HousekeepingEntryIF.h" - class HousekeepingHelper; class GeneratesHousekeepingIF; using HousekeepingSetId_t = uint32_t; -class HousekeepingSet { +class HousekeepingSet : public HasTmTcParametersIF { public: #ifdef FSFW_INTROSPECTION HousekeepingSet(GeneratesHousekeepingIF* owner); void setEnum(EnumIF* theEnum); #else - HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id); + HousekeepingSet(GeneratesHousekeepingIF *owner, HousekeepingSetId_t id); #endif HousekeepingSetId_t getId() const { return id; } void report(const Action* action = nullptr); + void registerParameter(ParameterIF* parameter) override; + std::vector const* getParameters() override; + protected: HousekeepingHelper* helper; HousekeepingSetId_t id; #ifdef FSFW_INTROSPECTION const char* description; #endif - std::vector variables; + std::vector parameterList; }; \ No newline at end of file diff --git a/src/fsfw/introspection/HasTmTcParametersIF.h b/src/fsfw/introspection/HasTmTcParametersIF.h new file mode 100644 index 000000000..0ffa7b9bb --- /dev/null +++ b/src/fsfw/introspection/HasTmTcParametersIF.h @@ -0,0 +1,12 @@ +#pragma once + +#include "ParameterIF.h" +#include + +class HasTmTcParametersIF { + public: + ~HasTmTcParametersIF() = default; + + virtual void registerParameter(ParameterIF *parameter) = 0; + virtual std::vector const *getParameters() const = 0; +}; \ No newline at end of file diff --git a/src/fsfw/action/MinMaxParameter.h b/src/fsfw/introspection/MinMaxParameter.h similarity index 100% rename from src/fsfw/action/MinMaxParameter.h rename to src/fsfw/introspection/MinMaxParameter.h diff --git a/src/fsfw/action/Parameter.h b/src/fsfw/introspection/Parameter.h similarity index 90% rename from src/fsfw/action/Parameter.h rename to src/fsfw/introspection/Parameter.h index b14579089..5e5aa9c8f 100644 --- a/src/fsfw/action/Parameter.h +++ b/src/fsfw/introspection/Parameter.h @@ -2,7 +2,7 @@ #include -#include "Action.h" +#include "HasTmTcParametersIF.h" #include #include #include "ParameterIF.h" @@ -14,10 +14,10 @@ template class Parameter : public ParameterIF { protected: #ifdef FSFW_INTROSPECTION - Parameter(Action *owner, const char *name) + Parameter(HasTmTcParametersIF *owner, const char *name) : name(name) #else - Parameter(Action *owner) + Parameter(HasTmTcParametersIF *owner) #endif { owner->registerParameter(this); @@ -25,11 +25,11 @@ class Parameter : public ParameterIF { public: #ifdef FSFW_INTROSPECTION - static Parameter createParameter(Action *owner, const char *name) { + static Parameter createParameter(HasTmTcParametersIF *owner, const char *name) { return Parameter(owner, name); } #else - static Parameter createParameter(Action *owner) { return Parameter(owner); } + static Parameter createParameter(HasTmTcParametersIF *owner) { return Parameter(owner); } #endif bool isValid() override { diff --git a/src/fsfw/action/ParameterIF.h b/src/fsfw/introspection/ParameterIF.h similarity index 100% rename from src/fsfw/action/ParameterIF.h rename to src/fsfw/introspection/ParameterIF.h diff --git a/src/fsfw/introspection/Types.h b/src/fsfw/introspection/Types.h index 0fa9640dc..cb55b0011 100644 --- a/src/fsfw/introspection/Types.h +++ b/src/fsfw/introspection/Types.h @@ -3,6 +3,7 @@ //maybe call them MIB types as these are the ones exposed to the MIB? // Note: some DBs (Postgress, Mongo) only support signed 64bit integers. To have a common denominator, all integers are int64_t. // As such, ther is no unsigned Type, as there can not be a uint64_t and uint32_t completely fits into int64_t +// Floating is IEEE double namespace Types { enum ParameterType { SIGNED, FLOATING, ENUM, UNSUPPORTED }; } // namespace Types \ No newline at end of file diff --git a/src/fsfw/introspection/TypesHelper.h b/src/fsfw/introspection/TypesHelper.h index 30ef3635b..d864e77a0 100644 --- a/src/fsfw/introspection/TypesHelper.h +++ b/src/fsfw/introspection/TypesHelper.h @@ -31,7 +31,7 @@ class enumHelper { return 0; } - static std::vector getEnumValues() { return std::vector(); } + //TODO needed?: static std::vector getEnumValues() { return std::vector(); } static std::vector getEnumValues(EnumIF *anEnum) { std::vector vector;