提交 44c36e1d authored 作者: blu's avatar blu

big refacting of communitation architect

上级 b0eaf7ab
......@@ -51,48 +51,46 @@ namespace LVDB {
json * findConfigModule(json &config, string sn, string moduleName, int iid) {
json *ret = NULL;
json &data = config["data"];
for(auto &[k,v]: data.items()){
json &mgr = data[k];
if(mgr.count("ipcs") == 0) {
break;
}else{
json &ipcs = mgr["ipcs"];
for(auto &ipc:ipcs) {
if(ipc.count("modules") == 0) {
break;
json &mgr = config;
if(mgr.count("ipcs") == 0) {
return ret;
}else{
json &ipcs = mgr["ipcs"];
for(auto &ipc:ipcs) {
if(ipc.count("modules") == 0) {
break;
}else{
json &modules = ipc["modules"];
string modname = moduleName.substr(0,4);
string sub;
if(modname == "evml") {
sub = moduleName.substr(4, moduleName.size());
}else{
json &modules = ipc["modules"];
string modname = moduleName.substr(0,4);
string sub;
if(modname == "evml") {
sub = moduleName.substr(4, moduleName.size());
}else{
modname = moduleName;
}
modname = moduleName;
}
if(modules.count(modname) == 0){
break;
}else{
json &module = modules[modname];
for(auto &inst: module) {
if(inst.count("sn") != 0 && inst["sn"] == sn && inst.count("iid") != 0 && inst["iid"] == iid) {
if(!sub.empty()) {
if(inst.count("type") != 0 && inst["type"] == sub) {
return &inst;
}
// continue
}else{
if(modules.count(modname) == 0){
break;
}else{
json &module = modules[modname];
for(auto &inst: module) {
if(inst.count("sn") != 0 && inst["sn"] == sn && inst.count("iid") != 0 && inst["iid"] == iid) {
if(!sub.empty()) {
if(inst.count("type") != 0 && inst["type"] == sub) {
return &inst;
}
// continue
}else{
return &inst;
}
}
}
}
}
}
}
return ret;
}
......@@ -391,22 +389,7 @@ togo_end:
spdlog::error("failed to save new generated sn");
exit(1);
}else{
// // replace sn
// size_t idx = 0;
// for(auto &j:_sn_tmpl) {
// idx = 0;
// while(true) {
// idx = _config_default_tmpl.find(j, idx);
// if(idx == string::npos) break;
// _config_default_tmpl.replace(idx, j.size(), sn);
// idx+=sn.size();
// }
// }
// // replace camera addr, user, password, cloud-addr
// spdlog::debug("new config: {}", _config_default_tmpl);
// json j = json::parse(_config_default_tmpl);
// return setLocalConfig(j);
//
}
}
......
......@@ -220,8 +220,6 @@ class EvDaemon{
spdlog::warn("evdaemon {} peer disconnected: {}", devSn, selfId);
}
//update config
ret = LVDB::setLocalConfig(config);
if(ret < 0) {
spdlog::error("evdaemon {} failed to update localconfig", devSn);
}
......
......@@ -145,8 +145,6 @@ private:
spdlog::warn("evmgr {} peer disconnected: {}", devSn, selfId);
}
//update config
ret = LVDB::setLocalConfig(config);
if(ret < 0) {
spdlog::error("evmgr {} failed to update localconfig", devSn);
}
......
......@@ -100,7 +100,7 @@ private:
spdlog::error("failed to get local configuration");
exit(1);
}
spdlog::info("evmlmotion {} config: {}", devSn, config.dump(4));
json evmlmotion;
json &evmgr = this->config;
......@@ -146,7 +146,7 @@ private:
// TODO: multiple protocols support
if(evmlmotion.count("path") == 0) {
spdlog::warn("evmlmotion {} no params for path, using default: {}", selfId, URLOUT_DEFAULT);
spdlog::info("evmlmotion {} no params for path, using default: {}", selfId, URLOUT_DEFAULT);
urlOut = URLOUT_DEFAULT;
}
else {
......@@ -161,35 +161,35 @@ private:
// detection params
if(evmlmotion.count("thresh") == 0||evmlmotion["thresh"] < 10 ||evmlmotion["thresh"] >= 255) {
spdlog::warn("evmlmotion {} invalid thresh value. should be in (10,255), default to 80", selfId);
spdlog::info("evmlmotion {} invalid thresh value. should be in (10,255), default to 80", selfId);
detPara.thre = 80;
}else{
detPara.thre = evmlmotion["thresh"];
}
if(evmlmotion.count("area") == 0||evmlmotion["area"] < 10 ||evmlmotion["area"] >= int(FRAME_SIZE*FRAME_SIZE)*9/10) {
spdlog::warn("evmlmotion {} invalid area value. should be in (10, 500*500*/10), default to 500", selfId);
spdlog::info("evmlmotion {} invalid area value. should be in (10, 500*500*/10), default to 500", selfId);
detPara.area = FRAME_SIZE;
}else{
detPara.area = evmlmotion["area"];
}
if(evmlmotion.count("pre") == 0||evmlmotion["pre"] < 1 ||evmlmotion["pre"] >= 120) {
spdlog::warn("evmlmotion {} invalid pre value. should be in (1, 120), default to 3", selfId);
spdlog::info("evmlmotion {} invalid pre value. should be in (1, 120), default to 3", selfId);
detPara.pre = 3;
}else{
detPara.pre = evmlmotion["pre"];
}
if(evmlmotion.count("post") == 0||evmlmotion["post"] < 6 ||evmlmotion["post"] >= 120) {
spdlog::warn("evmlmotion {} invalid post value. should be in (6, 120), default to 30", selfId);
spdlog::info("evmlmotion {} invalid post value. should be in (6, 120), default to 30", selfId);
detPara.post = 30;
}else{
detPara.post = evmlmotion["post"];
}
if(evmlmotion.count("entropy") == 0||evmlmotion["entropy"] < 0 || evmlmotion["entropy"] >= 10) {
spdlog::warn("evmlmotion {} invalid entropy value. should be in (0, 10), default to 0.3", selfId);
spdlog::info("evmlmotion {} invalid entropy value. should be in (0, 10), default to 0.3", selfId);
detPara.entropy = 0.3;
}else{
detPara.entropy = evmlmotion["entropy"];
......
......@@ -126,9 +126,6 @@ private:
exit(1);
}
//update status and ping
evpusher["status"] = 1;
ret = LVDB::setLocalConfig(config);
if(ret < 0) {
spdlog::error("evpusher {} failed to set config: {}", selfId, config.dump());
}
......
......@@ -101,14 +101,14 @@ private:
pullerGid = evpuller["sn"].get<string>() + ":evpuller:" + to_string(evpuller["iid"]);
mgrSn = evmgr["sn"];
if(evslicer.count("path") == 0) {
spdlog::warn("evslicer {} no params for path, using default: {}", selfId, URLOUT_DEFAULT);
spdlog::info("evslicer {} no params for path, using default: {}", selfId, URLOUT_DEFAULT);
urlOut = URLOUT_DEFAULT;
}
else {
urlOut = evslicer["path"];
}
if(evslicer.count("days") == 0) {
spdlog::warn("evslicer {} no params for days, using default: {}", selfId, NUM_DAYS_DEFAULT);
spdlog::info("evslicer {} no params for days, using default: {}", selfId, NUM_DAYS_DEFAULT);
days = NUM_DAYS_DEFAULT;
}
else {
......@@ -116,7 +116,7 @@ private:
}
if(evslicer.count("minutes") == 0) {
spdlog::warn("evslicer {} no params for minutes, using default: {}", selfId, MINUTES_PER_SLICE_DEFAULT);
spdlog::info("evslicer {} no params for minutes, using default: {}", selfId, MINUTES_PER_SLICE_DEFAULT);
minutes = MINUTES_PER_SLICE_DEFAULT;
}
else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论