提交 4b804b0f authored 作者: blu's avatar blu

feature: LED & key trigger support

上级 c765eaa6
...@@ -89,14 +89,15 @@ private: ...@@ -89,14 +89,15 @@ private:
data["reports"] = json(); data["reports"] = json();
json modIdsOnline; json modIdsOnline;
json modIdsOffline; json modIdsOffline;
for(auto &[k,v]: this->peerData["status"].items()){ for(auto &[k,v]: this->peerData["status"].items()) {
// ignore evmgr // ignore evmgr
if(k.find("evmgr") != string::npos) { if(k.find("evmgr") != string::npos) {
continue; continue;
} }
if(v != 0 && v != -1 && v != 1 && v != 2) { if(v != 0 && v != -1 && v != 1 && v != 2) {
modIdsOnline.push_back(k); modIdsOnline.push_back(k);
}else{ }
else {
modIdsOffline.push_back(k); modIdsOffline.push_back(k);
} }
} }
...@@ -133,7 +134,7 @@ private: ...@@ -133,7 +134,7 @@ private:
} }
vector<string> modIdsLoopRecover; vector<string> modIdsLoopRecover;
for(auto &[k,v] :peerData["contConn"].items()){ for(auto &[k,v] :peerData["contConn"].items()) {
if(v > 4) { if(v > 4) {
// not offline // not offline
if(peerData["status"].count(k) != 0 && peerData["status"][k] != -1 && peerData["status"][k] != 2 && peerData["status"][k] != 1) { if(peerData["status"].count(k) != 0 && peerData["status"][k] != -1 && peerData["status"][k] != 2 && peerData["status"][k] != 1) {
...@@ -165,7 +166,7 @@ private: ...@@ -165,7 +166,7 @@ private:
} }
vector<vector<uint8_t> >body = {str2body("evcloudsvc:0:0"), str2body(EV_MSG_META_PING), str2body(data.dump())}; vector<vector<uint8_t> >body = {str2body("evcloudsvc:0:0"), str2body(EV_MSG_META_PING), str2body(data.dump())};
ret = z_send_multiple(s, body); ret = z_send_multiple(s, body);
...@@ -460,7 +461,8 @@ private: ...@@ -460,7 +461,8 @@ private:
return ret; return ret;
} }
void sendModConnectedMsg(json &modIds){ void sendModConnectedMsg(json &modIds)
{
json meta; json meta;
json data; json data;
string msg = fmt::format("evdaemon {} detects modules {} booted up", this->devSn, modIds.dump()); string msg = fmt::format("evdaemon {} detects modules {} booted up", this->devSn, modIds.dump());
...@@ -477,7 +479,8 @@ private: ...@@ -477,7 +479,8 @@ private:
} }
void sendModOfflineMsg(json &modIds){ void sendModOfflineMsg(json &modIds)
{
json meta; json meta;
json data; json data;
string msg = fmt::format("evdaemon {} detects modules {} offline", this->devSn, modIds.dump()); string msg = fmt::format("evdaemon {} detects modules {} offline", this->devSn, modIds.dump());
...@@ -520,7 +523,7 @@ private: ...@@ -520,7 +523,7 @@ private:
if(selfId.find("evmgr") == string::npos) { if(selfId.find("evmgr") == string::npos) {
sendModConnectedMsg(modIds); sendModConnectedMsg(modIds);
} }
if(this->peerData["tsLastConn"].count(selfId) == 0) { if(this->peerData["tsLastConn"].count(selfId) == 0) {
this->peerData["tsLastConn"][selfId] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count(); this->peerData["tsLastConn"][selfId] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
} }
...@@ -555,7 +558,7 @@ private: ...@@ -555,7 +558,7 @@ private:
if(selfId.find("evmgr") == string::npos) { if(selfId.find("evmgr") == string::npos) {
sendModOfflineMsg(modIds); sendModOfflineMsg(modIds);
} }
if(peerData["status"][selfId] == 1 || peerData["status"][selfId] == 2) { if(peerData["status"][selfId] == 1 || peerData["status"][selfId] == 2) {
spdlog::warn("evdaemon {} refuse to start {}: it was asked to be stopped, and is removed from cluster config", this->devSn, selfId); spdlog::warn("evdaemon {} refuse to start {}: it was asked to be stopped, and is removed from cluster config", this->devSn, selfId);
} }
......
...@@ -105,7 +105,8 @@ private: ...@@ -105,7 +105,8 @@ private:
if(config.count("portRouter") != 0) { if(config.count("portRouter") != 0) {
portRouter = to_string(config["portRouter"]); portRouter = to_string(config["portRouter"]);
}else if(config.count("port-router") != 0) { }
else if(config.count("port-router") != 0) {
portRouter = to_string(config["port-router"]); portRouter = to_string(config["port-router"]);
} }
......
...@@ -533,7 +533,8 @@ private: ...@@ -533,7 +533,8 @@ private:
return 0; return 0;
} }
void makeEvent(string evtType, int ts) { void makeEvent(string evtType, int ts)
{
json p; json p;
p["type"] = EV_MSG_TYPE_AI_MOTION; p["type"] = EV_MSG_TYPE_AI_MOTION;
p["gid"] = selfId; p["gid"] = selfId;
......
...@@ -865,7 +865,8 @@ protected: ...@@ -865,7 +865,8 @@ protected:
return ret; return ret;
} }
void reportUploadFailure(string modId, bool fail, string reason){ void reportUploadFailure(string modId, bool fail, string reason)
{
string modifier = fail?"failed": "successfully"; string modifier = fail?"failed": "successfully";
string status = fail?"active":"recover"; string status = fail?"active":"recover";
string msg = fmt::format("evslicer {} {} upload videos: {}", selfId, modifier, reason); string msg = fmt::format("evslicer {} {} upload videos: {}", selfId, modifier, reason);
...@@ -1141,7 +1142,7 @@ public: ...@@ -1141,7 +1142,7 @@ public:
} }
} }
if(resp.count("code") != 0 && resp["code"] == 0){ if(resp.count("code") != 0 && resp["code"] == 0) {
if(bUploadFailed) { if(bUploadFailed) {
bUploadFailed = false; bUploadFailed = false;
reportUploadFailure(selfId, false, strResp); reportUploadFailure(selfId, false, strResp);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论