[zhoulongyu]: 添加配置库数据: 工作模式,连拍,连拍间隔,视频大小; 分辨率(需要修改)

This commit is contained in:
jas 2023-12-16 22:42:27 +08:00
parent ae20412ee7
commit c25e185c93
4 changed files with 122 additions and 37 deletions

View File

@ -21,17 +21,46 @@
enum class IpcConfigKey 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_SHORT,
TEST_LONG, TEST_LONG,
TEST_LLONG, TEST_LLONG,
TEST_CHAR, TEST_CHAR,
TEST_BOOL, TEST_BOOL,
TEST_FLOAT, TEST_FLOAT,
TEST_DOUBLE,
TEST_STRING, TEST_STRING,
END 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 class IIpcConfig
{ {

View File

@ -22,9 +22,27 @@ IpcConfig::IpcConfig()
{ {
mCfgChanged = CONFIG_HAS_NOT_CHANGED; mCfgChanged = CONFIG_HAS_NOT_CHANGED;
std::map<std::string, std::reference_wrapper<int>> innerMapInt; std::map<std::string, std::reference_wrapper<int>> innerMapWorkMode;
innerMapInt.insert(std::make_pair("test_num", std::reference_wrapper<int>(mAllData.testNum))); innerMapWorkMode.insert(std::make_pair("work_mode", std::reference_wrapper<int>(mAllData.workMode)));
mCfgMapInt.insert(std::make_pair(IpcConfigKey::TEST_NUM, innerMapInt)); mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_WORK_MODE, innerMapWorkMode));
std::map<std::string, std::reference_wrapper<int>> innerMapContinuousShot;
innerMapContinuousShot.insert(
std::make_pair("continuous_shot", std::reference_wrapper<int>(mAllData.continuousShot)));
mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_CONTINUOUS_SHOT, innerMapContinuousShot));
std::map<std::string, std::reference_wrapper<int>> innerMapBurstPhotoInterval;
innerMapBurstPhotoInterval.insert(
std::make_pair("burst_photo_interval", std::reference_wrapper<int>(mAllData.burstPhotoInterval)));
mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_BURST_PHOTO_INTERVAL, innerMapBurstPhotoInterval));
std::map<std::string, std::reference_wrapper<double>> innerMapImageSize;
innerMapImageSize.insert(std::make_pair("image_size", std::reference_wrapper<double>(mAllData.imageSize)));
mCfgMapDouble.insert(std::make_pair(IpcConfigKey::KEY_IMGAE_SIZE, innerMapImageSize));
std::map<std::string, std::reference_wrapper<int>> innerMapVideoSize;
innerMapVideoSize.insert(std::make_pair("video_size", std::reference_wrapper<int>(mAllData.videoSize)));
mCfgMapInt.insert(std::make_pair(IpcConfigKey::KEY_VIDEO_SIZE, innerMapVideoSize));
std::map<std::string, std::reference_wrapper<short>> innerMapShort; std::map<std::string, std::reference_wrapper<short>> innerMapShort;
innerMapShort.insert(std::make_pair("test_short", std::reference_wrapper<short>(mAllData.testShort))); innerMapShort.insert(std::make_pair("test_short", std::reference_wrapper<short>(mAllData.testShort)));
@ -50,10 +68,6 @@ IpcConfig::IpcConfig()
innerMapFloat.insert(std::make_pair("test_float", std::reference_wrapper<float>(mAllData.testFloat))); innerMapFloat.insert(std::make_pair("test_float", std::reference_wrapper<float>(mAllData.testFloat)));
mCfgMapFloat.insert(std::make_pair(IpcConfigKey::TEST_FLOAT, innerMapFloat)); mCfgMapFloat.insert(std::make_pair(IpcConfigKey::TEST_FLOAT, innerMapFloat));
std::map<std::string, std::reference_wrapper<double>> innerMapDouble;
innerMapDouble.insert(std::make_pair("test_double", std::reference_wrapper<double>(mAllData.testDouble)));
mCfgMapDouble.insert(std::make_pair(IpcConfigKey::TEST_DOUBLE, innerMapDouble));
std::map<std::string, std::reference_wrapper<CHAR_STRING>> innerMapString; std::map<std::string, std::reference_wrapper<CHAR_STRING>> innerMapString;
innerMapString.insert(std::make_pair("test_string", std::reference_wrapper<CHAR_STRING>(mAllData.testString))); innerMapString.insert(std::make_pair("test_string", std::reference_wrapper<CHAR_STRING>(mAllData.testString)));
mCfgMapString.insert(std::make_pair(IpcConfigKey::TEST_STRING, innerMapString)); 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) void IpcConfig::ReadAllConfigParameters(void)
{ {
StatusCode code = ConfigGetInt(mCfg, "test_num", &(mAllData.testNum)); StatusCode workModeCode = ConfigGetInt(mCfg, "work_mode", &(mAllData.workMode));
if (StatusCodeEqual(code, "CONFIG_CODE_PARAM_NOT_EXIST")) { if (StatusCodeEqual(workModeCode, "CONFIG_CODE_PARAM_NOT_EXIST")) {
LogWarning("test_num doesn't exist, will make it as default.\n"); LogWarning("work_mode doesn't exist, will make it as default.\n");
mCfgChanged = CONFIG_HAS_CHANGED; mCfgChanged = CONFIG_HAS_CHANGED;
constexpr int DEFAULT_TEST_NUM = 10; mAllData.workMode = WORK_MODE_PIC;
mAllData.testNum = DEFAULT_TEST_NUM; ConfigSetInt(mCfg, "work_mode", mAllData.workMode);
ConfigSetInt(mCfg, "test_num", mAllData.testNum); }
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)); StatusCode shortCode = ConfigGetShort(mCfg, "test_short", &(mAllData.testShort));
@ -395,15 +440,6 @@ void IpcConfig::ReadAllConfigParameters(void)
ConfigSetFloat(mCfg, "test_float", mAllData.testFloat); 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; const char *testString = NULL;
StatusCode stringCode = ConfigGetString(mCfg, "test_string", &(testString)); StatusCode stringCode = ConfigGetString(mCfg, "test_string", &(testString));
if (StatusCodeEqual(stringCode, "CONFIG_CODE_PARAM_NOT_EXIST")) { if (StatusCodeEqual(stringCode, "CONFIG_CODE_PARAM_NOT_EXIST")) {

View File

@ -25,14 +25,18 @@ constexpr bool CONFIG_HAS_NOT_CHANGED = false;
typedef char CHAR_STRING[256]; typedef char CHAR_STRING[256];
typedef struct Config_s typedef struct Config_s
{ {
int testNum; int workMode;
int continuousShot;
int burstPhotoInterval;
int videoSize;
double imageSize;
short testShort; short testShort;
long testLong;
long long testLLong;
char testChar; char testChar;
bool testBool; bool testBool;
long testLong;
long long testLLong;
float testFloat; float testFloat;
double testDouble;
CHAR_STRING testString; CHAR_STRING testString;
} Config_s; } Config_s;
class MapInt class MapInt

View File

@ -11,10 +11,31 @@ TEST(IpcConfigTest, Demo)
CreateIpcConfig(); CreateIpcConfig();
ILogInit(LOG_INSTANCE_TYPE_END); ILogInit(LOG_INSTANCE_TYPE_END);
IIpcConfig::GetInstance()->Init(); IIpcConfig::GetInstance()->Init();
int testNum = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::TEST_NUM);
LogInfo("Get testNum = %d\n", testNum); int workMode = IIpcConfig::GetInstance()->GetInt(IpcConfigKey::KEY_WORK_MODE);
const int numInt = 999; LogInfo("Get workMode = %d\n", workMode);
IIpcConfig::GetInstance()->SetInt(IpcConfigKey::TEST_NUM, numInt); 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); short testShort = IIpcConfig::GetInstance()->GetShort(IpcConfigKey::TEST_SHORT);
LogInfo("Get test_short = %d\n", testShort); LogInfo("Get test_short = %d\n", testShort);
@ -46,11 +67,6 @@ TEST(IpcConfigTest, Demo)
const float numFloat = 1.123456; const float numFloat = 1.123456;
IIpcConfig::GetInstance()->SetFloat(IpcConfigKey::TEST_FLOAT, numFloat); 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); const std::string testString = IIpcConfig::GetInstance()->GetString(IpcConfigKey::TEST_STRING);
LogInfo("Get testString = %s\n", testString.c_str()); LogInfo("Get testString = %s\n", testString.c_str());
const std::string string = "define"; const std::string string = "define";