eive-obsw/bsp_hosted/GlobalConfigHandler.h

64 lines
1.8 KiB
C
Raw Normal View History

/*
* GlobalConfigHandler.h
*
* Created on: May 3, 2022
* Author: metobs
*/
#ifndef BSP_LINUX_GLOBALCONFIGHANDLER_H_
#define BSP_LINUX_GLOBALCONFIGHANDLER_H_
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/storagemanager/StorageManagerIF.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <sstream>
#include <string>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include "mission/memory/NVMParameterBase.h"
#include "OBSWConfig.h"
static constexpr double PARAM0_DEFAULT = 5.0;
static constexpr double PARAM1_DEFAULT = 905.0;
enum ParamIds : uint8_t {
PARAM0 = 0,
PARAM1 = 1,
};
static std::map<ParamIds, std::string> PARAM_KEY_MAP = {
{PARAM0, "Parameter0"},
{PARAM1, "Parameter1"},
};
/*
* Idea: This class is intended to be used as a subclass for the Core Controller.
* 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.
*/
class GlobalConfigHandler: public SystemObject, public ExecutableObjectIF, public NVMParameterBase{
public:
GlobalConfigHandler(object_id_t objectId, std::string configFilePath);
virtual ~GlobalConfigHandler();
ReturnValue_t performOperation(uint8_t operationCode);
ReturnValue_t initialize();
ReturnValue_t lockConfigFile();
ReturnValue_t unlockConfigFile();
ReturnValue_t setConfigFileValue();
ReturnValue_t getConfigFileValue();
ReturnValue_t insertConfigFileValue();
ReturnValue_t resetConfigFileValues();
ReturnValue_t WriteConfigFile();
ReturnValue_t ReadConfigFile();
ReturnValue_t ResetConfigFile();
private:
std::string configFilePath;
static MutexIF* configLock ;
};
#endif /* BSP_LINUX_GLOBALCONFIGHANDLER_H_ */