2022-06-07 09:54:52 +02:00
|
|
|
/*
|
|
|
|
* GlobalConfigHandler.h
|
|
|
|
*
|
|
|
|
* Created on: May 3, 2022
|
2022-07-05 12:57:50 +02:00
|
|
|
* Author: Jona Petri (IRS)
|
2022-06-07 09:54:52 +02:00
|
|
|
*/
|
|
|
|
|
2022-07-05 12:57:50 +02:00
|
|
|
#ifndef MISSION_UTILITY_GLOBALCONFIGHANDLER_H_
|
|
|
|
#define MISSION_UTILITY_GLOBALCONFIGHANDLER_H_
|
2022-06-07 09:54:52 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
#include <fsfw/action/ActionHelper.h>
|
|
|
|
#include <fsfw/action/HasActionsIF.h>
|
2022-06-07 09:54:52 +02:00
|
|
|
#include <fsfw/objectmanager/SystemObject.h>
|
2022-07-14 17:35:49 +02:00
|
|
|
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
2022-06-07 09:54:52 +02:00
|
|
|
#include <fsfw/storagemanager/StorageManagerIF.h>
|
|
|
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
2022-07-14 17:35:49 +02:00
|
|
|
|
2022-06-07 09:54:52 +02:00
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
2022-07-14 17:35:49 +02:00
|
|
|
|
|
|
|
#include "GlobalConfigFileDefinitions.h"
|
2022-06-07 09:54:52 +02:00
|
|
|
#include "OBSWConfig.h"
|
2022-06-08 11:08:19 +02:00
|
|
|
#include "fsfw/parameters/HasParametersIF.h"
|
|
|
|
#include "fsfw/parameters/ParameterHelper.h"
|
2022-07-14 17:35:49 +02:00
|
|
|
#include "mission/memory/NVMParameterBase.h"
|
2022-06-07 09:54:52 +02:00
|
|
|
|
|
|
|
static std::map<ParamIds, std::string> PARAM_KEY_MAP = {
|
2022-07-14 17:35:49 +02:00
|
|
|
{PARAM0, "Parameter0"},
|
|
|
|
{PARAM1, "Parameter1"},
|
2022-06-07 09:54:52 +02:00
|
|
|
};
|
|
|
|
/*
|
|
|
|
* Idea: This class is intended to be used as a subclass for the Core Controller.
|
2022-07-14 17:35:49 +02:00
|
|
|
* Its tasks is managing a configuration JSON file containing config values important for various
|
|
|
|
* object. If some function to read or write a config value is called, a mutex should be used so
|
|
|
|
* only one call is done at a time.
|
2022-06-07 09:54:52 +02:00
|
|
|
*/
|
2022-07-14 17:35:49 +02:00
|
|
|
class GlobalConfigHandler : public SystemObject,
|
|
|
|
public ExecutableObjectIF,
|
|
|
|
public NVMParameterBase {
|
|
|
|
public:
|
|
|
|
GlobalConfigHandler(object_id_t objectId, std::string configFilePath);
|
|
|
|
virtual ~GlobalConfigHandler();
|
2022-07-05 12:57:50 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CONFIGHANDLER;
|
2022-07-05 12:57:50 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
static constexpr Event SET_CONFIGFILEVALUE_FAILED = MAKE_EVENT(1, severity::MEDIUM);
|
|
|
|
static constexpr Event GET_CONFIGFILEVALUE_FAILED = MAKE_EVENT(2, severity::MEDIUM);
|
|
|
|
static constexpr Event INSERT_CONFIGFILEVALUE_FAILED = MAKE_EVENT(3, severity::MEDIUM);
|
|
|
|
static constexpr Event WRITE_CONFIGFILE_FAILED = MAKE_EVENT(4, severity::MEDIUM);
|
|
|
|
static constexpr Event READ_CONFIGFILE_FAILED = MAKE_EVENT(5, severity::MEDIUM);
|
2022-07-05 14:56:31 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
ReturnValue_t performOperation(uint8_t operationCode);
|
2022-06-08 09:18:17 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
ReturnValue_t initialize();
|
2022-06-08 11:08:19 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
template <typename T>
|
|
|
|
ReturnValue_t setConfigFileValue(ParamIds paramID, T data);
|
|
|
|
template <typename T>
|
|
|
|
ReturnValue_t getConfigFileValue(ParamIds paramID, T& data);
|
2022-07-05 12:57:50 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
ReturnValue_t ResetConfigFile();
|
|
|
|
ReturnValue_t WriteConfigFile();
|
|
|
|
std::string getConfigFileName();
|
2022-06-07 09:54:52 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
private:
|
2022-09-29 13:20:05 +02:00
|
|
|
static MutexIF* CONFIG_LOCK;
|
2022-07-05 10:02:43 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
ReturnValue_t lockConfigFile();
|
|
|
|
ReturnValue_t unlockConfigFile();
|
|
|
|
ReturnValue_t resetConfigFileValues();
|
2022-06-07 09:54:52 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
ReturnValue_t setConfigFileName(std::string configFileName);
|
2022-07-05 10:02:43 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
ReturnValue_t ReadConfigFile();
|
2022-07-05 10:02:43 +02:00
|
|
|
|
2022-07-14 17:35:49 +02:00
|
|
|
MessageQueueIF* commandQueue;
|
2022-06-07 09:54:52 +02:00
|
|
|
};
|
|
|
|
|
2022-07-05 12:57:50 +02:00
|
|
|
#endif /* MISSION_UTILITY_GLOBALCONFIGHANDLER_H_ */
|