Added events for failure of config file handler functions
This commit is contained in:
parent
0fb620b290
commit
7cd048b03f
@ -58,9 +58,6 @@ ReturnValue_t GlobalConfigHandler::unlockConfigFile(){
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TBD for set/get/insert: Mutx lock, set/get/insert, Mutex unlock
|
|
||||||
//Use template functions for different data types
|
|
||||||
//Trigger Event, if set/get/insert/write/Read fails
|
|
||||||
template <typename T> ReturnValue_t GlobalConfigHandler::setConfigFileValue(std::string key, T data){
|
template <typename T> ReturnValue_t GlobalConfigHandler::setConfigFileValue(std::string key, T data){
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
ReturnValue_t resultSet = RETURN_OK;
|
ReturnValue_t resultSet = RETURN_OK;
|
||||||
@ -75,6 +72,7 @@ template <typename T> ReturnValue_t GlobalConfigHandler::setConfigFileValue(std:
|
|||||||
|
|
||||||
resultSet=setValue(key, data);
|
resultSet=setValue(key, data);
|
||||||
if(resultSet!=RETURN_OK){
|
if(resultSet!=RETURN_OK){
|
||||||
|
triggerEvent(SET_CONFIGFILEVALUE_FAILED, 0, 0);
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "GlobalConfigHandler::setConfigFileValue set json failed with " << result << std::endl;
|
sif::info << "GlobalConfigHandler::setConfigFileValue set json failed with " << result << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -105,6 +103,7 @@ template <typename T> ReturnValue_t GlobalConfigHandler::getConfigFileValue(std:
|
|||||||
|
|
||||||
resultGet=getValue(key, data);
|
resultGet=getValue(key, data);
|
||||||
if (resultGet!= RETURN_OK){
|
if (resultGet!= RETURN_OK){
|
||||||
|
triggerEvent(GET_CONFIGFILEVALUE_FAILED, 0, 0);
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "GlobalConfigHandler::getConfigFileValue lock mutex failed with " << result << std::endl;
|
sif::info << "GlobalConfigHandler::getConfigFileValue lock mutex failed with " << result << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -133,6 +132,7 @@ template <typename T> ReturnValue_t GlobalConfigHandler::insertConfigFileValue(s
|
|||||||
|
|
||||||
resultInsert=insertValue(key, data);//Should never fail
|
resultInsert=insertValue(key, data);//Should never fail
|
||||||
if(resultInsert!=RETURN_OK){
|
if(resultInsert!=RETURN_OK){
|
||||||
|
triggerEvent(INSERT_CONFIGFILEVALUE_FAILED, 0, 0);
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "GlobalConfigHandler::insertConfigFileValue insert failed with " << result << std::endl;
|
sif::info << "GlobalConfigHandler::insertConfigFileValue insert failed with " << result << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -181,6 +181,7 @@ ReturnValue_t GlobalConfigHandler::WriteConfigFile(){
|
|||||||
|
|
||||||
resultWrite =writeJsonFile();
|
resultWrite =writeJsonFile();
|
||||||
if(resultWrite!=RETURN_OK){
|
if(resultWrite!=RETURN_OK){
|
||||||
|
triggerEvent(WRITE_CONFIGFILE_FAILED, 0, 0);
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "GlobalConfigHandler::WriteConfigFile write json failed with " << result << std::endl;
|
sif::info << "GlobalConfigHandler::WriteConfigFile write json failed with " << result << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -209,6 +210,7 @@ ReturnValue_t GlobalConfigHandler::ReadConfigFile(){
|
|||||||
|
|
||||||
resultRead=readJsonFile();
|
resultRead=readJsonFile();
|
||||||
if(resultRead!=RETURN_OK){
|
if(resultRead!=RETURN_OK){
|
||||||
|
triggerEvent(READ_CONFIGFILE_FAILED, 0, 0);
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "GlobalConfigHandler::ReadConfigFile read json failed with " << result << std::endl;
|
sif::info << "GlobalConfigHandler::ReadConfigFile read json failed with " << result << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -230,3 +232,15 @@ ReturnValue_t GlobalConfigHandler::ResetConfigFile(){
|
|||||||
result =writeJsonFile();
|
result =writeJsonFile();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ReturnValue_t GlobalConfigHandler::setConfigFileName(std::string configFileName){
|
||||||
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
setFullName(configFileName);
|
||||||
|
result=ResetConfigFile();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
std::string GlobalConfigHandler::getConfigFileName(){
|
||||||
|
|
||||||
|
return getFullName();
|
||||||
|
}
|
||||||
|
@ -39,6 +39,15 @@ class GlobalConfigHandler: public SystemObject, public ExecutableObjectIF, publi
|
|||||||
public:
|
public:
|
||||||
GlobalConfigHandler(object_id_t objectId, std::string configFilePath);
|
GlobalConfigHandler(object_id_t objectId, std::string configFilePath);
|
||||||
virtual ~GlobalConfigHandler();
|
virtual ~GlobalConfigHandler();
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
ReturnValue_t performOperation(uint8_t operationCode);
|
ReturnValue_t performOperation(uint8_t operationCode);
|
||||||
ReturnValue_t initialize();
|
ReturnValue_t initialize();
|
||||||
|
|
||||||
@ -52,8 +61,10 @@ public:
|
|||||||
ReturnValue_t ReadConfigFile();
|
ReturnValue_t ReadConfigFile();
|
||||||
ReturnValue_t ResetConfigFile();
|
ReturnValue_t ResetConfigFile();
|
||||||
|
|
||||||
|
ReturnValue_t setConfigFileName(std::string configFileName);
|
||||||
|
std::string getConfigFileName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string configFilePath;
|
|
||||||
static MutexIF* configLock ;
|
static MutexIF* configLock ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ enum: uint8_t {
|
|||||||
PDU2_HANDLER = 134,
|
PDU2_HANDLER = 134,
|
||||||
ACU_HANDLER = 135,
|
ACU_HANDLER = 135,
|
||||||
SYRLINKS = 136,
|
SYRLINKS = 136,
|
||||||
|
CONFIGHANDLER=137,
|
||||||
COMMON_SUBSYSTEM_ID_END
|
COMMON_SUBSYSTEM_ID_END
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user