Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
f981a53a
提交
f981a53a
authored
10月 10, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor of delta config
上级
217dce32
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
79 行增加
和
5 行删除
+79
-5
utils.cpp
opencv-motion-detect/inc/utils.cpp
+0
-0
utils.hpp
opencv-motion-detect/inc/utils.hpp
+1
-0
test_regex.cpp
opencv-motion-detect/test_regex.cpp
+78
-5
没有找到文件。
opencv-motion-detect/inc/utils.cpp
浏览文件 @
f981a53a
差异被折叠。
点击展开。
opencv-motion-detect/inc/utils.hpp
浏览文件 @
f981a53a
...
@@ -46,6 +46,7 @@ namespace cfgutils {
...
@@ -46,6 +46,7 @@ namespace cfgutils {
int
getPeerId
(
string
modName
,
json
&
modElem
,
string
&
peerId
,
string
&
peerName
);
int
getPeerId
(
string
modName
,
json
&
modElem
,
string
&
peerId
,
string
&
peerName
);
json
*
findModuleConfig
(
string
peerId
,
json
&
data
);
json
*
findModuleConfig
(
string
peerId
,
json
&
data
);
json
getModulesOperFromConfDiff
(
json
&
oldConfig
,
json
&
newConfig
,
json
&
diff
,
string
sn
);
json
getModulesOperFromConfDiff
(
json
&
oldConfig
,
json
&
newConfig
,
json
&
diff
,
string
sn
);
json
getModuleGidsFromCfg
(
string
sn
,
json
&
data
,
string
caller
=
""
,
int
ipcIdx
=
-
1
);
}
}
struct
StrException
:
public
std
::
exception
struct
StrException
:
public
std
::
exception
...
...
opencv-motion-detect/test_regex.cpp
浏览文件 @
f981a53a
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include "json.hpp"
#include "json.hpp"
#include <spdlog/spdlog.h>
#include <spdlog/spdlog.h>
#include <fmt/format.h>
#include <fmt/format.h>
#include "utils.hpp"
using
namespace
std
;
using
namespace
std
;
using
namespace
nlohmann
;
using
namespace
nlohmann
;
...
@@ -241,16 +242,88 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -241,16 +242,88 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
}
}
}
}
}
}
}
}
}
}
if
(
hasError
){
// whole cluster
ret
[
"code"
]
=
1
;
if
(
!
matched
&&
!
hasError
)
{
break
;
// /PSBV7GKN
}
// "value":{"addr":"127.0.0.1","api-cloud":"http://127.0.0.1:8089","ipcs":[{"addr":"172.31.0.129","modules":{"evml":[{"area":200,"enabled":1,"entropy":0.3,"iid":1,"post":30,"pre":3,"sn":"PSBV7GKN","thresh":30,"type":"motion"}],"evpuller":[{"addr":"127.0.0.1","enabled":1,"iid":1,"port-pub":5556,"sn":"PSBV7GKN"}],"evpusher":[{"enabled":0,"iid":1,"password":"","sn":"PSBV7GKN","token":"","urlDest":"rtsp://40.73.41.176/PSBV7GKN","user":""}],"evslicer":[{"enabled":1,"iid":1,"path":"slices","sn":"PSBV7GKN","video-server-addr":"http://40.73.41.176:10009/upload/evtvideos/"}]},"password":"iLabService","port":554,"proto":"rtsp","sn":"iLabService","user":"admin"}],"mqtt-cloud":"<cloud_addr>","port-cloud":5556,"port-router":5550,"proto":"zmq","sn":"PSBV7GKN"}
string
clusterRegStr
=
"/(
\\
w+)"
;
std
::
regex
clusterRegex
(
clusterRegStr
);
std
::
smatch
results
;
if
(
std
::
regex_match
(
path_
,
results
,
clusterRegex
))
{
if
(
results
.
size
()
==
2
)
{
matched
=
true
;
string
mgrSn
=
results
[
1
].
str
();
json
mgr
;
if
(
d
[
"op"
]
==
"remove"
){
mgr
[
mgrSn
]
=
oldConfig
[
mgrSn
];
}
else
{
mgr
[
mgrSn
]
=
newConfig
[
mgrSn
];
}
json
jret
=
cfgutils
::
getModuleGidsFromCfg
(
sn
,
mgr
,
"getModulesOperFromConfDiff"
);
spdlog
::
info
(
"jret: {}"
,
jret
.
dump
());
if
(
jret
[
"code"
]
!=
0
)
{
ret
[
"msg"
]
=
jret
[
"msg"
];
hasError
=
true
;
break
;
}
else
{
for
(
auto
&
k
:
jret
[
"data"
])
{
if
(
d
[
"op"
]
==
"remove"
){
ret
[
"data"
][
string
(
k
)]
=
0
;
}
else
{
ret
[
"data"
][
string
(
k
)]
=
2
;
}
}
}
}
}
}
// one ipc
if
(
!
matched
&&
!
hasError
)
{
// /PSBV7GKN/ipcs/0"
// {"addr":"172.31.0.129","modules":{"evml":[{"area":200,"enabled":1,"entropy":0.3,"iid":1,"post":30,"pre":3,"sn":"PSBV7GKN","thresh":30,"type":"motion"}],"evpuller":[{"addr":"127.0.0.1","enabled":1,"iid":1,"port-pub":5556,"sn":"PSBV7GKN"}],"evpusher":[{"enabled":0,"iid":1,"password":"","sn":"PSBV7GKN","token":"","urlDest":"rtsp://40.73.41.176/PSBV7GKN","user":""}],"evslicer":[{"enabled":1,"iid":1,"path":"slices","sn":"PSBV7GKN","video-server-addr":"http://40.73.41.176:10009/upload/evtvideos/"}]},"password":"iLabService","port":554,"proto":"rtsp","sn":"iLabService","user":"admin"}
string
clusterRegStr
=
"/(
\\
w+)/ipcs/(
\\
d+)"
;
std
::
regex
clusterRegex
(
clusterRegStr
);
std
::
smatch
results
;
if
(
std
::
regex_match
(
path_
,
results
,
clusterRegex
))
{
if
(
results
.
size
()
==
3
)
{
matched
=
true
;
string
mgrSn
=
results
[
1
].
str
();
int
ipcIdx
=
stoi
(
results
[
2
].
str
());
json
mgr
;
if
(
d
[
"op"
]
==
"remove"
){
mgr
[
mgrSn
]
=
oldConfig
[
mgrSn
];
}
else
{
mgr
[
mgrSn
]
=
newConfig
[
mgrSn
];
}
json
jret
=
cfgutils
::
getModuleGidsFromCfg
(
sn
,
mgr
,
"getModulesOperFromConfDiff"
,
ipcIdx
);
spdlog
::
info
(
"jret: {}"
,
jret
.
dump
());
if
(
jret
[
"code"
]
!=
0
)
{
ret
[
"msg"
]
=
jret
[
"msg"
];
hasError
=
true
;
break
;
}
else
{
for
(
auto
&
k
:
jret
[
"data"
])
{
if
(
d
[
"op"
]
==
"remove"
){
ret
[
"data"
][
string
(
k
)]
=
0
;
}
else
{
ret
[
"data"
][
string
(
k
)]
=
2
;
}
}
}
}
}
}
}
}
}
}
if
(
hasError
){
ret
[
"code"
]
=
1
;
}
}
catch
(
exception
&
e
)
{
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"getModulesOperFromConfDiff exception: {}"
,
e
.
what
());
spdlog
::
error
(
"getModulesOperFromConfDiff exception: {}"
,
e
.
what
());
ret
[
"code"
]
=
-
1
;
ret
[
"code"
]
=
-
1
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论