Merge branch 'dg102_feature_new_process' of http://192.168.1.212:3000/zhangsheng/WLG into dg102_feature_new_process
This commit is contained in:
commit
78db33f4b2
@ -220,6 +220,8 @@ std::string JsonData::JsonCmd_Cgi_09(Param_09 ¶m) {
|
|||||||
jsChannelData["2xPhase"] = atof(arrRes[j][13].c_str());
|
jsChannelData["2xPhase"] = atof(arrRes[j][13].c_str());
|
||||||
jsChannelData["3xPhase"] = atof(arrRes[j][14].c_str());
|
jsChannelData["3xPhase"] = atof(arrRes[j][14].c_str());
|
||||||
jsChannelData["4xPhase"] = atof(arrRes[j][15].c_str());
|
jsChannelData["4xPhase"] = atof(arrRes[j][15].c_str());
|
||||||
|
jsChannelData["kurtosis"] = atof(arrRes[j][21].c_str());
|
||||||
|
jsChannelData["IntegratRMSMENS"] = atof(arrRes[j][22].c_str());
|
||||||
jsChannelData["TimeStamp"] = atof(arrRes[j][17].c_str());
|
jsChannelData["TimeStamp"] = atof(arrRes[j][17].c_str());
|
||||||
jsSensor.append(jsChannelData);
|
jsSensor.append(jsChannelData);
|
||||||
}
|
}
|
||||||
@ -371,7 +373,7 @@ std::string JsonData::JsonCmd_Cgi_10(Param_10 ¶m) {
|
|||||||
jsonVal["content"] = (jsStaticData);
|
jsonVal["content"] = (jsStaticData);
|
||||||
}
|
}
|
||||||
jsonVal["Static"] = param.strStatic;
|
jsonVal["Static"] = param.strStatic;
|
||||||
zlog_info(zct, "vecRes = %zu,channelID = %s", vecRes.size(), vecRes[0][0].c_str());
|
zlog_info(zct, "vecRes = %zu,channelID = %s", vecRes.size(), vecRes[0][1].c_str());
|
||||||
} else {
|
} else {
|
||||||
jsonVal["success"] = false;
|
jsonVal["success"] = false;
|
||||||
jsonVal["content"].resize(0);
|
jsonVal["content"].resize(0);
|
||||||
|
|||||||
@ -26,7 +26,7 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) {
|
|||||||
batteryLevelThreshold = readIntValue("config", "batteryLevelThreshold", (char *)GlobalConfig::Config_G.c_str());
|
batteryLevelThreshold = readIntValue("config", "batteryLevelThreshold", (char *)GlobalConfig::Config_G.c_str());
|
||||||
char looseValue[10] = {0x00};
|
char looseValue[10] = {0x00};
|
||||||
char whereCon[100] = {0};
|
char whereCon[100] = {0};
|
||||||
std::string effect = "" ,rssi = "",batteryPower = "";
|
std::string effect = "" ,rssi = "0",batteryPower = "";
|
||||||
readStringValue("config", "loose", looseValue, (char *)GlobalConfig::Config_G.c_str());
|
readStringValue("config", "loose", looseValue, (char *)GlobalConfig::Config_G.c_str());
|
||||||
Json::Value jsArray;
|
Json::Value jsArray;
|
||||||
array_t arrRes;
|
array_t arrRes;
|
||||||
@ -108,10 +108,42 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) {
|
|||||||
std::vector<std::string> vParamRSSI;
|
std::vector<std::string> vParamRSSI;
|
||||||
boost::split(vParamRSSI, arrRes[j][40], boost::is_any_of(","), boost::token_compress_on);
|
boost::split(vParamRSSI, arrRes[j][40], boost::is_any_of(","), boost::token_compress_on);
|
||||||
if (vParamRSSI.size() > 1) {
|
if (vParamRSSI.size() > 1) {
|
||||||
jsSensorData["RSSI"] = arrRes[j][40];
|
jsSensorData["RSSI"] = atof(vParamRSSI[1].c_str()) / 255.0;
|
||||||
} else {
|
} else {
|
||||||
jsSensorData["RSSI"] = "0," + arrRes[j][40];
|
jsSensorData["RSSI"] = arrRes[j][40];
|
||||||
|
rssi = arrRes[j][40];
|
||||||
}
|
}
|
||||||
|
batteryPower = arrRes[j][43];
|
||||||
|
std::vector<std::string> vParamBatteryPower;
|
||||||
|
float fBatteryPower = 100.0;
|
||||||
|
if(batteryPower != ""){
|
||||||
|
boost::split(vParamBatteryPower, batteryPower, boost::is_any_of(","), boost::token_compress_on);
|
||||||
|
if (vParamBatteryPower.size() > 0) {
|
||||||
|
fBatteryPower = atof(vParamBatteryPower[1].c_str())/atof(vParamBatteryPower[0].c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memset(whereCon,0x00,sizeof(whereCon));
|
||||||
|
sprintf(whereCon,"shortAddr = '%s' ",arrRes[j][30].c_str());
|
||||||
|
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine("t_shutdown_info","*",whereCon);
|
||||||
|
if (vecResult.size() == 0)
|
||||||
|
{
|
||||||
|
effect = "0";
|
||||||
|
}else{
|
||||||
|
effect = vecResult[5];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//同时满足时的优先级:低电量>低信号>停机
|
||||||
|
if(effect == "1"){
|
||||||
|
jsSensorData["waveStatus"] = 0; //灰色
|
||||||
|
}
|
||||||
|
if(lowSignal == 1 && atof(rssi.c_str()) < signalThreshold){
|
||||||
|
jsSensorData["waveStatus"] = 1;//红色
|
||||||
|
}
|
||||||
|
if(lowBatteryLevel == 1 && fBatteryPower < batteryLevelThreshold){
|
||||||
|
jsSensorData["waveStatus"] = 2;//红色
|
||||||
|
}
|
||||||
|
|
||||||
jsSensorData["update"] = atoi(arrRes[j][41].c_str());
|
jsSensorData["update"] = atoi(arrRes[j][41].c_str());
|
||||||
jsSensorData["MeasurementID"] = arrRes[j][44];
|
jsSensorData["MeasurementID"] = arrRes[j][44];
|
||||||
jsSensorData["battery"] = arrRes[j][43];
|
jsSensorData["battery"] = arrRes[j][43];
|
||||||
@ -558,7 +590,7 @@ std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m) {
|
|||||||
while (inFile.read((char *)&fTemp, sizeof(fTemp))) {
|
while (inFile.read((char *)&fTemp, sizeof(fTemp))) {
|
||||||
vecWave.push_back(fTemp);
|
vecWave.push_back(fTemp);
|
||||||
}
|
}
|
||||||
zlog_info(zct,"LF vecWave size %zu",vecWave.size());
|
zlog_info(zct,"LF vecWave size %zu,filename = %s",vecWave.size(),filename.c_str());
|
||||||
//进行傅立叶变换
|
//进行傅立叶变换
|
||||||
Calculation::FFTSpec(vecWave, fftWave);
|
Calculation::FFTSpec(vecWave, fftWave);
|
||||||
sampleRateReference = 1024;
|
sampleRateReference = 1024;
|
||||||
|
|||||||
@ -705,6 +705,9 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
|||||||
jsonVal[JSON_FIELD_CMD] = "60";
|
jsonVal[JSON_FIELD_CMD] = "60";
|
||||||
jsonVal["success"] = true;
|
jsonVal["success"] = true;
|
||||||
jsonVal["message"] = "";
|
jsonVal["message"] = "";
|
||||||
|
char wherecon[100] = {0};
|
||||||
|
char insertSql[200] = {0};
|
||||||
|
char updateSql[100] = {0};
|
||||||
if(param.mMode == 0){
|
if(param.mMode == 0){
|
||||||
char file_path[64]={0};
|
char file_path[64]={0};
|
||||||
char cmd[128]={0};
|
char cmd[128]={0};
|
||||||
@ -790,9 +793,7 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
|||||||
char localtimestamp[32] = {0};
|
char localtimestamp[32] = {0};
|
||||||
GetTimeNet(localtimestamp, 1);
|
GetTimeNet(localtimestamp, 1);
|
||||||
std::vector<UpgradeParameter> param_list;
|
std::vector<UpgradeParameter> param_list;
|
||||||
char wherecon[100] = {0};
|
|
||||||
char insertSql[200] = {0};
|
|
||||||
char updateSql[100] = {0};
|
|
||||||
for (size_t i = 0; i < param.dataNodeNo.size(); i++)
|
for (size_t i = 0; i < param.dataNodeNo.size(); i++)
|
||||||
{
|
{
|
||||||
UpgradeParameter upgrade_parameter;
|
UpgradeParameter upgrade_parameter;
|
||||||
@ -810,7 +811,7 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
|||||||
}
|
}
|
||||||
sprintf(insertSql, " '%s','%s','','','','','%d.%d','%s',1,'%s'",vecResult[3].c_str(),localtimestamp,sf_ver_m,sf_ver_s,vecResult[1].c_str(),param.fileName.c_str());
|
sprintf(insertSql, " '%s','%s','','','','','%d.%d','%s',1,'%s'",vecResult[3].c_str(),localtimestamp,sf_ver_m,sf_ver_s,vecResult[1].c_str(),param.fileName.c_str());
|
||||||
sqlite_db_ctrl::instance().InsertData(" firmware_upgrade ", insertSql);
|
sqlite_db_ctrl::instance().InsertData(" firmware_upgrade ", insertSql);
|
||||||
//0 默认状态,1 升级中,2 升级成功,3 升级失败
|
//0 默认状态,1 升级中,2 升级成功,3 升级失败 4,停止升级
|
||||||
memset(wherecon,0,sizeof(wherecon));
|
memset(wherecon,0,sizeof(wherecon));
|
||||||
memset(updateSql,0,sizeof(updateSql));
|
memset(updateSql,0,sizeof(updateSql));
|
||||||
sprintf(wherecon," zigbeeShortAddr = '%s'",vecResult[3].c_str());
|
sprintf(wherecon," zigbeeShortAddr = '%s'",vecResult[3].c_str());
|
||||||
@ -836,10 +837,28 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
|||||||
}
|
}
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}else if(param.mMode == 1){
|
}else if(param.mMode == 1){
|
||||||
|
std::vector<uint16_t> short_addr_list;
|
||||||
for (size_t i = 0; i < param.dataNodeNo.size(); i++)
|
for (size_t i = 0; i < param.dataNodeNo.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
UpgradeParameter upgrade_parameter;
|
||||||
|
memset(wherecon,0,sizeof(wherecon));
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(wherecon," dataNodeNo = '%s' ",param.dataNodeNo[i].c_str());
|
||||||
|
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " hardVersion,softVersion,ProductNo,zigbeeShortAddr ", wherecon);
|
||||||
|
|
||||||
|
uint16_t short_addr;
|
||||||
|
char *end_ptr = NULL;
|
||||||
|
short_addr = strtol(vecResult[3].c_str(), &end_ptr, 16);
|
||||||
|
short_addr_list.push_back(short_addr);
|
||||||
|
memset(wherecon,0,sizeof(wherecon));
|
||||||
|
memset(updateSql,0,sizeof(updateSql));
|
||||||
|
sprintf(wherecon," zigbeeShortAddr = '%s'",vecResult[3].c_str());
|
||||||
|
sprintf(updateSql, " upgradeStatus = %d ", 4);
|
||||||
|
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql,wherecon);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
scheduler::instance().CancelUpgradeSensor(short_addr_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return show_value_.write(jsonVal);
|
return show_value_.write(jsonVal);
|
||||||
|
|||||||
@ -420,7 +420,7 @@ std::string LocalServer::HandleCgi_cmd(std::string &pData) {
|
|||||||
case kTransducerUpgrade:{
|
case kTransducerUpgrade:{
|
||||||
JsonData jd;
|
JsonData jd;
|
||||||
Param_60 param;
|
Param_60 param;
|
||||||
std::string type = recvBody["cmd"].asString();
|
std::string type = recvBody["type"].asString();
|
||||||
if (0 == type.compare("UPDATE")) {
|
if (0 == type.compare("UPDATE")) {
|
||||||
param.mMode = 0;
|
param.mMode = 0;
|
||||||
param.fileName = recvBody["fileName"].asString();
|
param.fileName = recvBody["fileName"].asString();
|
||||||
|
|||||||
@ -98,12 +98,45 @@ void PlatformInit::Init() {
|
|||||||
zlog_error(zbt, "PlatFormInit exception happend.");
|
zlog_error(zbt, "PlatFormInit exception happend.");
|
||||||
std::string errorinfo = "系统初始化异常";
|
std::string errorinfo = "系统初始化异常";
|
||||||
}
|
}
|
||||||
|
char whereCon[128] = {0};
|
||||||
|
char insertSql[128] = {0};
|
||||||
|
int rows = 0;
|
||||||
|
std::string MeasurementID = "0";
|
||||||
|
std::string ShortAdd = "0";
|
||||||
array_t arrResult = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(T_SENSOR_INFO(TNAME), " MeasurementID,zigbeeShortAddr ", NULL);
|
array_t arrResult = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(T_SENSOR_INFO(TNAME), " MeasurementID,zigbeeShortAddr ", NULL);
|
||||||
for (size_t i = 0; i < arrResult.size(); i++) {
|
if (arrResult.size() > 1)
|
||||||
compressWaveChannel tempchannel;
|
{
|
||||||
WaveChannel tempwavechannel;
|
for (size_t i = 0; i < arrResult.size(); i++) {
|
||||||
g_mapCompress.insert(std::make_pair(arrResult[i][1], tempchannel));
|
compressWaveChannel tempchannel;
|
||||||
g_mapWaveChannel.insert(std::make_pair(arrResult[i][0], tempwavechannel));
|
WaveChannel tempwavechannel;
|
||||||
|
g_mapCompress.insert(std::make_pair(arrResult[i][1], tempchannel));
|
||||||
|
g_mapWaveChannel.insert(std::make_pair(arrResult[i][0], tempwavechannel));
|
||||||
|
MeasurementID = arrResult[i][0];
|
||||||
|
ShortAdd = arrResult[i][1];
|
||||||
|
sprintf(whereCon, "MeasurementID = '%s' ", arrResult[i][0].c_str());
|
||||||
|
rows = sqlite_db_ctrl::instance().GetTableRows("t_shutdown_info",whereCon);
|
||||||
|
zlog_info(zbt, "MeasurementID = %s,ShortAdd = %s,rows = %d", MeasurementID.c_str(), ShortAdd.c_str(), rows);
|
||||||
|
if(rows < 1){
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(insertSql, " '%s','%s','0','0','0','0'",
|
||||||
|
MeasurementID.c_str(), ShortAdd.c_str());
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_shutdown_info", insertSql);
|
||||||
|
}
|
||||||
|
rows = sqlite_db_ctrl::instance().GetTableRows("t_debug_info",whereCon);
|
||||||
|
if(rows < 1){
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(insertSql, " '%s','%s','','','','','','0',''",
|
||||||
|
MeasurementID.c_str(), ShortAdd.c_str());
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_debug_info", insertSql);
|
||||||
|
}
|
||||||
|
rows = sqlite_db_ctrl::instance().GetTableRows("t_wave_triger_info",whereCon);
|
||||||
|
if(rows < 1){
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(insertSql, " '%s','%s','0','0','0','0','0'",
|
||||||
|
MeasurementID.c_str(), ShortAdd.c_str());
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_wave_triger_info", insertSql);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,10 +92,10 @@ int SensorScheduler::StartSchedule(uint16_t short_addr, int &next_duration, bool
|
|||||||
long nxt_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + 60 + (i-nth_wave_slice)*60;
|
long nxt_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + 60 + (i-nth_wave_slice)*60;
|
||||||
next_duration = nxt_ts - current_ts_;
|
next_duration = nxt_ts - current_ts_;
|
||||||
if (next_duration < 10) {
|
if (next_duration < 10) {
|
||||||
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 25", id, short_addr);
|
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 25", id, short_addr,next_duration);
|
||||||
next_duration = 25;
|
next_duration = 25;
|
||||||
} else if (next_duration > eigen_value_send_interval_) {
|
} else if (next_duration > eigen_value_send_interval_) {
|
||||||
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 120", id, short_addr);
|
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 120", id, short_addr,next_duration);
|
||||||
next_duration = 120;
|
next_duration = 120;
|
||||||
}
|
}
|
||||||
z = true;
|
z = true;
|
||||||
@ -460,11 +460,11 @@ int SensorScheduler::GetNextDuration(uint16_t short_addr, bool &z, int &next_tas
|
|||||||
long next_ts = CalcNextTimestamp(id, short_addr, z, next_task_id);
|
long next_ts = CalcNextTimestamp(id, short_addr, z, next_task_id);
|
||||||
int duration = next_ts - current_ts;
|
int duration = next_ts - current_ts;
|
||||||
if (duration < 10) {
|
if (duration < 10) {
|
||||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 25", id, short_addr);
|
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 25", id, short_addr,duration);
|
||||||
duration = 25;
|
duration = 25;
|
||||||
return duration;
|
return duration;
|
||||||
} else if (duration > eigen_value_send_interval_) {
|
} else if (duration > eigen_value_send_interval_) {
|
||||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 120", id, short_addr);
|
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 120", id, short_addr,duration);
|
||||||
duration = 120;
|
duration = 120;
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
@ -499,11 +499,11 @@ int SensorScheduler::GetDebugUpgradeNextDuration(uint16_t short_addr) {
|
|||||||
|
|
||||||
int duration = available_ts - current_ts;
|
int duration = available_ts - current_ts;
|
||||||
if (duration < 10) {
|
if (duration < 10) {
|
||||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 25", id, short_addr);
|
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 25", id, short_addr,duration);
|
||||||
duration = 25;
|
duration = 25;
|
||||||
return duration;
|
return duration;
|
||||||
} else if (duration > eigen_value_send_interval_) {
|
} else if (duration > eigen_value_send_interval_) {
|
||||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 120", id, short_addr);
|
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 120", id, short_addr,duration);
|
||||||
duration = 120;
|
duration = 120;
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
@ -1380,7 +1380,7 @@ void SensorScheduler::GenerateUpgradeSchedule() {
|
|||||||
long nth_eigen_value_slice = seconds_in_current_wave_slice / eigen_value_send_interval_;
|
long nth_eigen_value_slice = seconds_in_current_wave_slice / eigen_value_send_interval_;
|
||||||
long seconds_in_current_eigen_slice = seconds_in_current_wave_slice % eigen_value_send_interval_;
|
long seconds_in_current_eigen_slice = seconds_in_current_wave_slice % eigen_value_send_interval_;
|
||||||
int previous_wave_slice = wave_slice_num_per_eigen_interval_ * (nth_eigen_value_slice + 1);
|
int previous_wave_slice = wave_slice_num_per_eigen_interval_ * (nth_eigen_value_slice + 1);
|
||||||
zlog_debug(zbt, "seconds_in_current_wave_slice:%d, nth_eigen_value_slice:%d, seconds_in_current_eigen_slice:%d, previous_wave_slice: %d",
|
zlog_debug(zbt, "seconds_in_current_wave_slice:%ld, nth_eigen_value_slice:%ld, seconds_in_current_eigen_slice:%ld, previous_wave_slice: %d",
|
||||||
seconds_in_current_wave_slice, nth_eigen_value_slice, seconds_in_current_eigen_slice, previous_wave_slice);
|
seconds_in_current_wave_slice, nth_eigen_value_slice, seconds_in_current_eigen_slice, previous_wave_slice);
|
||||||
// if (previous_wave_slice < 0) {
|
// if (previous_wave_slice < 0) {
|
||||||
// zlog_error(zbt, "previous_wave_slice: %d", previous_wave_slice);
|
// zlog_error(zbt, "previous_wave_slice: %d", previous_wave_slice);
|
||||||
|
|||||||
@ -492,6 +492,8 @@ int Uart::WaveSendCondition(char* shortAddr){
|
|||||||
if (vParamBatteryPower.size() > 0) {
|
if (vParamBatteryPower.size() > 0) {
|
||||||
fBatteryPower = atof(vParamBatteryPower[1].c_str())/atof(vParamBatteryPower[0].c_str());
|
fBatteryPower = atof(vParamBatteryPower[1].c_str())/atof(vParamBatteryPower[0].c_str());
|
||||||
}
|
}
|
||||||
|
memset(whereCon, 0, sizeof(whereCon));
|
||||||
|
sprintf(whereCon,"shortAddr = '%s' ",shortAddr);
|
||||||
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine("t_shutdown_info","*",whereCon);
|
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine("t_shutdown_info","*",whereCon);
|
||||||
effect = vecResult[5];
|
effect = vecResult[5];
|
||||||
if((lowSignal == 1 && atof(rssi.c_str()) < signalThreshold) || (lowBatteryLevel == 1 && fBatteryPower < batteryLevelThreshold) || effect == "1"){
|
if((lowSignal == 1 && atof(rssi.c_str()) < signalThreshold) || (lowBatteryLevel == 1 && fBatteryPower < batteryLevelThreshold) || effect == "1"){
|
||||||
@ -525,7 +527,7 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
|||||||
tempchannel.CountZ = BUILD_UINT32(pData[21], pData[20],pData[19],pData[18]);
|
tempchannel.CountZ = BUILD_UINT32(pData[21], pData[20],pData[19],pData[18]);
|
||||||
sprintf(sensor_rssi, "%02d", pData[22] & 0xFF);
|
sprintf(sensor_rssi, "%02d", pData[22] & 0xFF);
|
||||||
}else{
|
}else{
|
||||||
int ret = 0;//WaveSendCondition(shortAdd);
|
int ret = WaveSendCondition(shortAdd);
|
||||||
if(ret == 1){
|
if(ret == 1){
|
||||||
zlog_warn(zct, "WaveSendCondition not meet condition ,shortAddr = %s",shortAdd);
|
zlog_warn(zct, "WaveSendCondition not meet condition ,shortAddr = %s",shortAdd);
|
||||||
scheduler::instance().WaveSuccess(ushortAdd,true);
|
scheduler::instance().WaveSuccess(ushortAdd,true);
|
||||||
@ -578,15 +580,6 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
|||||||
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str());
|
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str());
|
||||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||||
|
|
||||||
std::vector<std::string> vParamRSSI;
|
|
||||||
boost::split(vParamRSSI, vecDataNodeNo[1], boost::is_any_of(","), boost::token_compress_on);
|
|
||||||
memset(updateSql,0,sizeof(updateSql));
|
|
||||||
memset(whereCon,0,sizeof(whereCon));
|
|
||||||
if (vParamRSSI.size() > 0) {
|
|
||||||
sprintf(updateSql, "RSSI = '%s,%02d' ", vParamRSSI[0].c_str(), pData[22] & 0xFF);
|
|
||||||
sprintf(whereCon, "dataNodeNo='%s'", (char *)vecDataNodeNo[0].c_str());
|
|
||||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
zlog_info(zct, "count X = %d,Y = %d,Z = %d,vol X = %d,vol Y = %d,vol Z = %d ", tempchannel.CountX, tempchannel.CountY, tempchannel.CountZ,tempchannel.CountVolX,tempchannel.CountVolY,tempchannel.CountVolZ);
|
zlog_info(zct, "count X = %d,Y = %d,Z = %d,vol X = %d,vol Y = %d,vol Z = %d ", tempchannel.CountX, tempchannel.CountY, tempchannel.CountZ,tempchannel.CountVolX,tempchannel.CountVolY,tempchannel.CountVolZ);
|
||||||
zlog_info(zct, "compress X = %d,Y = %d,Z = %d ", tempchannel.compressChannelX, tempchannel.compressChannelY, tempchannel.compressChannelZ);
|
zlog_info(zct, "compress X = %d,Y = %d,Z = %d ", tempchannel.compressChannelX, tempchannel.compressChannelY, tempchannel.compressChannelZ);
|
||||||
@ -629,16 +622,6 @@ int Uart::DealSensorRSSI(const char *pData,uint16_t ushortAdd){
|
|||||||
memset(whereCon,0,sizeof(whereCon));
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str());
|
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str());
|
||||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||||
|
|
||||||
std::vector<std::string> vParamRSSI;
|
|
||||||
boost::split(vParamRSSI, vecDataNodeNo[1], boost::is_any_of(","), boost::token_compress_on);
|
|
||||||
memset(updateSql,0,sizeof(updateSql));
|
|
||||||
memset(whereCon,0,sizeof(whereCon));
|
|
||||||
if (vParamRSSI.size() > 0) {
|
|
||||||
sprintf(updateSql, "RSSI = '%s,%02d' ", vParamRSSI[0].c_str(), pData[7] & 0xFF);
|
|
||||||
sprintf(whereCon, "dataNodeNo='%s'", (char *)vecDataNodeNo[0].c_str());
|
|
||||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -677,7 +660,14 @@ int Uart::DealFeatureValue(const char *pData,uint16_t ushortAdd){
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
DealAskTask(ushortAdd);
|
// char logInfo[100] = {0x00};
|
||||||
|
// std::vector<uint8_t>& data_vec = map_send_data[ushortAdd];
|
||||||
|
// const uint8_t* send_data = data_vec.data();
|
||||||
|
// WriteToUart((const char*)send_data, 100);
|
||||||
|
// mssleep(50000);
|
||||||
|
// WriteToUart((const char*)send_data, 100);
|
||||||
|
// mssleep(50000);
|
||||||
|
// WriteToUart((const char*)send_data, 100);
|
||||||
}else {
|
}else {
|
||||||
DealAskTask(ushortAdd);
|
DealAskTask(ushortAdd);
|
||||||
DealDataNodeFeature(pData, 0);
|
DealDataNodeFeature(pData, 0);
|
||||||
@ -1502,14 +1492,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// char tmp[23] = {0x00};
|
|
||||||
// char tmp2[23] = {0x00};
|
|
||||||
// for (int j = 0; j < 23; j++) {
|
|
||||||
// sprintf(tmp, "%02x ", UartRecvBuf[i + j] & 0xff);
|
|
||||||
// strcat(tmp2, tmp);
|
|
||||||
// }
|
|
||||||
// zlog_info(zct, "str = %s", tmp2);
|
|
||||||
DealRecvData(RecvBuf);
|
DealRecvData(RecvBuf);
|
||||||
} else if (command == 35) {
|
} else if (command == 35) {
|
||||||
char signalNode[10] = {0x00};
|
char signalNode[10] = {0x00};
|
||||||
@ -1529,14 +1511,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
|||||||
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char *)vecDataNodeNo[0].c_str(), strTimetamp.c_str());
|
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char *)vecDataNodeNo[0].c_str(), strTimetamp.c_str());
|
||||||
sprintf(tableName, "t_dataStatic_%s", (char *)vecDataNodeNo[0].c_str());
|
sprintf(tableName, "t_dataStatic_%s", (char *)vecDataNodeNo[0].c_str());
|
||||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||||
|
|
||||||
std::vector<std::string> vParamRSSI;
|
|
||||||
boost::split(vParamRSSI, vecDataNodeNo[1], boost::is_any_of(","), boost::token_compress_on);
|
|
||||||
if (vParamRSSI.size() > 0) {
|
|
||||||
sprintf(updateSql, "RSSI = '%s,%02d' ", vParamRSSI[0].c_str(), UartRecvBuf[i + 14] & 0xFF);
|
|
||||||
sprintf(whereCon, "dataNodeNo='%s'", (char *)vecDataNodeNo[0].c_str());
|
|
||||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1609,18 +1583,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
|||||||
} else {
|
} else {
|
||||||
jsBody["looseStatus"] = "0";
|
jsBody["looseStatus"] = "0";
|
||||||
}
|
}
|
||||||
std::vector<std::string> vParamRSSI;
|
|
||||||
boost::split(vParamRSSI, vecDataNodeNo[2], boost::is_any_of(","), boost::token_compress_on);
|
|
||||||
memset(updateSql,0,sizeof(updateSql));
|
|
||||||
memset(whereCon,0,sizeof(whereCon));
|
|
||||||
if (vParamRSSI.size() == 1) {
|
|
||||||
sprintf(updateSql, "RSSI = '%02d,%s' ", UartRecvBuf[i + 6] & 0xFF, vParamRSSI[0].c_str());
|
|
||||||
|
|
||||||
} else if (vParamRSSI.size() == 2) {
|
|
||||||
sprintf(updateSql, "RSSI = '%02d,%s' ", UartRecvBuf[i + 6] & 0xFF, vParamRSSI[1].c_str());
|
|
||||||
}
|
|
||||||
sprintf(whereCon, "dataNodeNo='%s'", (char *)vecDataNodeNo[0].c_str());
|
|
||||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
|
||||||
|
|
||||||
jsonVal["cmd"] = "52";
|
jsonVal["cmd"] = "52";
|
||||||
jsBody["timeStamp"] = strTimetamp;
|
jsBody["timeStamp"] = strTimetamp;
|
||||||
|
|||||||
@ -69,6 +69,10 @@ void Uart::RecordBattery(std::string &strLongAddr, DataRecvStatic &dataStatic, s
|
|||||||
actualRate = (wave_dataLen / 1024.0f) / (dataStatic.nodeSendTime / 1000.0f); //单位:KB/s
|
actualRate = (wave_dataLen / 1024.0f) / (dataStatic.nodeSendTime / 1000.0f); //单位:KB/s
|
||||||
}
|
}
|
||||||
float comprehensiveRSSI = (zigbeeSignal + zigbeeSignalNode) * (actualRate / standardRate);
|
float comprehensiveRSSI = (zigbeeSignal + zigbeeSignalNode) * (actualRate / standardRate);
|
||||||
|
if (comprehensiveRSSI > 1.0f) {
|
||||||
|
comprehensiveRSSI = 1.0f; //综合信号强度最大为1
|
||||||
|
}
|
||||||
|
|
||||||
zlog_info(zct, "dataNodeNo='%s',wave_dataLen=%d,nodeSendTime=%f,actualRate=%f", strLongAddr.c_str(), wave_dataLen, dataStatic.nodeSendTime, actualRate);
|
zlog_info(zct, "dataNodeNo='%s',wave_dataLen=%d,nodeSendTime=%f,actualRate=%f", strLongAddr.c_str(), wave_dataLen, dataStatic.nodeSendTime, actualRate);
|
||||||
//更新综合信号强度到数据库
|
//更新综合信号强度到数据库
|
||||||
char updateSql[256] = {0};
|
char updateSql[256] = {0};
|
||||||
@ -273,23 +277,23 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
|||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
|
|
||||||
//时间戳判断,是否重包
|
//时间戳判断,是否重包
|
||||||
sprintf(whereCon, "timeStamp = '%s'", localtimestamp);
|
// sprintf(whereCon, "timeStamp = '%s'", localtimestamp);
|
||||||
int count = sqlite_db_ctrl::instance().GetTableRows(szTableNameStatic, whereCon); //避免重复数据
|
// int count = sqlite_db_ctrl::instance().GetTableRows(szTableNameStatic, whereCon); //避免重复数据
|
||||||
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
// sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
||||||
|
|
||||||
int count2 = sqlite_db_ctrl::instance().GetTableRows(szTableNameData, whereCon);
|
// int count2 = sqlite_db_ctrl::instance().GetTableRows(szTableNameData, whereCon);
|
||||||
if (count > 0 || count2 > 0) {
|
// if (count > 0 || count2 > 0) {
|
||||||
char logInfo[100] = {0x00};
|
// char logInfo[100] = {0x00};
|
||||||
sprintf(logInfo, "ShortAddr = %s,localtimestamp = %s,staticData = %d, data = %d", strShortAddr.c_str(), localtimestamp, count, count2);
|
// sprintf(logInfo, "ShortAddr = %s,localtimestamp = %s,staticData = %d, data = %d", strShortAddr.c_str(), localtimestamp, count, count2);
|
||||||
zlog_info(zct, logInfo);
|
// zlog_info(zct, logInfo);
|
||||||
std::vector<uint8_t>& data_vec = map_send_data[u_short_addr];
|
// std::vector<uint8_t>& data_vec = map_send_data[u_short_addr];
|
||||||
const uint8_t* send_data = data_vec.data();
|
// const uint8_t* send_data = data_vec.data();
|
||||||
WriteToUart((const char*)send_data, 100);
|
// WriteToUart((const char*)send_data, 100);
|
||||||
mssleep(50000);
|
// mssleep(50000);
|
||||||
WriteToUart((const char*)send_data, 100);
|
// WriteToUart((const char*)send_data, 100);
|
||||||
mssleep(50000);
|
// mssleep(50000);
|
||||||
WriteToUart((const char*)send_data, 100);
|
// WriteToUart((const char*)send_data, 100);
|
||||||
}
|
// }
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
||||||
///////////////////////////////////////////////////////////// for V2.0.3 upgrade to V3.0
|
///////////////////////////////////////////////////////////// for V2.0.3 upgrade to V3.0
|
||||||
@ -941,15 +945,15 @@ std::vector<float> Uart::DealData(int iChannel, float coe, unsigned int sampleRa
|
|||||||
memcpy(dealdata, data, j * 92);
|
memcpy(dealdata, data, j * 92);
|
||||||
deallen = j * 92;
|
deallen = j * 92;
|
||||||
}
|
}
|
||||||
if(iChannel == WAVE_LF_X){
|
// if(iChannel == WAVE_LF_X){
|
||||||
for (size_t i = 0; i < 200; i++) {
|
// for (size_t i = 0; i < 200; i++) {
|
||||||
float fTemp = 0.0f;
|
// float fTemp = 0.0f;
|
||||||
memset(buf, 0, 8);
|
// memset(buf, 0, 8);
|
||||||
sprintf(buf, "%02x%02x", dealdata[2 * i + 1], dealdata[i * 2]);
|
// sprintf(buf, "%02x%02x", dealdata[2 * i + 1], dealdata[i * 2]);
|
||||||
printf("%s ", buf);
|
// printf("%s ", buf);
|
||||||
}
|
// }
|
||||||
printf("\n");
|
// printf("\n");
|
||||||
}
|
// }
|
||||||
for (size_t i = 0; i < deallen; i++) {
|
for (size_t i = 0; i < deallen; i++) {
|
||||||
float fTemp = 0.0f;
|
float fTemp = 0.0f;
|
||||||
memset(buf, 0, 8);
|
memset(buf, 0, 8);
|
||||||
@ -996,13 +1000,13 @@ std::vector<float> Uart::DealData(int iChannel, float coe, unsigned int sampleRa
|
|||||||
if (vecData.size() == 24000 && iChannel == WAVE_Z) { //过滤数据包结尾空数据
|
if (vecData.size() == 24000 && iChannel == WAVE_Z) { //过滤数据包结尾空数据
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (vecData.size() == 4096 && iChannel == WAVE_LF_X) { //过滤数据包结尾空数据
|
if (vecData.size() == 13108 && iChannel == WAVE_LF_X) { //过滤数据包结尾空数据
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (vecData.size() == 4096 && iChannel == WAVE_LF_Y) { //过滤数据包结尾空数据
|
if (vecData.size() == 13108 && iChannel == WAVE_LF_Y) { //过滤数据包结尾空数据
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (vecData.size() == 4096 && iChannel == WAVE_LF_Z) { //过滤数据包结尾空数据
|
if (vecData.size() == 13108 && iChannel == WAVE_LF_Z) { //过滤数据包结尾空数据
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1289,12 +1293,41 @@ void Uart::WriteDatFile(int sampleRate, std::string &strMeasurementID, int iChan
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
FILE *fp = fopen(strFileName.c_str(), "w");
|
FILE *fp = fopen(strFileName.c_str(), "w");
|
||||||
fwrite(localtimestamp,sizeof(localtimestamp),1,fp);
|
|
||||||
zlog_info(zct, " vecData.size : %zu,start ", vecData.size());
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
fwrite(localtimestamp,sizeof(localtimestamp),1,fp);
|
||||||
|
for (size_t i = 0; i < vecData.size(); i++) {
|
||||||
|
frTemp = vecData[i] - mean;
|
||||||
|
memset(buf, 0x00, sizeof(buf));
|
||||||
|
sprintf(buf, "%.2f", frTemp);
|
||||||
|
fwrite(&frTemp,sizeof(float),1,fp);
|
||||||
|
if (iChannel == WAVE_X){
|
||||||
|
wave_channel.WaveChannelX[i] = frTemp;
|
||||||
|
}else if (iChannel == WAVE_Y){
|
||||||
|
wave_channel.WaveChannelY[i] = frTemp;
|
||||||
|
}else if (iChannel == WAVE_Z){
|
||||||
|
wave_channel.WaveChannelZ[i] = frTemp;
|
||||||
|
}else if (iChannel == WAVE_LF_X){
|
||||||
|
wave_vol_channel.WaveChannelVolX[i] = frTemp;
|
||||||
|
}else if (iChannel == WAVE_LF_Y){
|
||||||
|
wave_vol_channel.WaveChannelVolY[i] = frTemp;
|
||||||
|
}else if (iChannel == WAVE_LF_Z){
|
||||||
|
wave_vol_channel.WaveChannelVolZ[i] = frTemp;
|
||||||
|
}
|
||||||
|
if (i != vecData.size() -1){
|
||||||
|
strncpy(mqttData + id ,buf,strlen(buf));
|
||||||
|
id = id + strlen(buf);
|
||||||
|
strncpy(mqttData + id,",",1);
|
||||||
|
id = id + 1;
|
||||||
|
}else{
|
||||||
|
strncpy(mqttData + id ,buf,strlen(buf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
zlog_info(zct, " vecData.size : %zu,start ", vecData.size());
|
||||||
|
|
||||||
|
zlog_info(zct, " product = %s,version = %d ,iChannel = %d", product.c_str(),version,iChannel);
|
||||||
if ((product == "02" && sampleRate == 24000 && iChannel == WAVE_Z && version == 1) ||
|
if ((product == "02" && sampleRate == 24000 && iChannel == WAVE_Z && version == 1) ||
|
||||||
(iChannel == WAVE_Z && version == 1) ||
|
(iChannel == WAVE_Z && version == 0) ||
|
||||||
((iChannel == WAVE_LF_X || iChannel == WAVE_LF_Y|| iChannel == WAVE_LF_Z) && version == 0)){
|
((iChannel == WAVE_LF_X || iChannel == WAVE_LF_Y|| iChannel == WAVE_LF_Z) && version == 0)){
|
||||||
sampleRate = 25600;
|
sampleRate = 25600;
|
||||||
zlog_info(zct, " sampleRate = %d,product = %s,ACCSampleTime = %f ", sampleRate,product.c_str(),ACCSampleTime);
|
zlog_info(zct, " sampleRate = %d,product = %s,ACCSampleTime = %f ", sampleRate,product.c_str(),ACCSampleTime);
|
||||||
@ -1314,9 +1347,11 @@ void Uart::WriteDatFile(int sampleRate, std::string &strMeasurementID, int iChan
|
|||||||
}
|
}
|
||||||
}else if(std::fabs(ACCSampleTime - 1.28) < epsilon){
|
}else if(std::fabs(ACCSampleTime - 1.28) < epsilon){
|
||||||
outputData = Calculation::fftInterpolate(vecData, outSize);
|
outputData = Calculation::fftInterpolate(vecData, outSize);
|
||||||
|
zlog_info(zct, " outputData_size %zu ,ACCSampleTime %f", outputData.size(),ACCSampleTime);
|
||||||
}else if(std::fabs(ACCSampleTime - 3.2) < epsilon){
|
}else if(std::fabs(ACCSampleTime - 3.2) < epsilon){
|
||||||
outSize = 2560;
|
outSize = 8192;
|
||||||
outputData = Calculation::fftInterpolate(vecData, outSize);
|
outputData = Calculation::fftInterpolate(vecData, outSize);
|
||||||
|
zlog_info(zct, " outputData_size %zu ,ACCSampleTime %f", outputData.size(),ACCSampleTime);
|
||||||
}
|
}
|
||||||
zlog_info(zct, " outputData_size %zu ", outputData.size());
|
zlog_info(zct, " outputData_size %zu ", outputData.size());
|
||||||
float mean = Calculation::mean(outputData);
|
float mean = Calculation::mean(outputData);
|
||||||
@ -1326,20 +1361,6 @@ void Uart::WriteDatFile(int sampleRate, std::string &strMeasurementID, int iChan
|
|||||||
frTemp = outputData[i] - mean;
|
frTemp = outputData[i] - mean;
|
||||||
memset(buf, 0x00, sizeof(buf));
|
memset(buf, 0x00, sizeof(buf));
|
||||||
sprintf(buf, "%.2f", frTemp);
|
sprintf(buf, "%.2f", frTemp);
|
||||||
fwrite(&frTemp,sizeof(float),1,fp);
|
|
||||||
if (iChannel == WAVE_X){
|
|
||||||
wave_channel.WaveChannelX[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_Y){
|
|
||||||
wave_channel.WaveChannelY[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_Z){
|
|
||||||
wave_channel.WaveChannelZ[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_LF_X){
|
|
||||||
wave_vol_channel.WaveChannelVolX[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_LF_Y){
|
|
||||||
wave_vol_channel.WaveChannelVolY[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_LF_Z){
|
|
||||||
wave_vol_channel.WaveChannelVolZ[i] = frTemp;
|
|
||||||
}
|
|
||||||
if (i != outputData.size() -1){
|
if (i != outputData.size() -1){
|
||||||
strncpy(mqttData + id ,buf,strlen(buf));
|
strncpy(mqttData + id ,buf,strlen(buf));
|
||||||
id = id + strlen(buf);
|
id = id + strlen(buf);
|
||||||
@ -1349,36 +1370,8 @@ void Uart::WriteDatFile(int sampleRate, std::string &strMeasurementID, int iChan
|
|||||||
strncpy(mqttData + id ,buf,strlen(buf));
|
strncpy(mqttData + id ,buf,strlen(buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
for (size_t i = 0; i < vecData.size(); i++) {
|
|
||||||
frTemp = vecData[i] - mean;
|
|
||||||
memset(buf, 0x00, sizeof(buf));
|
|
||||||
sprintf(buf, "%.2f", frTemp);
|
|
||||||
fwrite(&frTemp,sizeof(float),1,fp);
|
|
||||||
if (iChannel == WAVE_X){
|
|
||||||
wave_channel.WaveChannelX[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_Y){
|
|
||||||
wave_channel.WaveChannelY[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_Z){
|
|
||||||
wave_channel.WaveChannelZ[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_LF_X){
|
|
||||||
wave_vol_channel.WaveChannelVolX[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_LF_Y){
|
|
||||||
wave_vol_channel.WaveChannelVolY[i] = frTemp;
|
|
||||||
}else if (iChannel == WAVE_LF_Z){
|
|
||||||
wave_vol_channel.WaveChannelVolZ[i] = frTemp;
|
|
||||||
}
|
|
||||||
if (i != vecData.size() -1){
|
|
||||||
strncpy(mqttData + id ,buf,strlen(buf));
|
|
||||||
id = id + strlen(buf);
|
|
||||||
strncpy(mqttData + id,",",1);
|
|
||||||
id = id + 1;
|
|
||||||
}else{
|
|
||||||
strncpy(mqttData + id ,buf,strlen(buf));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fclose(fp);
|
|
||||||
zlog_info(zct, "fopen file vecData.size : %zu end ", vecData.size());
|
zlog_info(zct, "fopen file vecData.size : %zu end ", vecData.size());
|
||||||
wave_channel.wave_timestamp = nowTimetamp;
|
wave_channel.wave_timestamp = nowTimetamp;
|
||||||
g_mapWaveChannel[strMeasurementID] = wave_channel;
|
g_mapWaveChannel[strMeasurementID] = wave_channel;
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#include "common/common_func.hpp"
|
#include "common/common_func.hpp"
|
||||||
#include "minilzo/minilzo.h"
|
#include "minilzo/minilzo.h"
|
||||||
#include "scheduler/wave_feature_set.hpp"
|
#include "scheduler/wave_feature_set.hpp"
|
||||||
|
#include "scheduler/schedule.hpp"
|
||||||
|
|
||||||
extern zlog_category_t* zct;
|
extern zlog_category_t* zct;
|
||||||
extern zlog_category_t* zbt;
|
extern zlog_category_t* zbt;
|
||||||
@ -53,9 +54,9 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
char wherecon[512] = {0};
|
char wherecon[512] = {0};
|
||||||
sprintf(wherecon," short_Addr = '%02x%02x' and status = 3 and start_timestamp > ( SELECT MAX(submit_timestamp) FROM firmware_upgrade ) order by start_timestamp DESC",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
sprintf(wherecon," short_Addr = '%02x%02x' and status = 3 and start_timestamp > ( SELECT MAX(submit_timestamp) FROM firmware_upgrade ) order by start_timestamp DESC",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||||
std::string spend_count = sqlite_db_ctrl::instance().GetData(" firmware_upgrade ","spend_count",wherecon);
|
std::string spend_count = sqlite_db_ctrl::instance().GetData(" firmware_upgrade ","spend_count",wherecon);
|
||||||
if (atoi(spend_count.c_str()) >= 10){
|
//if (atoi(spend_count.c_str()) >= 12)
|
||||||
|
{
|
||||||
zlog_warn(zbt, "UpdateWirelessNode spend_count %d,shortAddr = %02x%02x", atoi(spend_count.c_str()), UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
zlog_warn(zbt, "UpdateWirelessNode spend_count %d,shortAddr = %02x%02x", atoi(spend_count.c_str()), UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
if (spend_count == "")spend_count = "0";
|
if (spend_count == "")spend_count = "0";
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
// zlog_warn(zct,"This block contains incompressible data.out_len = %lu,thisSize = %lu",out_len,thisSize);
|
// zlog_warn(zct,"This block contains incompressible data.out_len = %lu,thisSize = %lu",out_len,thisSize);
|
||||||
// memcpy(fw_senddata,buffer,thisSize);
|
// memcpy(fw_senddata,buffer,thisSize);
|
||||||
// }
|
// }
|
||||||
memcpy(fw_senddata,buffer,thisSize);
|
//memcpy(fw_senddata,buffer,thisSize);
|
||||||
unsigned char Data[100] = {0x00};
|
unsigned char Data[100] = {0x00};
|
||||||
unsigned char size[4] = {0x00};
|
unsigned char size[4] = {0x00};
|
||||||
zlog_info(zct, "thisSize = %d", (int)thisSize);
|
zlog_info(zct, "thisSize = %d", (int)thisSize);
|
||||||
@ -195,7 +196,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
UpdateData[4]=UINT16_LOW(shortAdd);
|
UpdateData[4]=UINT16_LOW(shortAdd);
|
||||||
UpdateData[5]=0x10;
|
UpdateData[5]=0x10;
|
||||||
UpdateData[6]=0xff & j;
|
UpdateData[6]=0xff & j;
|
||||||
memcpy(&UpdateData[7],fw_senddata + 92 * j,92);
|
memcpy(&UpdateData[7],buffer + 92 * j,92);
|
||||||
tmp = 0x00;
|
tmp = 0x00;
|
||||||
for(int k = 0; k < 99;k++){
|
for(int k = 0; k < 99;k++){
|
||||||
tmp +=UpdateData[k];
|
tmp +=UpdateData[k];
|
||||||
@ -215,6 +216,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
if(time >= 150){
|
if(time >= 150){
|
||||||
zlog_warn(zct, "gpio_read failed shortAdd %02x %02x,index = %d", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd),j);
|
zlog_warn(zct, "gpio_read failed shortAdd %02x %02x,index = %d", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd),j);
|
||||||
zlog_warn(zct, "gpio_read failed \n");
|
zlog_warn(zct, "gpio_read failed \n");
|
||||||
|
scheduler::instance().UpgradeResult(shortAdd,kRecvDataLenError);
|
||||||
bUpdate = false;
|
bUpdate = false;
|
||||||
upgrade_status = 3;
|
upgrade_status = 3;
|
||||||
goto endUpdate;
|
goto endUpdate;
|
||||||
@ -235,7 +237,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
UpdateData[4] = UINT16_LOW(shortAdd);
|
UpdateData[4] = UINT16_LOW(shortAdd);
|
||||||
UpdateData[5] = 0x10;
|
UpdateData[5] = 0x10;
|
||||||
UpdateData[6] = 0xff & Count;
|
UpdateData[6] = 0xff & Count;
|
||||||
memcpy(&UpdateData[7], fw_senddata + 92 * Count, lastSize);
|
memcpy(&UpdateData[7], buffer + 92 * Count, lastSize);
|
||||||
tmp = 0x00;
|
tmp = 0x00;
|
||||||
for (int k = 0; k < 99; k++) {
|
for (int k = 0; k < 99; k++) {
|
||||||
tmp += UpdateData[k];
|
tmp += UpdateData[k];
|
||||||
@ -259,6 +261,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
if (time >= 150) {
|
if (time >= 150) {
|
||||||
zlog_warn(zct, "gpio_read failed shortAdd %02x %02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
zlog_warn(zct, "gpio_read failed shortAdd %02x %02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||||
zlog_warn(zct, "gpio_read failed \n");
|
zlog_warn(zct, "gpio_read failed \n");
|
||||||
|
scheduler::instance().UpgradeResult(shortAdd,kRecvDataLenError);
|
||||||
bUpdate = false;
|
bUpdate = false;
|
||||||
upgrade_status = 3;
|
upgrade_status = 3;
|
||||||
goto endUpdate;
|
goto endUpdate;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user