Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
6c00a563
提交
6c00a563
authored
9月 04, 2019
作者:
bruce.lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init
上级
2201b433
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
113 行增加
和
56 行删除
+113
-56
settings.json
.vscode/settings.json
+3
-1
evcloudsvc.cpp
opencv-motion-detect/evcloudsvc.cpp
+110
-55
没有找到文件。
.vscode/settings.json
浏览文件 @
6c00a563
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
"C_Cpp.intelliSenseEngineFallback"
:
"Enabled"
,
"C_Cpp.intelliSenseEngineFallback"
:
"Enabled"
,
"python.pythonPath"
:
"/opt/apps/conda/anaconda3/bin/python"
,
"python.pythonPath"
:
"/opt/apps/conda/anaconda3/bin/python"
,
"files.associations"
:
{
"files.associations"
:
{
"chrono"
:
"cpp"
"chrono"
:
"cpp"
,
"optional"
:
"cpp"
}
}
}
}
\ No newline at end of file
opencv-motion-detect/evcloudsvc.cpp
浏览文件 @
6c00a563
...
@@ -26,66 +26,16 @@ class HttpSrv{
...
@@ -26,66 +26,16 @@ class HttpSrv{
// sn:module -> sn_of_evmgr
// sn:module -> sn_of_evmgr
json
configMap
;
json
configMap
;
protected
:
json
config
(
string
body
){
public
:
void
run
(){
// load configmap
json
cnfm
;
LVDB
::
getValue
(
cnfm
,
"configmap"
);
if
(
cnfm
.
size
()
!=
0
){
this
->
configMap
=
cnfm
;
}
svr
.
Get
(
"/config"
,
[
this
](
const
Request
&
req
,
Response
&
res
){
json
ret
;
json
ret
;
ret
[
"code"
]
=
0
;
ret
[
"code"
]
=
0
;
ret
[
"time"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
ret
[
"msg"
]
=
"ok"
;
ret
[
"msg"
]
=
"ok"
;
if
(
!
req
.
has_param
(
"sn"
)
||
!
req
.
has_param
(
"module"
)
||
req
.
get_param_value
(
"module"
).
size
()
<
4
){
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"evcloud bad req: no sn/module param"
;
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
}
else
{
string
sn
=
req
.
get_param_value
(
"sn"
);
string
module
=
req
.
get_param_value
(
"module"
);
string
modname
=
module
.
substr
(
0
,
4
);
if
(
modname
==
"evml"
)
{
modname
=
"evml:"
+
module
.
substr
(
4
,
module
.
size
());
}
else
{
modname
=
module
;
}
string
key
=
sn
+
":"
+
modname
;
if
(
this
->
configMap
.
count
(
key
)
!=
0
)
{
json
config
;
ret
=
LVDB
::
getLocalConfig
(
config
,
this
->
configMap
[
key
]);
if
(
ret
<
0
)
{
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"evcloud failed to get config with k, v:"
+
key
+
" "
+
this
->
configMap
[
key
].
get
<
string
>
();
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
}
else
{
ret
[
"data"
]
=
config
;
}
}
else
{
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"no config for sn "
+
sn
,
+
", module "
+
module
;
}
}
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
});
svr
.
Post
(
"/config"
,
[
this
](
const
Request
&
req
,
Response
&
res
){
json
ret
;
ret
[
"time"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
ret
[
"time"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
ret
[
"code"
]
=
0
;
ret
[
"msg"
]
=
"ok"
;
try
{
try
{
json
newConfig
=
json
::
parse
(
req
.
body
);
json
newConfig
=
json
::
parse
(
body
);
if
(
newConfig
.
count
(
"data"
)
==
0
||
newConfig
[
"data"
].
size
()
==
0
)
{
if
(
newConfig
.
count
(
"data"
)
==
0
||
newConfig
[
"data"
].
size
()
==
0
)
{
ret
[
"code"
]
=
1
;
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"evcloudsvc invalid config body received: "
+
req
.
body
;
ret
[
"msg"
]
=
"evcloudsvc invalid config body received: "
+
body
;
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
}
else
{
}
else
{
json
&
data
=
newConfig
[
"data"
];
json
&
data
=
newConfig
[
"data"
];
...
@@ -136,15 +86,120 @@ class HttpSrv{
...
@@ -136,15 +86,120 @@ class HttpSrv{
// save configmap
// save configmap
LVDB
::
setValue
(
this
->
configMap
,
"configmap"
);
LVDB
::
setValue
(
this
->
configMap
,
"configmap"
);
}
}
catch
(
exception
&
e
)
{
ret
.
clear
();
ret
[
"code"
]
=
-
1
;
ret
[
"msg"
]
=
e
.
what
();
}
return
ret
;
}
protected
:
public
:
void
run
(){
// load configmap
json
cnfm
;
LVDB
::
getValue
(
cnfm
,
"configmap"
);
if
(
cnfm
.
size
()
!=
0
){
this
->
configMap
=
cnfm
;
}
svr
.
Post
(
"/register"
,
[
this
](
const
Request
&
req
,
Response
&
res
){
json
ret
;
try
{
json
config
=
json
::
parse
(
req
.
body
);
string
sn
=
req
.
get_param_value
(
"sn"
);
string
module
=
req
.
get_param_value
(
"module"
);
if
(
sn
.
empty
()
||
module
.
empty
()){
throw
"no para sn/module"
;
}
string
modname
=
module
.
substr
(
0
,
4
);
if
(
modname
==
"evml"
)
{
modname
=
"evml:"
+
module
.
substr
(
4
,
module
.
size
());
}
else
{
modname
=
module
;
}
}
// TODO: restart other components
string
key
=
sn
+
":"
+
modname
;
if
(
this
->
configMap
.
count
(
key
)
==
0
){
//
//
spdlog
::
info
(
"evcloudsvc no such edge module registred: {}, create new entry"
,
key
);
ret
=
this
->
config
(
req
.
body
);
if
(
ret
[
"code"
]
==
0
)
{
ret
[
"data"
]
=
config
[
"data"
];
}
}
else
{
// TODO: calc md5
int
r
;
ret
[
"code"
]
=
0
;
ret
[
"msg"
]
=
"ok"
;
string
dk
=
this
->
configMap
[
key
];
json
data
;
r
=
LVDB
::
getLocalConfig
(
data
,
dk
);
if
(
ret
<
0
)
{
ret
[
"code"
]
=
r
;
ret
[
"msg"
]
=
"failed to get config for: "
+
dk
;
}
else
{
ret
[
"data"
]
=
data
;
}
}
}
catch
(
exception
&
e
)
{
}
catch
(
exception
&
e
)
{
ret
.
clear
();
ret
.
clear
();
ret
[
"code"
]
=
1
;
ret
[
"code"
]
=
-
1
;
ret
[
"msg"
]
=
e
.
what
();
ret
[
"msg"
]
=
e
.
what
();
}
}
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
});
svr
.
Get
(
"/config"
,
[
this
](
const
Request
&
req
,
Response
&
res
){
json
ret
;
ret
[
"code"
]
=
0
;
ret
[
"time"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
ret
[
"msg"
]
=
"ok"
;
if
(
!
req
.
has_param
(
"sn"
)
||
!
req
.
has_param
(
"module"
)
||
req
.
get_param_value
(
"module"
).
size
()
<
4
){
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"evcloud bad req: no sn/module param"
;
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
}
else
{
string
sn
=
req
.
get_param_value
(
"sn"
);
string
module
=
req
.
get_param_value
(
"module"
);
string
modname
=
module
.
substr
(
0
,
4
);
if
(
modname
==
"evml"
)
{
modname
=
"evml:"
+
module
.
substr
(
4
,
module
.
size
());
}
else
{
modname
=
module
;
}
string
key
=
sn
+
":"
+
modname
;
if
(
this
->
configMap
.
count
(
key
)
!=
0
)
{
json
config
;
ret
=
LVDB
::
getLocalConfig
(
config
,
this
->
configMap
[
key
]);
if
(
ret
<
0
)
{
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"evcloud failed to get config with k, v:"
+
key
+
" "
+
this
->
configMap
[
key
].
get
<
string
>
();
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
}
else
{
ret
[
"data"
]
=
config
;
}
}
else
{
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"no config for sn "
+
sn
,
+
", module "
+
module
;
}
}
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
});
svr
.
Post
(
"/config"
,
[
this
](
const
Request
&
req
,
Response
&
res
){
auto
ret
=
this
->
config
(
req
.
body
);
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
});
});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论