|
|
@ -116,8 +116,8 @@ void TestPageItemMgr::processOnButton(json cmd) { |
|
|
|
|
|
|
|
vector<string> params; |
|
|
|
for (auto& p : buttons->params) { |
|
|
|
auto it = cmd.find(p.name); |
|
|
|
if (it == cmd.end()) { |
|
|
|
auto it = cmd["params"].find(p.name); |
|
|
|
if (it == cmd["params"].end()) { |
|
|
|
THROW_APP_EXCEPTION(err::kappe_missing_param, "missing parameter %s", p.name.c_str()); |
|
|
|
} |
|
|
|
params.push_back(it->get<string>()); |
|
|
@ -134,20 +134,27 @@ void TestPageItemMgr::processOnButton(json cmd) { |
|
|
|
} |
|
|
|
} |
|
|
|
void TestPageItemMgr::startReportState(int interval) { |
|
|
|
if (m_thread) m_thread->wake(); |
|
|
|
if (m_thread) { |
|
|
|
m_thread->wake(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
m_thread.reset(new Thread("TestPageItemMgr", [this, interval]() { |
|
|
|
while (!m_thread->getExitFlag()) { |
|
|
|
logger->info("TestPageItemMgr thread start"); |
|
|
|
ThisThread thisThread; |
|
|
|
while (!thisThread.getExitFlag()) { |
|
|
|
json state = readState(); |
|
|
|
onState(state); |
|
|
|
m_thread->sleepForMs(interval * 1000); |
|
|
|
thisThread.sleepForMs(interval ); |
|
|
|
} |
|
|
|
logger->info("TestPageItemMgr thread exit"); |
|
|
|
})); |
|
|
|
} |
|
|
|
void TestPageItemMgr::stopReportState() { |
|
|
|
if (m_thread) { |
|
|
|
m_thread->wake(); |
|
|
|
m_thread->join(); |
|
|
|
m_thread = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
json TestPageItemMgr::readState() { |
|
|
|