Browse Source

添加部分日志

storage-in-realtime
zhaohe 12 months ago
parent
commit
a073f92c19
  1. 2
      appsrc/baseservice/iflytop_front_end_service/iflytop_front_end_service.cpp
  2. 2
      appsrc/baseservice/iflytop_front_end_service/iflytop_front_end_service.hpp
  3. 6
      appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp
  4. 11
      appsrc/service/app/disinfection_ctrl/disinfection_state_machine.cpp
  5. 63
      appsrc/service/app_core.cpp
  6. 17
      appsrc/service/app_core.hpp
  7. 4
      doc/TESTCMD.md

2
appsrc/baseservice/iflytop_front_end_service/iflytop_front_end_service.cpp

@ -90,7 +90,7 @@ void IflytopFrontEndService::sendReport(json reportType, json report) {
}
}
void IflytopFrontEndService::sendClassReport(string fromclass, string fromfn, json& content) {
void IflytopFrontEndService::sendClassReport(string fromclass, string fromfn, const json& content) {
json report;
report["fromClass"] = fromclass;
report["fromFn"] = fromfn;

2
appsrc/baseservice/iflytop_front_end_service/iflytop_front_end_service.hpp

@ -54,7 +54,7 @@ class IflytopFrontEndService : public enable_shared_from_this<IflytopFrontEndSer
void initialize(string ip = "0.0.0.0");
void startListen();
void sendReport(json reportType, json report);
void sendClassReport(string fromclass, string fromfn, json& content);
void sendClassReport(string fromclass, string fromfn, const json& content);
void sendPrompt(string message);
private:

6
appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp

@ -276,12 +276,13 @@ void DisinfectionCtrlService::logState(bool forcelog) {
void DisinfectionCtrlService::traceState() {
string tracecontent;
tracecontent += fmt::format("[{}] ", string(sm.getState()));
tracecontent += fmt::format("TRACE [{}] ", string(sm.getState()));
tracecontent += fmt::format("dvalue:{} ", s_dvalue);
tracecontent += fmt::format("log:{}->{} ", s_nlog, m_tlog);
tracecontent += fmt::format("takebreak:{} ", s_isDisinfectionTakeBreak);
tracecontent += fmt::format("remaintime:{} ", s_remaintime);
logger->info(tracecontent);
}
@ -439,7 +440,6 @@ void DisinfectionCtrlService::processStateDehumidificationBeforeDisinfection(Dis
void DisinfectionCtrlService::processStatePreheat(DisinfectionEvent* event) {
if (event->event == kevent_enter_state) {
logger->info("preheat state enter");
tryLogState(true);
dics->Blower_ctrl(90);
@ -448,8 +448,6 @@ void DisinfectionCtrlService::processStatePreheat(DisinfectionEvent* event) {
s_remaintime = getSettingAsInt(SettingId::pre_heat_time_s);
} else if (event->event == kevent_exit_state) {
logger->info("preheat state exit");
dics->Blower_ctrl(0);
usleep(1000 * 1000);
dics->Heater_ctrl(0);

11
appsrc/service/app/disinfection_ctrl/disinfection_state_machine.cpp

@ -66,17 +66,18 @@ void DisinfectionStateMachine::process() {
enter_event.event = kevent_enter_state;
enter_event.enterState.last = event->changeState.from;
callStateProcesser(m_state, &exit_event);
m_state = event->changeState.to;
m_enter_state_tp = zsystem_clock().now();
logger->info("CHANGE STATE: {} -----------------------> {}", //
string(event->changeState.from), string(event->changeState.to));
logger->info("PROCESS EVEN: {:10}:{}", string(m_state), disinfection_event_to_string(exit_event.event));
callStateProcesser(m_state, &exit_event);
m_state = event->changeState.to;
m_enter_state_tp = zsystem_clock().now();
logger->info("PROCESS EVEN: {:10}:{}", string(m_state), disinfection_event_to_string(exit_event.event));
callStateProcesser(m_state, &enter_event);
} else {
logger->info("PROCESS EVEN: {}", disinfection_event_to_string(event->event));
logger->info("PROCESS EVEN: {:10}:{}", m_state, disinfection_event_to_string(event->event));
callStateProcesser(m_state, event.get());
}
}

63
appsrc/service/app_core.cpp

@ -126,34 +126,20 @@ void AppCore::initialize() {
}
});
REGFN(AppCore, getState);
REGFN(AppCore, promptConfirm);
REGFN(AppCore, promptGetAll);
REGFN(AppCore, promptGetNext);
REGFN(AppCore, startGenFakeH2O2Data);
REGFN(AppCore, stopGenFakeH2O2Data);
REGFNV2(AppCore, getState);
REGFNV2(AppCore, promptConfirm);
REGFNV2(AppCore, promptGetAll);
REGFNV2(AppCore, promptGetNext);
REGFNV2(AppCore, startGenFakeH2O2Data);
REGFNV2(AppCore, stopGenFakeH2O2Data);
};
void AppCore::getState(shared_ptr<MsgProcessContext> cxt) {
void AppCore::fn_getState(shared_ptr<MsgProcessContext> cxt) {
lock_guard<recursive_mutex> lock(warningPromptListMutex);
auto& content = cxt->content;
content["state"] = DS->getDeviceState();
content["loginInfo"]["loginFlag"] = DS->isLogin();
content["loginInfo"]["loginUid"] = DS->getLoginUid();
content["loginInfo"]["isLoginAdmin"] = DS->isLoginAdmin();
content["estate"]["ecode"] = DS->getAppExceptionCode();
content["estate"]["state"] = DS->getAppExceptionFlag();
content["estate"]["emessage"] = DS->getAppExceptionMessage();
content["testMode"]["isInTestMode"] = DS->isTestMode();
content["promptNum"] = warningPromptList.size();
cxt->content = getState();
}
void AppCore::promptConfirm(shared_ptr<MsgProcessContext> cxt) {
void AppCore::fn_promptConfirm(shared_ptr<MsgProcessContext> cxt) {
lock_guard<recursive_mutex> lock(warningPromptListMutex);
string promptId = cxt->params["promptId"];
@ -166,7 +152,7 @@ void AppCore::promptConfirm(shared_ptr<MsgProcessContext> cxt) {
GET_SERVICE(WarningLightControler)->setwarningFlag(false);
}
void AppCore::promptGetAll(shared_ptr<MsgProcessContext> cxt) {
void AppCore::fn_promptGetAll(shared_ptr<MsgProcessContext> cxt) {
lock_guard<recursive_mutex> lock(warningPromptListMutex);
auto content = cxt->content;
content["prompts"] = json::array();
@ -175,7 +161,7 @@ void AppCore::promptGetAll(shared_ptr<MsgProcessContext> cxt) {
}
}
void AppCore::promptGetNext(shared_ptr<MsgProcessContext> cxt) {
void AppCore::fn_promptGetNext(shared_ptr<MsgProcessContext> cxt) {
lock_guard<recursive_mutex> lock(warningPromptListMutex);
auto content = cxt->content;
if (warningPromptList.size() > 0) {
@ -183,7 +169,7 @@ void AppCore::promptGetNext(shared_ptr<MsgProcessContext> cxt) {
}
}
void AppCore::setInTestMode(shared_ptr<MsgProcessContext> cxt) {
void AppCore::fn_setInTestMode(shared_ptr<MsgProcessContext> cxt) {
bool isInTestMode = cxt->params["isInTestMode"];
DS->setTestMode(isInTestMode);
json content;
@ -199,7 +185,7 @@ typedef struct {
bool enable[3];
} fake_h2o2_data_cache_t;
void AppCore::startGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt) {
void AppCore::fn_startGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt) {
if (m_genFakeH2O2DataThread) {
m_genFakeH2O2DataThread->join();
m_genFakeH2O2DataThread = nullptr;
@ -233,7 +219,7 @@ void AppCore::startGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt) {
}
}));
}
void AppCore::stopGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt) {
void AppCore::fn_stopGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt) {
if (m_genFakeH2O2DataThread) {
m_genFakeH2O2DataThread->join();
m_genFakeH2O2DataThread = nullptr;
@ -242,11 +228,28 @@ void AppCore::stopGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt) {
void AppCore::loop() {}
void AppCore::onDeviceStateChange() {
json content;
SEND_CLASS_REPORT("AppCore", "onDeviceStateChange", content);
SEND_CLASS_REPORT("AppCore", "onDeviceStateChange", getState());
}
void AppCore::insertPrompt(shared_ptr<Prompt> prompt) {
lock_guard<recursive_mutex> lock(warningPromptListMutex);
warningPromptList.push_back(prompt);
if (prompt->isWarning) GET_SERVICE(WarningLightControler)->setwarningFlag(true);
}
json AppCore::getState() {
json ret;
ret["state"] = DS->getDeviceState();
ret["loginInfo"]["loginFlag"] = DS->isLogin();
ret["loginInfo"]["loginUid"] = DS->getLoginUid();
ret["loginInfo"]["isLoginAdmin"] = DS->isLoginAdmin();
ret["estate"]["ecode"] = DS->getAppExceptionCode();
ret["estate"]["state"] = DS->getAppExceptionFlag();
ret["estate"]["emessage"] = DS->getAppExceptionMessage();
ret["testMode"]["isInTestMode"] = DS->isTestMode();
ret["promptNum"] = warningPromptList.size();
return ret;
}

17
appsrc/service/app_core.hpp

@ -67,18 +67,19 @@ class AppCore : public enable_shared_from_this<AppCore> {
void initialize();
private:
void getState(shared_ptr<MsgProcessContext> cxt);
void fn_getState(shared_ptr<MsgProcessContext> cxt);
void promptConfirm(shared_ptr<MsgProcessContext> cxt);
void promptGetAll(shared_ptr<MsgProcessContext> cxt);
void promptGetNext(shared_ptr<MsgProcessContext> cxt);
void fn_promptConfirm(shared_ptr<MsgProcessContext> cxt);
void fn_promptGetAll(shared_ptr<MsgProcessContext> cxt);
void fn_promptGetNext(shared_ptr<MsgProcessContext> cxt);
// 测试
void setInTestMode(shared_ptr<MsgProcessContext> cxt);
void startGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt);
void stopGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt);
void fn_setInTestMode(shared_ptr<MsgProcessContext> cxt);
void fn_startGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt);
void fn_stopGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt);
// void warningPro();
private:
json getState();
void dosystem(string order, bool dump);
void loop();

4
doc/TESTCMD.md

@ -29,7 +29,7 @@
```json
{
"messageType": "Command",
"fnName": "startGenFakeH2O2Data",
"fnName": "fn_startGenFakeH2O2Data",
"className": "AppCore",
"messageId": "1234",
"timeStamp": 1234,
@ -68,7 +68,7 @@
```json
{
"messageType": "Command",
"fnName": "stopGenFakeH2O2Data",
"fnName": "fn_stopGenFakeH2O2Data",
"className": "AppCore",
"messageId":"1234",
"timeStamp": 1234

Loading…
Cancel
Save