Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
ed80379a
提交
ed80379a
authored
8月 29, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init
上级
a1b5acad
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
166 行增加
和
86 行删除
+166
-86
Makefile
opencv-motion-detect/Makefile
+1
-1
database.cpp
opencv-motion-detect/database.cpp
+84
-3
evmgr.cpp
opencv-motion-detect/evmgr.cpp
+16
-1
evmlmotion.cpp
opencv-motion-detect/evmlmotion.cpp
+43
-61
evpuller.cpp
opencv-motion-detect/evpuller.cpp
+5
-6
evpusher.cpp
opencv-motion-detect/evpusher.cpp
+6
-7
evslicer.cpp
opencv-motion-detect/evslicer.cpp
+6
-6
database.h
opencv-motion-detect/inc/database.h
+5
-1
没有找到文件。
opencv-motion-detect/Makefile
浏览文件 @
ed80379a
#
DEBUG=-g
DEBUG
=
-g
CC
=
gcc
CPP
=
g++
CPPFLAGS
=
$(DEBUG)
-Wall
-std
=
gnu++1z
...
...
opencv-motion-detect/database.cpp
浏览文件 @
ed80379a
...
...
@@ -56,13 +56,28 @@ namespace LVDB {
break
;
}
else
{
json
&
modules
=
ipc
[
"modules"
];
if
(
modules
.
count
(
moduleName
)
==
0
){
string
modname
=
moduleName
.
substr
(
0
,
4
);
string
sub
;
if
(
modname
==
"evml"
)
{
sub
=
moduleName
.
substr
(
4
,
moduleName
.
size
());
}
else
{
modname
=
moduleName
;
}
if
(
modules
.
count
(
modname
)
==
0
){
break
;
}
else
{
json
&
module
=
modules
[
mod
uleN
ame
];
json
&
module
=
modules
[
mod
n
ame
];
for
(
auto
&
inst
:
module
)
{
if
(
inst
.
count
(
"sn"
)
!=
0
&&
inst
[
"sn"
]
==
sn
&&
inst
.
count
(
"iid"
)
!=
0
&&
inst
[
"iid"
]
==
iid
)
{
return
&
inst
;
if
(
!
sub
.
empty
())
{
if
(
inst
.
count
(
"type"
)
!=
0
&&
inst
[
"type"
]
==
sub
)
{
return
&
inst
;
}
// continue
}
else
{
return
&
inst
;
}
}
}
}
...
...
@@ -74,6 +89,72 @@ namespace LVDB {
return
ret
;
}
int
traverseConfigureModules
(
json
&
config
,
cb_traverse_configration_module
cb
,
string
moduleName
){
int
ret
=
0
;
if
(
config
.
count
(
"data"
)
==
0
)
{
return
-
1
;
}
if
(
cb
==
NULL
)
{
return
-
2
;
}
json
&
data
=
config
[
"data"
];
for
(
auto
&
[
k
,
v
]
:
data
.
items
()){
json
&
mgr
=
data
[
k
];
if
(
mgr
.
count
(
"ipcs"
)
==
0
)
{
break
;
}
else
{
json
&
ipcs
=
mgr
[
"ipcs"
];
for
(
auto
&
ipc
:
ipcs
)
{
if
(
ipc
.
count
(
"modules"
)
==
0
)
{
continue
;
}
else
{
string
modname
,
sub
;
if
(
!
moduleName
.
empty
()){
modname
=
moduleName
.
substr
(
0
,
4
);
if
(
modname
==
"evml"
)
{
sub
=
moduleName
.
substr
(
4
,
moduleName
.
size
());
}
else
{
modname
=
moduleName
;
}
}
json
&
modules
=
ipc
[
"modules"
];
if
(
!
modname
.
empty
())
{
if
(
modules
.
count
(
modname
)
==
0
)
{
return
-
3
;
}
else
{
json
&
module
=
modules
[
modname
];
if
(
!
sub
.
empty
())
{
for
(
auto
&
m
:
module
)
{
if
(
m
.
count
(
"type"
)
!=
0
&&
m
[
"type"
]
==
sub
)
{
ret
=
cb
(
modname
,
m
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to traverse and callback config on module: {}"
,
m
.
dump
());
return
ret
;
}
}
}
}
}
}
else
{
for
(
auto
&
[
mn
,
mod
]
:
modules
.
items
())
{
for
(
auto
&
m
:
mod
)
{
ret
=
cb
(
mn
,
m
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to traverse and callback config on module: {}"
,
m
.
dump
());
return
ret
;
}
}
}
}
}
}
}
}
return
0
;
}
int
_getDB
(
string
fileName
,
DB
**
pdb
)
{
static
bool
bmk
=
false
;
int
ret
=
0
;
...
...
opencv-motion-detect/evmgr.cpp
浏览文件 @
ed80379a
...
...
@@ -72,6 +72,21 @@ private:
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
// set all module status to 0
ret
=
LVDB
::
traverseConfigureModules
(
config
,
[](
string
modname
,
json
&
m
)
->
int
{
if
(
m
.
count
(
"status"
)
!=
0
)
{
cout
<<
modname
<<
" ,"
<<
m
.
dump
()
<<
endl
;
m
[
"status"
]
=
0
;
}
return
0
;
});
if
(
ret
<
0
)
{
spdlog
::
error
(
"evmgr {} failed to set module status to 0"
,
devSn
);
}
else
{
//spdlog::info("new config: {}", config.dump());
LVDB
::
setLocalConfig
(
config
);
}
int
opt_notify
=
ZMQ_NOTIFY_DISCONNECT
|
ZMQ_NOTIFY_CONNECT
;
string
proto
,
addr
;
...
...
@@ -243,7 +258,7 @@ togo_sleep_continue:
}
else
{
// message to mgr
spdlog
::
info
(
"evmgr {} subsystem report msg received: {}; {}; {}"
,
devSn
,
zmqhelper
::
body2str
(
body
[
0
]),
zmqhelper
::
body2str
(
body
[
1
]),
zmqhelper
::
body2str
(
body
[
2
]));
//
spdlog::info("evmgr {} subsystem report msg received: {}; {}; {}", devSn, zmqhelper::body2str(body[0]), zmqhelper::body2str(body[1]), zmqhelper::body2str(body[2]));
if
(
meta
==
"pong"
||
meta
==
"ping"
)
{
// update status
spdlog
::
info
(
"evmgr {}, ping msg from {}"
,
devSn
,
selfId
);
...
...
opencv-motion-detect/evmlmotion.cpp
浏览文件 @
ed80379a
...
...
@@ -99,19 +99,18 @@ private:
tsLastBoot
=
info
[
"lastboot"
];
tsUpdateTime
=
info
[
"updatetime"
];
spdlog
::
info
(
"evm
gr
info: sn = {}, lastboot = {}, updatetime = {}"
,
info
[
"sn"
].
get
<
string
>
(),
ctime
(
&
tsLastBoot
),
ctime
(
&
tsUpdateTime
));
spdlog
::
info
(
"evm
lmotion
info: sn = {}, lastboot = {}, updatetime = {}"
,
info
[
"sn"
].
get
<
string
>
(),
ctime
(
&
tsLastBoot
),
ctime
(
&
tsUpdateTime
));
devSn
=
info
[
"sn"
];
ret
=
LVDB
::
getLocalConfig
(
config
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
while
(
!
inited
)
{
// TODO: req config
bool
found
=
false
;
try
{
ret
=
LVDB
::
getLocalConfig
(
config
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
spdlog
::
info
(
"config: {:s}"
,
config
.
dump
());
json
evmlmotion
;
json
evmgr
;
...
...
@@ -162,7 +161,7 @@ private:
// TODO: multiple protocols support
if
(
evmlmotion
.
count
(
"path"
)
==
0
)
{
spdlog
::
warn
(
"evslicer {}
{}
no params for path, using default: {}"
,
selfId
,
URLOUT_DEFAULT
);
spdlog
::
warn
(
"evslicer {} no params for path, using default: {}"
,
selfId
,
URLOUT_DEFAULT
);
urlOut
=
URLOUT_DEFAULT
;
}
else
{
...
...
@@ -174,6 +173,42 @@ private:
spdlog
::
error
(
"failed mkdir {}"
,
urlOut
);
return
-
1
;
}
// setup sub
pSubCtx
=
zmq_ctx_new
();
pSub
=
zmq_socket
(
pSubCtx
,
ZMQ_SUB
);
ret
=
zmq_setsockopt
(
pSub
,
ZMQ_SUBSCRIBE
,
""
,
0
);
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evmlmotion {} failed set setsockopt: {}"
,
selfId
,
urlPub
);
return
-
1
;
}
ret
=
zmq_connect
(
pSub
,
urlPub
.
c_str
());
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evmlmotion {} failed connect pub: {}"
,
selfId
,
urlPub
);
return
-
2
;
}
// setup dealer
pDealerCtx
=
zmq_ctx_new
();
pDealer
=
zmq_socket
(
pDealerCtx
,
ZMQ_DEALER
);
spdlog
::
info
(
"evmlmotion {} connect to router {}"
,
selfId
,
urlRouter
);
ret
=
zmq_setsockopt
(
pDealer
,
ZMQ_IDENTITY
,
selfId
.
c_str
(),
selfId
.
size
());
ret
+=
zmq_setsockopt
(
pDealer
,
ZMQ_ROUTING_ID
,
selfId
.
c_str
(),
selfId
.
size
());
if
(
ret
<
0
)
{
spdlog
::
error
(
"evpusher {} {} failed setsockopts router: {}"
,
selfId
,
urlRouter
);
return
-
3
;
}
if
(
ret
<
0
)
{
spdlog
::
error
(
"evmlmotion {} failed setsockopts router: {}"
,
selfId
,
urlRouter
);
return
-
3
;
}
ret
=
zmq_connect
(
pDealer
,
urlRouter
.
c_str
());
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evmlmotion {} failed connect dealer: {}"
,
selfId
,
urlRouter
);
return
-
4
;
}
//ping
ret
=
ping
();
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"evmlmotion {} exception in EvPuller.init {:s} retrying"
,
selfId
,
e
.
what
());
...
...
@@ -209,58 +244,6 @@ private:
return
ret
;
}
int
setupMq
()
{
int
ret
=
0
;
// setup sub
pSubCtx
=
zmq_ctx_new
();
pSub
=
zmq_socket
(
pSubCtx
,
ZMQ_SUB
);
ret
=
zmq_setsockopt
(
pSub
,
ZMQ_SUBSCRIBE
,
""
,
0
);
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evmlmotion {} failed set setsockopt: {}"
,
selfId
,
urlPub
);
return
-
1
;
}
ret
=
zmq_connect
(
pSub
,
urlPub
.
c_str
());
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evmlmotion {} failed connect pub: {}"
,
selfId
,
urlPub
);
return
-
2
;
}
// setup dealer
pDealerCtx
=
zmq_ctx_new
();
pDealer
=
zmq_socket
(
pDealerCtx
,
ZMQ_DEALER
);
spdlog
::
info
(
"evmlmotion {} try create req to {}"
,
selfId
,
urlRouter
);
ret
=
zmq_setsockopt
(
pDealer
,
ZMQ_IDENTITY
,
selfId
.
c_str
(),
selfId
.
size
());
ret
+=
zmq_setsockopt
(
pDealer
,
ZMQ_ROUTING_ID
,
selfId
.
c_str
(),
selfId
.
size
());
if
(
ret
<
0
)
{
spdlog
::
error
(
"evpusher {} {} failed setsockopts router: {}"
,
selfId
,
urlRouter
);
return
-
3
;
}
if
(
ret
<
0
)
{
spdlog
::
error
(
"evmlmotion {} failed setsockopts router: {}"
,
selfId
,
urlRouter
);
return
-
3
;
}
ret
=
zmq_connect
(
pDealer
,
urlRouter
.
c_str
());
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evmlmotion {} failed connect dealer: {}"
,
selfId
,
urlRouter
);
return
-
4
;
}
//ping
ret
=
ping
();
// TODO: don't need this anymore, since I've used the draft feature of ZOUTER_NOTIFICATION instead
// thPing = thread([&,this]() {
// while(true) {
// this_thread::sleep_for(chrono::seconds(EV_HEARTBEAT_SECONDS-2));
// ping();
// }
// });
// thPing.detach();
return
ret
;
}
int
getInputFormat
()
{
int
ret
=
0
;
...
...
@@ -639,7 +622,6 @@ public:
{
evtQueue
=
queue
;
init
();
setupMq
();
getInputFormat
();
setupStream
();
};
...
...
opencv-motion-detect/evpuller.cpp
浏览文件 @
ed80379a
...
...
@@ -168,17 +168,16 @@ private:
spdlog
::
info
(
"evpuller info: sn = {}, lastboot = {}, updatetime = {}"
,
info
[
"sn"
].
get
<
string
>
(),
ctime
(
&
tsLastBoot
),
ctime
(
&
tsUpdateTime
));
devSn
=
info
[
"sn"
];
ret
=
LVDB
::
getLocalConfig
(
config
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
while
(
!
inited
)
{
// TODO: req config
bool
found
=
false
;
string
user
,
passwd
,
addr
;
try
{
ret
=
LVDB
::
getLocalConfig
(
config
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
spdlog
::
info
(
"config dump: {:s}"
,
config
.
dump
());
json
data
=
config
[
"data"
];
// first try to check mgr with same sn
...
...
opencv-motion-detect/evpusher.cpp
浏览文件 @
ed80379a
...
...
@@ -63,19 +63,18 @@ private:
tsLastBoot
=
info
[
"lastboot"
];
tsUpdateTime
=
info
[
"updatetime"
];
spdlog
::
info
(
"ev
mg
r info: sn = {}, lastboot = {}, updatetime = {}"
,
info
[
"sn"
].
get
<
string
>
(),
ctime
(
&
tsLastBoot
),
ctime
(
&
tsUpdateTime
));
spdlog
::
info
(
"ev
pushe
r info: sn = {}, lastboot = {}, updatetime = {}"
,
info
[
"sn"
].
get
<
string
>
(),
ctime
(
&
tsLastBoot
),
ctime
(
&
tsUpdateTime
));
devSn
=
info
[
"sn"
];
ret
=
LVDB
::
getLocalConfig
(
config
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
while
(
!
inited
)
{
// TODO: req config
bool
found
=
false
;
try
{
ret
=
LVDB
::
getLocalConfig
(
config
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
spdlog
::
info
(
"config: {:s}"
,
config
.
dump
());
json
evpusher
;
json
evmgr
;
...
...
opencv-motion-detect/evslicer.cpp
浏览文件 @
ed80379a
...
...
@@ -72,19 +72,19 @@ private:
tsLastBoot
=
info
[
"lastboot"
];
tsUpdateTime
=
info
[
"updatetime"
];
spdlog
::
info
(
"ev
mg
r info: sn = {}, lastboot = {}, updatetime = {}"
,
info
[
"sn"
].
get
<
string
>
(),
ctime
(
&
tsLastBoot
),
ctime
(
&
tsUpdateTime
));
spdlog
::
info
(
"ev
slice
r info: sn = {}, lastboot = {}, updatetime = {}"
,
info
[
"sn"
].
get
<
string
>
(),
ctime
(
&
tsLastBoot
),
ctime
(
&
tsUpdateTime
));
devSn
=
info
[
"sn"
];
ret
=
LVDB
::
getLocalConfig
(
config
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
// TODO: read local slices list and last index
while
(
!
inited
)
{
// TODO: req config
bool
found
=
false
;
try
{
ret
=
LVDB
::
getLocalConfig
(
config
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
spdlog
::
info
(
"config: {:s}"
,
config
.
dump
());
json
evslicer
;
json
evmgr
;
...
...
opencv-motion-detect/inc/database.h
浏览文件 @
ed80379a
...
...
@@ -41,7 +41,10 @@ namespace LVDB {
// log
int
getLog
(
json
&
log
,
json
&
writeOptions
,
string
fileName
);
int
setLog
(
json
&
log
,
json
&
readOptions
,
string
fileName
);
int
setLog
(
json
&
log
,
json
&
readOptions
,
string
fileName
);
typedef
int
(
*
cb_traverse_configration_module
)(
string
modname
,
json
&
mod
);
int
traverseConfigureModules
(
json
&
config
,
cb_traverse_configration_module
cb
,
string
moduleName
=
""
);
}
#endif
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论