fsfw/archive/datapoolglob/GlobalDataSet.h

99 lines
2.9 KiB
C
Raw Normal View History

2020-07-09 00:59:10 +02:00
#ifndef FRAMEWORK_DATAPOOLGLOB_DATASET_H_
#define FRAMEWORK_DATAPOOLGLOB_DATASET_H_
2020-05-17 01:17:11 +02:00
#include "../datapool/PoolDataSetBase.h"
2020-05-17 01:17:11 +02:00
/**
* @brief The DataSet class manages a set of locally checked out variables
* for the global data pool.
* @details
2020-05-17 23:41:28 +02:00
* This class uses the read-commit() semantic provided by the DataSetBase class.
* It extends the base class by using the global data pool,
* having a valid state and implementing lock und unlock calls for the global
* datapool.
2020-05-17 01:17:11 +02:00
*
2020-05-17 23:41:28 +02:00
* For more information on how this class works, see the DataSetBase
* documentation.
2020-05-17 01:17:11 +02:00
* @author Bastian Baetz
* @ingroup data_pool
*/
2020-07-14 15:45:03 +02:00
class GlobDataSet: public PoolDataSetBase {
2020-05-17 01:17:11 +02:00
public:
/**
2020-05-17 23:41:28 +02:00
* @brief Creates an empty GlobDataSet. Use registerVariable or
* supply a pointer to this dataset to PoolVariable
* initializations to register pool variables.
2020-05-17 01:17:11 +02:00
*/
GlobDataSet();
/**
* @brief The destructor automatically manages writing the valid
* information of variables.
* @details
* In case the data set was read out, but not committed(indicated by state),
* the destructor parses all variables that are still registered to the set.
* For each, the valid flag in the data pool is set to "invalid".
*/
~GlobDataSet();
2020-05-17 23:41:28 +02:00
2020-05-17 01:17:11 +02:00
/**
* Variant of method above which sets validity of all elements of the set.
* @param valid Validity information from PoolVariableIF.
* @return - @c RETURN_OK if all variables were read successfully.
* - @c COMMITING_WITHOUT_READING if set was not read yet and
* contains non write-only variables
*/
2020-06-05 20:33:57 +02:00
ReturnValue_t commit(bool valid, uint32_t lockTimeout = MutexIF::BLOCKING);
ReturnValue_t commit(uint32_t lockTimeout = MutexIF::BLOCKING) override;
2020-05-17 01:17:11 +02:00
/**
* Set all entries
* @param valid
*/
void setSetValid(bool valid);
2020-07-14 15:45:03 +02:00
bool isValid() const override;
2020-05-17 01:17:11 +02:00
/**
* Set the valid information of all variables contained in the set which
* are not read-only
*
* @param valid Validity information from PoolVariableIF.
*/
void setEntriesValid(bool valid);
//!< This definition sets the maximum number of variables to
//! register in one DataSet.
static const uint8_t DATA_SET_MAX_SIZE = 63;
2020-05-17 01:17:11 +02:00
private:
/**
* If the valid state of a dataset is always relevant to the whole
* data set we can use this flag.
*/
bool valid = false;
2020-05-17 23:41:28 +02:00
2020-05-17 01:17:11 +02:00
/**
* @brief This is a small helper function to facilitate locking
2020-05-17 23:41:28 +02:00
* the global data pool.
2020-05-17 01:17:11 +02:00
* @details
* It makes use of the lockDataPool method offered by the DataPool class.
*/
2020-06-05 20:33:57 +02:00
ReturnValue_t lockDataPool(uint32_t timeoutMs) override;
2020-05-17 01:17:11 +02:00
/**
* @brief This is a small helper function to facilitate
2020-05-17 23:41:28 +02:00
* unlocking the global data pool
2020-05-17 01:17:11 +02:00
* @details
* It makes use of the freeDataPoolLock method offered by the DataPool class.
*/
ReturnValue_t unlockDataPool() override;
void handleAlreadyReadDatasetCommit();
ReturnValue_t handleUnreadDatasetCommit();
PoolVariableIF* registeredVariables[DATA_SET_MAX_SIZE];
2020-05-17 01:17:11 +02:00
};
2020-07-09 00:59:10 +02:00
#endif /* FRAMEWORK_DATAPOOLGLOB_DATASET_H_ */