v1.14.0 #304

Merged
muellerr merged 366 commits from develop into main 2022-10-10 17:46:38 +02:00
11 changed files with 268 additions and 269 deletions
Showing only changes of commit 3ca11b5894 - Show all commits

View File

@ -1,5 +1,4 @@
target_sources(${OBSW_NAME} PUBLIC InitMission.cpp main.cpp ObjectFactory.cpp)
add_subdirectory(fsfwconfig)
add_subdirectory(boardconfig)

View File

@ -173,8 +173,6 @@ void initmission::initTasks() {
}
#endif /* OBSW_ADD_TEST_CODE == 1 */
sif::info << "Starting tasks.." << std::endl;
tmTcDistributor->startTask();
tmtcBridgeTask->startTask();

View File

@ -26,7 +26,6 @@
#include <test/testtasks/TestTask.h>
#endif
#include "mission/utility/GlobalConfigHandler.h"
#include <dummies/AcuDummy.h>
#include <dummies/BpxDummy.h>
#include <dummies/ComCookieDummy.h>
@ -45,6 +44,8 @@
#include <dummies/SyrlinksDummy.h>
#include <dummies/TemperatureSensorsDummy.h>
#include "mission/utility/GlobalConfigHandler.h"
void Factory::setStaticFrameworkObjectIds() {
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL;
@ -90,6 +91,4 @@ void ObjectFactory::produce(void* args) {
new SusDummy();
new ThermalController(objects::THERMAL_CONTROLLER, objects::NO_OBJECT);
new TestTask(objects::TEST_TASK);
}

View File

@ -31,7 +31,9 @@ int main(void) {
<< "v" << common::OBSW_VERSION << " | FSFW v" << fsfw::FSFW_VERSION << " --"
<< std::endl;
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
std::cout << "-- " <<" BSP HOSTED"<< " --" << std::endl;
std::cout << "-- "
<< " BSP HOSTED"
<< " --" << std::endl;
initmission::initMission();

View File

@ -1,3 +1,3 @@
if(TGT_BSP MATCHES "arm/q7s" OR TGT_BSP MATCHES "")
target_sources(${LIB_EIVE_MISSION} PRIVATE ThermalController.cpp)
target_sources(${LIB_EIVE_MISSION} PRIVATE ThermalController.cpp)
endif()

View File

@ -1,5 +1,2 @@
target_sources(${LIB_EIVE_MISSION} PRIVATE
CCSDSHandler.cpp
VirtualChannel.cpp
TmFunnel.cpp
)
target_sources(${LIB_EIVE_MISSION} PRIVATE CCSDSHandler.cpp VirtualChannel.cpp
TmFunnel.cpp)

View File

@ -1,2 +1,3 @@
target_sources(${LIB_EIVE_MISSION} PRIVATE TmFunnel.cpp Timestamp.cpp
ProgressPrinter.cpp Filenaming.cpp GlobalConfigHandler.cpp)
target_sources(
${LIB_EIVE_MISSION} PRIVATE TmFunnel.cpp Timestamp.cpp ProgressPrinter.cpp
Filenaming.cpp GlobalConfigHandler.cpp)

View File

@ -8,7 +8,6 @@
#ifndef MISSION_UTILITY_GLOBALCONFIGFILEDEFINITIONS_H_
#define MISSION_UTILITY_GLOBALCONFIGFILEDEFINITIONS_H_
static constexpr double PARAM0_DEFAULT = 5.0;
static constexpr int PARAM1_DEFAULT = 905;
@ -18,6 +17,4 @@ enum ParamIds : uint8_t {
PARAM2 = 2,
};
#endif /* MISSION_UTILITY_GLOBALCONFIGFILEDEFINITIONS_H_ */

View File

@ -6,256 +6,263 @@
*/
#include "GlobalConfigHandler.h"
#include <fsfw/ipc/MutexFactory.h>
#include "fsfw/serviceinterface/ServiceInterface.h"
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/ipc/MutexFactory.h>
#include <fsfw/ipc/QueueFactory.h>
#include "fsfw/serviceinterface/ServiceInterface.h"
MutexIF* GlobalConfigHandler::configLock = nullptr;
GlobalConfigHandler::GlobalConfigHandler(object_id_t objectId, std::string configFilePath):
SystemObject(objectId),
NVMParameterBase(configFilePath),
commandQueue(QueueFactory::instance()->createMessageQueue(20))
{
if (configLock == nullptr) {
configLock = MutexFactory::instance()->createMutex();
}
GlobalConfigHandler::GlobalConfigHandler(object_id_t objectId, std::string configFilePath)
: SystemObject(objectId),
NVMParameterBase(configFilePath),
commandQueue(QueueFactory::instance()->createMessageQueue(20)) {
if (configLock == nullptr) {
configLock = MutexFactory::instance()->createMutex();
}
}
ReturnValue_t GlobalConfigHandler::initialize(){
ReturnValue_t result = SystemObject::initialize();
if (result != RETURN_OK) {
ReturnValue_t GlobalConfigHandler::initialize() {
ReturnValue_t result = SystemObject::initialize();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::initialize: SystemObject::initialize() failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::initialize: SystemObject::initialize() failed with "
<< result << std::endl;
#endif
return result;
}
return result;
}
result = ReadConfigFile();
if(result!=RETURN_OK){
result = ReadConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::initialize: Creating JSON file at " << getFullName() << std::endl;
sif::info << "GlobalConfigHandler::initialize: Creating JSON file at " << getFullName()
<< std::endl;
#endif
result=ResetConfigFile();
if (result != RETURN_OK) {
return result;
}
}
result = ResetConfigFile();
if (result != RETURN_OK) {
return result;
}
}
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::initialize success " << std::endl;
sif::info << "GlobalConfigHandler::initialize success " << std::endl;
#endif
return result;
}
GlobalConfigHandler::~GlobalConfigHandler() {
return result;
}
GlobalConfigHandler::~GlobalConfigHandler() {}
ReturnValue_t GlobalConfigHandler::performOperation(uint8_t operationCode) {
ReturnValue_t result = RETURN_OK;
sif::debug<<"GlobalConfigHandler::performOperation"<<std::endl;
sif::debug << "GlobalConfigHandler::performOperation" << std::endl;
return result;
}
ReturnValue_t GlobalConfigHandler::lockConfigFile(){
ReturnValue_t result = RETURN_OK;
result = configLock->lockMutex(MutexIF::TimeoutType::WAITING, 10);
return result;
}
ReturnValue_t GlobalConfigHandler::unlockConfigFile(){
ReturnValue_t GlobalConfigHandler::lockConfigFile() {
ReturnValue_t result = RETURN_OK;
result=configLock->unlockMutex();
result = configLock->lockMutex(MutexIF::TimeoutType::WAITING, 10);
return result;
}
ReturnValue_t GlobalConfigHandler::unlockConfigFile() {
ReturnValue_t result = RETURN_OK;
result = configLock->unlockMutex();
return result;
}
template <typename T> ReturnValue_t GlobalConfigHandler::setConfigFileValue(ParamIds paramID, T data){
ReturnValue_t result = RETURN_OK;
ReturnValue_t resultSet = RETURN_OK;
template <typename T>
ReturnValue_t GlobalConfigHandler::setConfigFileValue(ParamIds paramID, T data) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t resultSet = RETURN_OK;
result=lockConfigFile();
if (result!= RETURN_OK){
result = lockConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::setConfigFileValue lock mutex failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::setConfigFileValue lock mutex failed with " << result
<< std::endl;
#endif
return result;
}
return result;
}
std:: string paramString;
paramString=PARAM_KEY_MAP[paramID];
std::string paramString;
paramString = PARAM_KEY_MAP[paramID];
//Check if key exists in map before setting value. No check is done in setValue! Somehow PARAM_KEY_MAP.count(paramID) == 0 does not work
if (paramString.empty() == true) {
// Check if key exists in map before setting value. No check is done in setValue! Somehow
// PARAM_KEY_MAP.count(paramID) == 0 does not work
if (paramString.empty() == true) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::setConfigFileValue ParamId " << PARAM_KEY_MAP[paramID]<<" not found!" << std::endl;
sif::info << "GlobalConfigHandler::setConfigFileValue ParamId " << PARAM_KEY_MAP[paramID]
<< " not found!" << std::endl;
#endif
triggerEvent(SET_CONFIGFILEVALUE_FAILED, 1, 0);
return RETURN_FAILED;
}
triggerEvent(SET_CONFIGFILEVALUE_FAILED, 1, 0);
return RETURN_FAILED;
}
resultSet=setValue(PARAM_KEY_MAP[paramID], data);
if(resultSet!=RETURN_OK){
triggerEvent(SET_CONFIGFILEVALUE_FAILED, 0, 0);
resultSet = setValue(PARAM_KEY_MAP[paramID], data);
if (resultSet != RETURN_OK) {
triggerEvent(SET_CONFIGFILEVALUE_FAILED, 0, 0);
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::setConfigFileValue set json failed with " << resultSet << std::endl;
sif::info << "GlobalConfigHandler::setConfigFileValue set json failed with " << resultSet
<< std::endl;
#endif
}
}
result=unlockConfigFile();
if (result!= RETURN_OK){
result = unlockConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::setConfigFileValue unlock mutex failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::setConfigFileValue unlock mutex failed with " << result
<< std::endl;
#endif
return result;
}
return result;
}
return resultSet;
return resultSet;
}
template <typename T> ReturnValue_t GlobalConfigHandler::getConfigFileValue(ParamIds paramID, T& data){
ReturnValue_t result = RETURN_OK;
ReturnValue_t resultGet = RETURN_OK;
template <typename T>
ReturnValue_t GlobalConfigHandler::getConfigFileValue(ParamIds paramID, T& data) {
ReturnValue_t result = RETURN_OK;
ReturnValue_t resultGet = RETURN_OK;
result=lockConfigFile();
if (result!= RETURN_OK){
result = lockConfigFile();
if (result != RETURN_OK) {
#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
return result;
}
return result;
}
resultGet=getValue(PARAM_KEY_MAP[paramID], data);
if (resultGet!= RETURN_OK){
triggerEvent(GET_CONFIGFILEVALUE_FAILED, 0, 0);
resultGet = getValue(PARAM_KEY_MAP[paramID], data);
if (resultGet != RETURN_OK) {
triggerEvent(GET_CONFIGFILEVALUE_FAILED, 0, 0);
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::getConfigFileValue getValue failed with " << resultGet << std::endl;
sif::info << "GlobalConfigHandler::getConfigFileValue getValue failed with " << resultGet
<< std::endl;
#endif
}
result=unlockConfigFile();
if (result!= RETURN_OK){
}
result = unlockConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::getConfigFileValue unlock mutex failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::getConfigFileValue unlock mutex failed with " << result
<< std::endl;
#endif
return result;
}
return result;
}
return resultGet;
return resultGet;
}
ReturnValue_t GlobalConfigHandler::resetConfigFileValues(){
ReturnValue_t result = RETURN_OK;
result=lockConfigFile();
if (result!= RETURN_OK){
ReturnValue_t GlobalConfigHandler::resetConfigFileValues() {
ReturnValue_t result = RETURN_OK;
result = lockConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::resetConfigFileValues lock mutex failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::resetConfigFileValues lock mutex failed with " << result
<< std::endl;
#endif
return result;
}
insertValue(PARAM_KEY_MAP[PARAM0], PARAM0_DEFAULT);
insertValue(PARAM_KEY_MAP[PARAM1], PARAM1_DEFAULT);
return result;
}
insertValue(PARAM_KEY_MAP[PARAM0], PARAM0_DEFAULT);
insertValue(PARAM_KEY_MAP[PARAM1], PARAM1_DEFAULT);
result=unlockConfigFile();
if (result!= RETURN_OK){
result = unlockConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::resetConfigFileValues unlock mutex failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::resetConfigFileValues unlock mutex failed with " << result
<< std::endl;
#endif
return result;
}
return result;
return result;
}
return result;
}
ReturnValue_t GlobalConfigHandler::WriteConfigFile(){
ReturnValue_t result = RETURN_OK;
ReturnValue_t resultWrite = RETURN_OK;
result=lockConfigFile();
if (result!= RETURN_OK){
ReturnValue_t GlobalConfigHandler::WriteConfigFile() {
ReturnValue_t result = RETURN_OK;
ReturnValue_t resultWrite = RETURN_OK;
result = lockConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::WriteConfigFile lock mutex failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::WriteConfigFile lock mutex failed with " << result
<< std::endl;
#endif
return result;
}
return result;
}
resultWrite =writeJsonFile();
if(resultWrite!=RETURN_OK){
triggerEvent(WRITE_CONFIGFILE_FAILED, 0, 0);
resultWrite = writeJsonFile();
if (resultWrite != RETURN_OK) {
triggerEvent(WRITE_CONFIGFILE_FAILED, 0, 0);
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::WriteConfigFile write json failed with " << resultWrite << std::endl;
sif::info << "GlobalConfigHandler::WriteConfigFile write json failed with " << resultWrite
<< std::endl;
#endif
}
}
result=unlockConfigFile();
if (result!= RETURN_OK){
result = unlockConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::WriteConfigFile unlock mutex failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::WriteConfigFile unlock mutex failed with " << result
<< std::endl;
#endif
return result;
}
return resultWrite;
return result;
}
return resultWrite;
}
ReturnValue_t GlobalConfigHandler::ReadConfigFile(){
ReturnValue_t result = RETURN_OK;
ReturnValue_t resultRead = RETURN_OK;
result=lockConfigFile();
if (result!= RETURN_OK){
ReturnValue_t GlobalConfigHandler::ReadConfigFile() {
ReturnValue_t result = RETURN_OK;
ReturnValue_t resultRead = RETURN_OK;
result = lockConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::ReadConfigFile lock mutex failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::ReadConfigFile lock mutex failed with " << result
<< std::endl;
#endif
return result;
}
return result;
}
resultRead=readJsonFile();
if(resultRead!=RETURN_OK){
triggerEvent(READ_CONFIGFILE_FAILED, 0, 0);
resultRead = readJsonFile();
if (resultRead != RETURN_OK) {
triggerEvent(READ_CONFIGFILE_FAILED, 0, 0);
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::ReadConfigFile read json failed with " << resultRead << std::endl;
sif::info << "GlobalConfigHandler::ReadConfigFile read json failed with " << resultRead
<< std::endl;
#endif
}
}
result=unlockConfigFile();
if (result!= RETURN_OK){
result = unlockConfigFile();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::ReadConfigFile unlock mutex failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::ReadConfigFile unlock mutex failed with " << result
<< std::endl;
#endif
return result;
}
return result;
}
return resultRead;
return resultRead;
}
ReturnValue_t GlobalConfigHandler::ResetConfigFile(){
ReturnValue_t result = RETURN_OK;
result=resetConfigFileValues();
if (result!= RETURN_OK){
ReturnValue_t GlobalConfigHandler::ResetConfigFile() {
ReturnValue_t result = RETURN_OK;
result = resetConfigFileValues();
if (result != RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "GlobalConfigHandler::ResetConfigFile failed with " << result << std::endl;
sif::info << "GlobalConfigHandler::ResetConfigFile failed with " << result << std::endl;
#endif
return result;
}
result =writeJsonFile();
return result;
return result;
}
result = writeJsonFile();
return result;
}
ReturnValue_t GlobalConfigHandler::setConfigFileName(std::string configFileName){
ReturnValue_t result = RETURN_OK;
setFullName(configFileName);
result=ResetConfigFile();
return result;
ReturnValue_t GlobalConfigHandler::setConfigFileName(std::string configFileName) {
ReturnValue_t result = RETURN_OK;
setFullName(configFileName);
result = ResetConfigFile();
return result;
}
std::string GlobalConfigHandler::getConfigFileName(){
std::string GlobalConfigHandler::getConfigFileName() { return getFullName(); }
return getFullName();
}
template ReturnValue_t GlobalConfigHandler::getConfigFileValue<double>(ParamIds paramID, double& data);
template ReturnValue_t GlobalConfigHandler::getConfigFileValue<int32_t>(ParamIds paramID, int32_t& data);
template ReturnValue_t GlobalConfigHandler::setConfigFileValue<double>(ParamIds paramID, double data);
template ReturnValue_t GlobalConfigHandler::setConfigFileValue<int32_t>(ParamIds paramID, int32_t data);
template ReturnValue_t GlobalConfigHandler::getConfigFileValue<double>(ParamIds paramID,
double& data);
template ReturnValue_t GlobalConfigHandler::getConfigFileValue<int32_t>(ParamIds paramID,
int32_t& data);
template ReturnValue_t GlobalConfigHandler::setConfigFileValue<double>(ParamIds paramID,
double data);
template ReturnValue_t GlobalConfigHandler::setConfigFileValue<int32_t>(ParamIds paramID,
int32_t data);

View File

@ -8,73 +8,72 @@
#ifndef MISSION_UTILITY_GLOBALCONFIGHANDLER_H_
#define MISSION_UTILITY_GLOBALCONFIGHANDLER_H_
#include <fsfw/action/ActionHelper.h>
#include <fsfw/action/HasActionsIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.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 "GlobalConfigFileDefinitions.h"
#include "OBSWConfig.h"
#include "fsfw/parameters/HasParametersIF.h"
#include "fsfw/parameters/ParameterHelper.h"
#include <fsfw/action/ActionHelper.h>
#include <fsfw/action/HasActionsIF.h>
#include "GlobalConfigFileDefinitions.h"
#include "mission/memory/NVMParameterBase.h"
static std::map<ParamIds, std::string> PARAM_KEY_MAP = {
{PARAM0, "Parameter0"},
{PARAM1, "Parameter1"},
{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.
* 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();
class GlobalConfigHandler : public SystemObject,
public ExecutableObjectIF,
public NVMParameterBase {
public:
GlobalConfigHandler(object_id_t objectId, std::string configFilePath);
virtual ~GlobalConfigHandler();
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CONFIGHANDLER;
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);
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();
template <typename T>
ReturnValue_t setConfigFileValue(ParamIds paramID, T data);
template <typename T>
ReturnValue_t getConfigFileValue(ParamIds paramID, T& data);
template <typename T> ReturnValue_t setConfigFileValue(ParamIds paramID, T data);
template <typename T> ReturnValue_t getConfigFileValue(ParamIds paramID, T& data);
ReturnValue_t ResetConfigFile();
ReturnValue_t WriteConfigFile();
std::string getConfigFileName();
private:
static MutexIF* configLock;
ReturnValue_t ResetConfigFile();
ReturnValue_t WriteConfigFile();
std::string getConfigFileName();
private:
static MutexIF* configLock ;
ReturnValue_t lockConfigFile();
ReturnValue_t unlockConfigFile();
ReturnValue_t resetConfigFileValues();
ReturnValue_t setConfigFileName(std::string configFileName);
ReturnValue_t ReadConfigFile();
MessageQueueIF* commandQueue;
ReturnValue_t lockConfigFile();
ReturnValue_t unlockConfigFile();
ReturnValue_t resetConfigFileValues();
ReturnValue_t setConfigFileName(std::string configFileName);
ReturnValue_t ReadConfigFile();
MessageQueueIF* commandQueue;
};
#endif /* MISSION_UTILITY_GLOBALCONFIGHANDLER_H_ */

View File

@ -1,65 +1,65 @@
#include <mission/utility/GlobalConfigHandler.h>
#include <objects/systemObjectList.h>
#include <catch2/catch_test_macros.hpp>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include "../testEnvironment.h"
#include <objects/systemObjectList.h>
TEST_CASE("Configfile Handler", "[ConfigHandler]") {
sif::debug << "Testcase config file handler" << std::endl;
testEnvironment::initialize();
// Init handler
GlobalConfigHandler confighandler = GlobalConfigHandler(objects::CONFIG_TEST, "JSON.config");
REQUIRE(confighandler.initialize() == HasReturnvaluesIF::RETURN_OK);
sif::debug<<"Testcase config file handler"<<std::endl;
testEnvironment::initialize();
//Init handler
GlobalConfigHandler confighandler= GlobalConfigHandler(objects::CONFIG_TEST,"JSON.config");
REQUIRE(confighandler.initialize() == HasReturnvaluesIF::RETURN_OK);
// Reset handler
REQUIRE(confighandler.ResetConfigFile() == HasReturnvaluesIF::RETURN_OK);
//Reset handler
REQUIRE(confighandler.ResetConfigFile() == HasReturnvaluesIF::RETURN_OK);
// Get and set double as well as int values
double doubleData = 0.0;
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleData) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(doubleData == 5.0);
//Get and set double as well as int values
double doubleData=0.0;
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleData) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(doubleData==5.0);
doubleData = 55.9;
double doubleDataRead = 0;
REQUIRE(confighandler.setConfigFileValue(PARAM0, doubleData) == HasReturnvaluesIF::RETURN_OK);
doubleData=55.9;
double doubleDataRead=0;
REQUIRE(confighandler.setConfigFileValue(PARAM0, doubleData) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleDataRead) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(doubleDataRead == doubleData);
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleDataRead) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(doubleDataRead==doubleData);
REQUIRE(confighandler.WriteConfigFile() == HasReturnvaluesIF::RETURN_OK);
REQUIRE(confighandler.WriteConfigFile()==HasReturnvaluesIF::RETURN_OK);
int intData = 0;
int intData=0;
REQUIRE(confighandler.getConfigFileValue(PARAM1, intData) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(intData == 905);
REQUIRE(confighandler.getConfigFileValue(PARAM1, intData) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(intData==905);
intData = 1337;
int intDataRead = 0;
REQUIRE(confighandler.setConfigFileValue(PARAM1, intData) == HasReturnvaluesIF::RETURN_OK);
intData=1337;
int intDataRead=0;
REQUIRE(confighandler.setConfigFileValue(PARAM1, intData) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(confighandler.getConfigFileValue(PARAM1, intDataRead) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(intDataRead == intData);
REQUIRE(confighandler.getConfigFileValue(PARAM1, intDataRead) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(intDataRead==intData);
REQUIRE(confighandler.WriteConfigFile() == HasReturnvaluesIF::RETURN_OK);
REQUIRE(confighandler.WriteConfigFile()==HasReturnvaluesIF::RETURN_OK);
// Check file name
REQUIRE(confighandler.getConfigFileName() == "JSON.config");
//Check file name
REQUIRE(confighandler.getConfigFileName()=="JSON.config");
// Reset and check if it worked
REQUIRE(confighandler.ResetConfigFile() == HasReturnvaluesIF::RETURN_OK);
//Reset and check if it worked
REQUIRE(confighandler.ResetConfigFile() == HasReturnvaluesIF::RETURN_OK);
doubleData=0.0;
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleData) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(doubleData==5.0);
//Test invalid Parameter
REQUIRE(confighandler.getConfigFileValue(PARAM2, doubleData) != HasReturnvaluesIF::RETURN_OK);//NVMParameterBase::KEY_NOT_EXISTS is private, why?
REQUIRE(confighandler.setConfigFileValue(PARAM2, doubleData) != HasReturnvaluesIF::RETURN_OK);
doubleData = 0.0;
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleData) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(doubleData == 5.0);
// Test invalid Parameter
REQUIRE(confighandler.getConfigFileValue(PARAM2, doubleData) !=
HasReturnvaluesIF::RETURN_OK); // NVMParameterBase::KEY_NOT_EXISTS is private, why?
REQUIRE(confighandler.setConfigFileValue(PARAM2, doubleData) != HasReturnvaluesIF::RETURN_OK);
}