Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
704a6290
提交
704a6290
authored
10月 09, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upload video files
上级
b718c2f5
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
29 行删除
+20
-29
config.json
opencv-motion-detect/deployment/config.json
+1
-1
test_regex.cpp
opencv-motion-detect/test_regex.cpp
+19
-28
没有找到文件。
opencv-motion-detect/deployment/config.json
浏览文件 @
704a6290
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
],
],
"evpusher"
:[
"evpusher"
:[
{
{
"enabled"
:
1
,
"enabled"
:
0
,
"iid"
:
1
,
"iid"
:
1
,
"password"
:
""
,
"password"
:
""
,
"sn"
:
"PSBV7GKN"
,
"sn"
:
"PSBV7GKN"
,
...
...
opencv-motion-detect/test_regex.cpp
浏览文件 @
704a6290
...
@@ -19,9 +19,9 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -19,9 +19,9 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
ret
[
"msg"
]
=
"ok"
;
ret
[
"msg"
]
=
"ok"
;
ret
[
"data"
]
=
json
();
ret
[
"data"
]
=
json
();
bool
hasError
=
false
;
bool
hasError
=
false
;
spdlog
::
info
(
"matching {}
"
,
diff
.
dump
());
spdlog
::
info
(
"matching {}
, size:{}, type:{}"
,
diff
.
dump
(),
diff
.
size
(),
diff
.
type_name
());
try
{
try
{
for
(
auto
&
d
:
diff
.
array
()
)
{
for
(
auto
&
d
:
diff
)
{
spdlog
::
info
(
"d :{}, {}"
,
d
.
dump
(),
d
.
size
());
spdlog
::
info
(
"d :{}, {}"
,
d
.
dump
(),
d
.
size
());
if
(
d
.
count
(
"path"
)
!=
0
)
{
if
(
d
.
count
(
"path"
)
!=
0
)
{
string
path_
=
d
[
"path"
];
string
path_
=
d
[
"path"
];
...
@@ -35,10 +35,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -35,10 +35,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
string
ipcRegStr
=
string
(
"/"
)
+
sn
+
"/ipcs/(
\\
d+)/(
\\
w+)"
;
string
ipcRegStr
=
string
(
"/"
)
+
sn
+
"/ipcs/(
\\
d+)/(
\\
w+)"
;
std
::
smatch
results
;
std
::
smatch
results
;
std
::
regex
ipcRegex
(
ipcRegStr
);
std
::
regex
ipcRegex
(
ipcRegStr
);
spdlog
::
info
(
"x diff: {}"
,
diff
.
dump
());
if
(
std
::
regex_match
(
path_
,
results
,
ipcRegex
))
{
if
(
std
::
regex_match
(
path_
,
results
,
ipcRegex
))
{
if
(
results
.
size
()
==
3
)
{
if
(
results
.
size
()
==
3
)
{
spdlog
::
info
(
"matched ipc: {}"
,
path_
);
matched
=
true
;
matched
=
true
;
int
ipcIdx
=
stoi
(
results
[
1
].
str
());
int
ipcIdx
=
stoi
(
results
[
1
].
str
());
string
tag
=
results
[
2
].
str
();
string
tag
=
results
[
2
].
str
();
...
@@ -76,14 +74,11 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -76,14 +74,11 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
}
}
}
}
}
}
}
else
{
for
(
auto
&
i
:
results
)
{
spdlog
::
info
(
"
\t
{}"
,
i
.
str
());
}
}
}
}
else
{
spdlog
::
info
(
"no match for ipc"
,
path_
);
}
}
// else{
// spdlog::info("no match for ipc", path_);
// }
// match module config
// match module config
if
(
!
matched
&&
!
hasError
)
{
if
(
!
matched
&&
!
hasError
)
{
...
@@ -93,14 +88,13 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -93,14 +88,13 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
std
::
smatch
results2
;
std
::
smatch
results2
;
if
(
std
::
regex_match
(
path_
,
results2
,
moduleRegex
))
{
if
(
std
::
regex_match
(
path_
,
results2
,
moduleRegex
))
{
if
(
results2
.
size
()
==
5
)
{
if
(
results2
.
size
()
==
5
)
{
spdlog
::
info
(
"matched module: {}"
,
path_
);
int
ipcIdx
=
stoi
(
results2
[
1
].
str
());
int
ipcIdx
=
stoi
(
results2
[
1
].
str
());
int
modIdx
=
stoi
(
results
[
3
].
str
());
int
modIdx
=
stoi
(
results
2
[
3
].
str
());
string
modName
=
results
[
2
].
str
();
string
modName
=
results
2
[
2
].
str
();
string
propName
=
results
[
4
].
str
();
string
propName
=
results
2
[
4
].
str
();
if
(
d
[
"op"
]
==
"replace"
||
d
[
"op"
]
==
"add"
)
{
if
(
d
[
"op"
]
==
"replace"
||
d
[
"op"
]
==
"add"
)
{
auto
&
oldMod
=
oldConfig
[
sn
][
"ipcs"
][
ipcIdx
][
"modules"
][
modIdx
];
auto
&
oldMod
=
oldConfig
[
sn
][
"ipcs"
][
ipcIdx
][
"modules"
][
mod
Name
][
mod
Idx
];
auto
&
newMod
=
newConfig
[
sn
][
"ipcs"
][
ipcIdx
][
"modules"
][
modIdx
];
auto
&
newMod
=
newConfig
[
sn
][
"ipcs"
][
ipcIdx
][
"modules"
][
mod
Name
][
mod
Idx
];
if
(
oldMod
.
count
(
"iid"
)
==
0
||
newMod
.
count
(
"iid"
)
==
0
)
{
if
(
oldMod
.
count
(
"iid"
)
==
0
||
newMod
.
count
(
"iid"
)
==
0
)
{
string
msg
=
fmt
::
format
(
"invalid module config ipcs[{}]['modules'][{}][{}] having no iid field"
,
ipcIdx
,
modName
,
modIdx
);
string
msg
=
fmt
::
format
(
"invalid module config ipcs[{}]['modules'][{}][{}] having no iid field"
,
ipcIdx
,
modName
,
modIdx
);
spdlog
::
error
(
msg
);
spdlog
::
error
(
msg
);
...
@@ -119,8 +113,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -119,8 +113,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
}
}
}
}
string
oldGid
=
sn
+
":"
+
modName
+
":"
+
oldMod
[
"iid"
].
get
<
string
>
(
);
string
oldGid
=
sn
+
":"
+
modName
+
":"
+
to_string
(
oldMod
[
"iid"
].
get
<
int
>
()
);
string
newGid
=
sn
+
":"
+
modName
+
":"
+
newMod
[
"iid"
].
get
<
string
>
(
);
string
newGid
=
sn
+
":"
+
modName
+
":"
+
to_string
(
newMod
[
"iid"
].
get
<
int
>
()
);
if
(
oldGid
!=
newGid
)
{
if
(
oldGid
!=
newGid
)
{
ret
[
"data"
][
oldGid
]
=
0
;
ret
[
"data"
][
oldGid
]
=
0
;
...
@@ -130,10 +124,10 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -130,10 +124,10 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
if
(
newMod
[
"enabled"
].
get
<
int
>
()
==
0
)
{
if
(
newMod
[
"enabled"
].
get
<
int
>
()
==
0
)
{
ret
[
"data"
][
newGid
]
=
0
;
ret
[
"data"
][
newGid
]
=
0
;
}
else
{
}
else
{
ret
[
"data"
][
newGid
]
=
2
;
ret
[
"data"
][
newGid
]
=
1
;
}
}
}
else
{
}
else
{
// other prop modification
//
disabled
//
it was disabled. just ignore
if
(
ret
[
"data"
].
count
(
newGid
)
!=
0
&&
ret
[
"data"
][
newGid
].
get
<
int
>
()
==
0
)
{
if
(
ret
[
"data"
].
count
(
newGid
)
!=
0
&&
ret
[
"data"
][
newGid
].
get
<
int
>
()
==
0
)
{
// nop
// nop
}
else
{
}
else
{
...
@@ -143,14 +137,11 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -143,14 +137,11 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
}
}
}
}
}
}
}
else
{
for
(
auto
&
i
:
results
)
{
spdlog
::
info
(
"
\t
{}"
,
i
.
str
());
}
}
}
}
else
{
spdlog
::
info
(
"no match for module {}"
,
path_
);
}
}
// else{
// spdlog::info("no match for module {}", path_);
// }
}
}
if
(
hasError
){
if
(
hasError
){
...
@@ -176,7 +167,7 @@ int main(){
...
@@ -176,7 +167,7 @@ int main(){
config
=
config
[
"data"
];
config
=
config
[
"data"
];
iff2
>>
config2
;
iff2
>>
config2
;
config2
=
config2
[
"data"
];
config2
=
config2
[
"data"
];
json
dif
=
json
::
diff
(
config2
,
config
)
.
dump
()
;
json
dif
=
json
::
diff
(
config2
,
config
);
spdlog
::
info
(
"diff: {}"
,
dif
.
dump
());
spdlog
::
info
(
"diff: {}"
,
dif
.
dump
());
auto
ret
=
getModulesOperFromConfDiff
(
config2
,
config
,
dif
,
"PSBV7GKN"
);
auto
ret
=
getModulesOperFromConfDiff
(
config2
,
config
,
dif
,
"PSBV7GKN"
);
spdlog
::
info
(
"parse: {}"
,
ret
.
dump
());
spdlog
::
info
(
"parse: {}"
,
ret
.
dump
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论