|
@ -30,6 +30,11 @@ static T jsonGet(json j) { |
|
|
return val; |
|
|
return val; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainControlService::dosystem(string order) { |
|
|
|
|
|
logger->info("do:{}", order); |
|
|
|
|
|
system(order.c_str()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void MainControlService::initialize() { |
|
|
void MainControlService::initialize() { |
|
|
GET_TO_SERVICE(m_zconfig); |
|
|
GET_TO_SERVICE(m_zconfig); |
|
|
// system("systemctl restart zchromium.service");
|
|
|
// system("systemctl restart zchromium.service");
|
|
@ -220,10 +225,10 @@ void MainControlService::processFrontEndMessage(weak_ptr<WebSocket> webSocket, j |
|
|
if (cmdstr == "shutdown") { |
|
|
if (cmdstr == "shutdown") { |
|
|
int delayms = jsonGet<int>(cmd["delayms"]); |
|
|
int delayms = jsonGet<int>(cmd["delayms"]); |
|
|
logger->info("shutdown {} ms", delayms); |
|
|
logger->info("shutdown {} ms", delayms); |
|
|
m_autoshutdownThread.reset(new Thread("autoShutdown", [delayms]() { |
|
|
|
|
|
|
|
|
m_autoshutdownThread.reset(new Thread("autoShutdown", [delayms, this]() { |
|
|
ThisThread thisThread; |
|
|
ThisThread thisThread; |
|
|
thisThread.sleepForMs(delayms); |
|
|
thisThread.sleepForMs(delayms); |
|
|
system("shutdown -h now"); |
|
|
|
|
|
|
|
|
dosystem("shutdown -h now"); |
|
|
})); |
|
|
})); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@ -231,10 +236,10 @@ void MainControlService::processFrontEndMessage(weak_ptr<WebSocket> webSocket, j |
|
|
if (cmdstr == "shutdown") { |
|
|
if (cmdstr == "shutdown") { |
|
|
int delayms = jsonGet<int>(cmd["delayms"]); |
|
|
int delayms = jsonGet<int>(cmd["delayms"]); |
|
|
logger->info("shutdown {} ms", delayms); |
|
|
logger->info("shutdown {} ms", delayms); |
|
|
m_autoshutdownThread.reset(new Thread("autoShutdown", [delayms]() { |
|
|
|
|
|
|
|
|
m_autoshutdownThread.reset(new Thread("autoShutdown", [delayms, this]() { |
|
|
ThisThread thisThread; |
|
|
ThisThread thisThread; |
|
|
thisThread.sleepForMs(delayms); |
|
|
thisThread.sleepForMs(delayms); |
|
|
system("shutdown -h now"); |
|
|
|
|
|
|
|
|
dosystem("shutdown -h now"); |
|
|
})); |
|
|
})); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@ -247,21 +252,39 @@ void MainControlService::processFrontEndMessage(weak_ptr<WebSocket> webSocket, j |
|
|
"year":2023, |
|
|
"year":2023, |
|
|
"month":8, |
|
|
"month":8, |
|
|
"day":25, |
|
|
"day":25, |
|
|
|
|
|
} |
|
|
|
|
|
#endif
|
|
|
|
|
|
int32_t year = jsonGet<int>(cmd["year"]); |
|
|
|
|
|
int32_t month = jsonGet<int>(cmd["month"]); |
|
|
|
|
|
int32_t day = jsonGet<int>(cmd["day"]); |
|
|
|
|
|
logger->info("updateDate {} {} {}", year, month, day); |
|
|
|
|
|
// date -s "2023-01-02 02:32:32"
|
|
|
|
|
|
dosystem(fmt::format("date -s \"{}{}{} `date +%T`\"", year, month, day).c_str()); |
|
|
|
|
|
dosystem(fmt::format("hwclock -w").c_str()); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (cmdstr == "updateTime") { |
|
|
|
|
|
#if 0
|
|
|
|
|
|
{ |
|
|
|
|
|
"command":"updateTime", |
|
|
|
|
|
"messageId":"1111222333444555", |
|
|
"hour":11, |
|
|
"hour":11, |
|
|
"min":12, |
|
|
"min":12, |
|
|
"second":13, |
|
|
"second":13, |
|
|
} |
|
|
} |
|
|
#endif
|
|
|
#endif
|
|
|
int32_t year = jsonGet<int>(cmd["year"]); |
|
|
|
|
|
int32_t month = jsonGet<int>(cmd["month"]); |
|
|
|
|
|
int32_t day = jsonGet<int>(cmd["day"]); |
|
|
|
|
|
int32_t hour = jsonGet<int>(cmd["hour"]); |
|
|
int32_t hour = jsonGet<int>(cmd["hour"]); |
|
|
int32_t min = jsonGet<int>(cmd["min"]); |
|
|
int32_t min = jsonGet<int>(cmd["min"]); |
|
|
int32_t second = jsonGet<int>(cmd["second"]); |
|
|
int32_t second = jsonGet<int>(cmd["second"]); |
|
|
logger->info("updateDate {} {} {} {}:{}:{}", year, month, day, hour, min, second); |
|
|
|
|
|
|
|
|
logger->info("updateDate {}:{}:{}", hour, min, second); |
|
|
|
|
|
// date -s "2023-01-02 02:32:32"
|
|
|
|
|
|
dosystem(fmt::format("date -s \"`date +%Y-%m-%d` {}:{}:{}\"", hour, min, second).c_str()); |
|
|
|
|
|
dosystem(fmt::format("hwclock -w").c_str()); |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
/*******************************************************************************
|
|
|
* 消毒相关指令 * |
|
|
* 消毒相关指令 * |
|
|
*******************************************************************************/ |
|
|
*******************************************************************************/ |
|
|