Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
b76c83c4
提交
b76c83c4
authored
10月 09, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upload video files
上级
704a6290
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
78 行增加
和
18 行删除
+78
-18
test_regex.cpp
opencv-motion-detect/test_regex.cpp
+78
-18
没有找到文件。
opencv-motion-detect/test_regex.cpp
浏览文件 @
b76c83c4
...
@@ -32,19 +32,21 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -32,19 +32,21 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
set
<
string
>
oprations
{
"add"
,
"replace"
,
"remove"
};
set
<
string
>
oprations
{
"add"
,
"replace"
,
"remove"
};
set
<
string
>
pullerTag
{
"addr"
,
"user"
,
"password"
,
"proto"
,
"port"
/*, "sn"*/
};
set
<
string
>
pullerTag
{
"addr"
,
"user"
,
"password"
,
"proto"
,
"port"
/*, "sn"*/
};
string
ipcRegStr
=
string
(
"/"
)
+
sn
+
"
/ipcs/(
\\
d+)/(
\\
w+)"
;
string
ipcRegStr
=
"/(
\\
w+)
/ipcs/(
\\
d+)/(
\\
w+)"
;
std
::
smatch
results
;
std
::
smatch
results
;
std
::
regex
ipcRegex
(
ipcRegStr
);
std
::
regex
ipcRegex
(
ipcRegStr
);
if
(
std
::
regex_match
(
path_
,
results
,
ipcRegex
))
{
if
(
std
::
regex_match
(
path_
,
results
,
ipcRegex
))
{
if
(
results
.
size
()
==
3
)
{
if
(
results
.
size
()
==
4
)
{
matched
=
true
;
matched
=
true
;
int
ipcIdx
=
stoi
(
results
[
1
].
str
());
string
mgrSn
=
results
[
1
].
str
();
string
tag
=
results
[
2
].
str
();
int
ipcIdx
=
stoi
(
results
[
2
].
str
());
string
tag
=
results
[
3
].
str
();
if
(
pullerTag
.
find
(
tag
)
!=
pullerTag
.
end
())
{
if
(
pullerTag
.
find
(
tag
)
!=
pullerTag
.
end
())
{
// TODO: op = remove
// TODO: op = remove
if
(
d
[
"op"
]
==
"add"
||
d
[
"op"
]
==
"replace"
)
{
if
(
d
[
"op"
]
==
"add"
||
d
[
"op"
]
==
"replace"
)
{
// start
// start
auto
ipc
=
newConfig
[
sn
][
"ipcs"
][
ipcIdx
];
auto
ipc
=
newConfig
[
mgrSn
][
"ipcs"
][
ipcIdx
];
auto
ipcOld
=
oldConfig
[
mgrSn
][
"ipcs"
][
ipcIdx
];
if
(
ipc
.
count
(
"modules"
)
==
0
||
ipc
[
"modules"
].
size
()
==
0
||
ipc
[
"moudles"
].
count
(
"evpuller"
)
==
0
||
ipc
[
"modules"
][
"evpuller"
].
size
()
==
0
)
{
if
(
ipc
.
count
(
"modules"
)
==
0
||
ipc
[
"modules"
].
size
()
==
0
||
ipc
[
"moudles"
].
count
(
"evpuller"
)
==
0
||
ipc
[
"modules"
][
"evpuller"
].
size
()
==
0
)
{
string
msg
=
fmt
::
format
(
"invalid config for ipc[{}]['modules']['evpuller']: {}"
,
ipcIdx
,
newConfig
.
dump
());
string
msg
=
fmt
::
format
(
"invalid config for ipc[{}]['modules']['evpuller']: {}"
,
ipcIdx
,
newConfig
.
dump
());
spdlog
::
error
(
msg
);
spdlog
::
error
(
msg
);
...
@@ -56,6 +58,19 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -56,6 +58,19 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
int
idx
=
0
;
int
idx
=
0
;
for
(
auto
&
puller
:
evpullers
)
{
for
(
auto
&
puller
:
evpullers
)
{
// strutil
// strutil
if
(
puller
.
count
(
"sn"
)
==
0
)
{
string
msg
=
fmt
::
format
(
"invalid config for ipc[{}]['modules']['evpuller'][{}] no sn field: {}"
,
ipcIdx
,
idx
,
newConfig
.
dump
());
ret
[
"msg"
]
=
msg
;
spdlog
::
error
(
msg
);
hasError
=
true
;
break
;
}
if
(
puller
[
"sn"
].
get
<
string
>
()
!=
sn
)
{
spdlog
::
debug
(
"skip {} for expecting sn: {}"
,
puller
.
dump
(),
sn
);
continue
;
}
if
(
puller
.
count
(
"iid"
)
==
0
||
puller
.
count
(
"addr"
)
==
0
)
{
if
(
puller
.
count
(
"iid"
)
==
0
||
puller
.
count
(
"addr"
)
==
0
)
{
string
msg
=
fmt
::
format
(
"invliad config as of having no iid/addr/enabled field in ipc[{}]['modules']['evpuller'][{}]: {}"
,
ipcIdx
,
idx
,
newConfig
.
dump
());
string
msg
=
fmt
::
format
(
"invliad config as of having no iid/addr/enabled field in ipc[{}]['modules']['evpuller'][{}]: {}"
,
ipcIdx
,
idx
,
newConfig
.
dump
());
spdlog
::
error
(
msg
);
spdlog
::
error
(
msg
);
...
@@ -83,18 +98,20 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -83,18 +98,20 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
// match module config
// match module config
if
(
!
matched
&&
!
hasError
)
{
if
(
!
matched
&&
!
hasError
)
{
// /NMXH73Y2/ipcs/0/modules/evpusher/0/urlDest
// /NMXH73Y2/ipcs/0/modules/evpusher/0/urlDest
string
moduleRegStr
=
string
(
"/"
)
+
sn
+
"
/ipcs/(
\\
d+)/modules/(
\\
w+)/(
\\
d+)/(
\\
w+)"
;
string
moduleRegStr
=
"/(
\\
w+)
/ipcs/(
\\
d+)/modules/(
\\
w+)/(
\\
d+)/(
\\
w+)"
;
std
::
regex
moduleRegex
(
moduleRegStr
);
std
::
regex
moduleRegex
(
moduleRegStr
);
std
::
smatch
results2
;
std
::
smatch
results
;
if
(
std
::
regex_match
(
path_
,
results2
,
moduleRegex
))
{
if
(
std
::
regex_match
(
path_
,
results
,
moduleRegex
))
{
if
(
results2
.
size
()
==
5
)
{
if
(
results
.
size
()
==
6
)
{
int
ipcIdx
=
stoi
(
results2
[
1
].
str
());
matched
=
true
;
int
modIdx
=
stoi
(
results2
[
3
].
str
());
string
mgrSn
=
results
[
1
].
str
();
string
modName
=
results2
[
2
].
str
();
int
ipcIdx
=
stoi
(
results
[
2
].
str
());
string
propName
=
results2
[
4
].
str
();
int
modIdx
=
stoi
(
results
[
4
].
str
());
if
(
d
[
"op"
]
==
"replace"
||
d
[
"op"
]
==
"add"
)
{
string
modName
=
results
[
3
].
str
();
auto
&
oldMod
=
oldConfig
[
sn
][
"ipcs"
][
ipcIdx
][
"modules"
][
modName
][
modIdx
];
string
propName
=
results
[
5
].
str
();
auto
&
newMod
=
newConfig
[
sn
][
"ipcs"
][
ipcIdx
][
"modules"
][
modName
][
modIdx
];
if
(
d
[
"op"
]
==
"replace"
||
d
[
"op"
]
==
"add"
||
d
[
"op"
]
==
"remove"
)
{
auto
&
oldMod
=
oldConfig
[
mgrSn
][
"ipcs"
][
ipcIdx
][
"modules"
][
modName
][
modIdx
];
auto
&
newMod
=
newConfig
[
mgrSn
][
"ipcs"
][
ipcIdx
][
"modules"
][
modName
][
modIdx
];
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
);
...
@@ -113,6 +130,24 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -113,6 +130,24 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
}
}
}
}
if
(
newMod
.
count
(
"sn"
)
==
0
)
{
string
msg
=
fmt
::
format
(
"invalid module config ipcs[{}]['modules'][{}][{}] having no sn field"
,
ipcIdx
,
modName
,
modIdx
);
spdlog
::
error
(
msg
);
hasError
=
true
;
break
;
}
if
(
newMod
[
"sn"
].
get
<
string
>
()
!=
sn
&&
oldMod
.
count
(
"sn"
)
!=
0
&&
oldMod
[
"sn"
].
get
<
string
>
()
==
sn
)
{
string
oldGid
=
sn
+
":"
+
modName
+
":"
+
to_string
(
oldMod
[
"iid"
].
get
<
int
>
());
ret
[
"data"
][
oldGid
]
=
0
;
continue
;
}
else
if
(
newMod
[
"sn"
].
get
<
string
>
()
!=
sn
&&
(
oldMod
.
count
(
"sn"
)
==
0
||
(
oldMod
.
count
(
"sn"
)
!=
0
&&
oldMod
[
"sn"
].
get
<
string
>
()
!=
sn
))){
// ignore
continue
;
}
else
{
// oldSn == newSn == sn, below
}
string
oldGid
=
sn
+
":"
+
modName
+
":"
+
to_string
(
oldMod
[
"iid"
].
get
<
int
>
());
string
oldGid
=
sn
+
":"
+
modName
+
":"
+
to_string
(
oldMod
[
"iid"
].
get
<
int
>
());
string
newGid
=
sn
+
":"
+
modName
+
":"
+
to_string
(
newMod
[
"iid"
].
get
<
int
>
());
string
newGid
=
sn
+
":"
+
modName
+
":"
+
to_string
(
newMod
[
"iid"
].
get
<
int
>
());
...
@@ -121,7 +156,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -121,7 +156,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
}
}
if
(
propName
==
"enabled"
)
{
if
(
propName
==
"enabled"
)
{
if
(
newMod
[
"enabled"
].
get
<
int
>
()
==
0
)
{
if
(
newMod
.
count
(
"enabled"
)
==
0
||
newMod
[
"enabled"
].
get
<
int
>
()
==
0
)
{
ret
[
"data"
][
newGid
]
=
0
;
ret
[
"data"
][
newGid
]
=
0
;
}
else
{
}
else
{
ret
[
"data"
][
newGid
]
=
1
;
ret
[
"data"
][
newGid
]
=
1
;
...
@@ -142,10 +177,35 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
...
@@ -142,10 +177,35 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
// else{
// else{
// spdlog::info("no match for module {}", path_);
// spdlog::info("no match for module {}", path_);
// }
// }
}
}
// whole submodule
if
(
!
matched
&&
!
hasError
)
{
// /PSBV7GKN/ipcs/0/modules/evpusher/0
// {"enabled":0,"iid":1,"password":"","sn":"PSBV7GKN","token":"","urlDest":"rtsp://40.73.41.176/PSBV7GKN","user":""}
string
moduleRegStr
=
"/(
\\
w+)/ipcs/(
\\
d+)/modules/(
\\
w+)/(
\\
d+)"
;
std
::
regex
moduleRegex
(
moduleRegStr
);
std
::
smatch
results
;
if
(
std
::
regex_match
(
path_
,
results
,
moduleRegex
))
{
if
(
results
.
size
()
==
5
)
{
matched
=
true
;
string
mgrSn
=
results
[
1
].
str
();
int
ipcIdx
=
stoi
(
results
[
2
].
str
());
int
modIdx
=
stoi
(
results
[
4
].
str
());
string
modName
=
results
[
3
].
str
();
auto
&
modObj
=
d
[
"value"
];
if
(
modObj
.
count
(
"sn"
)
==
0
&&
d
[
"op"
]
!=
"remove"
)
{
string
msg
=
fmt
::
format
(
"invalid modue config having no sn /{}/ipcs/{}/modules/{}/{}"
,
mgrSn
,
ipcIdx
,
modName
,
modIdx
);
// /spdlog
}
}
}
}
if
(
hasError
){
if
(
hasError
){
ret
[
"code"
]
=
1
;
ret
[
"code"
]
=
1
;
break
;
}
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论