mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
Add:Ipc config module.
This commit is contained in:
parent
0eb06e4213
commit
a879da6532
|
@ -7,8 +7,9 @@ set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_S
|
|||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/FilesManager/include")
|
||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/StorageManager/include")
|
||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade/include")
|
||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/IpcConfig/include")
|
||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/StatusCode/include")
|
||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/Log/include")
|
||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${HAL_SOURCE_PATH}/include")
|
||||
|
||||
set(HUNTTING_LINK_LIB McuManager MissionManager StateMachine AppManager FilesManager StorageManager HuntingUpgrade StatusCode Log Hal pthread dl)
|
||||
set(HUNTTING_LINK_LIB McuManager MissionManager StateMachine AppManager FilesManager StorageManager HuntingUpgrade IpcConfig StatusCode Log Hal pthread dl)
|
|
@ -17,6 +17,7 @@
|
|||
#include "IFilesManager.h"
|
||||
#include "IHalCpp.h"
|
||||
#include "IHuntingUpgrade.h"
|
||||
#include "IIpcConfig.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
#include "IMediaManager.h"
|
||||
|
@ -66,6 +67,7 @@ StatusCode MainThread::Init(void)
|
|||
IHalCpp::GetInstance()->Init();
|
||||
IMcuManager::GetInstance()->Init();
|
||||
IStorageManager::GetInstance()->Init();
|
||||
IIpcConfig::GetInstance()->Init();
|
||||
IMediaManager::GetInstance()->Init();
|
||||
IMissionManager::GetInstance()->Init();
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
|
@ -74,6 +76,7 @@ StatusCode MainThread::UnInit(void)
|
|||
{
|
||||
IMissionManager::GetInstance()->UnInit();
|
||||
IMediaManager::GetInstance()->UnInit();
|
||||
IIpcConfig::GetInstance()->UnInit();
|
||||
IStorageManager::GetInstance()->UnInit();
|
||||
IMcuManager::GetInstance()->UnInit();
|
||||
IHalCpp::GetInstance()->UnInit();
|
||||
|
@ -92,6 +95,7 @@ StatusCode MainThread::CreateAllModules(void)
|
|||
CreateAppManagerModule();
|
||||
CreateMediaManagerModule();
|
||||
CreateHuntingUpgradeModule();
|
||||
CreateIpcConfigModule();
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
void MainThread::DestoryAllModules(void)
|
||||
|
@ -105,6 +109,7 @@ void MainThread::DestoryAllModules(void)
|
|||
DestroyStorageManagerModule();
|
||||
DestroyMcuManager();
|
||||
DestroyHalCppModule();
|
||||
DestroyIpcConfigModule();
|
||||
}
|
||||
void MainThread::ResetAllPtrMaker(void)
|
||||
{
|
||||
|
|
|
@ -13,6 +13,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "McuMonitor.h"
|
||||
#include "ILog.h"
|
||||
#include "IMcuManager.h"
|
||||
void McuMonitor::Init(std::shared_ptr<VMcuMonitor> &monitor)
|
||||
{
|
||||
IMcuManager::GetInstance()->SetMcuMonitor(monitor);
|
||||
}
|
||||
void McuMonitor::UnInit(void)
|
||||
{
|
||||
}
|
||||
void McuMonitor::RecvIpcMissionEvent(std::shared_ptr<VMcuRecv> &recv, const IpcMission &mission)
|
||||
{
|
||||
}
|
||||
|
@ -21,10 +30,40 @@ void McuMonitor::RecvMcuHeartBeatEvent(std::shared_ptr<VMcuRecv> &recv)
|
|||
}
|
||||
void McuMonitor::RecvGetIntervalStartEvent(std::shared_ptr<VMcuRecv> &recv)
|
||||
{
|
||||
LogInfo("RecvGetIntervalStartEvent\n");
|
||||
std::shared_ptr<McuRecv<McuGetIntervalStart>> recvData =
|
||||
std::dynamic_pointer_cast<McuRecv<McuGetIntervalStart>>(recv);
|
||||
if (recvData) {
|
||||
recvData->mDataRecvReply.mHour = 10;
|
||||
recvData->mDataRecvReply.mMin = 10;
|
||||
recvData->mDataRecvReply.mSecond = 10;
|
||||
recv->ReplyFinished(true);
|
||||
}
|
||||
recv->ReplyFinished(false);
|
||||
}
|
||||
void McuMonitor::RecvGetDateTime(std::shared_ptr<VMcuRecv> &recv)
|
||||
{
|
||||
LogInfo("RecvGetDateTime\n");
|
||||
std::shared_ptr<McuRecv<McuReplyDateTime>> recvData = std::dynamic_pointer_cast<McuRecv<McuReplyDateTime>>(recv);
|
||||
if (recvData) {
|
||||
recvData->mDataRecvReply.mYear = 2024;
|
||||
recvData->mDataRecvReply.mMon = 10;
|
||||
recvData->mDataRecvReply.mDay = 10;
|
||||
recvData->mDataRecvReply.mHour = 10;
|
||||
recvData->mDataRecvReply.mMin = 10;
|
||||
recvData->mDataRecvReply.mSecond = 10;
|
||||
recv->ReplyFinished(true);
|
||||
}
|
||||
recv->ReplyFinished(false);
|
||||
}
|
||||
void McuMonitor::RecvGetPirSensitivity(std::shared_ptr<VMcuRecv> &recv)
|
||||
{
|
||||
LogInfo("RecvGetPirSensitivity\n");
|
||||
std::shared_ptr<McuRecv<McuGetPirSensitivity>> recvData =
|
||||
std::dynamic_pointer_cast<McuRecv<McuGetPirSensitivity>>(recv);
|
||||
if (recvData) {
|
||||
recvData->mDataRecvReply.mSensitivity = 9;
|
||||
recv->ReplyFinished(true);
|
||||
}
|
||||
recv->ReplyFinished(false);
|
||||
}
|
|
@ -20,6 +20,8 @@ class McuMonitor : public VMcuMonitor
|
|||
public:
|
||||
McuMonitor() = default;
|
||||
virtual ~McuMonitor() = default;
|
||||
void Init(std::shared_ptr<VMcuMonitor> &monitor);
|
||||
void UnInit(void);
|
||||
void RecvIpcMissionEvent(std::shared_ptr<VMcuRecv> &recv, const IpcMission &mission) override;
|
||||
void RecvMcuHeartBeatEvent(std::shared_ptr<VMcuRecv> &recv) override;
|
||||
void RecvGetIntervalStartEvent(std::shared_ptr<VMcuRecv> &recv) override;
|
||||
|
|
|
@ -18,13 +18,16 @@
|
|||
#include "MissionStateMachine.h"
|
||||
TopState::TopState() : State("TopState")
|
||||
{
|
||||
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] = std::bind(&TopState::StorageStartInitHandle, this, _1);
|
||||
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =
|
||||
std::bind(&TopState::StorageStartInitHandle, this, _1);
|
||||
}
|
||||
void TopState::GoInState()
|
||||
{
|
||||
LogInfo(" ========== TopState::GoInState.\n");
|
||||
std::shared_ptr<VMediaMonitor> monitor = std::dynamic_pointer_cast<TopState>(shared_from_this());
|
||||
IMediaManager::GetInstance()->SetMediaMonitor(monitor);
|
||||
std::shared_ptr<VMcuMonitor> mcuMonitor = std::dynamic_pointer_cast<VMcuMonitor>(shared_from_this());
|
||||
McuMonitor::Init(mcuMonitor);
|
||||
std::shared_ptr<VMediaMonitor> mediaMonitor = std::dynamic_pointer_cast<VMediaMonitor>(shared_from_this());
|
||||
IMediaManager::GetInstance()->SetMediaMonitor(mediaMonitor);
|
||||
MissionStateMachine::GetInstance()->SwitchState(SystemState::MISSION_STATE);
|
||||
}
|
||||
void TopState::GoOutState()
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
#include "DataProcessing.h"
|
||||
#include "IMediaManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include "McuMonitor.h"
|
||||
class TopState : public State,
|
||||
public DataProcessing,
|
||||
public VMediaMonitor,
|
||||
public McuMonitor,
|
||||
public std::enable_shared_from_this<TopState>
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -14,7 +14,6 @@ include_directories(
|
|||
#link_directories(
|
||||
#)
|
||||
|
||||
|
||||
if (DEFINED IPC_CONFIG_FILE_PATH)
|
||||
add_definitions(-DIPC_CONFIG_FILE_PATH=\"${IPC_CONFIG_FILE_PATH}\")
|
||||
else()
|
||||
|
|
|
@ -90,7 +90,8 @@ enum PirSensitivity
|
|||
PIR_SENSITIVITY_MAX = 9,
|
||||
PIR_SENSITIVITY_END,
|
||||
};
|
||||
|
||||
bool CreateIpcConfigModule(void);
|
||||
bool DestroyIpcConfigModule(void);
|
||||
class IIpcConfig
|
||||
{
|
||||
public:
|
||||
|
@ -121,5 +122,4 @@ public:
|
|||
virtual const std::string GetString(const IpcConfigKey &key);
|
||||
virtual void SetString(const IpcConfigKey &key, const std::string string);
|
||||
};
|
||||
bool CreateIpcConfig(void);
|
||||
#endif
|
|
@ -12,13 +12,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "IpcConfig.h"
|
||||
#include "IpcConfigImpl.h"
|
||||
#include "ILog.h"
|
||||
#include <string.h>
|
||||
|
||||
#define CHECK_MAP(map) (map.size() == 1 ? true : false)
|
||||
|
||||
IpcConfig::IpcConfig()
|
||||
IpcConfigImpl::IpcConfigImpl()
|
||||
{
|
||||
mCfgChanged = CONFIG_HAS_NOT_CHANGED;
|
||||
|
||||
|
@ -101,7 +101,7 @@ IpcConfig::IpcConfig()
|
|||
innerMapFloat.insert(std::make_pair("test_float", std::reference_wrapper<float>(mAllData.testFloat)));
|
||||
mCfgMapFloat.insert(std::make_pair(IpcConfigKey::TEST_FLOAT, innerMapFloat));
|
||||
}
|
||||
const StatusCode IpcConfig::Init(void)
|
||||
const StatusCode IpcConfigImpl::Init(void)
|
||||
{
|
||||
memset(&mAllData, 0, sizeof(Config_s));
|
||||
mCfg = OpenConfigFile(IPC_CONFIG_FILE_PATH);
|
||||
|
@ -112,7 +112,7 @@ const StatusCode IpcConfig::Init(void)
|
|||
ReadAllConfigParameters();
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
const StatusCode IpcConfig::UnInit(void)
|
||||
const StatusCode IpcConfigImpl::UnInit(void)
|
||||
{
|
||||
if (CONFIG_HAS_CHANGED == mCfgChanged) {
|
||||
LogInfo("Save config files.\n");
|
||||
|
@ -121,12 +121,12 @@ const StatusCode IpcConfig::UnInit(void)
|
|||
CloseConfigFile(mCfg);
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
const StatusCode IpcConfig::ConfigFileSave(void)
|
||||
const StatusCode IpcConfigImpl::ConfigFileSave(void)
|
||||
{
|
||||
return ConfigSaveFile(mCfg);
|
||||
}
|
||||
|
||||
const int IpcConfig::GetInt(const IpcConfigKey &key)
|
||||
const int IpcConfigImpl::GetInt(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<int>>>::iterator iter;
|
||||
iter = mCfgMapInt.find(key);
|
||||
|
@ -137,7 +137,7 @@ const int IpcConfig::GetInt(const IpcConfigKey &key)
|
|||
constexpr int UNKNOWN_CONFIG = -1;
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetInt(const IpcConfigKey &key, const int &value)
|
||||
void IpcConfigImpl::SetInt(const IpcConfigKey &key, const int &value)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<int>>>::iterator iter;
|
||||
iter = mCfgMapInt.find(key);
|
||||
|
@ -151,7 +151,7 @@ void IpcConfig::SetInt(const IpcConfigKey &key, const int &value)
|
|||
LogError("Can't find the key.\n");
|
||||
}
|
||||
}
|
||||
const short IpcConfig::GetShort(const IpcConfigKey &key)
|
||||
const short IpcConfigImpl::GetShort(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<short>>>::iterator iter;
|
||||
iter = mCfgMapShort.find(key);
|
||||
|
@ -162,7 +162,7 @@ const short IpcConfig::GetShort(const IpcConfigKey &key)
|
|||
constexpr short UNKNOWN_CONFIG = -1;
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetShort(const IpcConfigKey &key, const short &value)
|
||||
void IpcConfigImpl::SetShort(const IpcConfigKey &key, const short &value)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<short>>>::iterator iter;
|
||||
iter = mCfgMapShort.find(key);
|
||||
|
@ -176,7 +176,7 @@ void IpcConfig::SetShort(const IpcConfigKey &key, const short &value)
|
|||
LogError("Can't find the key.\n");
|
||||
}
|
||||
}
|
||||
const long IpcConfig::GetLong(const IpcConfigKey &key)
|
||||
const long IpcConfigImpl::GetLong(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<long>>>::iterator iter;
|
||||
iter = mCfgMapLong.find(key);
|
||||
|
@ -187,7 +187,7 @@ const long IpcConfig::GetLong(const IpcConfigKey &key)
|
|||
constexpr long UNKNOWN_CONFIG = -1;
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetLong(const IpcConfigKey &key, const long &value)
|
||||
void IpcConfigImpl::SetLong(const IpcConfigKey &key, const long &value)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<long>>>::iterator iter;
|
||||
iter = mCfgMapLong.find(key);
|
||||
|
@ -201,7 +201,7 @@ void IpcConfig::SetLong(const IpcConfigKey &key, const long &value)
|
|||
LogError("Can't find the key.\n");
|
||||
}
|
||||
}
|
||||
const long long IpcConfig::GetLLong(const IpcConfigKey &key)
|
||||
const long long IpcConfigImpl::GetLLong(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<long long>>>::iterator iter;
|
||||
iter = mCfgMapLLong.find(key);
|
||||
|
@ -212,7 +212,7 @@ const long long IpcConfig::GetLLong(const IpcConfigKey &key)
|
|||
constexpr long long UNKNOWN_CONFIG = -1;
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetLLong(const IpcConfigKey &key, const long long &value)
|
||||
void IpcConfigImpl::SetLLong(const IpcConfigKey &key, const long long &value)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<long long>>>::iterator iter;
|
||||
iter = mCfgMapLLong.find(key);
|
||||
|
@ -226,7 +226,7 @@ void IpcConfig::SetLLong(const IpcConfigKey &key, const long long &value)
|
|||
LogError("Can't find the key.\n");
|
||||
}
|
||||
}
|
||||
const char IpcConfig::GetChar(const IpcConfigKey &key)
|
||||
const char IpcConfigImpl::GetChar(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<char>>>::iterator iter;
|
||||
iter = mCfgMapChar.find(key);
|
||||
|
@ -237,7 +237,7 @@ const char IpcConfig::GetChar(const IpcConfigKey &key)
|
|||
constexpr char UNKNOWN_CONFIG = '\0';
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetChar(const IpcConfigKey &key, const char &character)
|
||||
void IpcConfigImpl::SetChar(const IpcConfigKey &key, const char &character)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<char>>>::iterator iter;
|
||||
iter = mCfgMapChar.find(key);
|
||||
|
@ -251,7 +251,7 @@ void IpcConfig::SetChar(const IpcConfigKey &key, const char &character)
|
|||
LogError("Can't find the key.\n");
|
||||
}
|
||||
}
|
||||
const float IpcConfig::GetFloat(const IpcConfigKey &key)
|
||||
const float IpcConfigImpl::GetFloat(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<float>>>::iterator iter;
|
||||
iter = mCfgMapFloat.find(key);
|
||||
|
@ -262,7 +262,7 @@ const float IpcConfig::GetFloat(const IpcConfigKey &key)
|
|||
constexpr float UNKNOWN_CONFIG = -1.00;
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetFloat(const IpcConfigKey &key, const float &value)
|
||||
void IpcConfigImpl::SetFloat(const IpcConfigKey &key, const float &value)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<float>>>::iterator iter;
|
||||
iter = mCfgMapFloat.find(key);
|
||||
|
@ -276,7 +276,7 @@ void IpcConfig::SetFloat(const IpcConfigKey &key, const float &value)
|
|||
LogError("Can't find the key.\n");
|
||||
}
|
||||
}
|
||||
const double IpcConfig::GetDouble(const IpcConfigKey &key)
|
||||
const double IpcConfigImpl::GetDouble(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<double>>>::iterator iter;
|
||||
iter = mCfgMapDouble.find(key);
|
||||
|
@ -287,7 +287,7 @@ const double IpcConfig::GetDouble(const IpcConfigKey &key)
|
|||
constexpr double UNKNOWN_CONFIG = -1.00;
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetDouble(const IpcConfigKey &key, const double &value)
|
||||
void IpcConfigImpl::SetDouble(const IpcConfigKey &key, const double &value)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<double>>>::iterator iter;
|
||||
iter = mCfgMapDouble.find(key);
|
||||
|
@ -301,7 +301,7 @@ void IpcConfig::SetDouble(const IpcConfigKey &key, const double &value)
|
|||
LogError("Can't find the key.\n");
|
||||
}
|
||||
}
|
||||
const long double IpcConfig::GetLongDouble(const IpcConfigKey &key)
|
||||
const long double IpcConfigImpl::GetLongDouble(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::reference_wrapper<long double>>::iterator iter;
|
||||
iter = mCfgMapLongDouble.find(key);
|
||||
|
@ -312,7 +312,7 @@ const long double IpcConfig::GetLongDouble(const IpcConfigKey &key)
|
|||
constexpr long double UNKNOWN_CONFIG = -1.0;
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetLongDouble(const IpcConfigKey &key, const long double &value)
|
||||
void IpcConfigImpl::SetLongDouble(const IpcConfigKey &key, const long double &value)
|
||||
{
|
||||
std::map<IpcConfigKey, std::reference_wrapper<long double>>::iterator iter;
|
||||
iter = mCfgMapLongDouble.find(key);
|
||||
|
@ -324,7 +324,7 @@ void IpcConfig::SetLongDouble(const IpcConfigKey &key, const long double &value)
|
|||
LogError("Can't find the key.\n");
|
||||
}
|
||||
}
|
||||
const bool IpcConfig::GetBool(const IpcConfigKey &key)
|
||||
const bool IpcConfigImpl::GetBool(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<bool>>>::iterator iter;
|
||||
iter = mCfgMapBool.find(key);
|
||||
|
@ -335,7 +335,7 @@ const bool IpcConfig::GetBool(const IpcConfigKey &key)
|
|||
constexpr bool UNKNOWN_CONFIG = false;
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetBool(const IpcConfigKey &key, const bool &value)
|
||||
void IpcConfigImpl::SetBool(const IpcConfigKey &key, const bool &value)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<bool>>>::iterator iter;
|
||||
iter = mCfgMapBool.find(key);
|
||||
|
@ -349,7 +349,7 @@ void IpcConfig::SetBool(const IpcConfigKey &key, const bool &value)
|
|||
LogError("Can't find the key.\n");
|
||||
}
|
||||
}
|
||||
const std::string IpcConfig::GetString(const IpcConfigKey &key)
|
||||
const std::string IpcConfigImpl::GetString(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<CHAR_STRING>>>::iterator iter;
|
||||
iter = mCfgMapString.find(key);
|
||||
|
@ -361,7 +361,7 @@ const std::string IpcConfig::GetString(const IpcConfigKey &key)
|
|||
const std::string UNKNOWN_CONFIG = "undefine";
|
||||
return UNKNOWN_CONFIG;
|
||||
}
|
||||
void IpcConfig::SetString(const IpcConfigKey &key, const std::string string)
|
||||
void IpcConfigImpl::SetString(const IpcConfigKey &key, const std::string string)
|
||||
{
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<CHAR_STRING>>>::iterator iter;
|
||||
iter = mCfgMapString.find(key);
|
||||
|
@ -376,7 +376,7 @@ void IpcConfig::SetString(const IpcConfigKey &key, const std::string string)
|
|||
}
|
||||
}
|
||||
|
||||
void IpcConfig::ReadAllConfigParameters(void)
|
||||
void IpcConfigImpl::ReadAllConfigParameters(void)
|
||||
{
|
||||
StatusCode workModeCode = ConfigGetInt(mCfg, "work_mode", &(mAllData.workMode));
|
||||
if (StatusCodeEqual(workModeCode, "CONFIG_CODE_PARAM_NOT_EXIST")) {
|
|
@ -12,8 +12,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef IPCCONFIG_H
|
||||
#define IPCCONFIG_H
|
||||
#ifndef IPC_CONFIG_IMPL_H
|
||||
#define IPC_CONFIG_IMPL_H
|
||||
#include "ConfigBase.h"
|
||||
#include "IIpcConfig.h"
|
||||
#include "StatusCode.h"
|
||||
|
@ -50,11 +50,11 @@ public:
|
|||
MapInt() = default;
|
||||
~MapInt() = default;
|
||||
};
|
||||
class IpcConfig : public IIpcConfig
|
||||
class IpcConfigImpl : public IIpcConfig
|
||||
{
|
||||
public:
|
||||
IpcConfig();
|
||||
virtual ~IpcConfig() = default;
|
||||
IpcConfigImpl();
|
||||
virtual ~IpcConfigImpl() = default;
|
||||
const StatusCode Init(void) override;
|
||||
const StatusCode UnInit(void) override;
|
||||
const StatusCode ConfigFileSave(void) override;
|
|
@ -14,29 +14,41 @@
|
|||
*/
|
||||
#include "IpcConfigMakePtr.h"
|
||||
#include "ILog.h"
|
||||
#include "IpcConfig.h"
|
||||
bool CreateIpcConfig(void)
|
||||
#include "IpcConfigImpl.h"
|
||||
bool CreateIpcConfigModule(void)
|
||||
{
|
||||
auto instance = std::make_shared<IIpcConfig>();
|
||||
StatusCode code = IpcConfigMakePtr::GetInstance()->CreateIpcConfig(instance);
|
||||
if (IsCodeOK(code)) {
|
||||
LogInfo("CreateIpcConfig is ok.\n");
|
||||
LogInfo("CreateIpcConfigModule is ok.\n");
|
||||
IIpcConfig::GetInstance(&instance);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool DestroyIpcConfigModule(void)
|
||||
{
|
||||
auto instance = std::make_shared<IIpcConfig>();
|
||||
IIpcConfig::GetInstance(&instance);
|
||||
return true;
|
||||
}
|
||||
std::shared_ptr<IpcConfigMakePtr> &IpcConfigMakePtr::GetInstance(std::shared_ptr<IpcConfigMakePtr> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<IpcConfigMakePtr>();
|
||||
if (impl) {
|
||||
instance = *impl;
|
||||
if (instance.use_count() == 1) {
|
||||
LogInfo("Instance changed succeed.\n");
|
||||
instance = *impl;
|
||||
}
|
||||
else {
|
||||
LogError("Can't changing the instance becase of using by some one.\n");
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
const StatusCode IpcConfigMakePtr::CreateIpcConfig(std::shared_ptr<IIpcConfig> &impl)
|
||||
{
|
||||
auto tmp = std::make_shared<IpcConfig>();
|
||||
auto tmp = std::make_shared<IpcConfigImpl>();
|
||||
impl = tmp;
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace IpcConfigTest
|
|||
TEST(IpcConfigTest, Demo)
|
||||
{
|
||||
CreateLogModule();
|
||||
CreateIpcConfig();
|
||||
CreateIpcConfigModule();
|
||||
ILogInit(LOG_INSTANCE_TYPE_END);
|
||||
IIpcConfig::GetInstance()->Init();
|
||||
|
||||
|
|
|
@ -945,8 +945,9 @@ TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_AUTO_OtherSideGetIntervalSt
|
|||
recvData->mDataRecvReply.mHour = 10;
|
||||
recvData->mDataRecvReply.mMin = 10;
|
||||
recvData->mDataRecvReply.mSecond = 10;
|
||||
recv->ReplyFinished(true);
|
||||
}
|
||||
recv->ReplyFinished(true);
|
||||
recv->ReplyFinished(false);
|
||||
}
|
||||
};
|
||||
IMcuManager::GetInstance()->Init();
|
||||
|
@ -982,8 +983,9 @@ TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_AUTO_OtherSideGetIntervalSt
|
|||
recvData->mDataRecvReply.mHour = 10;
|
||||
recvData->mDataRecvReply.mMin = 10;
|
||||
recvData->mDataRecvReply.mSecond = 10;
|
||||
recv->ReplyFinished(true);
|
||||
}
|
||||
recv->ReplyFinished(true);
|
||||
recv->ReplyFinished(false);
|
||||
}
|
||||
};
|
||||
IMcuManager::GetInstance()->Init();
|
||||
|
@ -1017,8 +1019,9 @@ TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_AUTO_OtherSideGetDateTime)
|
|||
recvData->mDataRecvReply.mHour = 10;
|
||||
recvData->mDataRecvReply.mMin = 10;
|
||||
recvData->mDataRecvReply.mSecond = 10;
|
||||
recv->ReplyFinished(true);
|
||||
}
|
||||
recv->ReplyFinished(true);
|
||||
recv->ReplyFinished(false);
|
||||
}
|
||||
};
|
||||
IMcuManager::GetInstance()->Init();
|
||||
|
@ -1057,8 +1060,9 @@ TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_AUTO_OtherSideGetDateTime2)
|
|||
recvData->mDataRecvReply.mHour = 10;
|
||||
recvData->mDataRecvReply.mMin = 10;
|
||||
recvData->mDataRecvReply.mSecond = 10;
|
||||
recv->ReplyFinished(true);
|
||||
}
|
||||
recv->ReplyFinished(true);
|
||||
recv->ReplyFinished(false);
|
||||
}
|
||||
};
|
||||
IMcuManager::GetInstance()->Init();
|
||||
|
@ -1087,8 +1091,9 @@ TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_AUTO_OtherSideGetPirSensiti
|
|||
EXPECT_NE(recvData, nullptr) << "recvData is not McuGetPirSensitivity.";
|
||||
if (recvData) {
|
||||
recvData->mDataRecvReply.mSensitivity = 9;
|
||||
recv->ReplyFinished(true);
|
||||
}
|
||||
recv->ReplyFinished(true);
|
||||
recv->ReplyFinished(false);
|
||||
}
|
||||
};
|
||||
IMcuManager::GetInstance()->Init();
|
||||
|
@ -1122,8 +1127,9 @@ TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_AUTO_OtherSideGetPirSensiti
|
|||
EXPECT_NE(recvData, nullptr) << "recvData is not McuGetPirSensitivity.";
|
||||
if (recvData) {
|
||||
recvData->mDataRecvReply.mSensitivity = 9;
|
||||
recv->ReplyFinished(true);
|
||||
}
|
||||
recv->ReplyFinished(true);
|
||||
recv->ReplyFinished(false);
|
||||
}
|
||||
};
|
||||
IMcuManager::GetInstance()->Init();
|
||||
|
|
Loading…
Reference in New Issue
Block a user