Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
6ee36698
提交
6ee36698
authored
9月 09, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
big refacting of communitation architect
上级
be9df0e8
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
53 行增加
和
28 行删除
+53
-28
evdaemon.cpp
opencv-motion-detect/evdaemon.cpp
+40
-25
evmgr.cpp
opencv-motion-detect/evmgr.cpp
+4
-0
utils.hpp
opencv-motion-detect/inc/utils.hpp
+9
-3
没有找到文件。
opencv-motion-detect/evdaemon.cpp
浏览文件 @
6ee36698
...
@@ -81,16 +81,20 @@ class EvDaemon{
...
@@ -81,16 +81,20 @@ class EvDaemon{
// startup evmgr
// startup evmgr
peerId
=
v
[
"sn"
].
get
<
string
>
()
+
":evmgr:0"
;
peerId
=
v
[
"sn"
].
get
<
string
>
()
+
":evmgr:0"
;
// offline
// offline
this
->
peerData
[
"status"
][
peerId
]
=
0
;
this
->
peerData
[
"config"
][
peerId
]
=
v
;
this
->
peerData
[
"config"
][
peerId
]
=
v
;
ret
=
zmqhelper
::
forkSubsystem
(
devSn
,
peerId
,
portRouter
,
pid
);
if
(
this
->
peerData
[
"status"
].
count
(
peerId
)
==
0
||
this
->
peerData
[
"status"
][
peerId
]
==
0
)
{
if
(
ret
!=
0
)
{
this
->
peerData
[
"status"
][
peerId
]
=
0
;
spdlog
::
error
(
"evdaemon {} failed to fork subsystem: {}"
,
devSn
,
peerId
);
ret
=
zmqhelper
::
forkSubsystem
(
devSn
,
peerId
,
portRouter
,
pid
);
// TODO: clean up and reload config
if
(
ret
!=
0
)
{
exit
(
1
);
spdlog
::
error
(
"evdaemon {} failed to fork subsystem: {}"
,
devSn
,
peerId
);
}
// TODO: clean up and reload config
this
->
peerData
[
"pids"
][
peerId
]
=
pid
;
exit
(
1
);
spdlog
::
info
(
"evdaemon {} created subsystem {}"
,
devSn
,
peerId
);
}
this
->
peerData
[
"pids"
][
peerId
]
=
pid
;
spdlog
::
info
(
"evdaemon {} created subsystem {}"
,
devSn
,
peerId
);
}
else
{
// TODO:
}
}
}
// startup other submodules
// startup other submodules
...
@@ -110,16 +114,21 @@ class EvDaemon{
...
@@ -110,16 +114,21 @@ class EvDaemon{
// TODO: cleanup and reload
// TODO: cleanup and reload
}
}
this
->
peerData
[
"status"
][
peerId
]
=
0
;
this
->
peerData
[
"config"
][
peerId
]
=
v
;
this
->
peerData
[
"config"
][
peerId
]
=
v
;
ret
=
zmqhelper
::
forkSubsystem
(
devSn
,
peerId
,
portRouter
,
pid
);
if
(
ret
!=
0
)
{
if
(
this
->
peerData
[
"status"
].
count
(
peerId
)
==
0
||
this
->
peerData
[
"status"
][
peerId
]
==
0
)
{
spdlog
::
error
(
"evdaemon {} failed to fork subsystem: {}"
,
devSn
,
peerId
);
this
->
peerData
[
"status"
][
peerId
]
=
0
;
// TODO: cleanup and reload
ret
=
zmqhelper
::
forkSubsystem
(
devSn
,
peerId
,
portRouter
,
pid
);
exit
(
1
);
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evdaemon {} failed to fork subsystem: {}"
,
devSn
,
peerId
);
// TODO: cleanup and reload
exit
(
1
);
}
this
->
peerData
[
"pids"
][
peerId
]
=
pid
;
spdlog
::
info
(
"evdaemon {} created subsystem {}"
,
devSn
,
peerId
);
}
else
{
// TODO:
}
}
this
->
peerData
[
"pids"
][
peerId
]
=
pid
;
spdlog
::
info
(
"evdaemon {} created subsystem {}"
,
devSn
,
peerId
);
}
}
}
}
}
}
...
@@ -139,8 +148,10 @@ class EvDaemon{
...
@@ -139,8 +148,10 @@ class EvDaemon{
int
ret
=
reloadCfg
();
int
ret
=
reloadCfg
();
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evdaemon {} failed to setup subsystems, please check log for more info"
,
this
->
devSn
);
spdlog
::
error
(
"evdaemon {} failed to setup subsystems, please check log for more info"
,
this
->
devSn
);
this_thread
::
sleep_for
(
chrono
::
seconds
(
5
));
}
}
this_thread
::
sleep_for
(
chrono
::
seconds
(
5
));
break
;
break
;
}
}
});
});
...
@@ -163,12 +174,12 @@ class EvDaemon{
...
@@ -163,12 +174,12 @@ class EvDaemon{
return
-
1
;
return
-
1
;
}
}
if
(
peerData
[
"status"
].
count
(
selfId
)
==
0
)
{
//
if(peerData["status"].count(selfId) == 0) {
spdlog
::
warn
(
"evdaemon {} unkown module with id: {}, peerStats {}"
,
devSn
,
selfId
,
peerData
[
"status"
].
dump
(
4
));
//
spdlog::warn("evdaemon {} unkown module with id: {}, peerStats {}", devSn, selfId, peerData["status"].dump(4));
return
-
1
;
//
return -1;
}
//
}
if
(
peerData
[
"status"
][
selfId
]
==
0
)
{
if
(
peerData
[
"status"
]
.
count
(
selfId
)
==
0
||
peerData
[
"status"
]
[
selfId
]
==
0
)
{
peerData
[
"status"
][
selfId
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
peerData
[
"status"
][
selfId
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
spdlog
::
info
(
"evdaemon {} peer connected: {}"
,
devSn
,
selfId
);
spdlog
::
info
(
"evdaemon {} peer connected: {}"
,
devSn
,
selfId
);
eventConn
=
true
;
eventConn
=
true
;
...
@@ -344,8 +355,12 @@ class EvDaemon{
...
@@ -344,8 +355,12 @@ class EvDaemon{
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
});
});
svr
.
Post
(
"/reset"
,
[](
const
Request
&
req
,
Response
&
res
){
svr
.
Get
(
"/reset"
,
[](
const
Request
&
req
,
Response
&
res
){
json
ret
;
ret
[
"code"
]
=
0
;
ret
[
"msg"
]
=
"resetting ..."
;
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
kill
(
getpid
(),
SIGTERM
);
});
});
svr
.
listen
(
"0.0.0.0"
,
8088
);
svr
.
listen
(
"0.0.0.0"
,
8088
);
...
...
opencv-motion-detect/evmgr.cpp
浏览文件 @
6ee36698
...
@@ -259,6 +259,10 @@ protected:
...
@@ -259,6 +259,10 @@ protected:
bStopSig
=
true
;
bStopSig
=
true
;
break
;
break
;
}
}
if
(
1
==
getppid
())
{
spdlog
::
error
(
"evmgr {} exit since evdaemon is dead"
,
devSn
);
exit
(
1
);
}
auto
body
=
z_recv_multiple
(
pRouter
,
false
);
auto
body
=
z_recv_multiple
(
pRouter
,
false
);
if
(
body
.
size
()
==
0
)
{
if
(
body
.
size
()
==
0
)
{
spdlog
::
error
(
"evmgr {} failed to receive multiple msg: {}"
,
devSn
,
zmq_strerror
(
zmq_errno
()));
spdlog
::
error
(
"evmgr {} failed to receive multiple msg: {}"
,
devSn
,
zmq_strerror
(
zmq_errno
()));
...
...
opencv-motion-detect/inc/utils.hpp
浏览文件 @
6ee36698
...
@@ -51,6 +51,12 @@ json registry(json &conf, string sn, string module) {
...
@@ -51,6 +51,12 @@ json registry(json &conf, string sn, string module) {
return
ret
;
return
ret
;
}
}
#define EVCLOUD_REQ_E_CONN -2
#define EVCLOUD_REQ_E_DATA -3
#define EVCLOUD_REQ_E_PARAM -4
#define EVCLOUD_REQ_E_ABORT -5
#define EVCLOUD_REQ_E_NONE 0
/// req config
/// req config
json
reqConfig
(
json
&
info
){
json
reqConfig
(
json
&
info
){
json
ret
;
json
ret
;
...
@@ -61,7 +67,7 @@ json reqConfig(json &info){
...
@@ -61,7 +67,7 @@ json reqConfig(json &info){
string
sn
=
info
.
at
(
"sn"
).
get
<
string
>
();
string
sn
=
info
.
at
(
"sn"
).
get
<
string
>
();
if
(
uri
.
Host
.
empty
()
||
uri
.
Port
.
empty
()
||
uri
.
Protocol
.
find
(
"http"
)
==
string
::
npos
)
{
if
(
uri
.
Host
.
empty
()
||
uri
.
Port
.
empty
()
||
uri
.
Protocol
.
find
(
"http"
)
==
string
::
npos
)
{
string
msg
=
string
(
__FILE__
)
+
":"
+
to_string
(
__LINE__
)
+
": request cloud configuration error. invalid api-cloud in info: "
+
api
;
string
msg
=
string
(
__FILE__
)
+
":"
+
to_string
(
__LINE__
)
+
": request cloud configuration error. invalid api-cloud in info: "
+
api
;
ret
[
"code"
]
=
1
;
ret
[
"code"
]
=
EVCLOUD_REQ_E_PARAM
;
ret
[
"msg"
]
=
msg
;
ret
[
"msg"
]
=
msg
;
spdlog
::
error
(
msg
);
spdlog
::
error
(
msg
);
return
ret
;
return
ret
;
...
@@ -76,7 +82,7 @@ json reqConfig(json &info){
...
@@ -76,7 +82,7 @@ json reqConfig(json &info){
const
char
*
msg
=
NULL
;
const
char
*
msg
=
NULL
;
if
(
res
==
nullptr
)
{
if
(
res
==
nullptr
)
{
msg
=
(
string
(
"error to connect to server: "
)
+
api
+
"/config"
).
c_str
();
msg
=
(
string
(
"error to connect to server: "
)
+
api
+
"/config"
).
c_str
();
ret
[
"code"
]
=
-
2
;
ret
[
"code"
]
=
EVCLOUD_REQ_E_CONN
;
}
else
{
}
else
{
msg
=
httplib
::
detail
::
status_message
(
res
->
status
);
msg
=
httplib
::
detail
::
status_message
(
res
->
status
);
ret
[
"code"
]
=
res
->
status
;
ret
[
"code"
]
=
res
->
status
;
...
@@ -88,7 +94,7 @@ json reqConfig(json &info){
...
@@ -88,7 +94,7 @@ json reqConfig(json &info){
ret
=
json
::
parse
(
res
->
body
);
ret
=
json
::
parse
(
res
->
body
);
}
}
}
catch
(
exception
&
e
)
{
}
catch
(
exception
&
e
)
{
ret
[
"code"
]
=
-
1
;
ret
[
"code"
]
=
EVCLOUD_REQ_E_DATA
;
string
msg
=
string
(
__FILE__
)
+
":"
+
to_string
(
__LINE__
)
+
string
(
": registry exception - "
)
+
e
.
what
();
string
msg
=
string
(
__FILE__
)
+
":"
+
to_string
(
__LINE__
)
+
string
(
": registry exception - "
)
+
e
.
what
();
ret
[
"msg"
]
=
msg
;
ret
[
"msg"
]
=
msg
;
spdlog
::
error
(
msg
);
spdlog
::
error
(
msg
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论