From ad4adc7cbadf01e6e4c1c1b82e538a44428ab30c Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 3 Jul 2023 17:10:16 +0200 Subject: [PATCH] breaking everything in preperation of new Datapool --- src/CMakeLists.txt | 2 +- src/fsfw/CMakeLists.txt | 10 +- src/fsfw/controller/CMakeLists.txt | 3 +- src/fsfw/datapool/CMakeLists.txt | 2 +- src/fsfw/datapool/DatapoolHelper.cpp | 20 ++ src/fsfw/datapool/DatapoolHelper.h | 24 ++ src/fsfw/datapool/Dataset.cpp | 143 ++++++++++++ src/fsfw/datapool/Dataset.h | 115 ++++++++++ src/fsfw/datapool/DatasetEntryIF.h | 54 +++++ src/fsfw/datapool/HasDatapoolIF.h | 9 + src/fsfw/datapool/HousekeepingEntry.h | 128 +++++++++++ src/fsfw/datapool/PoolDataSetBase.cpp | 217 ------------------ src/fsfw/datapool/PoolDataSetBase.h | 173 -------------- src/fsfw/datapool/PoolDataSetIF.h | 34 --- src/fsfw/datapool/PoolEntry.cpp | 102 -------- src/fsfw/datapool/PoolEntry.h | 140 ----------- src/fsfw/datapool/PoolVarList.h | 28 --- src/fsfw/datapool/PoolVariableIF.h | 62 ----- src/fsfw/datapool/ReadCommitIF.h | 27 --- src/fsfw/datapool/ReadCommitIFAttorney.h | 30 --- src/fsfw/datapool/SharedDataSetIF.h | 16 -- src/fsfw/datapool/TemplateSet.h | 23 ++ src/fsfw/datapoollocal.h | 11 - src/fsfw/devicehandlers/ChildHandlerBase.cpp | 2 +- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 160 +++++-------- src/fsfw/devicehandlers/DeviceHandlerBase.h | 74 ++---- .../DeviceHandlerFailureIsolation.cpp | 23 +- src/fsfw/devicehandlers/DeviceHandlerIF.h | 7 +- ...rmalSet.h => no_DeviceHandlerThermalSet.h} | 0 src/fsfw/internalerror/InternalErrorDataset.h | 16 +- .../internalerror/InternalErrorReporter.cpp | 74 ++---- .../internalerror/InternalErrorReporter.h | 25 +- src/fsfw/ipc/CommandMessageCleaner.cpp | 14 +- src/fsfw/monitoring/MonitorBase.h | 3 +- .../AccessLocalPoolF.h | 0 .../CMakeLists.txt | 0 .../DataSetIF.h | 0 .../HasLocalDataPoolIF.h | 0 .../LocalDataPoolManager.cpp | 0 .../LocalDataPoolManager.h | 4 +- .../LocalDataSet.cpp | 0 .../LocalDataSet.h | 0 .../LocalPoolDataSetBase.cpp | 0 .../LocalPoolDataSetBase.h | 0 .../LocalPoolObjectBase.cpp | 0 .../LocalPoolObjectBase.h | 0 .../LocalPoolVariable.h | 0 .../LocalPoolVariable.tpp | 0 .../LocalPoolVector.h | 0 .../LocalPoolVector.tpp | 0 .../MarkChangedIF.h | 0 .../PoolEntryIF.h | 0 .../ProvidesDataPoolSubscriptionIF.h | 0 .../SharedLocalDataSet.cpp | 0 .../SharedLocalDataSet.h | 0 .../StaticLocalDataSet.h | 0 .../internal/CMakeLists.txt | 0 .../internal/HasLocalDpIFManagerAttorney.cpp | 0 .../internal/HasLocalDpIFManagerAttorney.h | 0 .../internal/HasLocalDpIFUserAttorney.cpp | 0 .../internal/HasLocalDpIFUserAttorney.h | 0 .../internal/LocalDpManagerAttorney.h | 0 .../internal/LocalPoolDataSetAttorney.h | 0 .../localPoolDefinitions.h | 2 +- src/fsfw/power/Fuse.cpp | 20 +- src/fsfw/power/Fuse.h | 15 +- src/fsfw/power/PowerSensor.cpp | 32 +-- src/fsfw/power/PowerSensor.h | 31 ++- src/fsfw/pus/CMakeLists.txt | 2 +- src/fsfw/returnvalues/HasReturnvaluesIF.h | 8 - 70 files changed, 705 insertions(+), 1180 deletions(-) create mode 100644 src/fsfw/datapool/DatapoolHelper.cpp create mode 100644 src/fsfw/datapool/DatapoolHelper.h create mode 100644 src/fsfw/datapool/Dataset.cpp create mode 100644 src/fsfw/datapool/Dataset.h create mode 100644 src/fsfw/datapool/DatasetEntryIF.h create mode 100644 src/fsfw/datapool/HasDatapoolIF.h create mode 100644 src/fsfw/datapool/HousekeepingEntry.h delete mode 100644 src/fsfw/datapool/PoolDataSetBase.cpp delete mode 100644 src/fsfw/datapool/PoolDataSetBase.h delete mode 100644 src/fsfw/datapool/PoolDataSetIF.h delete mode 100644 src/fsfw/datapool/PoolEntry.cpp delete mode 100644 src/fsfw/datapool/PoolEntry.h delete mode 100644 src/fsfw/datapool/PoolVarList.h delete mode 100644 src/fsfw/datapool/PoolVariableIF.h delete mode 100644 src/fsfw/datapool/ReadCommitIF.h delete mode 100644 src/fsfw/datapool/ReadCommitIFAttorney.h delete mode 100644 src/fsfw/datapool/SharedDataSetIF.h create mode 100644 src/fsfw/datapool/TemplateSet.h delete mode 100644 src/fsfw/datapoollocal.h rename src/fsfw/devicehandlers/{DeviceHandlerThermalSet.h => no_DeviceHandlerThermalSet.h} (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/AccessLocalPoolF.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/CMakeLists.txt (100%) rename src/fsfw/{datapool => no_datapoollocal}/DataSetIF.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/HasLocalDataPoolIF.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalDataPoolManager.cpp (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalDataPoolManager.h (99%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalDataSet.cpp (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalDataSet.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalPoolDataSetBase.cpp (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalPoolDataSetBase.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalPoolObjectBase.cpp (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalPoolObjectBase.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalPoolVariable.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalPoolVariable.tpp (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalPoolVector.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/LocalPoolVector.tpp (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/MarkChangedIF.h (100%) rename src/fsfw/{datapool => no_datapoollocal}/PoolEntryIF.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/ProvidesDataPoolSubscriptionIF.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/SharedLocalDataSet.cpp (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/SharedLocalDataSet.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/StaticLocalDataSet.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/internal/CMakeLists.txt (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/internal/HasLocalDpIFManagerAttorney.cpp (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/internal/HasLocalDpIFManagerAttorney.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/internal/HasLocalDpIFUserAttorney.cpp (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/internal/HasLocalDpIFUserAttorney.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/internal/LocalDpManagerAttorney.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/internal/LocalPoolDataSetAttorney.h (100%) rename src/fsfw/{datapoollocal => no_datapoollocal}/localPoolDefinitions.h (98%) delete mode 100644 src/fsfw/returnvalues/HasReturnvaluesIF.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 57b24bd55..37795558c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,4 +8,4 @@ if(FSFW_ADD_HAL) add_subdirectory(fsfw_hal) endif() -add_subdirectory(fsfw_tests) +#add_subdirectory(fsfw_tests) diff --git a/src/fsfw/CMakeLists.txt b/src/fsfw/CMakeLists.txt index 3c68c7a23..638af1f5c 100644 --- a/src/fsfw/CMakeLists.txt +++ b/src/fsfw/CMakeLists.txt @@ -7,13 +7,13 @@ add_subdirectory(cfdp) add_subdirectory(container) add_subdirectory(controller) add_subdirectory(datapool) -add_subdirectory(datapoollocal) +#add_subdirectory(datapoollocal) add_subdirectory(devicehandlers) add_subdirectory(events) add_subdirectory(fdir) add_subdirectory(globalfunctions) add_subdirectory(health) -add_subdirectory(housekeeping) +#add_subdirectory(housekeeping) add_subdirectory(internalerror) add_subdirectory(introspection) add_subdirectory(ipc) @@ -21,14 +21,14 @@ add_subdirectory(memory) add_subdirectory(modes) add_subdirectory(objectmanager) add_subdirectory(parameters) -add_subdirectory(power) +#add_subdirectory(power) add_subdirectory(serialize) add_subdirectory(serviceinterface) add_subdirectory(storagemanager) add_subdirectory(subsystem) add_subdirectory(tasks) add_subdirectory(tcdistribution) -add_subdirectory(thermal) +#add_subdirectory(thermal) add_subdirectory(timemanager) add_subdirectory(tmtcpacket) add_subdirectory(tmtcservices) @@ -37,7 +37,7 @@ add_subdirectory(filesystem) # Optional if(FSFW_ADD_MONITORING) - add_subdirectory(monitoring) + #add_subdirectory(monitoring) endif() if(FSFW_ADD_PUS) add_subdirectory(pus) diff --git a/src/fsfw/controller/CMakeLists.txt b/src/fsfw/controller/CMakeLists.txt index c8c000d81..1112785af 100644 --- a/src/fsfw/controller/CMakeLists.txt +++ b/src/fsfw/controller/CMakeLists.txt @@ -1,2 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE ControllerBase.cpp - ExtendedControllerBase.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE ControllerBase.cpp) diff --git a/src/fsfw/datapool/CMakeLists.txt b/src/fsfw/datapool/CMakeLists.txt index b2ac592c4..332b9713c 100644 --- a/src/fsfw/datapool/CMakeLists.txt +++ b/src/fsfw/datapool/CMakeLists.txt @@ -1 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE PoolDataSetBase.cpp PoolEntry.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE Dataset.cpp DatapoolHelper.cpp) diff --git a/src/fsfw/datapool/DatapoolHelper.cpp b/src/fsfw/datapool/DatapoolHelper.cpp new file mode 100644 index 000000000..1e5e02f14 --- /dev/null +++ b/src/fsfw/datapool/DatapoolHelper.cpp @@ -0,0 +1,20 @@ +#include "DatapoolHelper.h" + +#include "Dataset.h" + +DatapoolHelper::DatapoolHelper() {} + +DatapoolHelper::~DatapoolHelper() {} + +const Dataset* DatapoolHelper::getDataSet(uint8_t id) { + auto iter = dataSets.find(id); + if (iter == dataSets.end()) { + return nullptr; + } + return iter->second; +} + +void DatapoolHelper::registerSet(Dataset* set) { + auto id = set->getId(); + dataSets.insert(std::pair(id, set)); +} \ No newline at end of file diff --git a/src/fsfw/datapool/DatapoolHelper.h b/src/fsfw/datapool/DatapoolHelper.h new file mode 100644 index 000000000..9be45797b --- /dev/null +++ b/src/fsfw/datapool/DatapoolHelper.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +#include + +class Dataset; + +class DatapoolHelper { + public: + DatapoolHelper(); + ~DatapoolHelper(); + + const Dataset* getDataSet(uint8_t id); + + const std::map* getDatasets() const { + return &dataSets; + } + + void registerSet(Dataset* set); + + private: + std::map dataSets; +}; diff --git a/src/fsfw/datapool/Dataset.cpp b/src/fsfw/datapool/Dataset.cpp new file mode 100644 index 000000000..db0414b85 --- /dev/null +++ b/src/fsfw/datapool/Dataset.cpp @@ -0,0 +1,143 @@ +#include "Dataset.h" + +#include +#include +#include + +#ifdef FSFW_INTROSPECTION +Dataset::Dataset(HasDatapoolIF* owner, bool allowUserCommit) + : allocated(true), allowUserCommit(allowUserCommit) { + this->owner.pointer = owner; + mutex = MutexFactory::instance()->createMutex(); +} + +Dataset::Dataset(uint32_t owner_id ) + : allocated(false), allowUserCommit(false) { + this->owner.id = owner_id; +} + +void Dataset::setEnum(EnumIF *theEnum) { + id = theEnum->getValue(); + description = theEnum->getDescription(); +} +#else +Dataset::Dataset(HasDatapoolIF* owner, uint8_t id, bool allowUserCommit) + : allocated(true), allowUserCommit(allowUserCommit), id(id) { + this->owner.pointer = owner; + mutex = MutexFactory::instance()->createMutex(); +} + +Dataset::Dataset(uint32_t owner_id, uint8_t id): id(id) { this->owner.id = owner_id; } +#endif + +Dataset::~Dataset() { MutexFactory::instance()->deleteMutex(mutex); } + +void Dataset::commit() { + if ((!allocated) && (!allowUserCommit)) { + return; + } + + lock(); + for (auto variable : variables) { + variable->commit(); + } + unlock(); +} + +void Dataset::commit(bool valid) { + if ((!allocated) && (!allowUserCommit)) { + return; + } + setAllValid(valid); + commit(); +} + +void Dataset::setAllValid(bool valid) { + if ((!allocated) && (!allowUserCommit)) { + return; + } + for (auto variable : variables) { + variable->setValid(valid); + } +} + +void Dataset::read() { + lock(); + for (auto variable : variables) { + variable->read(); + } + unlock(); +} + +bool Dataset::hasChanged() { + bool changed = hasChangedNoRead(); + read(); + return changed; +} + +bool Dataset::hasChangedOrOlderThan(uint32_t seconds) { + bool changed = hasChanged(); + //TODO time + read(); + return changed; +} + +uint8_t Dataset::getId() const { + return id; +} + +const std::vector* Dataset::getVariables() const { return &variables; } + +ReturnValue_t Dataset::initialize() { + if (allocated) { + //nothing to do + return returnvalue::OK; + } + HasDatapoolIF* actualOwner = ObjectManager::instance()->get(owner.id); + if (actualOwner == nullptr) { + return returnvalue::FAILED; + } + const Dataset* theOtherSet = actualOwner->getDatapoolHelper()->getDataSet(this->id); + if (theOtherSet == nullptr) { + return returnvalue::FAILED; + } + + if (theOtherSet->variables.size() != variables.size()) { + return returnvalue::FAILED; + } + + this->mutex = theOtherSet->mutex; + this->allowUserCommit = theOtherSet->allowUserCommit; + + for (size_t i = 0; i < variables.size(); i++) { + variables[i]->connect(theOtherSet->variables[i]); + } + + return returnvalue::OK; +} + +// operator[] + +#ifdef FSFW_INTROSPECTION +const char* Dataset::getDescription() const { return description; } +#endif + +bool Dataset::registerEntry(DatasetEntryIF* entry) { + variables.push_back(entry); + return allocated; +} + +void Dataset::lock() { mutex->lockMutex(MutexIF::TimeoutType::BLOCKING); } + +void Dataset::unlock() { mutex->unlockMutex(); } + +bool Dataset::hasChangedNoRead(){ + bool changed = false; + for (auto variable: variables){ + if (variable->changed()){ + changed = true; + break; + } + } + return changed; +} \ No newline at end of file diff --git a/src/fsfw/datapool/Dataset.h b/src/fsfw/datapool/Dataset.h new file mode 100644 index 000000000..126b54b92 --- /dev/null +++ b/src/fsfw/datapool/Dataset.h @@ -0,0 +1,115 @@ +#pragma once + +#include +#include +#include +#include + +#include + +#include "DatasetEntryIF.h" +#include "HasDatapoolIF.h" + +class Dataset { + protected: +#ifdef FSFW_INTROSPECTION + Dataset(HasDatapoolIF* owner, bool allowUserCommit); + Dataset(uint32_t owner_id); + void setEnum(EnumIF* theEnum); +#else + Dataset(HasDatapoolIF* owner, uint8_t id, bool allowUserCommit); + Dataset(uint32_t owner_id, uint8_t id); +#endif + public: + ~Dataset(); + /** + * Copy content of local copies into actual variable + * + */ + void commit(); + + /** + * Copy content of local copies into actual variable + * + * calls setValit(valid) before committing + * + */ + void commit(bool valid); + + /** + * set all contained variables to #valid + * + */ + void setAllValid(bool valid); + + /** + * Copy content of actual variables into local copies + * + * + */ + void read(); + + /** + * returns true if local copies and actual variables differ + * + * implicitely calls read() + */ + bool hasChanged(); + + /** + * returns true if local copies and actual variables differ + * or time since last time true has been returned is greater than + * supplied time + * + * implicitely calls read() + * + */ + bool hasChangedOrOlderThan(uint32_t seconds); + + /** + * get List of contained Valiables + */ + virtual const std::vector* getVariables() const; + + + ReturnValue_t initialize(); + + // operator[] + + uint8_t getId() const; + +#ifdef FSFW_INTROSPECTION + const char* getDescription() const; +#endif + + /** + * returns whether the set is the actual owned set (entries should allocate actual variables) + */ + bool registerEntry(DatasetEntryIF*); + + protected: + bool allocated; + bool allowUserCommit; + union { + uint32_t id; + HasDatapoolIF* pointer; + } owner; + uint8_t id; + MutexIF* mutex; +#ifdef FSFW_INTROSPECTION + const char* description; +#endif + std::vector variables; + + /** + * lock the mutex of the set + */ + void lock(); + + /** + * unlock the mutex of the set + */ + void unlock(); + + bool hasChangedNoRead(); +}; \ No newline at end of file diff --git a/src/fsfw/datapool/DatasetEntryIF.h b/src/fsfw/datapool/DatasetEntryIF.h new file mode 100644 index 000000000..a08a9ca27 --- /dev/null +++ b/src/fsfw/datapool/DatasetEntryIF.h @@ -0,0 +1,54 @@ +#ifndef FSFW_DATAPOOL_POOLENTRYIF_H_ +#define FSFW_DATAPOOL_POOLENTRYIF_H_ + +#include + +#include + +class DatasetEntryIF { + friend class Dataset; + + public: + /** + * @brief This is an empty virtual destructor, + * as it is required for C++ interfaces. + */ + virtual ~DatasetEntryIF() {} + /** + * @brief This method allows to set the valid information of the pool entry. + */ + virtual void setValid(bool isValid) = 0; + /** + * @brief This method allows to set the valid information of the pool entry. + */ + virtual bool getValid() = 0; + + + #ifdef FSFW_INTROSPECTION + + virtual const char *getName() = 0; + + virtual Types::ParameterType getType() = 0; + + virtual double getFloating() = 0; + virtual int64_t getSigned() = 0; + + virtual bool setFloating(double value) = 0; + virtual bool setSigned(int64_t value) = 0; + + virtual std::vector getEnumValues() = 0; + virtual const char *const * getEnumDescriptions() = 0; +#endif + + protected: + virtual void commit() = 0; + virtual void read() = 0; + virtual void connect(DatasetEntryIF* entry) = 0; + + /** + * returns if value and actual value is different + */ + virtual bool changed() = 0; +}; + +#endif /* FSFW_DATAPOOL_POOLENTRYIF_H_ */ diff --git a/src/fsfw/datapool/HasDatapoolIF.h b/src/fsfw/datapool/HasDatapoolIF.h new file mode 100644 index 000000000..5463d88e5 --- /dev/null +++ b/src/fsfw/datapool/HasDatapoolIF.h @@ -0,0 +1,9 @@ +#pragma once + +#include "DatapoolHelper.h" + +class HasDatapoolIF { + public: + virtual ~HasDatapoolIF() = default; + virtual DatapoolHelper* getDatapoolHelper() = 0; +}; \ No newline at end of file diff --git a/src/fsfw/datapool/HousekeepingEntry.h b/src/fsfw/datapool/HousekeepingEntry.h new file mode 100644 index 000000000..bcf6ba6c5 --- /dev/null +++ b/src/fsfw/datapool/HousekeepingEntry.h @@ -0,0 +1,128 @@ +#pragma once + +#include "Dataset.h" +#include "DatasetEntryIF.h" + +template +class DatasetEntry : public DatasetEntryIF { + protected: +#ifdef FSFW_INTROSPECTION + DatasetEntry(Dataset* set, const char* name) : name(name) { +#else + DatasetEntry(Dataset* set) { +#endif + allocated = set->registerEntry(this); + if (!allocated) { + return; + } + storedValue = new T(); + storedValid = new bool; + } + + public: + +#ifdef FSFW_INTROSPECTION + Types::ParameterType getType() override { + return enumHelper::value>::template getType(); + } +#endif + + +#ifdef FSFW_INTROSPECTION +static DatasetEntry createEntry(Dataset* set, const char *name) { + return DatasetEntry(set, name); + } +#else +static DatasetEntry createEntry(Dataset* set) { return DatasetEntry(set); } +#endif + + ~DatasetEntry() { + if (allocated) { + delete storedValue; + delete storedValid; + } + } + + operator T() { + return value; + } + + DatasetEntry &operator=(T newValue){ + value = newValue; + return *this; + } + + void setValid(bool isValid) override { valid = isValid; } + + bool getValid() override { return valid; } + +// TODO this is generic with the action parameter +#ifdef FSFW_INTROSPECTION + double getFloating() override { return (double)value; } + int64_t getSigned() override { return (int64_t)value; } + + bool setFloating(double value) override { + if (getType() != Types::FLOATING) { + return false; + } + this->value = value; + return true; + } + + bool setSigned(int64_t value) override { + if ((getType() != Types::SIGNED) && (getType() != Types::ENUM)) { + return false; + } + this->value = value; + return true; + } + + std::vector getEnumValues() override { + return enumHelper::value>::getEnumValues(&value); + } + const char* const* getEnumDescriptions() override { + return enumHelper::value>::getEnumDescriptions(&value); + } + + const char* getName() override { return name; } + + private: + const char* name; +#endif + + protected: + void commit() override { + *storedValue = value; + *storedValid = valid; + } + + void read() override { + value = *storedValue; + valid = *storedValid; + } + + void connect(DatasetEntryIF* entry) override { + DatasetEntry* theOther = dynamic_cast*>(entry); + if (theOther == nullptr) { + // Configuration error + return; + } + this->storedValue = theOther->storedValue; + this->storedValid = theOther->storedValid; + } + + bool changed() override { return ((value != *storedValue) || (valid != *storedValid)); } + + private: + T value; + T* storedValue; + bool* storedValid; + bool valid; + bool allocated; +}; + +#ifdef FSFW_INTROSPECTION +#define createEntry(p1, p2) createEntry(p1, p2) +#else +#define createEntry(p1, p2) createEntry(p1) +#endif \ No newline at end of file diff --git a/src/fsfw/datapool/PoolDataSetBase.cpp b/src/fsfw/datapool/PoolDataSetBase.cpp deleted file mode 100644 index 0df21d2a1..000000000 --- a/src/fsfw/datapool/PoolDataSetBase.cpp +++ /dev/null @@ -1,217 +0,0 @@ -#include "fsfw/datapool/PoolDataSetBase.h" - -#include - -#include "fsfw/datapool/ReadCommitIFAttorney.h" -#include "fsfw/serviceinterface/ServiceInterface.h" - -PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray, - const size_t maxFillCount) - : registeredVariables(registeredVariablesArray), maxFillCount(maxFillCount) {} - -PoolDataSetBase::~PoolDataSetBase() {} - -ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) { - if (registeredVariables == nullptr) { - /* Underlying container invalid */ - return returnvalue::FAILED; - } - if (state != States::STATE_SET_UNINITIALISED) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DataSet::registerVariable: Call made in wrong position." << std::endl; -#else - sif::printError("DataSet::registerVariable: Call made in wrong position."); -#endif - return DataSetIF::DATA_SET_UNINITIALISED; - } - if (variable == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DataSet::registerVariable: Pool variable is nullptr." << std::endl; -#else - sif::printError("DataSet::registerVariable: Pool variable is nullptr.\n"); -#endif - return DataSetIF::POOL_VAR_NULL; - } - if (fillCount >= maxFillCount) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DataSet::registerVariable: DataSet is full." << std::endl; -#else - sif::printError("DataSet::registerVariable: DataSet is full.\n"); -#endif - return DataSetIF::DATA_SET_FULL; - } - registeredVariables[fillCount] = variable; - fillCount++; - return returnvalue::OK; -} - -ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { - ReturnValue_t result = returnvalue::OK; - ReturnValue_t error = result; - if (state == States::STATE_SET_UNINITIALISED) { - lockDataPool(timeoutType, lockTimeout); - for (uint16_t count = 0; count < fillCount; count++) { - result = readVariable(count); - if (result != returnvalue::OK) { - error = result; - } - } - state = States::STATE_SET_WAS_READ; - unlockDataPool(); - } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PoolDataSetBase::read: Call made in wrong position. Don't forget to " - "commit member datasets!" - << std::endl; -#else - sif::printWarning( - "PoolDataSetBase::read: Call made in wrong position. Don't forget to " - "commit member datasets!\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - result = SET_WAS_ALREADY_READ; - } - - if (error != returnvalue::OK) { - result = error; - } - return result; -} - -uint16_t PoolDataSetBase::getFillCount() const { return fillCount; } - -ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { - ReturnValue_t result = returnvalue::OK; - if (registeredVariables[count] == nullptr) { - /* Configuration error. */ - return returnvalue::FAILED; - } - - /* These checks are often performed by the respective variable implementation too, but I guess - a double check does not hurt. */ - if (registeredVariables[count]->getReadWriteMode() != PoolVariableIF::VAR_WRITE and - registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER) { - if (protectEveryReadCommitCall) { - result = - registeredVariables[count]->read(timeoutTypeForSingleVars, mutexTimeoutForSingleVars); - } else { - /* The readWithoutLock function is protected, so we use the attorney here */ - result = ReadCommitIFAttorney::readWithoutLock(registeredVariables[count]); - } - - if (result != returnvalue::OK) { - result = INVALID_PARAMETER_DEFINITION; - } - } - return result; -} - -ReturnValue_t PoolDataSetBase::commit(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { - if (state == States::STATE_SET_WAS_READ) { - handleAlreadyReadDatasetCommit(timeoutType, lockTimeout); - return returnvalue::OK; - } else { - return handleUnreadDatasetCommit(timeoutType, lockTimeout); - } -} - -void PoolDataSetBase::handleAlreadyReadDatasetCommit(MutexIF::TimeoutType timeoutType, - uint32_t lockTimeout) { - lockDataPool(timeoutType, lockTimeout); - for (uint16_t count = 0; count < fillCount; count++) { - if ((registeredVariables[count]->getReadWriteMode() != PoolVariableIF::VAR_READ) and - (registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER)) { - if (protectEveryReadCommitCall) { - registeredVariables[count]->commit(timeoutTypeForSingleVars, mutexTimeoutForSingleVars); - } else { - /* The commitWithoutLock function is protected, so we use the attorney here */ - ReadCommitIFAttorney::commitWithoutLock(registeredVariables[count]); - } - } - } - state = States::STATE_SET_UNINITIALISED; - unlockDataPool(); -} - -ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(MutexIF::TimeoutType timeoutType, - uint32_t lockTimeout) { - ReturnValue_t result = returnvalue::OK; - lockDataPool(timeoutType, lockTimeout); - for (uint16_t count = 0; count < fillCount; count++) { - if ((registeredVariables[count]->getReadWriteMode() == PoolVariableIF::VAR_WRITE) and - (registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER)) { - if (protectEveryReadCommitCall) { - result = - registeredVariables[count]->commit(timeoutTypeForSingleVars, mutexTimeoutForSingleVars); - } else { - /* The commitWithoutLock function is protected, so we use the attorney here */ - ReadCommitIFAttorney::commitWithoutLock(registeredVariables[count]); - } - - } else if (registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER) { - if (result != COMMITING_WITHOUT_READING) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DataSet::commit(): commit-without-read call made " - "with non write-only variable." - << std::endl; -#endif - result = COMMITING_WITHOUT_READING; - } - } - } - state = States::STATE_SET_UNINITIALISED; - unlockDataPool(); - return result; -} - -ReturnValue_t PoolDataSetBase::lockDataPool(MutexIF::TimeoutType timeoutType, - uint32_t lockTimeout) { - return returnvalue::OK; -} - -ReturnValue_t PoolDataSetBase::unlockDataPool() { return returnvalue::OK; } - -ReturnValue_t PoolDataSetBase::serialize(uint8_t** buffer, size_t* size, const size_t maxSize, - SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = returnvalue::FAILED; - for (uint16_t count = 0; count < fillCount; count++) { - result = registeredVariables[count]->serialize(buffer, size, maxSize, streamEndianness); - if (result != returnvalue::OK) { - return result; - } - } - return result; -} - -ReturnValue_t PoolDataSetBase::deSerialize(const uint8_t** buffer, size_t* size, - SerializeIF::Endianness streamEndianness) { - ReturnValue_t result = returnvalue::FAILED; - for (uint16_t count = 0; count < fillCount; count++) { - result = registeredVariables[count]->deSerialize(buffer, size, streamEndianness); - if (result != returnvalue::OK) { - return result; - } - } - return result; -} - -size_t PoolDataSetBase::getSerializedSize() const { - uint32_t size = 0; - for (uint16_t count = 0; count < fillCount; count++) { - size += registeredVariables[count]->getSerializedSize(); - } - return size; -} - -void PoolDataSetBase::setContainer(PoolVariableIF** variablesContainer) { - this->registeredVariables = variablesContainer; -} - -PoolVariableIF** PoolDataSetBase::getContainer() const { return registeredVariables; } - -void PoolDataSetBase::setReadCommitProtectionBehaviour(bool protectEveryReadCommit, - MutexIF::TimeoutType timeoutType, - uint32_t mutexTimeout) { - this->protectEveryReadCommitCall = protectEveryReadCommit; - this->timeoutTypeForSingleVars = timeoutType; - this->mutexTimeoutForSingleVars = mutexTimeout; -} diff --git a/src/fsfw/datapool/PoolDataSetBase.h b/src/fsfw/datapool/PoolDataSetBase.h deleted file mode 100644 index 621dd8cc1..000000000 --- a/src/fsfw/datapool/PoolDataSetBase.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef FSFW_DATAPOOL_POOLDATASETBASE_H_ -#define FSFW_DATAPOOL_POOLDATASETBASE_H_ - -#include "PoolDataSetIF.h" -#include "PoolVariableIF.h" -#include "fsfw/ipc/MutexIF.h" -#include "fsfw/serialize/SerializeIF.h" - -/** - * @brief The DataSetBase class manages a set of locally checked out variables. - * @details - * This class manages a list, where a set of local variables (or pool variables) - * are registered. They are checked-out (i.e. their values are looked - * up and copied) with the read call. After the user finishes working with the - * pool variables, he can write back all variable values to the pool with - * the commit call. The data set manages locking and freeing the data pool, - * to ensure that all values are read and written back at once. - * - * An internal state manages usage of this class. Variables may only be - * registered before the read call is made, and the commit call only - * after the read call. - * - * If pool variables are writable and not committed until destruction - * of the set, the DataSet class automatically sets the valid flag in the - * data pool to invalid (without) changing the variable's value. - * - * The base class lockDataPool und unlockDataPool implementation are empty - * and should be implemented to protect the underlying pool type. - * @author Bastian Baetz - * @ingroup data_pool - */ -class PoolDataSetBase : public PoolDataSetIF, public SerializeIF { - public: - /** - * @brief Creates an empty dataset. Use registerVariable or - * supply a pointer to this dataset to PoolVariable - * initializations to register pool variables. - */ - PoolDataSetBase(PoolVariableIF** registeredVariablesArray, size_t maxFillCount); - - /* Forbidden for now */ - PoolDataSetBase(const PoolDataSetBase& otherSet) = delete; - const PoolDataSetBase& operator=(const PoolDataSetBase& otherSet) = delete; - - ~PoolDataSetBase() override; - - /** - * @brief The read call initializes reading out all registered variables. - * It is mandatory to call commit after every read call! - * @details - * It iterates through the list of registered variables and calls all read() - * functions of the registered pool variables (which read out their values - * from the data pool) which are not write-only. - * In case of an error (e.g. a wrong data type, or an invalid data pool id), - * the operation is aborted and @c INVALID_PARAMETER_DEFINITION returned. - * - * The data pool is locked during the whole read operation and - * freed afterwards. It is mandatory to call commit after a read call, - * even if the read operation is not successful! - * @return - * - @c returnvalue::OK if all variables were read successfully. - * - @c INVALID_PARAMETER_DEFINITION if a pool entry does not exist or there - * is a type conflict. - * - @c SET_WAS_ALREADY_READ if read() is called twice without calling - * commit() in between - */ - ReturnValue_t read(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, - uint32_t lockTimeout = 20) override; - /** - * @brief The commit call initializes writing back the registered variables. - * @details - * It iterates through the list of registered variables and calls the - * commit() method of the remaining registered variables (which write back - * their values to the pool). - * - * The data pool is locked during the whole commit operation and - * freed afterwards. The state changes to "was committed" after this operation. - * - * If the set does contain at least one variable which is not write-only - * commit() can only be called after read(). If the set only contains - * variables which are write only, commit() can be called without a - * preceding read() call. Every read call must be followed by a commit call! - * @return - @c returnvalue::OK if all variables were read successfully. - * - @c COMMITING_WITHOUT_READING if set was not read yet and - * contains non write-only variables - */ - ReturnValue_t commit(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, - uint32_t lockTimeout = 20) override; - - /** - * Register the passed pool variable instance into the data set. - * @param variable - * @return - */ - ReturnValue_t registerVariable(PoolVariableIF* variable) override; - - /** - * Provides the means to lock the underlying data structure to ensure - * thread-safety. Default implementation is empty - * @return Always returns -@c returnvalue::OK - */ - virtual ReturnValue_t lockDataPool( - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, - uint32_t timeoutMs = 20) override; - /** - * Provides the means to unlock the underlying data structure to ensure - * thread-safety. Default implementation is empty - * @return Always returns -@c returnvalue::OK - */ - virtual ReturnValue_t unlockDataPool() override; - - virtual uint16_t getFillCount() const override; - - /* SerializeIF implementations */ - virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, const size_t maxSize, - SerializeIF::Endianness streamEndianness) const override; - virtual size_t getSerializedSize() const override; - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - SerializeIF::Endianness streamEndianness) override; - - /** - * Can be used to individually protect every read and commit call. - * @param protectEveryReadCommit - * @param mutexTimeout - */ - void setReadCommitProtectionBehaviour( - bool protectEveryReadCommit, MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, - uint32_t mutexTimeout = 20); - - protected: - /** - * @brief The fill_count attribute ensures that the variables - * register in the correct array position and that the maximum - * number of variables is not exceeded. - */ - uint16_t fillCount = 0; - /** - * States of the seet. - */ - enum class States { - STATE_SET_UNINITIALISED, //!< DATA_SET_UNINITIALISED - STATE_SET_WAS_READ //!< DATA_SET_WAS_READ - }; - /** - * @brief state manages the internal state of the data set, - * which is important e.g. for the behavior on destruction. - */ - States state = States::STATE_SET_UNINITIALISED; - - /** - * @brief This array represents all pool variables registered in this set. - * Child classes can use a static or dynamic container to create - * an array of registered variables and assign the first entry here. - */ - PoolVariableIF** registeredVariables = nullptr; - const size_t maxFillCount = 0; - - void setContainer(PoolVariableIF** variablesContainer); - PoolVariableIF** getContainer() const; - - private: - bool protectEveryReadCommitCall = false; - MutexIF::TimeoutType timeoutTypeForSingleVars = MutexIF::TimeoutType::WAITING; - uint32_t mutexTimeoutForSingleVars = 20; - - ReturnValue_t readVariable(uint16_t count); - void handleAlreadyReadDatasetCommit( - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, uint32_t timeoutMs = 20); - ReturnValue_t handleUnreadDatasetCommit( - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, uint32_t timeoutMs = 20); -}; - -#endif /* FSFW_DATAPOOL_POOLDATASETBASE_H_ */ diff --git a/src/fsfw/datapool/PoolDataSetIF.h b/src/fsfw/datapool/PoolDataSetIF.h deleted file mode 100644 index 3d1676af0..000000000 --- a/src/fsfw/datapool/PoolDataSetIF.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef FSFW_DATAPOOL_POOLDATASETIF_H_ -#define FSFW_DATAPOOL_POOLDATASETIF_H_ - -#include "DataSetIF.h" -#include "ReadCommitIF.h" - -/** - * @brief Extendes the DataSetIF by adding abstract functions to lock - * and unlock a data pool and read/commit semantics. - */ -class PoolDataSetIF : virtual public DataSetIF, virtual public ReadCommitIF { - public: - virtual ~PoolDataSetIF(){}; - - /** - * @brief Most underlying data structures will have a pool like structure - * and will require a lock and unlock mechanism to ensure - * thread-safety - * @return Lock operation result - */ - virtual ReturnValue_t lockDataPool( - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, - uint32_t timeoutMs = 20) = 0; - - /** - * @brief Unlock call corresponding to the lock call. - * @return Unlock operation result - */ - virtual ReturnValue_t unlockDataPool() = 0; - - virtual bool isValid() const = 0; -}; - -#endif /* FSFW_DATAPOOL_POOLDATASETIF_H_ */ diff --git a/src/fsfw/datapool/PoolEntry.cpp b/src/fsfw/datapool/PoolEntry.cpp deleted file mode 100644 index 9138a7059..000000000 --- a/src/fsfw/datapool/PoolEntry.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "fsfw/datapool/PoolEntry.h" - -#include -#include - -#include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" - -template -PoolEntry::PoolEntry(uint8_t len, bool setValid) : length(len), valid(setValid) { - this->address = new T[this->length](); - std::memset(this->address, 0, this->getByteSize()); -} - -template -PoolEntry::PoolEntry(std::initializer_list initValues, bool setValid) - : length(static_cast(initValues.size())), valid(setValid) { - this->address = new T[this->length](); - if (initValues.size() > 0) { - std::copy(initValues.begin(), initValues.end(), this->address); - } -} - -template -PoolEntry::PoolEntry(const T* initValue, uint8_t setLength, bool setValid) - : length(setLength), valid(setValid) { - this->address = new T[this->length](); - if (initValue != nullptr) { - std::memcpy(this->address, initValue, this->getByteSize()); - } -} - -// As the data pool is global, this dtor is only be called on program exit. -// Warning! Never copy pool entries! -template -PoolEntry::~PoolEntry() { - delete[] this->address; -} - -template -uint16_t PoolEntry::getByteSize() { - return (sizeof(T) * this->length); -} - -template -uint8_t PoolEntry::getSize() { - return this->length; -} - -template -void* PoolEntry::getRawData() { - return this->address; -} - -template -void PoolEntry::setValid(bool isValid) { - this->valid = isValid; -} - -template -bool PoolEntry::getValid() { - return valid; -} - -template -void PoolEntry::print() { - const char* validString = nullptr; - if (valid) { - validString = "Valid"; - } else { - validString = "Invalid"; - } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PoolEntry information." << std::endl; - sif::info << "PoolEntry validity: " << validString << std::endl; -#else - sif::printInfo("PoolEntry information.\n"); - sif::printInfo("PoolEntry validity: %s\n", validString); -#endif - arrayprinter::print(reinterpret_cast(address), getByteSize()); -} - -template -inline T* PoolEntry::getDataPtr() { - return this->address; -} - -template -Type PoolEntry::getType() { - return PodTypeConversion::type; -} - -template class PoolEntry; -template class PoolEntry; -template class PoolEntry; -template class PoolEntry; -template class PoolEntry; -template class PoolEntry; -template class PoolEntry; -template class PoolEntry; -template class PoolEntry; -template class PoolEntry; diff --git a/src/fsfw/datapool/PoolEntry.h b/src/fsfw/datapool/PoolEntry.h deleted file mode 100644 index 4010f78d2..000000000 --- a/src/fsfw/datapool/PoolEntry.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef FSFW_DATAPOOL_POOLENTRY_H_ -#define FSFW_DATAPOOL_POOLENTRY_H_ - -#include -#include -#include - -#include "PoolEntryIF.h" - -/** - * @brief This is a small helper class that defines a single data pool entry. - * @details - * The helper is used to store all information together with the data as a - * single data pool entry. The content's type is defined by the template - * argument. - * - * It is prepared for use with plain old data types, but may be - * extended to complex types if necessary. It can be initialized with a - * certain value, size and validity flag. - * - * It holds a pointer to the real data and offers methods to access this data - * and to acquire additional information (such as validity and array/byte size). - * It is NOT intended to be used outside DataPool implementations as it performs - * dynamic memory allocation. - * - * @ingroup data_pool - */ -template -class PoolEntry : public PoolEntryIF { - public: - static_assert(not std::is_same::value, - "Do not use boolean for the PoolEntry type, use uint8_t " - "instead! The ECSS standard defines a boolean as a one bit " - "field. Therefore it is preferred to store a boolean as an " - "uint8_t"); - - PoolEntry(uint8_t len = 1, bool setValid = false); - - /** - * @brief In the classe's constructor, space is allocated on the heap and - * potential initialization values are copied to that space. - * @details - * Not passing any arguments will initialize an non-array pool entry - * with an initial invalid state and the value 0. - * Please note that if an initializer list is passed, the length of the - * initializer list needs to be correct for vector entries because - * required allocated space will be deduced from the initializer list length - * and the pool entry type. - * @param initValue - * Initializer list with values to initialize with, for example {0, 0} to - * initialize the a pool entry of a vector with two entries to 0. - * @param setValid - * Sets the initialization flag. It is invalid by default. - */ - PoolEntry(std::initializer_list initValue, bool setValid = false); - - /** - * @brief In the classe's constructor, space is allocated on the heap and - * potential init values are copied to that space. - * @param initValue - * A pointer to the single value or array that holds the init value. - * With the default value (nullptr), the entry is initalized with all 0. - * @param setLength - * Defines the array length of this entry. - * @param setValid - * Sets the initialization flag. It is invalid by default. - */ - PoolEntry(const T* initValue, uint8_t setLength = 1, bool setValid = false); - - //! Explicitely deleted copy ctor, copying is not allowed. - PoolEntry(const PoolEntry&) = delete; - //! Explicitely deleted copy assignment, copying is not allowed. - PoolEntry& operator=(const PoolEntry&) = delete; - - /** - * @brief The allocated memory for the variable is freed - * in the destructor. - * @details - * As the data pool is global, this dtor is only called on program exit. - * PoolEntries shall never be copied, as a copy might delete the variable - * on the heap. - */ - ~PoolEntry(); - - /** - * Return typed pointer to start of data. - * @return - */ - T* getDataPtr(); - - /** - * @brief getSize returns the array size of the entry. - * @details - * For non-array pool entries return type size, for vector entries - * return type size times the number of entries. - */ - uint8_t getSize(); - /** - * @brief This operation returns the size in bytes. - * @details The size is calculated by sizeof(type) * array_size. - */ - uint16_t getByteSize(); - /** - * @brief This operation returns a the address pointer casted to void*. - */ - void* getRawData(); - /** - * @brief This method allows to set the valid information - * of the pool entry. - */ - void setValid(bool isValid); - /** - * @brief This method allows to get the valid information - * of the pool entry. - */ - bool getValid(); - /** - * @brief This is a debug method that prints all values and the valid - * information to the screen. It prints all array entries in a row. - */ - void print(); - Type getType(); - - private: - /** - * @brief This attribute stores the length information. - */ - uint8_t length; - /** - * @brief Here, the validity information for a variable is stored. - * Every entry (single variable or vector) has one valid flag. - */ - uint8_t valid; - /** - * @brief This is the address pointing to the allocated memory. - */ - T* address; -}; - -#endif /* FSFW_DATAPOOL_POOLENTRY_H_ */ diff --git a/src/fsfw/datapool/PoolVarList.h b/src/fsfw/datapool/PoolVarList.h deleted file mode 100644 index 8d4df8c7b..000000000 --- a/src/fsfw/datapool/PoolVarList.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef FSFW_DATAPOOL_POOLVARLIST_H_ -#define FSFW_DATAPOOL_POOLVARLIST_H_ - -#include "../datapool/PoolVariableIF.h" -#include "../datapoolglob/GlobalPoolVariable.h" -template -class PoolVarList { - private: - GlobPoolVar variables[n_var]; - - public: - PoolVarList(const uint32_t set_id[n_var], DataSetIF* dataSet, - PoolVariableIF::ReadWriteMode_t setReadWriteMode) { - // I really should have a look at the new init list c++ syntax. - if (dataSet == NULL) { - return; - } - for (uint8_t count = 0; count < n_var; count++) { - variables[count].dataPoolId = set_id[count]; - variables[count].readWriteMode = setReadWriteMode; - dataSet->registerVariable(&variables[count]); - } - } - - GlobPoolVar& operator[](int i) { return variables[i]; } -}; - -#endif /* FSFW_DATAPOOL_POOLVARLIST_H_ */ diff --git a/src/fsfw/datapool/PoolVariableIF.h b/src/fsfw/datapool/PoolVariableIF.h deleted file mode 100644 index 69074310d..000000000 --- a/src/fsfw/datapool/PoolVariableIF.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef FSFW_DATAPOOL_POOLVARIABLEIF_H_ -#define FSFW_DATAPOOL_POOLVARIABLEIF_H_ - -#include "../returnvalues/returnvalue.h" -#include "../serialize/SerializeIF.h" -#include "ReadCommitIF.h" - -/** - * @brief This interface is used to control data pool - * variable representations. - * @details - * To securely handle data pool variables, all pool entries are locally - * managed by data pool variable access classes, which are called pool - * variables. To ensure a common state of a set of variables needed in a - * function, these local pool variables again are managed by other classes, - * like the DataSet classes. This interface provides unified access to - * local pool variables for such manager classes. - * @author Bastian Baetz - * @ingroup data_pool - */ -class PoolVariableIF : public SerializeIF, public ReadCommitIF { - public: - static constexpr uint8_t INTERFACE_ID = CLASS_ID::POOL_VARIABLE_IF; - static constexpr ReturnValue_t INVALID_READ_WRITE_MODE = MAKE_RETURN_CODE(0xA0); - static constexpr ReturnValue_t INVALID_POOL_ENTRY = MAKE_RETURN_CODE(0xA1); - - static constexpr bool VALID = 1; - static constexpr bool INVALID = 0; - static constexpr uint32_t NO_PARAMETER = 0xffffffff; - - enum ReadWriteMode_t { VAR_READ, VAR_WRITE, VAR_READ_WRITE }; - - /** - * @brief This is an empty virtual destructor, - * as it is proposed for C++ interfaces. - */ - virtual ~PoolVariableIF() {} - /** - * @brief This method returns if the variable is write-only, - * read-write or read-only. - */ - virtual ReadWriteMode_t getReadWriteMode() const = 0; - virtual void setReadWriteMode(ReadWriteMode_t newMode) = 0; - - /** - * @brief This operation shall return the data pool id of the variable. - */ - virtual uint32_t getDataPoolId() const = 0; - /** - * @brief With this call, the valid information of the - * variable is returned. - */ - virtual bool isValid() const = 0; - /** - * @brief With this call, the valid information of the variable is set. - */ - virtual void setValid(bool validity) = 0; -}; - -using pool_rwm_t = PoolVariableIF::ReadWriteMode_t; - -#endif /* FSFW_DATAPOOL_POOLVARIABLEIF_H_ */ diff --git a/src/fsfw/datapool/ReadCommitIF.h b/src/fsfw/datapool/ReadCommitIF.h deleted file mode 100644 index ca074dec0..000000000 --- a/src/fsfw/datapool/ReadCommitIF.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef FSFW_DATAPOOL_READCOMMITIF_H_ -#define FSFW_DATAPOOL_READCOMMITIF_H_ - -#include "../ipc/MutexIF.h" -#include "../returnvalues/returnvalue.h" - -/** - * @brief Common interface for all software objects which employ read-commit - * semantics. - */ -class ReadCommitIF { - friend class ReadCommitIFAttorney; - - public: - virtual ~ReadCommitIF() {} - virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) = 0; - virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) = 0; - - protected: - /* Optional and protected because this is interesting for classes grouping members with commit - and read semantics where the lock is only necessary once. */ - virtual ReturnValue_t readWithoutLock() { return read(MutexIF::TimeoutType::WAITING, 20); } - - virtual ReturnValue_t commitWithoutLock() { return commit(MutexIF::TimeoutType::WAITING, 20); } -}; - -#endif /* FSFW_DATAPOOL_READCOMMITIF_H_ */ diff --git a/src/fsfw/datapool/ReadCommitIFAttorney.h b/src/fsfw/datapool/ReadCommitIFAttorney.h deleted file mode 100644 index cca76c972..000000000 --- a/src/fsfw/datapool/ReadCommitIFAttorney.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_ -#define FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_ - -#include -#include - -/** - * @brief This class determines which members are allowed to access protected members - * of the ReadCommitIF. - */ -class ReadCommitIFAttorney { - private: - static ReturnValue_t readWithoutLock(ReadCommitIF* readCommitIF) { - if (readCommitIF == nullptr) { - return returnvalue::FAILED; - } - return readCommitIF->readWithoutLock(); - } - - static ReturnValue_t commitWithoutLock(ReadCommitIF* readCommitIF) { - if (readCommitIF == nullptr) { - return returnvalue::FAILED; - } - return readCommitIF->commitWithoutLock(); - } - - friend class PoolDataSetBase; -}; - -#endif /* FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_ */ diff --git a/src/fsfw/datapool/SharedDataSetIF.h b/src/fsfw/datapool/SharedDataSetIF.h deleted file mode 100644 index fc3ddcd8a..000000000 --- a/src/fsfw/datapool/SharedDataSetIF.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef FRAMEWORK_DATAPOOL_SHAREDDATASETIF_H_ -#define FRAMEWORK_DATAPOOL_SHAREDDATASETIF_H_ - -#include "PoolDataSetIF.h" - -class SharedDataSetIF { - public: - virtual ~SharedDataSetIF(){}; - - private: - virtual ReturnValue_t lockDataset(MutexIF::TimeoutType timeoutType, - dur_millis_t mutexTimeout) = 0; - virtual ReturnValue_t unlockDataset() = 0; -}; - -#endif /* FRAMEWORK_DATAPOOL_SHAREDDATASETIF_H_ */ diff --git a/src/fsfw/datapool/TemplateSet.h b/src/fsfw/datapool/TemplateSet.h new file mode 100644 index 000000000..1bc9d7642 --- /dev/null +++ b/src/fsfw/datapool/TemplateSet.h @@ -0,0 +1,23 @@ +#pragma once + +#include "DataSet.h" + +template +class TemplateSet : public Dataset { + public: +#ifdef FSFW_INTROSPECTION + TemplateSet(HasDatapoolIF* owner, HkIDs id, bool allowUserCommit) + : Dataset(owner, allowUserCommit) { + setEnum(&id); + owner->getDatapoolHelper()->registerSet(this); + } + TemplateSet(uint32_t owner_id, HkIDs id) : Dataset(owner_id) { setEnum(&id); } +#else + TemplateSet(HasDatapoolIF* owner, HkIDs id, bool allowUserCommit) + : Dataset(owner, (uint8_t)id, allowUserCommit) { + owner->getDatapoolHelper()->registerSet(this); + } + TemplateSet(uint32_t owner_id, HkIDs id) : Dataset(owner_id, (uint8_t)id) {} +#endif + virtual ~TemplateSet() = default; +}; \ No newline at end of file diff --git a/src/fsfw/datapoollocal.h b/src/fsfw/datapoollocal.h deleted file mode 100644 index 26021e08f..000000000 --- a/src/fsfw/datapoollocal.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_ -#define FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_ - -/* Collected related headers */ -#include "fsfw/datapoollocal/LocalDataSet.h" -#include "fsfw/datapoollocal/LocalPoolVariable.h" -#include "fsfw/datapoollocal/LocalPoolVector.h" -#include "fsfw/datapoollocal/SharedLocalDataSet.h" -#include "fsfw/datapoollocal/StaticLocalDataSet.h" - -#endif /* FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_ */ diff --git a/src/fsfw/devicehandlers/ChildHandlerBase.cpp b/src/fsfw/devicehandlers/ChildHandlerBase.cpp index ecd4cfc8d..9bd78e725 100644 --- a/src/fsfw/devicehandlers/ChildHandlerBase.cpp +++ b/src/fsfw/devicehandlers/ChildHandlerBase.cpp @@ -12,7 +12,7 @@ ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCo parentId(parent), childHandlerFdir(setObjectId) { this->setHkDestination(hkDestination); - this->setThermalStateRequestPoolIds(thermalStatePoolId, thermalRequestPoolId); + this->setThermalStateRequestPoolIds(); //TODO } ChildHandlerBase::~ChildHandlerBase() {} diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 6be29934f..52f9a21d6 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1,11 +1,9 @@ #include "fsfw/devicehandlers/DeviceHandlerBase.h" -#include "fsfw/datapool/PoolReadGuard.h" -#include "fsfw/datapoollocal/LocalPoolVariable.h" +#include "DeviceHandlerBase.h" #include "fsfw/devicehandlers/AcceptsDeviceResponsesIF.h" #include "fsfw/devicehandlers/DeviceTmReportingWrapper.h" #include "fsfw/globalfunctions/CRC.h" -#include "fsfw/housekeeping/HousekeepingMessage.h" #include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" @@ -33,7 +31,6 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device modeHelper(this), parameterHelper(this), actionHelper(this, nullptr), - poolManager(this, nullptr), childTransitionFailure(returnvalue::OK), fdirInstance(fdirInstance), defaultFDIRUsed(fdirInstance == nullptr), @@ -59,12 +56,7 @@ void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) { this->hkDestination = hkDestination; } -void DeviceHandlerBase::setThermalStateRequestPoolIds(lp_id_t thermalStatePoolId, - lp_id_t heaterRequestPoolId, - uint32_t thermalSetId) { - thermalSet = - new DeviceHandlerThermalSet(this, thermalSetId, thermalStatePoolId, heaterRequestPoolId); -} +void DeviceHandlerBase::setThermalStateRequestPoolIds() {} DeviceHandlerBase::~DeviceHandlerBase() { if (comCookie != nullptr) { @@ -115,9 +107,6 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { break; case CommunicationAction::GET_READ: doGetRead(); - /* This will be performed after datasets have been updated by the - custom device implementation. */ - poolManager.performHkOperation(); break; default: break; @@ -223,15 +212,15 @@ ReturnValue_t DeviceHandlerBase::initialize() { fillCommandAndReplyMap(); - if (thermalSet != nullptr) { - // Set temperature target state to NON_OP. - result = thermalSet->read(); - if (result == returnvalue::OK) { - thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; - thermalSet->heaterRequest.setValid(true); - thermalSet->commit(); - } - } + // if (thermalSet != nullptr) { //TODO + // // Set temperature target state to NON_OP. + // result = thermalSet->read(); + // if (result == returnvalue::OK) { + // thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; + // thermalSet->heaterRequest.setValid(true); + // thermalSet->commit(); + // } + // } return returnvalue::OK; } @@ -291,10 +280,10 @@ void DeviceHandlerBase::readCommandQueue() { return; } - result = poolManager.handleHousekeepingMessage(&command); - if (result == returnvalue::OK) { - return; - } + // result = poolManager.handleHousekeepingMessage(&command); //TODO + // if (result == returnvalue::OK) { + // return; + // } result = handleDeviceHandlerMessage(&command); if (result == returnvalue::OK) { @@ -421,7 +410,7 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode, Submode_t s } ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap( - DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, LocalPoolDataSetBase* replyDataSet, + DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, void* replyDataSet /*TODO*/, size_t replyLen, bool periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId, Countdown* countdown) { // No need to check, as we may try to insert multiple times. @@ -436,14 +425,14 @@ ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap( ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, uint16_t maxDelayCycles, - LocalPoolDataSetBase* dataSet, size_t replyLen, + void* dataSet/*TODO*/, size_t replyLen, bool periodic, Countdown* countdown) { DeviceReplyInfo info; info.maxDelayCycles = maxDelayCycles; info.periodic = periodic; info.delayCycles = 0; info.replyLen = replyLen; - info.dataSet = dataSet; + //info.dataSet = dataSet; info.command = deviceCommandMap.end(); info.countdown = countdown; auto resultPair = deviceReplyMap.emplace(replyId, info); @@ -536,15 +525,15 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI return returnvalue::OK; } -ReturnValue_t DeviceHandlerBase::setReplyDataset(DeviceCommandId_t replyId, - LocalPoolDataSetBase* dataSet) { - auto replyIter = deviceReplyMap.find(replyId); - if (replyIter == deviceReplyMap.end()) { - return returnvalue::FAILED; - } - replyIter->second.dataSet = dataSet; - return returnvalue::OK; -} +// ReturnValue_t DeviceHandlerBase::setReplyDataset(DeviceCommandId_t replyId, +// void* dataSet/*TODO*/) { +// auto replyIter = deviceReplyMap.find(replyId); +// if (replyIter == deviceReplyMap.end()) { +// return returnvalue::FAILED; +// } +// replyIter->second.dataSet = dataSet; +// return returnvalue::OK; +// } void DeviceHandlerBase::callChildStatemachine() { if (mode == _MODE_START_UP) { @@ -580,15 +569,15 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { } Clock::getUptime(&timeoutStart); - if (mode == MODE_OFF and thermalSet != nullptr) { - ReturnValue_t result = thermalSet->read(); - if (result == returnvalue::OK) { - if (thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) { - thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; - } - thermalSet->heaterRequest.commit(PoolVariableIF::VALID); - } - } + // if (mode == MODE_OFF and thermalSet != nullptr) { //TODO + // ReturnValue_t result = thermalSet->read(); + // if (result == returnvalue::OK) { + // if (thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) { + // thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; + // } + // thermalSet->heaterRequest.commit(PoolVariableIF::VALID); + // } + // } /* TODO: This will probably be done by the LocalDataPoolManager now */ // changeHK(mode, submode, true); } @@ -1077,14 +1066,14 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode, Submode_ } if ((commandedMode == MODE_ON) && (mode == MODE_OFF) and (thermalSet != nullptr)) { - ReturnValue_t result = thermalSet->read(); - if (result == returnvalue::OK) { - if ((thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) and - (not ThermalComponentIF::isOperational(thermalSet->thermalState.value))) { - triggerEvent(ThermalComponentIF::TEMP_NOT_IN_OP_RANGE, thermalSet->thermalState.value); - return NON_OP_TEMPERATURE; - } - } + // ReturnValue_t result = thermalSet->read(); //TODO + // if (result == returnvalue::OK) { + // if ((thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) and + // (not ThermalComponentIF::isOperational(thermalSet->thermalState.value))) { + // triggerEvent(ThermalComponentIF::TEMP_NOT_IN_OP_RANGE, thermalSet->thermalState.value); + // return NON_OP_TEMPERATURE; + // } + // } } return isModeCombinationValid(commandedMode, commandedSubmode); @@ -1136,15 +1125,15 @@ void DeviceHandlerBase::handleTransitionToOnMode(Mode_t commandedMode, Submode_t // need to call it twice childTransitionDelay = getTransitionDelayMs(_MODE_START_UP, MODE_ON); triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode); - if (thermalSet != nullptr) { - ReturnValue_t result = thermalSet->read(); - if (result == returnvalue::OK) { - if (thermalSet->heaterRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { - thermalSet->heaterRequest = ThermalComponentIF::STATE_REQUEST_OPERATIONAL; - thermalSet->commit(); - } - } - } + // if (thermalSet != nullptr) { //TODO + // ReturnValue_t result = thermalSet->read(); + // if (result == returnvalue::OK) { + // if (thermalSet->heaterRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { + // thermalSet->heaterRequest = ThermalComponentIF::STATE_REQUEST_OPERATIONAL; + // thermalSet->commit(); + // } + // } + // } } else { setTransition(MODE_ON, commandedSubmode); } @@ -1460,24 +1449,12 @@ void DeviceHandlerBase::debugInterface(uint8_t positionTracker, object_id_t obje void DeviceHandlerBase::performOperationHook() {} -ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - if (thermalSet != nullptr) { - localDataPoolMap.emplace(thermalSet->thermalStatePoolId, - new PoolEntry); - localDataPoolMap.emplace(thermalSet->heaterRequestPoolId, - new PoolEntry); - } - return returnvalue::OK; -} - ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() { // In this function, the task handle should be valid if the task // was implemented correctly. We still check to be 1000 % sure :-) if (executingTask != nullptr) { pstIntervalMs = executingTask->getPeriodMs(); } - this->poolManager.initializeAfterTaskCreation(); if (setStartupImmediately) { startTransition(MODE_ON, SUBMODE_NONE); @@ -1485,21 +1462,10 @@ ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() { return returnvalue::OK; } -LocalPoolDataSetBase* DeviceHandlerBase::getDataSetHandle(sid_t sid) { - auto iter = deviceReplyMap.find(sid.ownerSetId); - if (iter != deviceReplyMap.end()) { - return iter->second.dataSet; - } else { - return nullptr; - } -} - object_id_t DeviceHandlerBase::getObjectId() const { return SystemObject::getObjectId(); } void DeviceHandlerBase::setStartUpImmediately() { this->setStartupImmediately = true; } -dur_millis_t DeviceHandlerBase::getPeriodicOperationFrequency() const { return pstIntervalMs; } - DeviceCommandId_t DeviceHandlerBase::getPendingCommand() const { if (cookieInfo.pendingCommand != deviceCommandMap.end()) { return cookieInfo.pendingCommand->first; @@ -1508,16 +1474,18 @@ DeviceCommandId_t DeviceHandlerBase::getPendingCommand() const { } void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() { - for (const auto& reply : deviceReplyMap) { - if (reply.second.dataSet != nullptr) { - PoolReadGuard pg(reply.second.dataSet); - if (pg.getReadResult() == returnvalue::OK) { - reply.second.dataSet->setValidity(false, true); - } - } - } + // for (const auto& reply : deviceReplyMap) { + // if (reply.second.dataSet != nullptr) { + // PoolReadGuard pg(reply.second.dataSet); + // if (pg.getReadResult() == returnvalue::OK) { + // reply.second.dataSet->setValidity(false, true); + // } + // } + // } } +DatapoolHelper* DeviceHandlerBase::getDatapoolHelper() { return &datapoolHelper; } + void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const char* functionName, ReturnValue_t errorCode, const char* errorPrint) { if (errorPrint == nullptr) { @@ -1558,8 +1526,6 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch } } -LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() { return &poolManager; } - MessageQueueId_t DeviceHandlerBase::getCommanderQueueId(DeviceCommandId_t replyId) const { auto commandIter = deviceCommandMap.find(replyId); if (commandIter == deviceCommandMap.end()) { diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index ca1e1cc04..de17e31bc 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -6,12 +6,11 @@ #include "DeviceCommunicationIF.h" #include "DeviceHandlerFailureIsolation.h" #include "DeviceHandlerIF.h" -#include "DeviceHandlerThermalSet.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" -#include "fsfw/datapool/PoolVariableIF.h" -#include "fsfw/datapoollocal/HasLocalDataPoolIF.h" -#include "fsfw/datapoollocal/LocalDataPoolManager.h" +// #include "fsfw/datapool/PoolVariableIF.h" +#include "fsfw/datapool/HasDatapoolIF.h" +// #include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/health/HealthHelper.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/modes/HasModesIF.h" @@ -84,7 +83,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, public HasHealthIF, public HasActionsIF, public ReceivesParameterMessagesIF, - public HasLocalDataPoolIF { + public HasDatapoolIF { friend void(Factory::setStaticFrameworkObjectIds)(); public: @@ -113,10 +112,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param thermalStatePoolId * @param thermalRequestPoolId */ - void setThermalStateRequestPoolIds( - lp_id_t thermalStatePoolId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID, - lp_id_t thermalRequestPoolId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID, - uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID); + void setThermalStateRequestPoolIds(); // TODO /** * @brief Helper function to ease device handler development. * This will instruct the transition to MODE_ON immediately @@ -201,13 +197,13 @@ class DeviceHandlerBase : public DeviceHandlerIF, virtual void setParentQueue(MessageQueueId_t parentQueueId); /** @brief Implementations required for HasActionIF */ - ActionHelper* getActionHelper() override; + ActionHelper *getActionHelper() override; ReturnValue_t executeAction(Action *action) override; Mode_t getTransitionSourceMode() const; Submode_t getTransitionSourceSubMode() const; void getMode(Mode_t *mode, Submode_t *submode) override; - ModeHelper const * getModeHelper() const override; + ModeHelper const *getModeHelper() const override; ModeDefinitionHelper getModeDefinitionHelper() override; HealthState getHealth(); ReturnValue_t setHealth(HealthState health); @@ -314,8 +310,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) = 0; /* Reply handling */ - //TODO add way to say, not enough data in buffer, try again later - //ComIF needs to decide if buffer will be appended or overwritten + // TODO add way to say, not enough data in buffer, try again later + // ComIF needs to decide if buffer will be appended or overwritten /** * @brief Scans a buffer for a valid reply. * @details @@ -431,7 +427,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * - @c returnvalue::FAILED else. */ ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, - LocalPoolDataSetBase *replyDataSet = nullptr, + void *replyDataSet = nullptr, size_t replyLen = 0, bool periodic = false, bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0, @@ -452,7 +448,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * - @c returnvalue::FAILED else. */ ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, - LocalPoolDataSetBase *dataSet = nullptr, size_t replyLen = 0, + void *dataSet = nullptr, size_t replyLen = 0, bool periodic = false, Countdown *countdown = nullptr); /** @@ -500,13 +496,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ ReturnValue_t updateReplyMapEntry(DeviceCommandId_t deviceReply, uint16_t delayCycles, uint16_t maxDelayCycles, bool periodic = false); - /** - * @brief Can be used to set the dataset corresponding to a reply ID manually. - * @details - * Used by the local data pool manager. - */ - ReturnValue_t setReplyDataset(DeviceCommandId_t replyId, LocalPoolDataSetBase *dataset); - + /** * Get the time needed to transit from modeFrom to modeTo. * @@ -525,15 +515,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ virtual uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) = 0; - /* Functions used by the local data pool manager */ - /** - * This function is used to initialize the local housekeeping pool - * entries. The default implementation leaves the pool empty. - * @param localDataPoolMap - * @return - */ - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + /** * @brief Set all datapool variables that are update periodically in * normal mode invalid @@ -543,16 +525,10 @@ class DeviceHandlerBase : public DeviceHandlerIF, * variables inside the dataset to invalid. The user can override this * method optionally. */ - virtual void setNormalDatapoolEntriesInvalid(); - /** - * @brief Get the dataset handle for a given SID. - * @details - * The default implementation will use the deviceCommandMap to look for the corresponding - * dataset handle. The user can override this function if this is not desired. - * @param sid - * @return - */ - virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; + virtual void setNormalDatapoolEntriesInvalid(); //TODO + + DatapoolHelper* getDatapoolHelper() override; + /* HasModesIF overrides */ virtual void startTransition(Mode_t mode, Submode_t submode) override; @@ -722,7 +698,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, /* Action helper for HasActionsIF */ ActionHelper actionHelper; /* Housekeeping Manager */ - LocalDataPoolManager poolManager; + DatapoolHelper datapoolHelper; /** * @brief Information about commands @@ -763,7 +739,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, //! The dataset used to access housekeeping data related to the //! respective device reply. Will point to a dataset held by //! the child handler (if one is specified) - LocalPoolDataSetBase *dataSet = nullptr; + // LocalPoolDataSetBase *dataSet = nullptr; TODO //! The command that expects this reply. DeviceCommandMap::iterator command; //! Instead of using delayCycles to specify the maximum time to wait for the device reply, it @@ -795,7 +771,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, //! and to send replies. MessageQueueIF *commandQueue = nullptr; - DeviceHandlerThermalSet *thermalSet = nullptr; + void *thermalSet = nullptr; //TODO /** * Optional Error code. Can be set in doStartUp(), doShutDown() and @@ -912,12 +888,6 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ virtual void doOnActivity(); - /** - * Required for HasLocalDataPoolIF, return a handle to the local pool manager. - * @return - */ - LocalDataPoolManager *getHkManagerHandle() override; - /** * Returns the delay cycle count of a reply. * A count != 0 indicates that the command is already executed. @@ -1009,7 +979,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * by #switches are on * - @c PowerSwitchIF::SWITCH_OFF one of the switches specified by * #switches are off - * - @c PowerSwitchIF::returnvalue::FAILED if an error occured + * - @c returnvalue::FAILED if an error occured */ ReturnValue_t getStateOfSwitches(); @@ -1284,8 +1254,6 @@ class DeviceHandlerBase : public DeviceHandlerIF, ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message); - virtual dur_millis_t getPeriodicOperationFrequency() const override; - void parseReply(const uint8_t *receivedData, size_t receivedDataLen); void handleTransitionToOnMode(Mode_t commandedMode, Submode_t commandedSubmode); diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp index a3ac9ff7b..28c8676bc 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -4,7 +4,8 @@ #include "fsfw/health/HealthTableIF.h" #include "fsfw/modes/HasModesIF.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/power/Fuse.h" +//#include "fsfw/power/Fuse.h" +#include #include "fsfw/serviceinterface/ServiceInterfaceStream.h" #include "fsfw/thermal/ThermalComponentIF.h" @@ -77,16 +78,16 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) } } break; - case Fuse::FUSE_WENT_OFF: - // Not so good, because PCDU reacted. - case Fuse::POWER_ABOVE_HIGH_LIMIT: - // Better, because software detected over-current. - setFaulty(event->getEvent()); - break; - case Fuse::POWER_BELOW_LOW_LIMIT: - // Device might got stuck during boot, retry. - handleRecovery(event->getEvent()); - break; + // case Fuse::FUSE_WENT_OFF: + // // Not so good, because PCDU reacted. + // case Fuse::POWER_ABOVE_HIGH_LIMIT: + // // Better, because software detected over-current. + // setFaulty(event->getEvent()); + // break; + // case Fuse::POWER_BELOW_LOW_LIMIT: + // // Device might got stuck during boot, retry. + // handleRecovery(event->getEvent()); + // break; //****Thermal***** case ThermalComponentIF::COMPONENT_TEMP_LOW: case ThermalComponentIF::COMPONENT_TEMP_HIGH: diff --git a/src/fsfw/devicehandlers/DeviceHandlerIF.h b/src/fsfw/devicehandlers/DeviceHandlerIF.h index ed23b887b..a3aadef86 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerIF.h +++ b/src/fsfw/devicehandlers/DeviceHandlerIF.h @@ -2,7 +2,6 @@ #define FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_ #include "../action/HasActionsIF.h" -#include "../datapoollocal/localPoolDefinitions.h" #include "../events/Event.h" #include "../introspection/ClasslessEnum.h" #include "../ipc/MessageQueueSenderIF.h" @@ -170,10 +169,10 @@ class DeviceHandlerIF { NOTHING //!< Do nothing. }; - static constexpr uint32_t DEFAULT_THERMAL_SET_ID = sid_t::INVALID_SET_ID - 1; + static constexpr uint32_t DEFAULT_THERMAL_SET_ID = 0; // TODO sid_t::INVALID_SET_ID - 1; - static constexpr lp_id_t DEFAULT_THERMAL_STATE_POOL_ID = localpool::INVALID_LPID - 2; - static constexpr lp_id_t DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID = localpool::INVALID_LPID - 1; + static constexpr int DEFAULT_THERMAL_STATE_POOL_ID = 0; // TODOlocalpool::INVALID_LPID - 2; + static constexpr int DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID = 0; // TODOlocalpool::INVALID_LPID - 1; /** * Default Destructor diff --git a/src/fsfw/devicehandlers/DeviceHandlerThermalSet.h b/src/fsfw/devicehandlers/no_DeviceHandlerThermalSet.h similarity index 100% rename from src/fsfw/devicehandlers/DeviceHandlerThermalSet.h rename to src/fsfw/devicehandlers/no_DeviceHandlerThermalSet.h diff --git a/src/fsfw/internalerror/InternalErrorDataset.h b/src/fsfw/internalerror/InternalErrorDataset.h index 022cdedbf..959ddc724 100644 --- a/src/fsfw/internalerror/InternalErrorDataset.h +++ b/src/fsfw/internalerror/InternalErrorDataset.h @@ -1,22 +1,22 @@ #ifndef FSFW_INTERNALERROR_INTERNALERRORDATASET_H_ #define FSFW_INTERNALERROR_INTERNALERRORDATASET_H_ -#include -#include +#include +#include enum errorPoolIds { TM_HITS, QUEUE_HITS, STORE_HITS }; -class InternalErrorDataset : public StaticLocalDataSet<3 * sizeof(uint32_t)> { +class InternalErrorDataset { public: static constexpr uint8_t ERROR_SET_ID = 0; - InternalErrorDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ERROR_SET_ID) {} + InternalErrorDataset(void* owner) {} - InternalErrorDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ERROR_SET_ID)) {} + InternalErrorDataset(object_id_t objectId) {} - lp_var_t tmHits = lp_var_t(sid.objectId, TM_HITS, this); - lp_var_t queueHits = lp_var_t(sid.objectId, QUEUE_HITS, this); - lp_var_t storeHits = lp_var_t(sid.objectId, STORE_HITS, this); + // lp_var_t tmHits = lp_var_t(sid.objectId, TM_HITS, this); + // lp_var_t queueHits = lp_var_t(sid.objectId, QUEUE_HITS, this); + // lp_var_t storeHits = lp_var_t(sid.objectId, STORE_HITS, this); }; #endif /* FSFW_INTERNALERROR_INTERNALERRORDATASET_H_ */ diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index fb2dc8a61..862762238 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -1,22 +1,17 @@ #include "fsfw/internalerror/InternalErrorReporter.h" -#include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/ipc/MutexFactory.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/serviceinterface/ServiceInterface.h" InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth) : SystemObject(setObjectId), - poolManager(this, commandQueue), - internalErrorSid(setObjectId, InternalErrorDataset::ERROR_SET_ID), internalErrorDataset(this) { - commandQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); mutex = MutexFactory::instance()->createMutex(); } InternalErrorReporter::~InternalErrorReporter() { MutexFactory::instance()->deleteMutex(mutex); - QueueFactory::instance()->deleteMessageQueue(commandQueue); } void InternalErrorReporter::setDiagnosticPrintout(bool enable) { @@ -24,12 +19,6 @@ void InternalErrorReporter::setDiagnosticPrintout(bool enable) { } ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { - CommandMessage message; - ReturnValue_t result = commandQueue->receiveMessage(&message); - if (result != MessageQueueIF::EMPTY) { - poolManager.handleHousekeepingMessage(&message); - } - uint32_t newQueueHits = getAndResetQueueHits(); uint32_t newTmHits = getAndResetTmHits(); uint32_t newStoreHits = getAndResetStoreHits(); @@ -53,20 +42,19 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { } #endif - { - PoolReadGuard readGuard(&internalErrorDataset); - if (readGuard.getReadResult() == returnvalue::OK) { - internalErrorDataset.queueHits.value += newQueueHits; - internalErrorDataset.storeHits.value += newStoreHits; - internalErrorDataset.tmHits.value += newTmHits; - internalErrorDataset.setValidity(true, true); - if ((newQueueHits != 0) or (newStoreHits != 0) or (newTmHits != 0)) { - internalErrorDataset.setChanged(true); - } - } - } + // { + // PoolReadGuard readGuard(&internalErrorDataset); + // if (readGuard.getReadResult() == returnvalue::OK) { + // internalErrorDataset.queueHits.value += newQueueHits; + // internalErrorDataset.storeHits.value += newStoreHits; + // internalErrorDataset.tmHits.value += newTmHits; + // internalErrorDataset.setValidity(true, true); + // if ((newQueueHits != 0) or (newStoreHits != 0) or (newTmHits != 0)) { + // internalErrorDataset.setChanged(true); + // } + // } + // } - poolManager.performHkOperation(); return returnvalue::OK; } @@ -123,47 +111,15 @@ void InternalErrorReporter::incrementStoreHits() { object_id_t InternalErrorReporter::getObjectId() const { return SystemObject::getObjectId(); } -MessageQueueId_t InternalErrorReporter::getCommandQueue() const { - return this->commandQueue->getId(); -} - -ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry); - localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry); - localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry); - poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams( - internalErrorSid, false, - static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0))); - internalErrorDataset.setValidity(true, true); - return returnvalue::OK; -} - -dur_millis_t InternalErrorReporter::getPeriodicOperationFrequency() const { - return this->executingTask->getPeriodMs(); -} - -LocalPoolDataSetBase *InternalErrorReporter::getDataSetHandle(sid_t sid) { - return &internalErrorDataset; -} - -void InternalErrorReporter::setTaskIF(PeriodicTaskIF *task) { this->executingTask = task; } +// MessageQueueId_t InternalErrorReporter::getCommandQueue() const { +// return this->commandQueue->getId(); +// } ReturnValue_t InternalErrorReporter::initialize() { - ReturnValue_t result = poolManager.initialize(commandQueue); - if (result != returnvalue::OK) { - return result; - } return SystemObject::initialize(); } -ReturnValue_t InternalErrorReporter::initializeAfterTaskCreation() { - return poolManager.initializeAfterTaskCreation(); -} - void InternalErrorReporter::setMutexTimeout(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) { this->timeoutType = timeoutType; this->timeoutMs = timeoutMs; } - -LocalDataPoolManager *InternalErrorReporter::getHkManagerHandle() { return &poolManager; } diff --git a/src/fsfw/internalerror/InternalErrorReporter.h b/src/fsfw/internalerror/InternalErrorReporter.h index ca82d1a4f..633f96f4a 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.h +++ b/src/fsfw/internalerror/InternalErrorReporter.h @@ -2,7 +2,7 @@ #define FSFW_INTERNALERROR_INTERNALERRORREPORTER_H_ #include "InternalErrorReporterIF.h" -#include "fsfw/datapoollocal/LocalDataPoolManager.h" +// #include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/internalerror/InternalErrorDataset.h" #include "fsfw/ipc/MutexIF.h" #include "fsfw/objectmanager/SystemObject.h" @@ -18,8 +18,7 @@ */ class InternalErrorReporter : public SystemObject, public ExecutableObjectIF, - public InternalErrorReporterIF, - public HasLocalDataPoolIF { + public InternalErrorReporterIF { public: InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth = 5); @@ -35,15 +34,10 @@ class InternalErrorReporter : public SystemObject, virtual ~InternalErrorReporter(); virtual object_id_t getObjectId() const override; - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - virtual dur_millis_t getPeriodicOperationFrequency() const override; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - LocalDataPoolManager* getHkManagerHandle() override; + //virtual MessageQueueId_t getCommandQueue() const override; virtual ReturnValue_t initialize() override; - virtual ReturnValue_t initializeAfterTaskCreation() override; + //virtual ReturnValue_t initializeAfterTaskCreation() override; virtual ReturnValue_t performOperation(uint8_t opCode) override; virtual void queueMessageNotSent() override; @@ -52,19 +46,13 @@ class InternalErrorReporter : public SystemObject, virtual void storeFull() override; - virtual void setTaskIF(PeriodicTaskIF* task) override; - protected: - MessageQueueIF* commandQueue; - LocalDataPoolManager poolManager; - - PeriodicTaskIF* executingTask = nullptr; + // MessageQueueIF* commandQueue; MutexIF* mutex = nullptr; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t timeoutMs = 20; - sid_t internalErrorSid; InternalErrorDataset internalErrorDataset; bool diagnosticPrintout = true; @@ -72,9 +60,6 @@ class InternalErrorReporter : public SystemObject, uint32_t queueHits = 0; uint32_t tmHits = 0; uint32_t storeHits = 0; - PoolEntry tmHitsEntry = PoolEntry(); - PoolEntry storeHitsEntry = PoolEntry(); - PoolEntry queueHitsEntry = PoolEntry(); uint32_t getAndResetQueueHits(); void incrementQueueHits(); diff --git a/src/fsfw/ipc/CommandMessageCleaner.cpp b/src/fsfw/ipc/CommandMessageCleaner.cpp index 0a43774be..eccec5191 100644 --- a/src/fsfw/ipc/CommandMessageCleaner.cpp +++ b/src/fsfw/ipc/CommandMessageCleaner.cpp @@ -3,7 +3,7 @@ #include "fsfw/devicehandlers/DeviceHandlerMessage.h" #include "fsfw/filesystem/GenericFileSystemMessage.h" #include "fsfw/health/HealthMessage.h" -#include "fsfw/housekeeping/HousekeepingMessage.h" +// #include "fsfw/housekeeping/HousekeepingMessage.h" #include "fsfw/memory/MemoryMessage.h" #include "fsfw/modes/ModeMessage.h" #include "fsfw/monitoring/MonitoringMessage.h" @@ -33,9 +33,9 @@ void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) { case messagetypes::MEMORY: MemoryMessage::clear(message); break; - case messagetypes::MONITORING: - MonitoringMessage::clear(message); - break; + // case messagetypes::MONITORING: //TODO + // MonitoringMessage::clear(message); + // break; #ifdef FSFW_ADD_TMSTORAGE case messagetypes::TM_STORE: TmStoreMessage::clear(message); @@ -44,9 +44,9 @@ void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) { case messagetypes::PARAMETER: ParameterMessage::clear(message); break; - case messagetypes::HOUSEKEEPING: - HousekeepingMessage::clear(message); - break; + // case messagetypes::HOUSEKEEPING: + // HousekeepingMessage::clear(message); + // break; case messagetypes::FILE_SYSTEM_MESSAGE: GenericFileSystemMessage::clear(message); break; diff --git a/src/fsfw/monitoring/MonitorBase.h b/src/fsfw/monitoring/MonitorBase.h index dd0792b21..941e0d537 100644 --- a/src/fsfw/monitoring/MonitorBase.h +++ b/src/fsfw/monitoring/MonitorBase.h @@ -1,7 +1,6 @@ #ifndef FSFW_MONITORING_MONITORBASE_H_ #define FSFW_MONITORING_MONITORBASE_H_ -#include "../datapoollocal/LocalPoolVariable.h" #include "LimitViolationReporter.h" #include "MonitorReporter.h" #include "MonitoringIF.h" @@ -22,7 +21,7 @@ template class MonitorBase : public MonitorReporter { public: - MonitorBase(object_id_t reporterId, uint8_t monitorId, gp_id_t globalPoolId, + MonitorBase(object_id_t reporterId, uint8_t monitorId, /*gp_id_t globalPoolId TODO*/, uint16_t confirmationLimit) : MonitorReporter(reporterId, monitorId, globalPoolId, confirmationLimit), poolVariable(globalPoolId) {} diff --git a/src/fsfw/datapoollocal/AccessLocalPoolF.h b/src/fsfw/no_datapoollocal/AccessLocalPoolF.h similarity index 100% rename from src/fsfw/datapoollocal/AccessLocalPoolF.h rename to src/fsfw/no_datapoollocal/AccessLocalPoolF.h diff --git a/src/fsfw/datapoollocal/CMakeLists.txt b/src/fsfw/no_datapoollocal/CMakeLists.txt similarity index 100% rename from src/fsfw/datapoollocal/CMakeLists.txt rename to src/fsfw/no_datapoollocal/CMakeLists.txt diff --git a/src/fsfw/datapool/DataSetIF.h b/src/fsfw/no_datapoollocal/DataSetIF.h similarity index 100% rename from src/fsfw/datapool/DataSetIF.h rename to src/fsfw/no_datapoollocal/DataSetIF.h diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/no_datapoollocal/HasLocalDataPoolIF.h similarity index 100% rename from src/fsfw/datapoollocal/HasLocalDataPoolIF.h rename to src/fsfw/no_datapoollocal/HasLocalDataPoolIF.h diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/no_datapoollocal/LocalDataPoolManager.cpp similarity index 100% rename from src/fsfw/datapoollocal/LocalDataPoolManager.cpp rename to src/fsfw/no_datapoollocal/LocalDataPoolManager.cpp diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/no_datapoollocal/LocalDataPoolManager.h similarity index 99% rename from src/fsfw/datapoollocal/LocalDataPoolManager.h rename to src/fsfw/no_datapoollocal/LocalDataPoolManager.h index 8f369ea06..7064e6e96 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/no_datapoollocal/LocalDataPoolManager.h @@ -6,8 +6,8 @@ #include "AccessLocalPoolF.h" #include "ProvidesDataPoolSubscriptionIF.h" -#include "fsfw/datapool/DataSetIF.h" -#include "fsfw/datapool/PoolEntry.h" +#include "fsfw/datapoollocal/DataSetIF.h" +#include "fsfw/datapoollocal/PoolEntry.h" #include "fsfw/housekeeping/AcceptsHkPacketsIF.h" #include "fsfw/housekeeping/HousekeepingMessage.h" #include "fsfw/housekeeping/HousekeepingPacketDownlink.h" diff --git a/src/fsfw/datapoollocal/LocalDataSet.cpp b/src/fsfw/no_datapoollocal/LocalDataSet.cpp similarity index 100% rename from src/fsfw/datapoollocal/LocalDataSet.cpp rename to src/fsfw/no_datapoollocal/LocalDataSet.cpp diff --git a/src/fsfw/datapoollocal/LocalDataSet.h b/src/fsfw/no_datapoollocal/LocalDataSet.h similarity index 100% rename from src/fsfw/datapoollocal/LocalDataSet.h rename to src/fsfw/no_datapoollocal/LocalDataSet.h diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp b/src/fsfw/no_datapoollocal/LocalPoolDataSetBase.cpp similarity index 100% rename from src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp rename to src/fsfw/no_datapoollocal/LocalPoolDataSetBase.cpp diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.h b/src/fsfw/no_datapoollocal/LocalPoolDataSetBase.h similarity index 100% rename from src/fsfw/datapoollocal/LocalPoolDataSetBase.h rename to src/fsfw/no_datapoollocal/LocalPoolDataSetBase.h diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/no_datapoollocal/LocalPoolObjectBase.cpp similarity index 100% rename from src/fsfw/datapoollocal/LocalPoolObjectBase.cpp rename to src/fsfw/no_datapoollocal/LocalPoolObjectBase.cpp diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.h b/src/fsfw/no_datapoollocal/LocalPoolObjectBase.h similarity index 100% rename from src/fsfw/datapoollocal/LocalPoolObjectBase.h rename to src/fsfw/no_datapoollocal/LocalPoolObjectBase.h diff --git a/src/fsfw/datapoollocal/LocalPoolVariable.h b/src/fsfw/no_datapoollocal/LocalPoolVariable.h similarity index 100% rename from src/fsfw/datapoollocal/LocalPoolVariable.h rename to src/fsfw/no_datapoollocal/LocalPoolVariable.h diff --git a/src/fsfw/datapoollocal/LocalPoolVariable.tpp b/src/fsfw/no_datapoollocal/LocalPoolVariable.tpp similarity index 100% rename from src/fsfw/datapoollocal/LocalPoolVariable.tpp rename to src/fsfw/no_datapoollocal/LocalPoolVariable.tpp diff --git a/src/fsfw/datapoollocal/LocalPoolVector.h b/src/fsfw/no_datapoollocal/LocalPoolVector.h similarity index 100% rename from src/fsfw/datapoollocal/LocalPoolVector.h rename to src/fsfw/no_datapoollocal/LocalPoolVector.h diff --git a/src/fsfw/datapoollocal/LocalPoolVector.tpp b/src/fsfw/no_datapoollocal/LocalPoolVector.tpp similarity index 100% rename from src/fsfw/datapoollocal/LocalPoolVector.tpp rename to src/fsfw/no_datapoollocal/LocalPoolVector.tpp diff --git a/src/fsfw/datapoollocal/MarkChangedIF.h b/src/fsfw/no_datapoollocal/MarkChangedIF.h similarity index 100% rename from src/fsfw/datapoollocal/MarkChangedIF.h rename to src/fsfw/no_datapoollocal/MarkChangedIF.h diff --git a/src/fsfw/datapool/PoolEntryIF.h b/src/fsfw/no_datapoollocal/PoolEntryIF.h similarity index 100% rename from src/fsfw/datapool/PoolEntryIF.h rename to src/fsfw/no_datapoollocal/PoolEntryIF.h diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/no_datapoollocal/ProvidesDataPoolSubscriptionIF.h similarity index 100% rename from src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h rename to src/fsfw/no_datapoollocal/ProvidesDataPoolSubscriptionIF.h diff --git a/src/fsfw/datapoollocal/SharedLocalDataSet.cpp b/src/fsfw/no_datapoollocal/SharedLocalDataSet.cpp similarity index 100% rename from src/fsfw/datapoollocal/SharedLocalDataSet.cpp rename to src/fsfw/no_datapoollocal/SharedLocalDataSet.cpp diff --git a/src/fsfw/datapoollocal/SharedLocalDataSet.h b/src/fsfw/no_datapoollocal/SharedLocalDataSet.h similarity index 100% rename from src/fsfw/datapoollocal/SharedLocalDataSet.h rename to src/fsfw/no_datapoollocal/SharedLocalDataSet.h diff --git a/src/fsfw/datapoollocal/StaticLocalDataSet.h b/src/fsfw/no_datapoollocal/StaticLocalDataSet.h similarity index 100% rename from src/fsfw/datapoollocal/StaticLocalDataSet.h rename to src/fsfw/no_datapoollocal/StaticLocalDataSet.h diff --git a/src/fsfw/datapoollocal/internal/CMakeLists.txt b/src/fsfw/no_datapoollocal/internal/CMakeLists.txt similarity index 100% rename from src/fsfw/datapoollocal/internal/CMakeLists.txt rename to src/fsfw/no_datapoollocal/internal/CMakeLists.txt diff --git a/src/fsfw/datapoollocal/internal/HasLocalDpIFManagerAttorney.cpp b/src/fsfw/no_datapoollocal/internal/HasLocalDpIFManagerAttorney.cpp similarity index 100% rename from src/fsfw/datapoollocal/internal/HasLocalDpIFManagerAttorney.cpp rename to src/fsfw/no_datapoollocal/internal/HasLocalDpIFManagerAttorney.cpp diff --git a/src/fsfw/datapoollocal/internal/HasLocalDpIFManagerAttorney.h b/src/fsfw/no_datapoollocal/internal/HasLocalDpIFManagerAttorney.h similarity index 100% rename from src/fsfw/datapoollocal/internal/HasLocalDpIFManagerAttorney.h rename to src/fsfw/no_datapoollocal/internal/HasLocalDpIFManagerAttorney.h diff --git a/src/fsfw/datapoollocal/internal/HasLocalDpIFUserAttorney.cpp b/src/fsfw/no_datapoollocal/internal/HasLocalDpIFUserAttorney.cpp similarity index 100% rename from src/fsfw/datapoollocal/internal/HasLocalDpIFUserAttorney.cpp rename to src/fsfw/no_datapoollocal/internal/HasLocalDpIFUserAttorney.cpp diff --git a/src/fsfw/datapoollocal/internal/HasLocalDpIFUserAttorney.h b/src/fsfw/no_datapoollocal/internal/HasLocalDpIFUserAttorney.h similarity index 100% rename from src/fsfw/datapoollocal/internal/HasLocalDpIFUserAttorney.h rename to src/fsfw/no_datapoollocal/internal/HasLocalDpIFUserAttorney.h diff --git a/src/fsfw/datapoollocal/internal/LocalDpManagerAttorney.h b/src/fsfw/no_datapoollocal/internal/LocalDpManagerAttorney.h similarity index 100% rename from src/fsfw/datapoollocal/internal/LocalDpManagerAttorney.h rename to src/fsfw/no_datapoollocal/internal/LocalDpManagerAttorney.h diff --git a/src/fsfw/datapoollocal/internal/LocalPoolDataSetAttorney.h b/src/fsfw/no_datapoollocal/internal/LocalPoolDataSetAttorney.h similarity index 100% rename from src/fsfw/datapoollocal/internal/LocalPoolDataSetAttorney.h rename to src/fsfw/no_datapoollocal/internal/LocalPoolDataSetAttorney.h diff --git a/src/fsfw/datapoollocal/localPoolDefinitions.h b/src/fsfw/no_datapoollocal/localPoolDefinitions.h similarity index 98% rename from src/fsfw/datapoollocal/localPoolDefinitions.h rename to src/fsfw/no_datapoollocal/localPoolDefinitions.h index 07bfbfa83..7039d53cd 100644 --- a/src/fsfw/datapoollocal/localPoolDefinitions.h +++ b/src/fsfw/no_datapoollocal/localPoolDefinitions.h @@ -4,7 +4,7 @@ #include #include -#include "../datapool/PoolEntryIF.h" +#include "PoolEntryIF.h" #include "../objectmanager/SystemObjectIF.h" #include "../objectmanager/frameworkObjects.h" diff --git a/src/fsfw/power/Fuse.cpp b/src/fsfw/power/Fuse.cpp index 73b294521..03154673b 100644 --- a/src/fsfw/power/Fuse.cpp +++ b/src/fsfw/power/Fuse.cpp @@ -8,7 +8,7 @@ object_id_t Fuse::powerSwitchId = 0; -Fuse::Fuse(object_id_t fuseObjectId, uint8_t fuseId, sid_t variableSet, VariableIds ids, +Fuse::Fuse(object_id_t fuseObjectId, uint8_t fuseId, sid_t variableSet, float maxCurrent, uint16_t confirmationCount) : SystemObject(fuseObjectId), oldFuseState(0), @@ -16,10 +16,6 @@ Fuse::Fuse(object_id_t fuseObjectId, uint8_t fuseId, sid_t variableSet, Variable currentLimit(fuseObjectId, 1, ids.pidCurrent, confirmationCount, maxCurrent, FUSE_CURRENT_HIGH), powerMonitor(fuseObjectId, 2, ids.poolIdPower, confirmationCount), - set(variableSet), - voltage(ids.pidVoltage, &set), - current(ids.pidCurrent, &set), - state(ids.pidState, &set), power(ids.poolIdPower, &set, PoolVariableIF::VAR_READ_WRITE), parameterHelper(this), healthHelper(this, fuseObjectId) { @@ -60,11 +56,11 @@ void Fuse::calculatePowerLimits(float* low, float* high) { } ReturnValue_t Fuse::check() { - set.read(); + //set.read(); if (!healthHelper.healthTable->isHealthy(getObjectId())) { setAllMonitorsToUnchecked(); - set.setValidity(false, true); - return set.commit(); + //set.setValidity(false, true); + return returnvalues::OK; //TODO set.commit(); } ReturnValue_t result = returnvalue::OK; checkFuseState(); @@ -83,7 +79,7 @@ ReturnValue_t Fuse::check() { reportEvents(POWER_ABOVE_HIGH_LIMIT); } } - set.commit(); + //set.commit(); return result; } @@ -194,9 +190,9 @@ float Fuse::getPower() { } void Fuse::setDataPoolEntriesInvalid() { - set.read(); - set.setValidity(false, true); - set.commit(); + // set.read(); + // set.setValidity(false, true); + // set.commit(); } ReturnValue_t Fuse::getParameter(uint8_t domainId, uint8_t uniqueId, diff --git a/src/fsfw/power/Fuse.h b/src/fsfw/power/Fuse.h index c1b35899c..192e3aff5 100644 --- a/src/fsfw/power/Fuse.h +++ b/src/fsfw/power/Fuse.h @@ -3,7 +3,6 @@ #include -#include "../datapoollocal/StaticLocalDataSet.h" #include "../devicehandlers/HealthDevice.h" #include "../monitoring/AbsLimitMonitor.h" #include "../parameters/ParameterHelper.h" @@ -25,12 +24,6 @@ class Fuse : public SystemObject, 0.005 * 28.5; //!< This is the upper limit of residual power lost by fuses and switches. //!< Worst case is Fuse and one of two switches on. See PCDU ICD 1.9 p29 bottom public: - struct VariableIds { - gp_id_t pidVoltage; - gp_id_t pidCurrent; - gp_id_t pidState; - gp_id_t poolIdPower; - }; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::POWER_SWITCH_IF; //! PSS detected that current on a fuse is totally out of bounds. @@ -43,7 +36,7 @@ class Fuse : public SystemObject, static const Event POWER_BELOW_LOW_LIMIT = MAKE_EVENT(5, severity::LOW); typedef std::list DeviceList; - Fuse(object_id_t fuseObjectId, uint8_t fuseId, sid_t variableSet, VariableIds ids, + Fuse(object_id_t fuseObjectId, uint8_t fuseId, sid_t variableSet, float maxCurrent, uint16_t confirmationCount = 2); virtual ~Fuse(); void addDevice(PowerComponentIF *set); @@ -83,13 +76,9 @@ class Fuse : public SystemObject, void sendTransitionEvent(float currentValue, ReturnValue_t state) {} }; PowerMonitor powerMonitor; - StaticLocalDataSet<3> set; - lp_var_t voltage; - lp_var_t current; - lp_var_t state; +// TODO datapool - lp_var_t power; MessageQueueIF *commandQueue = nullptr; ParameterHelper parameterHelper; HealthHelper healthHelper; diff --git a/src/fsfw/power/PowerSensor.cpp b/src/fsfw/power/PowerSensor.cpp index 69c9e2722..3829668c9 100644 --- a/src/fsfw/power/PowerSensor.cpp +++ b/src/fsfw/power/PowerSensor.cpp @@ -7,10 +7,10 @@ PowerSensor::PowerSensor(object_id_t objectId, sid_t setId, VariableIds ids, Def : SystemObject(objectId), parameterHelper(this), healthHelper(this, objectId), - powerSensorSet(setId), - current(ids.pidCurrent, &powerSensorSet), - voltage(ids.pidVoltage, &powerSensorSet), - power(ids.poolIdPower, &powerSensorSet, PoolVariableIF::VAR_WRITE), + // powerSensorSet(setId), + // current(ids.pidCurrent, &powerSensorSet), + // voltage(ids.pidVoltage, &powerSensorSet), + // power(ids.poolIdPower, &powerSensorSet, PoolVariableIF::VAR_WRITE), currentLimit(objectId, MODULE_ID_CURRENT, ids.pidCurrent, confirmationCount, limits.currentMin, limits.currentMax, events.currentLow, events.currentHigh), voltageLimit(objectId, MODULE_ID_VOLTAGE, ids.pidVoltage, confirmationCount, @@ -21,7 +21,7 @@ PowerSensor::PowerSensor(object_id_t objectId, sid_t setId, VariableIds ids, Def PowerSensor::~PowerSensor() { QueueFactory::instance()->deleteMessageQueue(commandQueue); } ReturnValue_t PowerSensor::calculatePower() { - powerSensorSet.read(); + //powerSensorSet.read(); ReturnValue_t result1 = returnvalue::FAILED; ReturnValue_t result2 = returnvalue::FAILED; if (healthHelper.healthTable->isHealthy(getObjectId()) && voltage.isValid() && @@ -35,12 +35,12 @@ ReturnValue_t PowerSensor::calculatePower() { } if (result1 != returnvalue::OK || result2 != returnvalue::OK) { result1 = MonitoringIF::INVALID; - power.setValid(PoolVariableIF::INVALID); + // power.setValid(PoolVariableIF::INVALID); } else { - power.setValid(PoolVariableIF::VALID); - power.value = current.value * voltage.value; + // power.setValid(PoolVariableIF::VALID); + // power.value = current.value * voltage.value; } - powerSensorSet.commit(); + // powerSensorSet.commit(); return result1; } @@ -91,17 +91,17 @@ void PowerSensor::checkCommandQueue() { } void PowerSensor::setDataPoolEntriesInvalid() { - powerSensorSet.read(); - powerSensorSet.setValidity(false, true); - powerSensorSet.commit(); + // powerSensorSet.read(); + // powerSensorSet.setValidity(false, true); + // powerSensorSet.commit(); } float PowerSensor::getPower() { - if (power.isValid()) { - return power.value; - } else { + // if (power.isValid()) { + // return power.value; + // } else { return 0.0; - } + // } } ReturnValue_t PowerSensor::setHealth(HealthState health) { diff --git a/src/fsfw/power/PowerSensor.h b/src/fsfw/power/PowerSensor.h index 8e16d0b68..3fcc9f29b 100644 --- a/src/fsfw/power/PowerSensor.h +++ b/src/fsfw/power/PowerSensor.h @@ -1,7 +1,6 @@ #ifndef FSFW_POWER_POWERSENSOR_H_ #define FSFW_POWER_POWERSENSOR_H_ -#include "fsfw/datapoollocal/StaticLocalDataSet.h" #include "fsfw/devicehandlers/HealthDevice.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/monitoring/LimitMonitor.h" @@ -17,11 +16,11 @@ class PowerSensor : public SystemObject, public ReceivesParameterMessagesIF, pub friend class PowerController; public: - struct VariableIds { - gp_id_t pidCurrent; - gp_id_t pidVoltage; - gp_id_t poolIdPower; - }; + // struct VariableIds { + // gp_id_t pidCurrent; + // gp_id_t pidVoltage; + // gp_id_t poolIdPower; + // }; struct DefaultLimits { float currentMin; float currentMax; @@ -34,7 +33,7 @@ class PowerSensor : public SystemObject, public ReceivesParameterMessagesIF, pub Event voltageLow; Event voltageHigh; }; - PowerSensor(object_id_t objectId, sid_t sid, VariableIds setIds, DefaultLimits limits, + PowerSensor(object_id_t objectId, sid_t sid, DefaultLimits limits, SensorEvents events, uint16_t confirmationCount = 0); virtual ~PowerSensor(); ReturnValue_t calculatePower(); @@ -54,15 +53,15 @@ class PowerSensor : public SystemObject, public ReceivesParameterMessagesIF, pub ParameterHelper parameterHelper; HealthHelper healthHelper; // GlobDataSet set; - StaticLocalDataSet<3> powerSensorSet; - // Variables in - lp_var_t current; - lp_var_t voltage; - // PIDReader current; - // PIDReader voltage; - // Variables out - lp_var_t power; - // gp_float_t power; + // StaticLocalDataSet<3> powerSensorSet; + // // Variables in + // lp_var_t current; + // lp_var_t voltage; + // // PIDReader current; + // // PIDReader voltage; + // // Variables out + // lp_var_t power; + // // gp_float_t power; static const uint8_t MODULE_ID_CURRENT = 1; static const uint8_t MODULE_ID_VOLTAGE = 2; diff --git a/src/fsfw/pus/CMakeLists.txt b/src/fsfw/pus/CMakeLists.txt index 23b13e2a3..a56be67d9 100644 --- a/src/fsfw/pus/CMakeLists.txt +++ b/src/fsfw/pus/CMakeLists.txt @@ -2,7 +2,7 @@ target_sources( ${LIB_FSFW_NAME} PRIVATE Service1TelecommandVerification.cpp Service2DeviceAccess.cpp - Service3Housekeeping.cpp + #Service3Housekeeping.cpp Service5EventReporting.cpp #Service8FunctionManagement.cpp Service9TimeManagement.cpp diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h deleted file mode 100644 index 325b07e9d..000000000 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef FSFW_RETURNVALUES_HASRETURNVALUES_IF_H_ -#define FSFW_RETURNVALUES_HASRETURNVALUES_IF_H_ - -#warning "This header is deprecated, please include returnvalue.h" - -#include "returnvalue.h" - -#endif /* FSFW_RETURNVALUES_HASRETURNVALUES_IF_H_ */