diff --git a/Cidn-SH b/Cidn-SH index 56cd397..1737861 100644 Binary files a/Cidn-SH and b/Cidn-SH differ diff --git a/common/SH_CommonFunc.cpp b/common/SH_CommonFunc.cpp index f0b9dee..d505e7c 100644 --- a/common/SH_CommonFunc.cpp +++ b/common/SH_CommonFunc.cpp @@ -514,14 +514,17 @@ std::string GetCurrentTime() std::string strtime_now = std::string((char*)time_now); return strtime_now; } -void get_current_date( int day) +tm *get_current_date( ) { time_t t = time(NULL); struct tm *tm_info = localtime(&t); - int iyear;int imonth; + int iyear = 0;int imonth = 0;int day = 0;int hour = 0; iyear = tm_info->tm_year + 1900; imonth = tm_info->tm_mon + 1; day = tm_info->tm_mday; + hour = tm_info->tm_hour; + print_info("year = %d,month = %d,day = %d\n",iyear,imonth,day); + return tm_info; } int system_custom(const char *cmd, char *buf) { diff --git a/common/SH_CommonFunc.hpp b/common/SH_CommonFunc.hpp index 5dfd4f5..a63bd40 100644 --- a/common/SH_CommonFunc.hpp +++ b/common/SH_CommonFunc.hpp @@ -650,7 +650,7 @@ extern int CheckFileVersion(int argc, char** argv); */ extern std::string GetCurrentTime(); -extern void get_current_date( int day) ; +extern tm *get_current_date() ; /** * @brief 和系统交互函数 * @param cmd 要发出的系统命令 例:ls diff --git a/main.cpp b/main.cpp index ea499e0..660747d 100644 --- a/main.cpp +++ b/main.cpp @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) { printf(" Firmware compile time:%s %s,version %s\n", __DATE__, __TIME__,GlobalConfig::Version.c_str()); // 初始化日志记录,日志缓存区,记录数,未使用,后期,命令启动 - log_init(SOFTWARE_RUN_LOG, 1380, 160 * 1024 * 2); + log_init(SOFTWARE_RUN_LOG, 1380, 200 * 1024 * 2); LOG_INFO("####CIDNSOFT start####\n"); // 查看版本信息 diff --git a/threadfunc/SH_ThreadFunc.cpp b/threadfunc/SH_ThreadFunc.cpp index 26dec1e..d850eea 100644 --- a/threadfunc/SH_ThreadFunc.cpp +++ b/threadfunc/SH_ThreadFunc.cpp @@ -212,19 +212,18 @@ void CheckThread() std::string data = jd.JsonCmd_07(); data_publish(data.c_str(), GlobalConfig::Topic_G.mPubStatus.c_str()); HardStatus = 0; - if (GlobalConfig::day == 0) - { - get_current_date(GlobalConfig::day); - }else{ - int day = 0; - get_current_date(day); - if(GlobalConfig::day != day){ - LOG_INFO("global = %d ,day = %d\n",GlobalConfig::day,day); - sql_ctl->CalculateData(); - } + int hour = 0; + struct tm *tm_info = get_current_date(); + hour = tm_info->tm_hour; + print_info("hour = %d\n",hour); + int statistics = readIntValue( "config", "statistics",(char*)GlobalConfig::Config_G.c_str()); + if(statistics == 0 && hour > 13 ){ + writeIntValue("config", "statistics",1,(char*)GlobalConfig::Config_G.c_str()); + sql_ctl->CalculateData(); + }else if(statistics == 1 && hour < 13){ + writeIntValue("config", "statistics",0,(char*)GlobalConfig::Config_G.c_str()); } - - + } if(mqttresend == 1800){ mqttresend = 0;