Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
a1b5acad
提交
a1b5acad
authored
8月 29, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init
上级
452d784e
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
78 行增加
和
13 行删除
+78
-13
database.cpp
opencv-motion-detect/database.cpp
+33
-0
evmgr.cpp
opencv-motion-detect/evmgr.cpp
+26
-4
evpusher.cpp
opencv-motion-detect/evpusher.cpp
+5
-5
common.hpp
opencv-motion-detect/inc/common.hpp
+12
-2
database.h
opencv-motion-detect/inc/database.h
+2
-2
没有找到文件。
opencv-motion-detect/database.cpp
浏览文件 @
a1b5acad
...
@@ -41,6 +41,39 @@ namespace LVDB {
...
@@ -41,6 +41,39 @@ namespace LVDB {
#define LVDB_ERROR_HELD -1
#define LVDB_ERROR_HELD -1
#define LVDB_ERROR_OTHER -2
#define LVDB_ERROR_OTHER -2
json
*
findConfigModule
(
json
&
config
,
string
sn
,
string
moduleName
,
int
iid
)
{
json
*
ret
=
NULL
;
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
)
{
break
;
}
else
{
json
&
modules
=
ipc
[
"modules"
];
if
(
modules
.
count
(
moduleName
)
==
0
){
break
;
}
else
{
json
&
module
=
modules
[
moduleName
];
for
(
auto
&
inst
:
module
)
{
if
(
inst
.
count
(
"sn"
)
!=
0
&&
inst
[
"sn"
]
==
sn
&&
inst
.
count
(
"iid"
)
!=
0
&&
inst
[
"iid"
]
==
iid
)
{
return
&
inst
;
}
}
}
}
}
}
}
return
ret
;
}
int
_getDB
(
string
fileName
,
DB
**
pdb
)
{
int
_getDB
(
string
fileName
,
DB
**
pdb
)
{
static
bool
bmk
=
false
;
static
bool
bmk
=
false
;
int
ret
=
0
;
int
ret
=
0
;
...
...
opencv-motion-detect/evmgr.cpp
浏览文件 @
a1b5acad
...
@@ -26,10 +26,10 @@ update: 2019/08/23
...
@@ -26,10 +26,10 @@ update: 2019/08/23
namespace
fs
=
std
::
filesystem
;
namespace
fs
=
std
::
filesystem
;
#endif
#endif
#include "zmqhelper.hpp"
#include "
inc/
zmqhelper.hpp"
#include "tinythread.hpp"
#include "
inc/
tinythread.hpp"
#include "common.hpp"
#include "
inc/
common.hpp"
#include "database.h"
#include "
inc/
database.h"
using
namespace
std
;
using
namespace
std
;
using
namespace
zmqhelper
;
using
namespace
zmqhelper
;
...
@@ -144,15 +144,37 @@ togo_sleep_continue:
...
@@ -144,15 +144,37 @@ togo_sleep_continue:
if
(
body
.
size
()
==
2
&&
body
[
1
].
size
()
==
0
)
{
if
(
body
.
size
()
==
2
&&
body
[
1
].
size
()
==
0
)
{
selfId
=
body2str
(
body
[
0
]);
selfId
=
body2str
(
body
[
0
]);
bool
eventConn
=
false
;
bool
eventConn
=
false
;
// XTF2BJR9:evslicer:1
auto
sp
=
cloudutils
::
split
(
selfId
,
':'
);
if
(
sp
.
size
()
!=
3
)
{
spdlog
::
warn
(
"evmg {} inproper peer id: {}"
,
devSn
,
selfId
);
return
-
1
;
}
json
*
mod
=
LVDB
::
findConfigModule
(
config
,
sp
[
0
],
sp
[
1
],
stoi
(
sp
[
2
]));
if
(
mod
==
NULL
)
{
spdlog
::
warn
(
"evmgr {} failed to find module with id: {}"
,
devSn
,
selfId
);
return
-
1
;
}
if
(
peerStatus
.
count
(
selfId
)
==
0
||
peerStatus
[
selfId
]
==
0
)
{
if
(
peerStatus
.
count
(
selfId
)
==
0
||
peerStatus
[
selfId
]
==
0
)
{
peerStatus
[
selfId
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
peerStatus
[
selfId
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
spdlog
::
info
(
"evmgr {} peer connected: {}"
,
devSn
,
selfId
);
spdlog
::
info
(
"evmgr {} peer connected: {}"
,
devSn
,
selfId
);
eventConn
=
true
;
eventConn
=
true
;
mod
->
at
(
"status"
)
=
1
;
spdlog
::
debug
(
"evmgr {} update status of {} to 1"
,
devSn
,
selfId
);
}
}
else
{
else
{
peerStatus
[
selfId
]
=
0
;
peerStatus
[
selfId
]
=
0
;
mod
->
at
(
"status"
)
=
0
;
spdlog
::
warn
(
"evmgr {} peer disconnected: {}"
,
devSn
,
selfId
);
spdlog
::
warn
(
"evmgr {} peer disconnected: {}"
,
devSn
,
selfId
);
}
}
//update config
ret
=
LVDB
::
setLocalConfig
(
config
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"evmgr {} failed to update localconfig"
,
devSn
);
}
// event
// event
json
jEvt
;
json
jEvt
;
jEvt
[
"type"
]
=
EV_MSG_TYPE_CONN_STAT
;
jEvt
[
"type"
]
=
EV_MSG_TYPE_CONN_STAT
;
...
...
opencv-motion-detect/evpusher.cpp
浏览文件 @
a1b5acad
...
@@ -25,11 +25,11 @@ update: 2019/08/23
...
@@ -25,11 +25,11 @@ update: 2019/08/23
namespace
fs
=
std
::
filesystem
;
namespace
fs
=
std
::
filesystem
;
#endif
#endif
#include "zmqhelper.hpp"
#include "
inc/
zmqhelper.hpp"
#include "tinythread.hpp"
#include "
inc/
tinythread.hpp"
#include "common.hpp"
#include "
inc/
common.hpp"
#include "database.h"
#include "
inc/
database.h"
#include "spdlog/spdlog.h"
#include "
inc/
spdlog/spdlog.h"
#define MAX_ZMQ_MSG_SIZE 1204 * 1024 * 2
#define MAX_ZMQ_MSG_SIZE 1204 * 1024 * 2
using
namespace
std
;
using
namespace
std
;
...
...
opencv-motion-detect/inc/common.hpp
浏览文件 @
a1b5acad
...
@@ -17,6 +17,7 @@ extern "C"
...
@@ -17,6 +17,7 @@ extern "C"
#include <libavutil/timestamp.h>
#include <libavutil/timestamp.h>
#include <spdlog/spdlog.h>
#include <spdlog/spdlog.h>
#include <json.hpp>
#include <json.hpp>
#include <sstream>
using
json
=
nlohmann
::
json
;
using
json
=
nlohmann
::
json
;
#undef av_err2str
#undef av_err2str
...
@@ -374,8 +375,17 @@ json registry(const char *sn, const json &config)
...
@@ -374,8 +375,17 @@ json registry(const char *sn, const json &config)
return
json
();
return
json
();
}
}
vector
<
string
>
split
(
const
std
::
string
&
s
,
char
delimiter
)
{
std
::
vector
<
std
::
string
>
tokens
;
std
::
string
token
;
std
::
istringstream
tokenStream
(
s
);
while
(
getline
(
tokenStream
,
token
,
delimiter
))
{
tokens
.
push_back
(
token
);
}
return
tokens
;
}
}
// namespace cloudutils
}
// namespace cloudutils
...
...
opencv-motion-detect/inc/database.h
浏览文件 @
a1b5acad
...
@@ -22,8 +22,8 @@ namespace LVDB {
...
@@ -22,8 +22,8 @@ namespace LVDB {
#define LVDB_KEY_SN "SN"
#define LVDB_KEY_SN "SN"
#define LVDB_KEY_CONFIG "CONFIG"
#define LVDB_KEY_CONFIG "CONFIG"
//
json
*
findConfigModule
(
json
&
config
,
string
sn
,
string
moduleName
,
int
iid
);
//
//
int
delValue
(
string
key
,
string
fileName
);
int
delValue
(
string
key
,
string
fileName
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论