modify timing logic.
This commit is contained in:
parent
70a6cdb10b
commit
38e2065625
@ -77,9 +77,19 @@ std::string JsonData::JsonCmd_Cgi_02(Param_02 ¶m) {
|
|||||||
if (0 == param.mMode) {
|
if (0 == param.mMode) {
|
||||||
jsonVal["type"] = "SET";
|
jsonVal["type"] = "SET";
|
||||||
if (param.mMode == 0) { //本地校时
|
if (param.mMode == 0) { //本地校时
|
||||||
|
unsigned long set_timestamp = (unsigned long)param.mTimeStamp;
|
||||||
|
char localtimestamp[32] = {0};
|
||||||
|
GetTimeNet(localtimestamp, 1);
|
||||||
|
std::string current_system_timestamp = std::string(localtimestamp);
|
||||||
|
unsigned long current_timestamp = boost::lexical_cast<unsigned long>(current_system_timestamp);
|
||||||
|
unsigned long diff_seconds = abs(current_timestamp - set_timestamp);
|
||||||
|
if (diff_seconds > 5) {
|
||||||
SetTime((unsigned long)param.mTimeStamp);
|
SetTime((unsigned long)param.mTimeStamp);
|
||||||
mssleep(200);
|
mssleep(200);
|
||||||
system("hwclock -w");
|
system("hwclock -w");
|
||||||
|
} else {
|
||||||
|
zlog_warn(zct, "diff seconds:%ld lesser than 5, not to modify", diff_seconds);
|
||||||
|
}
|
||||||
} else if (param.mMode == 1) { //与服务器校时
|
} else if (param.mMode == 1) { //与服务器校时
|
||||||
char buf[256] = {0};
|
char buf[256] = {0};
|
||||||
sprintf(buf, "{\"dataNodeGatewayNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}", GlobalConfig::MacAddr_G.c_str());
|
sprintf(buf, "{\"dataNodeGatewayNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}", GlobalConfig::MacAddr_G.c_str());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user