fixed merge conflicts
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(devices)
|
||||
add_subdirectory(utility)
|
||||
add_subdirectory(memory)
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <fsfw/events/EventManager.h>
|
||||
#include <fsfw/health/HealthTable.h>
|
||||
#include <fsfw/internalError/InternalErrorReporter.h>
|
||||
#include <fsfw/internalerror/InternalErrorReporter.h>
|
||||
#include <fsfw/pus/CService200ModeCommanding.h>
|
||||
#include <fsfw/pus/Service17Test.h>
|
||||
#include <fsfw/pus/Service1TelecommandVerification.h>
|
||||
|
@ -4,10 +4,10 @@
|
||||
#include "GyroADIS16507Handler.h"
|
||||
|
||||
#if OBSW_ADIS16507_LINUX_COM_IF == 1
|
||||
#include "fsfw_hal/linux/utility.h"
|
||||
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
||||
#include "fsfw_hal/linux/spi/SpiComIF.h"
|
||||
#include "fsfw_hal/linux/UnixFileGuard.h"
|
||||
#include "fsfw/hal/linux/utility.h"
|
||||
#include "fsfw/hal/linux/spi/SpiCookie.h"
|
||||
#include "fsfw/hal/linux/spi/SpiComIF.h"
|
||||
#include "fsfw/hal/linux/UnixFileGuard.h"
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -329,7 +329,7 @@ ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool &localDat
|
||||
pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1 }));
|
||||
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry<uint8_t>( {
|
||||
pcduSwitches::INIT_STATE_RW }));
|
||||
#if TE0720 == 1
|
||||
#if BOARD_TE0720 == 1
|
||||
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 1 }));
|
||||
#else
|
||||
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( {pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN}));
|
||||
|
@ -265,7 +265,7 @@ ReturnValue_t PDU2Handler::initializeLocalDataPool(
|
||||
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry<uint8_t>( { 0 }));
|
||||
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry<uint8_t>( { 0 }));
|
||||
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry<uint8_t>( { 0 }));
|
||||
#if TE0720 == 1
|
||||
#if BOARD_TE0720 == 1
|
||||
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 1 }));
|
||||
#else
|
||||
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 0 }));
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
#include <mission/devices/devicedefinitions/RwDefinitions.h>
|
||||
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
|
||||
#include <fsfw/hal/linux/gpio/LinuxLibgpioIF.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
|
5
mission/memory/CMakeLists.txt
Normal file
5
mission/memory/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
target_sources(${TARGET_NAME} PUBLIC
|
||||
NVMParameterBase.cpp
|
||||
)
|
||||
|
||||
|
50
mission/memory/NVMParameterBase.cpp
Normal file
50
mission/memory/NVMParameterBase.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "NVMParameterBase.h"
|
||||
#include "fsfw/memory/HasFileSystemIF.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
NVMParameterBase::NVMParameterBase(std::string fullName): fullName(fullName) {
|
||||
}
|
||||
|
||||
ReturnValue_t NVMParameterBase::readJsonFile() {
|
||||
if(std::filesystem::exists(fullName)) {
|
||||
// Read JSON file content into object
|
||||
std::ifstream i(fullName);
|
||||
i >> json;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
ReturnValue_t NVMParameterBase::writeJsonFile() {
|
||||
std::ofstream o(fullName);
|
||||
o << std::setw(4) << json;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void NVMParameterBase::setFullName(std::string fullName) {
|
||||
this->fullName = fullName;
|
||||
}
|
||||
|
||||
std::string NVMParameterBase::getFullName() const {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
bool NVMParameterBase::getJsonFileExists() {
|
||||
return std::filesystem::exists(fullName);
|
||||
}
|
||||
|
||||
void NVMParameterBase::printKeys() const {
|
||||
sif::info << "Printing keys for JSON file " << fullName << std::endl;
|
||||
for(const auto& key: keys) {
|
||||
sif::info << key << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void NVMParameterBase::print() const {
|
||||
sif::info << "Printing JSON file " << fullName << std::endl;
|
||||
for(const auto& key: keys) {
|
||||
sif::info << key << ": " << json[key] << std::endl;
|
||||
}
|
||||
}
|
69
mission/memory/NVMParameterBase.h
Normal file
69
mission/memory/NVMParameterBase.h
Normal file
@ -0,0 +1,69 @@
|
||||
#ifndef BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_
|
||||
#define BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
class NVMParameterBase {
|
||||
public:
|
||||
virtual~ NVMParameterBase() {}
|
||||
|
||||
NVMParameterBase(std::string fullName);
|
||||
|
||||
bool getJsonFileExists();
|
||||
|
||||
/**
|
||||
* Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if
|
||||
* file does not exist yet.
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t readJsonFile();
|
||||
|
||||
virtual ReturnValue_t writeJsonFile();
|
||||
|
||||
void setFullName(std::string fullName);
|
||||
std::string getFullName() const;
|
||||
|
||||
template<typename T>
|
||||
ReturnValue_t insertValue(std::string key, T value);
|
||||
|
||||
template<typename T>
|
||||
ReturnValue_t setValue(std::string key, T value);
|
||||
|
||||
template<typename T>
|
||||
T getValue(std::string key) const;
|
||||
|
||||
void printKeys() const;
|
||||
void print() const;
|
||||
|
||||
private:
|
||||
nlohmann::json json;
|
||||
std::vector<std::string> keys;
|
||||
std::string fullName;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t NVMParameterBase::insertValue(std::string key, T value) {
|
||||
// Check whether key already exists. If it does not, insert it
|
||||
if (std::find(keys.begin(), keys.end(), key) == keys.end()) {
|
||||
keys.push_back(key);
|
||||
}
|
||||
json[key] = value;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) {
|
||||
json[key] = value;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T NVMParameterBase::getValue(std::string key) const {
|
||||
return json[key];
|
||||
}
|
||||
|
||||
#endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */
|
Reference in New Issue
Block a user