提交 e6caa780 authored 作者: blu's avatar blu

feature: record cmd from cloud to edge

上级 039ad9e8
......@@ -1427,6 +1427,69 @@ public:
res.set_content(ret.dump(), "text/json");
});
/// example
// {
// "target":"CHSVJE1Z:evslicer:1",
// "metaType":"cmd",
// "metaValue":"debug:record",
// "data":{
// "type":"event",
// "start":1571723088,
// "end":1571723098
// }
// }
svr.Post("/record", [this](const Request& req, Response& res) {
json ret;
string msg;
ret["code"] = 1;
ret["msg"] = "info not found";
json evslicer = json();
try {
auto body = json::parse(req.body);
auto sn = body["cameraSN"].get<string>();
auto start = body["start"];
auto end = body["end"];
auto type = body["type"].get<string>();
// find slicer id by camera sn
if(this->peerData["ipcStatus"].count(sn) != 0) {
auto dsn = this->peerData["ipcStatus"][sn]["mgrTerminal"].get<string>();
json j = getConfigForDevice(dsn);
if(j["code"] == 0) {
for(auto &[k,v]:j["data"].items()){
auto &ipcs = v["ipcs"];
for(auto &ipc: ipcs) {
if(ipc["sn"] == sn) {
evslicer = ipc["modules"]["evslicer"][0];
break;
}
}
}
}
}
if(evslicer.size() > 0) {
auto target = evslicer["sn"].get<string>() + ":evslicer:" + to_string(evslicer["iid"].get<int>());
json payload = json();
payload["target"] = target;
payload["metaType"] = "cmd";
payload["metaValue"] = "debug:record";
payload["data"] = json();
payload["data"]["type"] = type;
payload["data"]["start"] = start;
payload["data"]["end"] = end;
ret = this->handleCmd(payload);
}
}
catch(exception &e) {
ret["code"] = -1;
msg = fmt::format("evcloudsvc Post /cmd Exception: {}", e.what());
spdlog::error(msg);
ret["msg"] = msg;
}
res.set_content(ret.dump(), "text/json");
});
svr.Get("/keys", [](const Request& req, Response& res) {
string fileName = req.get_param_value("filename");
auto v = LVDB::getKeys(fileName);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论