2022-06-07 09:54:52 +02:00
|
|
|
/*
|
|
|
|
* 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"
|
2022-06-08 11:08:19 +02:00
|
|
|
#include "fsfw/parameters/HasParametersIF.h"
|
|
|
|
#include "fsfw/parameters/ParameterHelper.h"
|
|
|
|
#include <fsfw/action/ActionHelper.h>
|
|
|
|
#include <fsfw/action/HasActionsIF.h>
|
2022-06-07 09:54:52 +02:00
|
|
|
|
|
|
|
static constexpr double PARAM0_DEFAULT = 5.0;
|
2022-06-08 11:08:19 +02:00
|
|
|
static constexpr int PARAM1_DEFAULT = 905;
|
2022-06-07 09:54:52 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2022-06-08 11:08:19 +02:00
|
|
|
class GlobalConfigHandler: public SystemObject,
|
|
|
|
public ExecutableObjectIF,
|
|
|
|
public NVMParameterBase,
|
|
|
|
public ReceivesParameterMessagesIF,
|
|
|
|
public HasActionsIF{
|
2022-06-07 09:54:52 +02:00
|
|
|
public:
|
|
|
|
GlobalConfigHandler(object_id_t objectId, std::string configFilePath);
|
|
|
|
virtual ~GlobalConfigHandler();
|
2022-06-08 09:18:17 +02:00
|
|
|
|
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CONFIGHANDLER;
|
|
|
|
|
|
|
|
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-06-07 09:54:52 +02:00
|
|
|
ReturnValue_t performOperation(uint8_t operationCode);
|
2022-06-08 11:08:19 +02:00
|
|
|
void readCommandQueue();
|
2022-06-07 09:54:52 +02:00
|
|
|
ReturnValue_t initialize();
|
|
|
|
|
|
|
|
ReturnValue_t lockConfigFile();
|
|
|
|
ReturnValue_t unlockConfigFile();
|
2022-06-08 08:27:45 +02:00
|
|
|
template <typename T> ReturnValue_t setConfigFileValue(std::string key, T data);
|
|
|
|
template <typename T> ReturnValue_t getConfigFileValue(std::string key, T& data);
|
|
|
|
template <typename T> ReturnValue_t insertConfigFileValue(std::string key, T data);
|
2022-06-07 09:54:52 +02:00
|
|
|
ReturnValue_t resetConfigFileValues();
|
|
|
|
ReturnValue_t WriteConfigFile();
|
|
|
|
ReturnValue_t ReadConfigFile();
|
|
|
|
ReturnValue_t ResetConfigFile();
|
|
|
|
|
2022-06-08 09:18:17 +02:00
|
|
|
ReturnValue_t setConfigFileName(std::string configFileName);
|
|
|
|
std::string getConfigFileName();
|
|
|
|
|
2022-06-08 11:08:19 +02:00
|
|
|
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
|
|
|
ParameterWrapper* parameterWrapper,
|
|
|
|
const ParameterWrapper* newValues,
|
|
|
|
uint16_t startAtIndex);
|
|
|
|
|
|
|
|
ReturnValue_t handleDoubleParamUpdate(std::string key,
|
|
|
|
ParameterWrapper* parameterWrapper,
|
|
|
|
const ParameterWrapper* newValues);
|
|
|
|
ReturnValue_t handleIntParamUpdate(std::string key,
|
|
|
|
ParameterWrapper* parameterWrapper,
|
|
|
|
const ParameterWrapper* newValues) ;
|
|
|
|
MessageQueueId_t getCommandQueue() const override;
|
|
|
|
ReturnValue_t executeAction(ActionId_t actionId,
|
|
|
|
MessageQueueId_t commandedBy, const uint8_t* data,
|
|
|
|
size_t size) override;
|
2022-06-07 09:54:52 +02:00
|
|
|
private:
|
|
|
|
static MutexIF* configLock ;
|
|
|
|
|
2022-06-08 11:08:19 +02:00
|
|
|
ParameterHelper parameterHelper;
|
|
|
|
MessageQueueIF* commandQueue;
|
|
|
|
ActionHelper actionHelper;
|
2022-06-07 09:54:52 +02:00
|
|
|
|
2022-06-08 11:08:19 +02:00
|
|
|
double doubleDummy = 0.0;
|
|
|
|
int intDummy = 0;
|
2022-06-07 09:54:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* BSP_LINUX_GLOBALCONFIGHANDLER_H_ */
|