Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
f10da790
提交
f10da790
authored
9月 09, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
big refacting of communitation architect
上级
da155b43
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
134 行增加
和
3 行删除
+134
-3
evdaemon.cpp
opencv-motion-detect/evdaemon.cpp
+54
-1
evmlmotion.cpp
opencv-motion-detect/evmlmotion.cpp
+5
-1
evpuller.cpp
opencv-motion-detect/evpuller.cpp
+6
-0
evpusher.cpp
opencv-motion-detect/evpusher.cpp
+6
-0
evslicer.cpp
opencv-motion-detect/evslicer.cpp
+6
-0
utils.hpp
opencv-motion-detect/inc/utils.hpp
+57
-1
没有找到文件。
opencv-motion-detect/evdaemon.cpp
浏览文件 @
f10da790
...
@@ -165,7 +165,8 @@ class EvDaemon{
...
@@ -165,7 +165,8 @@ class EvDaemon{
void
setupSubSystems
()
{
void
setupSubSystems
()
{
thMon
=
thread
([
this
](){
thMon
=
thread
([
this
](){
while
(
true
)
{
while
(
true
)
{
if
(
bReload
)
{
if
(
this
->
bReload
)
{
cleanupSubSystems
();
int
ret
=
reloadCfg
();
int
ret
=
reloadCfg
();
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
cleanupSubSystems
();
cleanupSubSystems
();
...
@@ -181,6 +182,46 @@ class EvDaemon{
...
@@ -181,6 +182,46 @@ class EvDaemon{
thMon
.
detach
();
thMon
.
detach
();
}
}
int
startSubModule
(
string
peerId
){
int
ret
=
0
;
if
(
peerData
[
"status"
].
count
(
peerId
)
==
0
||
peerData
[
"status"
][
peerId
]
==
0
)
{
//
}
else
if
(
peerData
[
"pids"
].
count
(
peerId
)
!=
0
){
kill
(
peerData
[
"pids"
][
peerId
],
SIGTERM
);
peerData
[
"pids"
].
erase
(
peerId
);
peerData
[
"status"
][
peerId
]
=
0
;
}
json
jret
=
cloudutils
::
reqConfig
(
this
->
info
);
// apply config
try
{
if
(
jret
[
"code"
]
!=
0
)
{
spdlog
::
error
(
"evdaemon {} request cloud configration error: {}"
,
this
->
devSn
,
jret
[
"msg"
].
get
<
string
>
());
return
2
;
}
json
*
cfg
=
cfgutils
::
findModuleConfig
(
peerId
,
jret
[
"data"
]);
if
(
cfg
==
NULL
)
{
spdlog
::
error
(
"evdaemon failed to find module {} in config {}"
,
peerId
,
jret
[
"data"
].
dump
());
return
1
;
}
peerData
[
"config"
][
peerId
]
=
*
cfg
;
peerData
[
"status"
][
peerId
]
=
0
;
pid_t
pid
;
ret
=
zmqhelper
::
forkSubsystem
(
devSn
,
peerId
,
portRouter
,
pid
);
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evdaemon {} failed to fork subsystem: {}"
,
devSn
,
peerId
);
// TODO: clean up and reload config
return
-
3
;
}
this
->
peerData
[
"pids"
][
peerId
]
=
pid
;
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"evdaemon {} exception : {}"
,
devSn
,
e
.
what
());
return
-
1
;
}
return
0
;
}
int
handleMsg
(
vector
<
vector
<
uint8_t
>
>
&
body
)
int
handleMsg
(
vector
<
vector
<
uint8_t
>
>
&
body
)
{
{
...
@@ -217,7 +258,11 @@ class EvDaemon{
...
@@ -217,7 +258,11 @@ class EvDaemon{
}
}
else
{
else
{
peerData
[
"status"
][
selfId
]
=
0
;
peerData
[
"status"
][
selfId
]
=
0
;
peerData
[
"pids"
].
erase
(
selfId
);
peerData
[
"config"
].
erase
(
selfId
);
spdlog
::
warn
(
"evdaemon {} peer disconnected: {}"
,
devSn
,
selfId
);
spdlog
::
warn
(
"evdaemon {} peer disconnected: {}"
,
devSn
,
selfId
);
// restart this module
startSubModule
(
selfId
);
}
}
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -377,6 +422,14 @@ class EvDaemon{
...
@@ -377,6 +422,14 @@ class EvDaemon{
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
});
});
svr
.
Get
(
"/sync-cloud"
,
[
this
](
const
Request
&
req
,
Response
&
res
){
json
ret
;
ret
[
"code"
]
=
0
;
ret
[
"msg"
]
=
"syncing ..."
;
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
this
->
bReload
=
true
;
});
svr
.
Get
(
"/reset"
,
[](
const
Request
&
req
,
Response
&
res
){
svr
.
Get
(
"/reset"
,
[](
const
Request
&
req
,
Response
&
res
){
json
ret
;
json
ret
;
ret
[
"code"
]
=
0
;
ret
[
"code"
]
=
0
;
...
...
opencv-motion-detect/evmlmotion.cpp
浏览文件 @
f10da790
...
@@ -93,7 +93,7 @@ private:
...
@@ -93,7 +93,7 @@ private:
// TODO: req config
// TODO: req config
bool
found
=
false
;
bool
found
=
false
;
try
{
try
{
spdlog
::
info
(
"evmlmotion {} config: {}"
,
devSn
,
config
.
dump
(
4
));
spdlog
::
info
(
"evmlmotion {} config: {}"
,
devSn
,
config
.
dump
());
json
evmlmotion
;
json
evmlmotion
;
json
&
evmgr
=
this
->
config
;
json
&
evmgr
=
this
->
config
;
json
ipc
;
json
ipc
;
...
@@ -585,6 +585,10 @@ protected:
...
@@ -585,6 +585,10 @@ protected:
bStopSig
=
true
;
bStopSig
=
true
;
break
;
break
;
}
}
if
(
1
==
getppid
())
{
spdlog
::
error
(
"evmlmotion {} exit since evdaemon is dead"
,
selfId
);
exit
(
1
);
}
// business logic
// business logic
int
ret
=
zmq_msg_init
(
&
msg
);
int
ret
=
zmq_msg_init
(
&
msg
);
...
...
opencv-motion-detect/evpuller.cpp
浏览文件 @
f10da790
...
@@ -305,6 +305,12 @@ protected:
...
@@ -305,6 +305,12 @@ protected:
bStopSig
=
true
;
bStopSig
=
true
;
break
;
break
;
}
}
if
(
1
==
getppid
())
{
spdlog
::
error
(
"evpuller {} exit since evdaemon is dead"
,
selfId
);
exit
(
1
);
}
AVStream
*
in_stream
;
AVStream
*
in_stream
;
AVPacket
packet
;
AVPacket
packet
;
zmq_msg_t
msg
;
zmq_msg_t
msg
;
...
...
opencv-motion-detect/evpusher.cpp
浏览文件 @
f10da790
...
@@ -320,6 +320,12 @@ protected:
...
@@ -320,6 +320,12 @@ protected:
bStopSig
=
true
;
bStopSig
=
true
;
break
;
break
;
}
}
if
(
1
==
getppid
())
{
spdlog
::
error
(
"evpusher {} exit since evdaemon is dead"
,
selfId
);
exit
(
1
);
}
ret
=
zmq_msg_init
(
&
msg
);
ret
=
zmq_msg_init
(
&
msg
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
spdlog
::
error
(
"failed to init zmq msg"
);
spdlog
::
error
(
"failed to init zmq msg"
);
...
...
opencv-motion-detect/evslicer.cpp
浏览文件 @
f10da790
...
@@ -361,6 +361,12 @@ protected:
...
@@ -361,6 +361,12 @@ protected:
bStopSig
=
true
;
bStopSig
=
true
;
break
;
break
;
}
}
if
(
1
==
getppid
())
{
spdlog
::
error
(
"evmgr {} exit since evdaemon is dead"
,
selfId
);
exit
(
1
);
}
// business logic
// business logic
int
ret
=
zmq_msg_init
(
&
msg
);
int
ret
=
zmq_msg_init
(
&
msg
);
ret
=
zmq_recvmsg
(
pSub
,
&
msg
,
0
);
ret
=
zmq_recvmsg
(
pSub
,
&
msg
,
0
);
...
...
opencv-motion-detect/inc/utils.hpp
浏览文件 @
f10da790
...
@@ -143,7 +143,63 @@ namespace cfgutils {
...
@@ -143,7 +143,63 @@ namespace cfgutils {
return
0
;
return
0
;
}
}
}
json
*
findModuleConfig
(
string
peerId
,
json
&
data
)
{
json
*
ret
=
NULL
;
auto
pp
=
strutils
::
split
(
peerId
,
':'
);
if
(
pp
.
size
()
!=
3
)
{
spdlog
::
error
(
"invalid peerId: {}"
,
peerId
);
return
ret
;
}
string
sn
=
pp
[
0
];
string
modName
=
pp
[
1
];
string
iid
=
pp
[
2
];
//
string
subMn
=
modName
.
substr
(
0
,
4
);
if
(
subMn
==
"evml"
)
{
subMn
=
modName
.
substr
(
4
,
modName
.
size
());
}
else
{
subMn
=
""
;
}
for
(
auto
&
[
k
,
v
]
:
data
.
items
())
{
// it's evmgr
if
(
modName
==
"evmgr"
)
{
if
(
k
==
sn
)
{
ret
=
&
v
;
break
;
}
}
else
{
json
&
ipcs
=
v
[
"ipcs"
];
for
(
auto
&
ipc
:
ipcs
)
{
json
&
modules
=
ipc
[
"modules"
];
for
(
auto
&
[
mn
,
ml
]
:
modules
.
items
())
{
for
(
auto
&
m
:
ml
)
{
if
(
subMn
.
empty
()){
if
(
mn
==
modName
&&
m
[
"sn"
]
==
sn
&&
m
[
"iid"
]
==
iid
&&
m
[
"enabled"
]
!=
0
)
{
ret
=
&
v
;
break
;
}
}
else
{
if
(
subMn
==
m
[
"type"
]
&&
m
[
iid
]
==
iid
&&
m
[
"sn"
]
==
sn
&&
m
[
"enabled"
]
!=
0
)
{
ret
=
&
v
;
break
;
}
}
}
if
(
ret
!=
NULL
)
break
;
}
if
(
ret
!=
NULL
)
break
;
}
}
}
return
ret
;
}
}
// cfgutils
struct
StrException
:
public
std
::
exception
struct
StrException
:
public
std
::
exception
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论