修改日志为每日记录,增加传感器在线检测
This commit is contained in:
parent
0a6daf777b
commit
072f3d6d17
@ -31,7 +31,15 @@ int log_init(const char* file_name, int log_buf_size, int limit_size)
|
||||
memset(gLogParam.m_buf, '\0', sizeof(char) * gLogParam.m_log_buf_size);
|
||||
gLogParam.m_limit_size = limit_size;
|
||||
|
||||
strcpy(gLogParam.m_log_full_name, file_name);
|
||||
struct timeval now = {0,0};
|
||||
gettimeofday(&now, NULL);
|
||||
time_t t = now.tv_sec;
|
||||
struct tm* sys_tm = localtime(&t);
|
||||
char fileTime[20]={0x00};
|
||||
char fileName[100]={0x00};
|
||||
int n = snprintf(fileTime, 64, "%d-%02d-%02d.log", sys_tm->tm_year+1900, sys_tm->tm_mon+1, sys_tm->tm_mday);
|
||||
sprintf(fileName,"%s%s",file_name,fileTime);
|
||||
strcpy(gLogParam.m_log_full_name, fileName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
#define SYSTEMINFOFILE "/opt/configenv/SystemInfo.json" //系统信息
|
||||
#define SERVERCONFIG "/opt/configenv/ServerConfig.json"
|
||||
#define NETWORKCONFIG "/opt/configenv/NetWorkConfig.json"
|
||||
#define SOFTWARE_RUN_LOG "/opt/configenv/cidn.log"
|
||||
#define SOFTWARE_RUN_LOG "/opt/log/"
|
||||
#define BOARDTYPE "/opt/configenv/boardtype" //设备类型
|
||||
#define ZIGBEECONFIG "/opt/configenv/ZigbeeConfig.json"
|
||||
|
||||
@ -55,6 +55,8 @@
|
||||
#define UINT16_HIGH(x) ((x & 0xFF00u) >> 8u)
|
||||
#define UINT16_LOW(x) ((x & 0x00FFu))
|
||||
|
||||
#define onlineCheck 21600
|
||||
|
||||
#define GENERAL_BUF_SIZE 128*1024*10
|
||||
using namespace std;
|
||||
|
||||
|
@ -395,17 +395,24 @@ void JsonData::DataNodeStatusCheck()
|
||||
std::string strDataNodeNo = vetRes[i];
|
||||
std::string strChannelId= strDataNodeNo + "-X";
|
||||
char whereCon[64] = {};
|
||||
sprintf(whereCon, "dataNodeNo='%s' and channelID='%s'", strDataNodeNo.c_str(), strChannelId.c_str());
|
||||
sprintf(whereCon, "dataNodeNo='%s' and channelID='%s' ORDER BY timeStamp DESC LIMIT 0,1", strDataNodeNo.c_str(), strChannelId.c_str());
|
||||
array_t arrRes;
|
||||
std::string strTimeRes = sql_ctl->GetData(T_DATA_INFO(TNAME), T_DATA_INFO(TIMESTAMP), whereCon);
|
||||
if (strTimeRes.length() > 0) {
|
||||
int llastTime = boost::lexical_cast<int>(strTimeRes);
|
||||
int lTimeTemp = lNowTime - llastTime;
|
||||
LOG_INFO("lNowTime = %d,llastTime = %d",lNowTime,llastTime);
|
||||
lTimeTemp = abs(lTimeTemp);
|
||||
if (lTimeTemp > 21600) {
|
||||
if (lTimeTemp > onlineCheck) {
|
||||
LOG_INFO("0-lTimeTemp = %d,onlineCheck = %d",lTimeTemp,onlineCheck);
|
||||
char whereCon[32] = { 0 };
|
||||
sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str());
|
||||
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='0'", whereCon);
|
||||
}else {
|
||||
LOG_INFO("1-lTimeTemp = %d,onlineCheck = %d",lTimeTemp,onlineCheck);
|
||||
char whereCon[32] = { 0 };
|
||||
sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str());
|
||||
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='1'", whereCon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,10 +60,10 @@ void CheckThread()
|
||||
HardStatus = 0;
|
||||
}
|
||||
|
||||
if (21600 == online_check) {
|
||||
if (onlineCheck == online_check) {
|
||||
JsonData jd;
|
||||
jd.DataNodeStatusCheck();
|
||||
|
||||
LOG_INFO("online_check = %d",online_check);
|
||||
Param_29 param;
|
||||
std::string cmd29 = jd.JsonCmd_29(param);
|
||||
data_publish(cmd29.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||
|
@ -12,7 +12,6 @@ namespace{
|
||||
}
|
||||
char g_UartRecvBuf[GENERAL_BUF_SIZE];
|
||||
int offSize = 0;
|
||||
int Size = 0;
|
||||
// namespace{
|
||||
// PlatformInit *platform = PlatformInit::instance();
|
||||
// LocalServer *wlServer = LocalServer::instance();
|
||||
@ -90,7 +89,7 @@ void Uart::ReadFromUart()
|
||||
{
|
||||
if (mUart.is_open()) {
|
||||
print_info("async_read_some,wait......................................\n");
|
||||
mUart.async_read_some(buffer(&mUartRecvBuf[mRdLength], BUF_LENGTH-mRdLength-Size),
|
||||
mUart.async_read_some(buffer(&mUartRecvBuf[mRdLength], BUF_LENGTH-mRdLength-offSize),
|
||||
mStrand.wrap(
|
||||
boost::bind(&Uart::ReadHandle,this,
|
||||
boost::asio::placeholders::error,
|
||||
@ -144,18 +143,18 @@ try{
|
||||
char buf[6];
|
||||
char mUartRecvPackage[100] = {0};
|
||||
|
||||
memcpy(mUartRecvPackage, mUartRecvBuf+7-Size, 100);
|
||||
memcpy(mUartRecvPackage, mUartRecvBuf+7-offSize, 100);
|
||||
Count = Count - 100;
|
||||
sprintf(&buf[0], "%02X", mUartRecvPackage[0]&0xFF);
|
||||
sprintf(&buf[2], "%02X", mUartRecvPackage[1]&0xFF);
|
||||
sprintf(&buf[4], "%02X", mUartRecvPackage[2]&0xFF);
|
||||
std::string strHeadFlag(buf);
|
||||
print_info("data package head command type:%s,Size = %d\n", strHeadFlag.c_str(),Size);
|
||||
print_info("data package head command type:%s,Size = %d\n", strHeadFlag.c_str(),offSize);
|
||||
if ( 0 == strHeadFlag.compare("AA55AA") ) {
|
||||
DealRecvData(mUartRecvPackage);
|
||||
}
|
||||
}
|
||||
Size = 7;
|
||||
offSize = 7;
|
||||
}else{
|
||||
for (int j = 0; j < iPackageSize; j++) {
|
||||
char buf[6];
|
||||
@ -412,7 +411,7 @@ void Uart::UpdateWirelessNode(unsigned short shortAdd)
|
||||
}
|
||||
free(buffer);
|
||||
ZigbeeInit();
|
||||
Size = 0;
|
||||
offSize = 0;
|
||||
LOG_INFO("UpdateWirelessNode success");
|
||||
}
|
||||
void Uart::DealRecvData(const char *pData)
|
||||
@ -1938,7 +1937,7 @@ void Uart::DealWaveThread() //连续三秒没有原始数据,则处理缓存
|
||||
if (tmpTimeStamp > 3 ) { // TODO: 时间戳需要修改为绝对值,可能丢失时钟,或工作一会儿,才同步时钟,可能减出异常值 print_info("yes!The time difference is more than 3,nowTimeStamp : %ld m_TimeStamp : %ld\n", nowTimeStamp, m_TimeStamp);
|
||||
DealWave();
|
||||
m_TimeStamp = 0;
|
||||
Size = 0;
|
||||
offSize = 0;
|
||||
GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS;
|
||||
GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0;
|
||||
// 准备重新恢复到 8888 PanID,正常接收特征数据
|
||||
@ -2126,7 +2125,7 @@ void Uart::DealWave()
|
||||
boost::this_thread::sleep(boost::posix_time::seconds(1));
|
||||
}
|
||||
|
||||
Size = 0;
|
||||
offSize = 0;
|
||||
// memset(buf, 0, 8);
|
||||
// sprintf(buf, "%02x%02x", recvTemp.ShortAddr[0], recvTemp.ShortAddr[1]);
|
||||
// std::string strShortAddr = std::string(buf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user