From c25e185c93a145862ef7cfee452b843a4295da90 Mon Sep 17 00:00:00 2001 From: jas <1790731762@qq.com> Date: Sat, 16 Dec 2023 22:42:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[zhoulongyu]:=20=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=BA=93=E6=95=B0=E6=8D=AE:=20=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F,=E8=BF=9E=E6=8B=8D,=E8=BF=9E=E6=8B=8D?= =?UTF-8?q?=E9=97=B4=E9=9A=94,=E8=A7=86=E9=A2=91=E5=A4=A7=E5=B0=8F;=20?= =?UTF-8?q?=E5=88=86=E8=BE=A8=E7=8E=87(=E9=9C=80=E8=A6=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware/IpcConfig/include/IIpcConfig.h | 33 +++++++- middleware/IpcConfig/src/IpcConfig.cpp | 80 ++++++++++++++----- middleware/IpcConfig/src/IpcConfig.h | 12 ++- .../IpcConfig/src/IpcConfig_Test.cpp | 34 +++++--- 4 files changed, 122 insertions(+), 37 deletions(-) diff --git a/middleware/IpcConfig/include/IIpcConfig.h b/middleware/IpcConfig/include/IIpcConfig.h index 81f211b..8159bec 100644 --- a/middleware/IpcConfig/include/IIpcConfig.h +++ b/middleware/IpcConfig/include/IIpcConfig.h @@ -21,17 +21,46 @@ enum class IpcConfigKey { - TEST_NUM = 0, + KEY_WORK_MODE = 0, + KEY_CONTINUOUS_SHOT, + KEY_BURST_PHOTO_INTERVAL, + KEY_IMGAE_SIZE, + KEY_VIDEO_SIZE, TEST_SHORT, TEST_LONG, TEST_LLONG, TEST_CHAR, TEST_BOOL, TEST_FLOAT, - TEST_DOUBLE, TEST_STRING, END }; +enum WorkMode +{ + WORK_MODE_PIC = 0, + WORK_MODE_PIC_VIDEO, + WORK_MODE_END, +}; +enum ContinuousShot +{ + CONTINUOUS_SHOT_ONE_PIC = 1, + CONTINUOUS_SHOT_TWO_PIC, + CONTINUOUS_SHOT_THREE_PIC, + CONTINUOUS_SHOT_END, +}; +enum BurstPhotoInterval +{ + BURST_PHOTO_INTERVAL_MIN = 0, + BURST_PHOTO_INTERVAL_DEFAULT = 5, + BURST_PHOTO_INTERVAL_MAX = 99, + BURST_PHOTO_INTERVAL_END, +}; +enum VideoSize +{ + VIDEO_SIZE_10 = 10, + VIDEO_SIZE_15 = 15, + VIDEO_SIZE_END, +}; class IIpcConfig { diff --git a/middleware/IpcConfig/src/IpcConfig.cpp b/middleware/IpcConfig/src/IpcConfig.cpp index d30494c..40c28e6 100644 --- a/middleware/IpcConfig/src/IpcConfig.cpp +++ b/middleware/IpcConfig/src/IpcConfig.cpp @@ -22,9 +22,27 @@ IpcConfig::IpcConfig() { mCfgChanged = CONFIG_HAS_NOT_CHANGED; - std::map> innerMapInt; - innerMapInt.insert(std::make_pair("test_num", std::reference_wrapper(mAllData.testNum))); - mCfgMapInt.insert(std::make_pair(IpcConfigKey::TEST_NUM, innerMapInt)); + std::map> innerMapWorkMode; + innerMapWorkMode.insert(std::make_pair("work_mode", std::reference_wrapper(mAllData.workMode))); + mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_WORK_MODE, innerMapWorkMode)); + + std::map> innerMapContinuousShot; + innerMapContinuousShot.insert( + std::make_pair("continuous_shot", std::reference_wrapper(mAllData.continuousShot))); + mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_CONTINUOUS_SHOT, innerMapContinuousShot)); + + std::map> innerMapBurstPhotoInterval; + innerMapBurstPhotoInterval.insert( + std::make_pair("burst_photo_interval", std::reference_wrapper(mAllData.burstPhotoInterval))); + mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_BURST_PHOTO_INTERVAL, innerMapBurstPhotoInterval)); + + std::map> innerMapImageSize; + innerMapImageSize.insert(std::make_pair("image_size", std::reference_wrapper(mAllData.imageSize))); + mCfgMapDouble.insert(std::make_pair(IpcConfigKey::KEY_IMGAE_SIZE, innerMapImageSize)); + + std::map> innerMapVideoSize; + innerMapVideoSize.insert(std::make_pair("video_size", std::reference_wrapper(mAllData.videoSize))); + mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_VIDEO_SIZE, innerMapVideoSize)); std::map> innerMapShort; innerMapShort.insert(std::make_pair("test_short", std::reference_wrapper(mAllData.testShort))); @@ -50,10 +68,6 @@ IpcConfig::IpcConfig() innerMapFloat.insert(std::make_pair("test_float", std::reference_wrapper(mAllData.testFloat))); mCfgMapFloat.insert(std::make_pair(IpcConfigKey::TEST_FLOAT, innerMapFloat)); - std::map> innerMapDouble; - innerMapDouble.insert(std::make_pair("test_double", std::reference_wrapper(mAllData.testDouble))); - mCfgMapDouble.insert(std::make_pair(IpcConfigKey::TEST_DOUBLE, innerMapDouble)); - std::map> innerMapString; innerMapString.insert(std::make_pair("test_string", std::reference_wrapper(mAllData.testString))); mCfgMapString.insert(std::make_pair(IpcConfigKey::TEST_STRING, innerMapString)); @@ -332,13 +346,44 @@ void IpcConfig::SetString(const IpcConfigKey &key, const std::string string) void IpcConfig::ReadAllConfigParameters(void) { - StatusCode code = ConfigGetInt(mCfg, "test_num", &(mAllData.testNum)); - if (StatusCodeEqual(code, "CONFIG_CODE_PARAM_NOT_EXIST")) { - LogWarning("test_num doesn't exist, will make it as default.\n"); + StatusCode workModeCode = ConfigGetInt(mCfg, "work_mode", &(mAllData.workMode)); + if (StatusCodeEqual(workModeCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("work_mode doesn't exist, will make it as default.\n"); mCfgChanged = CONFIG_HAS_CHANGED; - constexpr int DEFAULT_TEST_NUM = 10; - mAllData.testNum = DEFAULT_TEST_NUM; - ConfigSetInt(mCfg, "test_num", mAllData.testNum); + mAllData.workMode = WORK_MODE_PIC; + ConfigSetInt(mCfg, "work_mode", mAllData.workMode); + } + + StatusCode continuousShotCode = ConfigGetInt(mCfg, "continuous_shot", &(mAllData.continuousShot)); + if (StatusCodeEqual(continuousShotCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("continuous_shot doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + mAllData.continuousShot = CONTINUOUS_SHOT_ONE_PIC; + ConfigSetInt(mCfg, "continuous_shot", mAllData.continuousShot); + } + + StatusCode burstPhotoIntervalCode = ConfigGetInt(mCfg, "burst_photo_interval", &(mAllData.burstPhotoInterval)); + if (StatusCodeEqual(burstPhotoIntervalCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("burst_photo_interval doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + mAllData.burstPhotoInterval = BURST_PHOTO_INTERVAL_DEFAULT; + ConfigSetInt(mCfg, "burst_photo_interval", mAllData.burstPhotoInterval); + } + + StatusCode imageSizeCode = ConfigGetDouble(mCfg, "image_size", &(mAllData.imageSize)); + if (StatusCodeEqual(imageSizeCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("image_size doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + mAllData.imageSize = 410.014; + ConfigSetDouble(mCfg, "image_size", mAllData.imageSize); + } + + StatusCode videoSizeCode = ConfigGetInt(mCfg, "video_size", &(mAllData.videoSize)); + if (StatusCodeEqual(videoSizeCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("video_size doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + mAllData.videoSize = VIDEO_SIZE_15; + ConfigSetInt(mCfg, "video_size", mAllData.videoSize); } StatusCode shortCode = ConfigGetShort(mCfg, "test_short", &(mAllData.testShort)); @@ -395,15 +440,6 @@ void IpcConfig::ReadAllConfigParameters(void) ConfigSetFloat(mCfg, "test_float", mAllData.testFloat); } - StatusCode doubleCode = ConfigGetDouble(mCfg, "test_double", &(mAllData.testDouble)); - if (StatusCodeEqual(doubleCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { - LogWarning("test_double doesn't exist, will make it as default.\n"); - mCfgChanged = CONFIG_HAS_CHANGED; - constexpr double DEFAULT_TEST_DOUBLE_NUM = 3.123456; - mAllData.testDouble = DEFAULT_TEST_DOUBLE_NUM; - ConfigSetDouble(mCfg, "test_double", mAllData.testDouble); - } - const char *testString = NULL; StatusCode stringCode = ConfigGetString(mCfg, "test_string", &(testString)); if (StatusCodeEqual(stringCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { diff --git a/middleware/IpcConfig/src/IpcConfig.h b/middleware/IpcConfig/src/IpcConfig.h index 73008bb..c064c2e 100644 --- a/middleware/IpcConfig/src/IpcConfig.h +++ b/middleware/IpcConfig/src/IpcConfig.h @@ -25,14 +25,18 @@ constexpr bool CONFIG_HAS_NOT_CHANGED = false; typedef char CHAR_STRING[256]; typedef struct Config_s { - int testNum; + int workMode; + int continuousShot; + int burstPhotoInterval; + int videoSize; + double imageSize; + short testShort; - long testLong; - long long testLLong; char testChar; bool testBool; + long testLong; + long long testLLong; float testFloat; - double testDouble; CHAR_STRING testString; } Config_s; class MapInt diff --git a/test/middleware/IpcConfig/src/IpcConfig_Test.cpp b/test/middleware/IpcConfig/src/IpcConfig_Test.cpp index eae0604..5891586 100644 --- a/test/middleware/IpcConfig/src/IpcConfig_Test.cpp +++ b/test/middleware/IpcConfig/src/IpcConfig_Test.cpp @@ -11,10 +11,31 @@ TEST(IpcConfigTest, Demo) CreateIpcConfig(); ILogInit(LOG_INSTANCE_TYPE_END); IIpcConfig::GetInstance()->Init(); - int testNum = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::TEST_NUM); - LogInfo("Get testNum = %d\n", testNum); - const int numInt = 999; - IIpcConfig::GetInstance()->SetInt(IpcConfigKey::TEST_NUM, numInt); + + int workMode = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_WORK_MODE); + LogInfo("Get workMode = %d\n", workMode); + workMode = WORK_MODE_PIC_VIDEO; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_WORK_MODE, workMode); + + int continuousShot = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_CONTINUOUS_SHOT); + LogInfo("Get continuousShot = %d\n", continuousShot); + continuousShot = CONTINUOUS_SHOT_TWO_PIC; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_CONTINUOUS_SHOT, continuousShot); + + int burstPhotoInterval = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_BURST_PHOTO_INTERVAL); + LogInfo("Get burstPhotoInterval = %d\n", burstPhotoInterval); + burstPhotoInterval = BURST_PHOTO_INTERVAL_DEFAULT; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_BURST_PHOTO_INTERVAL, burstPhotoInterval); + + double imageSize = IIpcConfig::GetInstance()->GetDouble(IpcConfigKey::KEY_IMGAE_SIZE); + LogInfo("Get image_size = %lf\n", imageSize); + imageSize = 320.023; + IIpcConfig::GetInstance()->SetDouble(IpcConfigKey::KEY_IMGAE_SIZE, imageSize); + + int videoSize = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_VIDEO_SIZE); + LogInfo("Get video_size = %d\n", videoSize); + videoSize = VIDEO_SIZE_10; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_VIDEO_SIZE, videoSize); short testShort = IIpcConfig::GetInstance()->GetShort(IpcConfigKey::TEST_SHORT); LogInfo("Get test_short = %d\n", testShort); @@ -46,11 +67,6 @@ TEST(IpcConfigTest, Demo) const float numFloat = 1.123456; IIpcConfig::GetInstance()->SetFloat(IpcConfigKey::TEST_FLOAT, numFloat); - double testDouble = IIpcConfig::GetInstance()->GetDouble(IpcConfigKey::TEST_DOUBLE); - LogInfo("Get test_double = %lf\n", testDouble); - const double numDouble = 123456789.123456; - IIpcConfig::GetInstance()->SetDouble(IpcConfigKey::TEST_DOUBLE, numDouble); - const std::string testString = IIpcConfig::GetInstance()->GetString(IpcConfigKey::TEST_STRING); LogInfo("Get testString = %s\n", testString.c_str()); const std::string string = "define"; From 985ae0edeff1662b13b42de23ec76846f53bab55 Mon Sep 17 00:00:00 2001 From: jas <1790731762@qq.com> Date: Sun, 17 Dec 2023 11:41:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[zhoulongyu]:=20=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=BA=93=E6=95=B0=E6=8D=AE:=20=E7=BA=A2=E5=A4=96?= =?UTF-8?q?=E7=81=AF=E5=8A=9F=E7=8E=87,PIR=E7=81=B5=E6=95=8F=E5=BA=A6,=20?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E5=BE=AA=E7=8E=AF=E5=BC=80=E5=85=B3,=20?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=87=BA=E5=8E=82,=20=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96SDk=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware/IpcConfig/include/IIpcConfig.h | 28 ++++++ middleware/IpcConfig/src/IpcConfig.cpp | 92 ++++++++++++++++--- middleware/IpcConfig/src/IpcConfig.h | 8 +- .../IpcConfig/src/IpcConfig_Test.cpp | 35 ++++++- 4 files changed, 143 insertions(+), 20 deletions(-) diff --git a/middleware/IpcConfig/include/IIpcConfig.h b/middleware/IpcConfig/include/IIpcConfig.h index 8159bec..e2e79e0 100644 --- a/middleware/IpcConfig/include/IIpcConfig.h +++ b/middleware/IpcConfig/include/IIpcConfig.h @@ -26,6 +26,12 @@ enum class IpcConfigKey KEY_BURST_PHOTO_INTERVAL, KEY_IMGAE_SIZE, KEY_VIDEO_SIZE, + KEY_INFRARED_LAMP_POWER, + KEY_DELAYED, + KEY_PIR_SENSITIVITY, + KEY_STORAGE_LOOP_SWITCH, + KEY_FACTORY_RESET_FLAG, + KEY_FORMATTING_SD_CARD, TEST_SHORT, TEST_LONG, TEST_LLONG, @@ -62,6 +68,28 @@ enum VideoSize VIDEO_SIZE_END, }; +enum InfraredIampPower +{ + INFRARED_IAMP_POWER_LOW = 0, + INFRARED_IAMP_POWER_MID, + INFRARED_IAMP_POWER_HIGH, + INFRARED_IAMP_POWER_END, +}; +enum Delayed +{ + DELAYED_MIN = 0, + DELAYED_DEFAULT = 5, + DELAYED_MAX = 99, + DELAYED_END, +}; +enum PirSensitivity +{ + PIR_SENSITIVITY_MIN = 0, + PIR_SENSITIVITY_DEFAULT = 5, + PIR_SENSITIVITY_MAX = 9, + PIR_SENSITIVITY_END, +}; + class IIpcConfig { public: diff --git a/middleware/IpcConfig/src/IpcConfig.cpp b/middleware/IpcConfig/src/IpcConfig.cpp index 40c28e6..e5503eb 100644 --- a/middleware/IpcConfig/src/IpcConfig.cpp +++ b/middleware/IpcConfig/src/IpcConfig.cpp @@ -44,6 +44,34 @@ IpcConfig::IpcConfig() innerMapVideoSize.insert(std::make_pair("video_size", std::reference_wrapper(mAllData.videoSize))); mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_VIDEO_SIZE, innerMapVideoSize)); + std::map> innerMapInfraredLampPower; + innerMapInfraredLampPower.insert( + std::make_pair("infrared_lamp_power", std::reference_wrapper(mAllData.infraredIampPower))); + mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_INFRARED_LAMP_POWER, innerMapInfraredLampPower)); + + std::map> innerMapDelayed; + innerMapDelayed.insert(std::make_pair("delayed", std::reference_wrapper(mAllData.delayed))); + mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_DELAYED, innerMapDelayed)); + + std::map> innerMapPirSensitivity; + innerMapPirSensitivity.insert( + std::make_pair("pir_sensitivity", std::reference_wrapper(mAllData.pirSensitivity))); + mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_PIR_SENSITIVITY, innerMapPirSensitivity)); + + std::map> innerMapStorageLoopSwitch; + innerMapStorageLoopSwitch.insert( + std::make_pair("storage_loop_switch", std::reference_wrapper(mAllData.storageLoopSwitch))); + mCfgMapBool.insert(std::make_pair(IpcConfigKey::KEY_STORAGE_LOOP_SWITCH, innerMapStorageLoopSwitch)); + + std::map> innerMapFactoryReset; + innerMapFactoryReset.insert(std::make_pair("factory_reset", std::reference_wrapper(mAllData.factoryReset))); + mCfgMapBool.insert(std::make_pair(IpcConfigKey::KEY_FACTORY_RESET_FLAG, innerMapFactoryReset)); + + std::map> innerMapFormattingSDCard; + innerMapFormattingSDCard.insert( + std::make_pair("formatting_SD_card", std::reference_wrapper(mAllData.formattingSDCard))); + mCfgMapBool.insert(std::make_pair(IpcConfigKey::KEY_FORMATTING_SD_CARD, innerMapFormattingSDCard)); + std::map> innerMapShort; innerMapShort.insert(std::make_pair("test_short", std::reference_wrapper(mAllData.testShort))); mCfgMapShort.insert(std::make_pair(IpcConfigKey::TEST_SHORT, innerMapShort)); @@ -60,10 +88,6 @@ IpcConfig::IpcConfig() innerMapChar.insert(std::make_pair("test_char", std::reference_wrapper(mAllData.testChar))); mCfgMapChar.insert(std::make_pair(IpcConfigKey::TEST_CHAR, innerMapChar)); - std::map> innerMapBool; - innerMapBool.insert(std::make_pair("test_bool", std::reference_wrapper(mAllData.testBool))); - mCfgMapBool.insert(std::make_pair(IpcConfigKey::TEST_BOOL, innerMapBool)); - std::map> innerMapFloat; innerMapFloat.insert(std::make_pair("test_float", std::reference_wrapper(mAllData.testFloat))); mCfgMapFloat.insert(std::make_pair(IpcConfigKey::TEST_FLOAT, innerMapFloat)); @@ -386,6 +410,57 @@ void IpcConfig::ReadAllConfigParameters(void) ConfigSetInt(mCfg, "video_size", mAllData.videoSize); } + StatusCode infraredIampPowerCode = ConfigGetInt(mCfg, "infrared_lamp_power", &(mAllData.infraredIampPower)); + if (StatusCodeEqual(infraredIampPowerCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("infrared_lamp_power doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + mAllData.infraredIampPower = INFRARED_IAMP_POWER_MID; + ConfigSetInt(mCfg, "infrared_lamp_power", mAllData.infraredIampPower); + } + + StatusCode delayedCode = ConfigGetInt(mCfg, "delayed", &(mAllData.delayed)); + if (StatusCodeEqual(delayedCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("delayed doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + mAllData.delayed = DELAYED_DEFAULT; + ConfigSetInt(mCfg, "delayed", mAllData.delayed); + } + + StatusCode pirSensitivityCode = ConfigGetInt(mCfg, "pir_sensitivity", &(mAllData.pirSensitivity)); + if (StatusCodeEqual(pirSensitivityCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("pir_sensitivity doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + mAllData.pirSensitivity = PIR_SENSITIVITY_DEFAULT; + ConfigSetInt(mCfg, "pir_sensitivity", mAllData.pirSensitivity); + } + + StatusCode storageLoopSwitchCode = ConfigGetBool(mCfg, "storage_loop_switch", &(mAllData.storageLoopSwitch)); + if (StatusCodeEqual(storageLoopSwitchCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("storage_loop_switch doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + constexpr bool storageLoopSwitch = true; + mAllData.storageLoopSwitch = storageLoopSwitch; + ConfigSetBool(mCfg, "storage_loop_switch", mAllData.storageLoopSwitch); + } + + StatusCode factoryResetCode = ConfigGetBool(mCfg, "factory_reset", &(mAllData.factoryReset)); + if (StatusCodeEqual(factoryResetCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("factory_resetCode doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + constexpr bool factoryReset = true; + mAllData.factoryReset = factoryReset; + ConfigSetBool(mCfg, "factory_reset", mAllData.factoryReset); + } + + StatusCode formattingSDCardCode = ConfigGetBool(mCfg, "formatting_SD_card", &(mAllData.formattingSDCard)); + if (StatusCodeEqual(formattingSDCardCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("formatting_SD_card doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + constexpr bool formattingSDCard = true; + mAllData.formattingSDCard = formattingSDCard; + ConfigSetBool(mCfg, "formatting_SD_card", mAllData.formattingSDCard); + } + StatusCode shortCode = ConfigGetShort(mCfg, "test_short", &(mAllData.testShort)); if (StatusCodeEqual(shortCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { LogWarning("test_short doesn't exist, will make it as default.\n"); @@ -422,15 +497,6 @@ void IpcConfig::ReadAllConfigParameters(void) ConfigSetChar(mCfg, "test_char", mAllData.testChar); } - StatusCode boolCode = ConfigGetBool(mCfg, "test_bool", &(mAllData.testBool)); - if (StatusCodeEqual(boolCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { - LogWarning("test_bool doesn't exist, will make it as default.\n"); - mCfgChanged = CONFIG_HAS_CHANGED; - constexpr bool DEFAULT_TEST_BOOL_NUM = true; - mAllData.testBool = DEFAULT_TEST_BOOL_NUM; - ConfigSetBool(mCfg, "test_bool", mAllData.testBool); - } - StatusCode floatCode = ConfigGetFloat(mCfg, "test_float", &(mAllData.testFloat)); if (StatusCodeEqual(floatCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { LogWarning("test_float doesn't exist, will make it as default.\n"); diff --git a/middleware/IpcConfig/src/IpcConfig.h b/middleware/IpcConfig/src/IpcConfig.h index c064c2e..ee354c7 100644 --- a/middleware/IpcConfig/src/IpcConfig.h +++ b/middleware/IpcConfig/src/IpcConfig.h @@ -25,15 +25,19 @@ constexpr bool CONFIG_HAS_NOT_CHANGED = false; typedef char CHAR_STRING[256]; typedef struct Config_s { + bool storageLoopSwitch; + bool factoryReset; + bool formattingSDCard; int workMode; int continuousShot; int burstPhotoInterval; int videoSize; + int infraredIampPower; + int delayed; + int pirSensitivity; double imageSize; - short testShort; char testChar; - bool testBool; long testLong; long long testLLong; float testFloat; diff --git a/test/middleware/IpcConfig/src/IpcConfig_Test.cpp b/test/middleware/IpcConfig/src/IpcConfig_Test.cpp index 5891586..5705a82 100644 --- a/test/middleware/IpcConfig/src/IpcConfig_Test.cpp +++ b/test/middleware/IpcConfig/src/IpcConfig_Test.cpp @@ -37,6 +37,36 @@ TEST(IpcConfigTest, Demo) videoSize = VIDEO_SIZE_10; IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_VIDEO_SIZE, videoSize); + int infraredIampPower = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_INFRARED_LAMP_POWER); + LogInfo("Get infrared_lamp_power = %d\n", infraredIampPower); + infraredIampPower = INFRARED_IAMP_POWER_LOW; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_INFRARED_LAMP_POWER, infraredIampPower); + + int delayed = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_DELAYED); + LogInfo("Get delayed = %d\n", delayed); + delayed = DELAYED_MAX; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_DELAYED, delayed); + + int pirSensitivity = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_PIR_SENSITIVITY); + LogInfo("Get pir_sensitivity = %d\n", pirSensitivity); + pirSensitivity = PIR_SENSITIVITY_MAX; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_PIR_SENSITIVITY, pirSensitivity); + + bool storageLoopSwitch = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::KEY_STORAGE_LOOP_SWITCH); + LogInfo("Get storage_loop_switch = %d\n", storageLoopSwitch); + storageLoopSwitch = false; + IIpcConfig::GetInstance()->SetBool(IpcConfigKey::KEY_STORAGE_LOOP_SWITCH, storageLoopSwitch); + + bool factoryReset = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::KEY_FACTORY_RESET_FLAG); + LogInfo("Get factory_reset = %d\n", factoryReset); + factoryReset = false; + IIpcConfig::GetInstance()->SetBool(IpcConfigKey::KEY_FACTORY_RESET_FLAG, factoryReset); + + bool formattingSDCard = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::KEY_FORMATTING_SD_CARD); + LogInfo("Get formatting_SD_card = %d\n", formattingSDCard); + formattingSDCard = false; + IIpcConfig::GetInstance()->SetBool(IpcConfigKey::KEY_FORMATTING_SD_CARD, formattingSDCard); + short testShort = IIpcConfig::GetInstance()->GetShort(IpcConfigKey::TEST_SHORT); LogInfo("Get test_short = %d\n", testShort); const short numShort = 888; @@ -57,11 +87,6 @@ TEST(IpcConfigTest, Demo) const char numChar = 'A'; IIpcConfig::GetInstance()->SetChar(IpcConfigKey::TEST_CHAR, numChar); - bool testBool = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::TEST_BOOL); - LogInfo("Get test_bool = %d\n", testBool); - const bool numBool = false; - IIpcConfig::GetInstance()->SetBool(IpcConfigKey::TEST_BOOL, numBool); - float testFloat = IIpcConfig::GetInstance()->GetFloat(IpcConfigKey::TEST_FLOAT); LogInfo("Get test_float = %lf\n", testFloat); const float numFloat = 1.123456; From d47aff4e473eb80b16e91178658383d15eaace71 Mon Sep 17 00:00:00 2001 From: jas <1790731762@qq.com> Date: Sun, 17 Dec 2023 20:37:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[zhoulongyu]:=20=E6=B7=BB=E5=8A=A0=E5=92=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE=E5=BA=93=E6=95=B0=E6=8D=AE?= =?UTF-8?q?:=20=E5=9B=BE=E7=89=87=E5=A4=A7=E5=B0=8F,=20=E5=A4=9C=E9=97=B4?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F,=20=E5=B7=A5=E4=BD=9C=E5=8C=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware/IpcConfig/include/IIpcConfig.h | 3 +- middleware/IpcConfig/src/IpcConfig.cpp | 69 ++++++++++----- middleware/IpcConfig/src/IpcConfig.h | 7 +- .../IpcConfig/src/IpcConfig_Test.cpp | 83 ++++++++++--------- 4 files changed, 96 insertions(+), 66 deletions(-) diff --git a/middleware/IpcConfig/include/IIpcConfig.h b/middleware/IpcConfig/include/IIpcConfig.h index e2e79e0..2f271d6 100644 --- a/middleware/IpcConfig/include/IIpcConfig.h +++ b/middleware/IpcConfig/include/IIpcConfig.h @@ -32,13 +32,14 @@ enum class IpcConfigKey KEY_STORAGE_LOOP_SWITCH, KEY_FACTORY_RESET_FLAG, KEY_FORMATTING_SD_CARD, + KEY_DARK_MODE, + KEY_WORK_INTERVAL, TEST_SHORT, TEST_LONG, TEST_LLONG, TEST_CHAR, TEST_BOOL, TEST_FLOAT, - TEST_STRING, END }; enum WorkMode diff --git a/middleware/IpcConfig/src/IpcConfig.cpp b/middleware/IpcConfig/src/IpcConfig.cpp index e5503eb..50cb272 100644 --- a/middleware/IpcConfig/src/IpcConfig.cpp +++ b/middleware/IpcConfig/src/IpcConfig.cpp @@ -36,9 +36,9 @@ IpcConfig::IpcConfig() std::make_pair("burst_photo_interval", std::reference_wrapper(mAllData.burstPhotoInterval))); mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_BURST_PHOTO_INTERVAL, innerMapBurstPhotoInterval)); - std::map> innerMapImageSize; - innerMapImageSize.insert(std::make_pair("image_size", std::reference_wrapper(mAllData.imageSize))); - mCfgMapDouble.insert(std::make_pair(IpcConfigKey::KEY_IMGAE_SIZE, innerMapImageSize)); + std::map> innerMapImageSize; + innerMapImageSize.insert(std::make_pair("image_size", std::reference_wrapper(mAllData.imageSize))); + mCfgMapString.insert(std::make_pair(IpcConfigKey::KEY_IMGAE_SIZE, innerMapImageSize)); std::map> innerMapVideoSize; innerMapVideoSize.insert(std::make_pair("video_size", std::reference_wrapper(mAllData.videoSize))); @@ -72,6 +72,15 @@ IpcConfig::IpcConfig() std::make_pair("formatting_SD_card", std::reference_wrapper(mAllData.formattingSDCard))); mCfgMapBool.insert(std::make_pair(IpcConfigKey::KEY_FORMATTING_SD_CARD, innerMapFormattingSDCard)); + std::map> innerMapDrakMode; + innerMapDrakMode.insert(std::make_pair("dark_mode", std::reference_wrapper(mAllData.darkMode))); + mCfgMapString.insert(std::make_pair(IpcConfigKey::KEY_DARK_MODE, innerMapDrakMode)); + + std::map> innerMapWorkInterval; + innerMapWorkInterval.insert( + std::make_pair("work_interval", std::reference_wrapper(mAllData.workingInterval))); + mCfgMapString.insert(std::make_pair(IpcConfigKey::KEY_WORK_INTERVAL, innerMapWorkInterval)); + std::map> innerMapShort; innerMapShort.insert(std::make_pair("test_short", std::reference_wrapper(mAllData.testShort))); mCfgMapShort.insert(std::make_pair(IpcConfigKey::TEST_SHORT, innerMapShort)); @@ -91,10 +100,6 @@ IpcConfig::IpcConfig() std::map> innerMapFloat; innerMapFloat.insert(std::make_pair("test_float", std::reference_wrapper(mAllData.testFloat))); mCfgMapFloat.insert(std::make_pair(IpcConfigKey::TEST_FLOAT, innerMapFloat)); - - std::map> innerMapString; - innerMapString.insert(std::make_pair("test_string", std::reference_wrapper(mAllData.testString))); - mCfgMapString.insert(std::make_pair(IpcConfigKey::TEST_STRING, innerMapString)); } const StatusCode IpcConfig::Init(void) { @@ -394,12 +399,17 @@ void IpcConfig::ReadAllConfigParameters(void) ConfigSetInt(mCfg, "burst_photo_interval", mAllData.burstPhotoInterval); } - StatusCode imageSizeCode = ConfigGetDouble(mCfg, "image_size", &(mAllData.imageSize)); + const char *imageSizeString = NULL; + StatusCode imageSizeCode = ConfigGetString(mCfg, "image_size", &(imageSizeString)); if (StatusCodeEqual(imageSizeCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { LogWarning("image_size doesn't exist, will make it as default.\n"); mCfgChanged = CONFIG_HAS_CHANGED; - mAllData.imageSize = 410.014; - ConfigSetDouble(mCfg, "image_size", mAllData.imageSize); + char defaultImageSize[] = "320*320"; + strncpy(mAllData.imageSize, defaultImageSize, sizeof(mAllData.imageSize)); + ConfigSetString(mCfg, "image_size", mAllData.imageSize); + } + else { + strncpy(mAllData.imageSize, imageSizeString, sizeof(mAllData.imageSize)); } StatusCode videoSizeCode = ConfigGetInt(mCfg, "video_size", &(mAllData.videoSize)); @@ -461,6 +471,32 @@ void IpcConfig::ReadAllConfigParameters(void) ConfigSetBool(mCfg, "formatting_SD_card", mAllData.formattingSDCard); } + const char *darkModeString = NULL; + StatusCode darkModeCode = ConfigGetString(mCfg, "dark_mode", &(darkModeString)); + if (StatusCodeEqual(darkModeCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("dark_mode doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + char defaultDarkMode[] = "19:00:00-07:00:00"; + strncpy(mAllData.darkMode, defaultDarkMode, sizeof(mAllData.darkMode)); + ConfigSetString(mCfg, "dark_mode", mAllData.darkMode); + } + else { + strncpy(mAllData.darkMode, darkModeString, sizeof(mAllData.darkMode)); + } + + const char *workIntervalString = NULL; + StatusCode workIntervalCode = ConfigGetString(mCfg, "work_interval", &(workIntervalString)); + if (StatusCodeEqual(workIntervalCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { + LogWarning("work_interval doesn't exist, will make it as default.\n"); + mCfgChanged = CONFIG_HAS_CHANGED; + char defaultWorkInterval[] = "07:00:01-07:00:00"; + strncpy(mAllData.workingInterval, defaultWorkInterval, sizeof(mAllData.workingInterval)); + ConfigSetString(mCfg, "work_interval", mAllData.workingInterval); + } + else { + strncpy(mAllData.workingInterval, workIntervalString, sizeof(mAllData.workingInterval)); + } + StatusCode shortCode = ConfigGetShort(mCfg, "test_short", &(mAllData.testShort)); if (StatusCodeEqual(shortCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { LogWarning("test_short doesn't exist, will make it as default.\n"); @@ -506,19 +542,6 @@ void IpcConfig::ReadAllConfigParameters(void) ConfigSetFloat(mCfg, "test_float", mAllData.testFloat); } - const char *testString = NULL; - StatusCode stringCode = ConfigGetString(mCfg, "test_string", &(testString)); - if (StatusCodeEqual(stringCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { - LogWarning("test_string doesn't exist, will make it as default.\n"); - mCfgChanged = CONFIG_HAS_CHANGED; - char DEFAULT_TEST_STRING[] = "undefine"; - strncpy(mAllData.testString, DEFAULT_TEST_STRING, sizeof(mAllData.testString)); - ConfigSetString(mCfg, "test_string", mAllData.testString); - } - else { - strncpy(mAllData.testString, testString, sizeof(mAllData.testString)); - } - if (CONFIG_HAS_CHANGED == mCfgChanged) { LogInfo("Save the config file.\n"); mCfgChanged = CONFIG_HAS_NOT_CHANGED; diff --git a/middleware/IpcConfig/src/IpcConfig.h b/middleware/IpcConfig/src/IpcConfig.h index ee354c7..7add2c5 100644 --- a/middleware/IpcConfig/src/IpcConfig.h +++ b/middleware/IpcConfig/src/IpcConfig.h @@ -22,7 +22,7 @@ constexpr bool CONFIG_HAS_CHANGED = true; constexpr bool CONFIG_HAS_NOT_CHANGED = false; -typedef char CHAR_STRING[256]; +typedef char CHAR_STRING[64]; typedef struct Config_s { bool storageLoopSwitch; @@ -35,13 +35,14 @@ typedef struct Config_s int infraredIampPower; int delayed; int pirSensitivity; - double imageSize; short testShort; char testChar; long testLong; long long testLLong; float testFloat; - CHAR_STRING testString; + CHAR_STRING imageSize; + CHAR_STRING darkMode; + CHAR_STRING workingInterval; } Config_s; class MapInt { diff --git a/test/middleware/IpcConfig/src/IpcConfig_Test.cpp b/test/middleware/IpcConfig/src/IpcConfig_Test.cpp index 5705a82..3206afb 100644 --- a/test/middleware/IpcConfig/src/IpcConfig_Test.cpp +++ b/test/middleware/IpcConfig/src/IpcConfig_Test.cpp @@ -12,60 +12,70 @@ TEST(IpcConfigTest, Demo) ILogInit(LOG_INSTANCE_TYPE_END); IIpcConfig::GetInstance()->Init(); - int workMode = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_WORK_MODE); + const int workMode = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_WORK_MODE); LogInfo("Get workMode = %d\n", workMode); - workMode = WORK_MODE_PIC_VIDEO; - IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_WORK_MODE, workMode); + const int wworkMode = WORK_MODE_PIC_VIDEO; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_WORK_MODE, wworkMode); - int continuousShot = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_CONTINUOUS_SHOT); + const int continuousShot = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_CONTINUOUS_SHOT); LogInfo("Get continuousShot = %d\n", continuousShot); - continuousShot = CONTINUOUS_SHOT_TWO_PIC; - IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_CONTINUOUS_SHOT, continuousShot); + const int ccontinuousShot = CONTINUOUS_SHOT_TWO_PIC; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_CONTINUOUS_SHOT, ccontinuousShot); - int burstPhotoInterval = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_BURST_PHOTO_INTERVAL); + const int burstPhotoInterval = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_BURST_PHOTO_INTERVAL); LogInfo("Get burstPhotoInterval = %d\n", burstPhotoInterval); - burstPhotoInterval = BURST_PHOTO_INTERVAL_DEFAULT; - IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_BURST_PHOTO_INTERVAL, burstPhotoInterval); + const int bburstPhotoInterval = BURST_PHOTO_INTERVAL_DEFAULT; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_BURST_PHOTO_INTERVAL, bburstPhotoInterval); - double imageSize = IIpcConfig::GetInstance()->GetDouble(IpcConfigKey::KEY_IMGAE_SIZE); - LogInfo("Get image_size = %lf\n", imageSize); - imageSize = 320.023; - IIpcConfig::GetInstance()->SetDouble(IpcConfigKey::KEY_IMGAE_SIZE, imageSize); + const std::string imageSize = IIpcConfig::GetInstance()->GetString(IpcConfigKey::KEY_IMGAE_SIZE); + LogInfo("Get image_size = %s\n", imageSize.c_str()); + const std::string iimageSize = "410*410"; + IIpcConfig::GetInstance()->SetString(IpcConfigKey::KEY_IMGAE_SIZE, iimageSize); - int videoSize = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_VIDEO_SIZE); + const int videoSize = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_VIDEO_SIZE); LogInfo("Get video_size = %d\n", videoSize); - videoSize = VIDEO_SIZE_10; - IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_VIDEO_SIZE, videoSize); + const int vvideoSize = VIDEO_SIZE_10; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_VIDEO_SIZE, vvideoSize); - int infraredIampPower = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_INFRARED_LAMP_POWER); + const int infraredIampPower = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_INFRARED_LAMP_POWER); LogInfo("Get infrared_lamp_power = %d\n", infraredIampPower); - infraredIampPower = INFRARED_IAMP_POWER_LOW; - IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_INFRARED_LAMP_POWER, infraredIampPower); + const int iinfraredIampPower = INFRARED_IAMP_POWER_LOW; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_INFRARED_LAMP_POWER, iinfraredIampPower); - int delayed = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_DELAYED); + const int delayed = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_DELAYED); LogInfo("Get delayed = %d\n", delayed); - delayed = DELAYED_MAX; - IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_DELAYED, delayed); + const int ddelayed = DELAYED_MAX; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_DELAYED, ddelayed); - int pirSensitivity = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_PIR_SENSITIVITY); + const int pirSensitivity = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_PIR_SENSITIVITY); LogInfo("Get pir_sensitivity = %d\n", pirSensitivity); - pirSensitivity = PIR_SENSITIVITY_MAX; - IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_PIR_SENSITIVITY, pirSensitivity); + const int ppirSensitivity = PIR_SENSITIVITY_MAX; + IIpcConfig::GetInstance()->SetInt(IpcConfigKey::KEY_PIR_SENSITIVITY, ppirSensitivity); - bool storageLoopSwitch = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::KEY_STORAGE_LOOP_SWITCH); + const bool storageLoopSwitch = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::KEY_STORAGE_LOOP_SWITCH); LogInfo("Get storage_loop_switch = %d\n", storageLoopSwitch); - storageLoopSwitch = false; - IIpcConfig::GetInstance()->SetBool(IpcConfigKey::KEY_STORAGE_LOOP_SWITCH, storageLoopSwitch); + const bool sstorageLoopSwitch = false; + IIpcConfig::GetInstance()->SetBool(IpcConfigKey::KEY_STORAGE_LOOP_SWITCH, sstorageLoopSwitch); - bool factoryReset = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::KEY_FACTORY_RESET_FLAG); + const bool factoryReset = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::KEY_FACTORY_RESET_FLAG); LogInfo("Get factory_reset = %d\n", factoryReset); - factoryReset = false; - IIpcConfig::GetInstance()->SetBool(IpcConfigKey::KEY_FACTORY_RESET_FLAG, factoryReset); + const bool ffactoryReset = false; + IIpcConfig::GetInstance()->SetBool(IpcConfigKey::KEY_FACTORY_RESET_FLAG, ffactoryReset); - bool formattingSDCard = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::KEY_FORMATTING_SD_CARD); + const bool formattingSDCard = IIpcConfig::GetInstance()->GetBool(IpcConfigKey::KEY_FORMATTING_SD_CARD); LogInfo("Get formatting_SD_card = %d\n", formattingSDCard); - formattingSDCard = false; - IIpcConfig::GetInstance()->SetBool(IpcConfigKey::KEY_FORMATTING_SD_CARD, formattingSDCard); + const bool fformattingSDCard = false; + IIpcConfig::GetInstance()->SetBool(IpcConfigKey::KEY_FORMATTING_SD_CARD, fformattingSDCard); + + const std::string workInterval = IIpcConfig::GetInstance()->GetString(IpcConfigKey::KEY_WORK_INTERVAL); + LogInfo("Get work_Interval = %s\n", workInterval.c_str()); + const std::string wworkInterval = "06:00:01-06:00:00"; + IIpcConfig::GetInstance()->SetString(IpcConfigKey::KEY_WORK_INTERVAL, wworkInterval); + + const std::string drakMode = IIpcConfig::GetInstance()->GetString(IpcConfigKey::KEY_DARK_MODE); + LogInfo("Get dark_mode = %s\n", drakMode.c_str()); + const std::string ddrakMode = "18:00:00-06:00:00"; + IIpcConfig::GetInstance()->SetString(IpcConfigKey::KEY_DARK_MODE, ddrakMode); short testShort = IIpcConfig::GetInstance()->GetShort(IpcConfigKey::TEST_SHORT); LogInfo("Get test_short = %d\n", testShort); @@ -92,11 +102,6 @@ TEST(IpcConfigTest, Demo) const float numFloat = 1.123456; IIpcConfig::GetInstance()->SetFloat(IpcConfigKey::TEST_FLOAT, numFloat); - const std::string testString = IIpcConfig::GetInstance()->GetString(IpcConfigKey::TEST_STRING); - LogInfo("Get testString = %s\n", testString.c_str()); - const std::string string = "define"; - IIpcConfig::GetInstance()->SetString(IpcConfigKey::TEST_STRING, string); - IIpcConfig::GetInstance()->ConfigFileSave(); IIpcConfig::GetInstance()->UnInit(); ILogUnInit();