From 5f24f2b7c3385a7f5cf0160886e784e6bfc852c0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-LBGFPFF\\CHAOS-PC" Date: Sat, 13 Nov 2021 15:38:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/SH_CommonFunc.hpp | 6 +++--- jsonparse/SH_JsonCmd.cpp | 18 +++++++++--------- uart/SH_Uart.cpp | 27 +++++++++++++-------------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/common/SH_CommonFunc.hpp b/common/SH_CommonFunc.hpp index dba2325..80595dd 100644 --- a/common/SH_CommonFunc.hpp +++ b/common/SH_CommonFunc.hpp @@ -144,9 +144,9 @@ struct DataNodeInfo { std::string BpNo; std::string SerialNo; std::string FirstPowerTime; - std::string WakeupTime; - std::string StaticTime; - std::string WaveTime; + int WakeupTime; + int StaticTime; + int WaveTime; int BateryV; std::string ProductNo; int RSSI; // 接收信号强度 diff --git a/jsonparse/SH_JsonCmd.cpp b/jsonparse/SH_JsonCmd.cpp index 1443ce5..2c77fd2 100644 --- a/jsonparse/SH_JsonCmd.cpp +++ b/jsonparse/SH_JsonCmd.cpp @@ -192,9 +192,9 @@ std::string JsonData::JsonCmd_26(Param_26 ¶m) jsSensorData["bpNo"] = arrRes[j][10]; jsSensorData["serialNo"] = arrRes[j][11]; jsSensorData["firstPowerTime"] = arrRes[j][12]; - jsSensorData["WakeupTime"] = arrRes[j][13]; - jsSensorData["StaticTime"] = arrRes[j][14]; - jsSensorData["WaveTime"] = arrRes[j][15]; + jsSensorData["WakeupTime"] = boost::lexical_cast(arrRes[j][13]); + jsSensorData["StaticTime"] = boost::lexical_cast(arrRes[j][14]); + jsSensorData["WaveTime"] = boost::lexical_cast(arrRes[j][15]); jsSensorData["BateryV"] = arrRes[j][16]; jsSensorData["ProductNo"] = arrRes[j][17]; jsSensorData["configFlag"] = boost::lexical_cast(arrRes[j][18]); @@ -213,14 +213,14 @@ std::string JsonData::JsonCmd_26(Param_26 ¶m) jsSensorData["zigbeeAddr"] = arrRes[j][30]; jsSensorData["zigbeeLongAddr"] = arrRes[j][31]; jsSensorData["zigbeeDesAddr"] = arrRes[j][32]; - jsSensorData["ZigbeePower"] = arrRes[j][33]; - jsSensorData["ZigbeeRetry"] = arrRes[j][34]; - jsSensorData["ZigbeeRetryGap"] = arrRes[j][35]; - jsSensorData["ACCSampleTime"] = arrRes[j][36]; + jsSensorData["ZigbeePower"] = boost::lexical_cast(arrRes[j][33]); + jsSensorData["ZigbeeRetry"] = boost::lexical_cast(arrRes[j][34]); + jsSensorData["ZigbeeRetryGap"] = boost::lexical_cast(arrRes[j][35]); + jsSensorData["ACCSampleTime"] = boost::lexical_cast(arrRes[j][36]); jsSensorData["status"] = boost::lexical_cast(arrRes[j][37]); jsSensorData["timeStamp"] = arrRes[j][38]; - jsSensorData["viff"] = arrRes[j][39]; - jsSensorData["RSSI"] = arrRes[j][40]; + jsSensorData["viff"] = boost::lexical_cast(arrRes[j][39]); + jsSensorData["RSSI"] = boost::lexical_cast(arrRes[j][40]); jsArray.append(jsSensorData); } } else { diff --git a/uart/SH_Uart.cpp b/uart/SH_Uart.cpp index 8990d1c..ade4c9c 100644 --- a/uart/SH_Uart.cpp +++ b/uart/SH_Uart.cpp @@ -459,19 +459,19 @@ void Uart::DealDataNodeInfo(const char *pData) memset(buf, 0, 32); sprintf(buf, "%d", BUILD_UINT32(pRecvData->Data[23], pRecvData->Data[24], pRecvData->Data[25], pRecvData->Data[26])); - dataNodeInfo.WakeupTime = std::string(buf);//唤醒次数 4 byte - + dataNodeInfo.WakeupTime = boost::lexical_cast(buf);//唤醒次数 4 byte + printf("WakeupTime = %d\n",dataNodeInfo.WakeupTime); memset(buf, 0, 32); sprintf(buf, "%d", BUILD_UINT32(pRecvData->Data[27], pRecvData->Data[28], pRecvData->Data[29], pRecvData->Data[30])); - dataNodeInfo.StaticTime = std::string(buf);//特征值发送次数 4 byte - + dataNodeInfo.StaticTime = boost::lexical_cast(buf);//特征值发送次数 4 byte + printf("StaticTime = %d\n",dataNodeInfo.StaticTime); memset(buf, 0, 32); - sprintf(buf, "%d", BUILD_UINT32(pRecvData->Data[31], pRecvData->Data[32], pRecvData->Data[33], pRecvData->Data[34])); - - dataNodeInfo.WaveTime = std::string(buf);//原始波形发送次数 4 byte +// sprintf(buf, "%d", BUILD_UINT32(pRecvData->Data[31], pRecvData->Data[32], pRecvData->Data[33], pRecvData->Data[34])); + dataNodeInfo.WaveTime = BUILD_UINT32(pRecvData->Data[31], pRecvData->Data[32], pRecvData->Data[33], pRecvData->Data[34]);//原始波形发送次数 4 byte + printf("dataNodeInfo.WaveTime = %d\n",dataNodeInfo.WaveTime); memset(buf, 0, 32); - sprintf(buf, "%02x%02x", pRecvData->Data[35], pRecvData->Data[36]); +// sprintf(buf, "%02x%02x", pRecvData->Data[35], pRecvData->Data[36]); dataNodeInfo.BateryV = BUILD_UINT16(pRecvData->Data[35],pRecvData->Data[36]);//电池电压 2 byte memset(buf, 0, 32); @@ -522,7 +522,7 @@ void Uart::DealDataNodeInfo(const char *pData) dataNodeInfo.ZigbeePower = boost::lexical_cast(buf); memset(buf, 0, 32); - sprintf(buf, "%02x", pRecvData->Data[51]);//Zigbee 重试次数 1 byte + sprintf(buf, "%d", BUILD_UINT16(00,pRecvData->Data[51]));//Zigbee 重试次数 1 byte dataNodeInfo.ZigbeeRetry = boost::lexical_cast(buf); memset(buf, 0, 32); @@ -601,17 +601,16 @@ void Uart::DealDataNodeInfo(const char *pData) if (sql_ctl->GetTableRows(T_SENSOR_INFO(TNAME), whereCon) > 0) { sql_ctl->DeleteTableData(T_SENSOR_INFO(TNAME), whereCon); } - printf("11111111111\n"); char insertSql[1024] = { 0 }; sprintf(insertSql, "'%s','%s','%d','%d','%d','%d','%d','%d',\ - '%s','%s','%s','%s','%s','%s',\ - '%s','%d','%d','%s','%d','%s',\ + '%s','%s','%s','%s','%s','%d',\ + '%d','%d','%d','%s','%d','%s',\ '%s','%u','%d','%d','%s','%d','%s','%s',\ '%s','%d','%s','%s','%s',\ '%d','%d','%d','%d','%s','%s','%d','%d'", dataNodeInfo.ZigbeeLongAddr.c_str(), " ", dataNodeInfo.InitFlag, dataNodeInfo.AccFlag, dataNodeInfo.ZigbeeFlag, dataNodeInfo.TemTopFlag, dataNodeInfo.TemBotFlag,dataNodeInfo.EquipSta,\ - dataNodeInfo.HardVersion.c_str(), dataNodeInfo.SoftVersion.c_str(), dataNodeInfo.BpNo.c_str(), dataNodeInfo.SerialNo.c_str(), dataNodeInfo.FirstPowerTime.c_str(), dataNodeInfo.WakeupTime.c_str(),\ - dataNodeInfo.StaticTime.c_str(),dataNodeInfo.WaveTime.c_str(),dataNodeInfo.BateryV,dataNodeInfo.ProductNo.c_str(),dataNodeInfo.ConfigFlag, dataNodeInfo.StartBrands.c_str(), \ + dataNodeInfo.HardVersion.c_str(), dataNodeInfo.SoftVersion.c_str(), dataNodeInfo.BpNo.c_str(), dataNodeInfo.SerialNo.c_str(), dataNodeInfo.FirstPowerTime.c_str(), dataNodeInfo.WakeupTime,\ + dataNodeInfo.StaticTime,dataNodeInfo.WaveTime,dataNodeInfo.BateryV,dataNodeInfo.ProductNo.c_str(),dataNodeInfo.ConfigFlag, dataNodeInfo.StartBrands.c_str(), \ dataNodeInfo.StopBrands.c_str(), dataNodeInfo.FeatureInterVal, dataNodeInfo.WaveInterVal, dataNodeInfo.SamplingRate,"",dataNodeInfo.Range, dataNodeInfo.EnvelopeBandPass.c_str(), dataNodeInfo.FaultFrequency.c_str(),\ dataNodeInfo.ZigbeePanId.c_str(), dataNodeInfo.ZigbeeChannel, dataNodeInfo.ZigbeeShortAddr.c_str(), dataNodeInfo.ZigbeeLongAddr.c_str(), dataNodeInfo.ZigbeeDesAddr.c_str(), \ dataNodeInfo.ZigbeePower,dataNodeInfo.ZigbeeRetry,dataNodeInfo.ZigbeeRetryGap,dataNodeInfo.ACCSampleTime,"1", dataNodeInfo.ConfigDate.c_str(),dataNodeInfo.VIntegralFilterFrequency,dataNodeInfo.RSSI);