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
3143f166d5
@ -58,7 +58,7 @@ public :
|
||||
};
|
||||
|
||||
|
||||
#define SAVE_COUNT 4800*4
|
||||
#define SAVE_COUNT 6048*7
|
||||
#define OneWeek 604800*7
|
||||
|
||||
|
||||
|
||||
@ -268,6 +268,7 @@ std::string JsonData::JsonCmd_Cgi_27(std::vector<Param_27> ¶m) {
|
||||
char localtimestamp[32] = {0};
|
||||
for (size_t i = 0; i < param.size(); i++)
|
||||
{
|
||||
zlog_info(zct,"type = %s",param[i].mType.c_str());
|
||||
if (param[i].mDataNodeNo.length() > 0 && param[i].mType == "DELETE") {
|
||||
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), param[i].mDataNodeNo.c_str());
|
||||
sqlite_db_ctrl::instance().DeleteTableData(T_SENSOR_INFO(TNAME), whereCon);
|
||||
@ -659,7 +660,15 @@ std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m) {
|
||||
resolution = (double)SampleRate / 8192;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
}
|
||||
if(param.mMode == 0 && productNo == "02"){
|
||||
std::string::size_type comper = param.mChannelId.find("Z");
|
||||
if (comper != std::string::npos) {
|
||||
resolution = 1 / 1.28;
|
||||
}else{
|
||||
resolution = 1 / 1.6;
|
||||
}
|
||||
}else if(param.mMode == 1 && productNo == "02"){
|
||||
resolution = 1 / 3.2;
|
||||
}
|
||||
|
||||
|
||||
@ -449,104 +449,161 @@ std::string JsonData::JsonCmd_Cgi_56(Param_56 ¶m) {
|
||||
vec_t res = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " * ", whereCon);
|
||||
int SampleRate = 0;
|
||||
double resolution = 0.0;
|
||||
std::string softVersion = res[9];
|
||||
std::string productNo = res[17];
|
||||
SampleRate = atoi(res[23].c_str());
|
||||
zlog_info(zct,"sensor type %s", res[17].c_str());
|
||||
|
||||
if (access(filename.c_str(), 0) >= 0) {
|
||||
std::ifstream inFile(filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if (!inFile) {
|
||||
zlog_error(zct, "read channel data error, filename:%s", filename.c_str());
|
||||
jsonVal["success"] = "false";
|
||||
jsonVal["message"] = "error";
|
||||
} else {
|
||||
float fTemp = 0;
|
||||
|
||||
inFile.read((char *)localtimestamp, sizeof(localtimestamp));
|
||||
std::string::size_type comper = param.mChannelId.find("Z");
|
||||
if (comper != std::string::npos && res[17] == "02") {
|
||||
while (inFile.read((char *)&fTemp, sizeof(fTemp))) {
|
||||
vecWave.push_back(fTemp);
|
||||
}
|
||||
//积分
|
||||
resolution = (double)SampleRate / vecWave.size();
|
||||
Calculation::Integration(vecWave, IntegrationWave, resolution);
|
||||
Calculation::FFTSpec(IntegrationWave, fftWave);
|
||||
sampleRateReference = 1000;
|
||||
|
||||
if ((compareVersions(softVersion, "2.6") == -1 && productNo == "02") || productNo == "01") {
|
||||
if (access(filename.c_str(), 0) >= 0) {
|
||||
std::ifstream inFile(filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if (!inFile) {
|
||||
zlog_error(zct, "read channel data error, filename:%s", filename.c_str());
|
||||
jsonVal["success"] = "false";
|
||||
jsonVal["message"] = "error";
|
||||
} else {
|
||||
while (inFile.read((char *)&fTemp, sizeof(fTemp))) { // 取8K进行计算
|
||||
float fTemp = 0;
|
||||
|
||||
vecWave.push_back(fTemp);
|
||||
inFile.read((char *)localtimestamp, sizeof(localtimestamp));
|
||||
std::string::size_type comper = param.mChannelId.find("Z");
|
||||
if (comper != std::string::npos && res[17] == "02") {
|
||||
while (inFile.read((char *)&fTemp, sizeof(fTemp))) {
|
||||
vecWave.push_back(fTemp);
|
||||
}
|
||||
//积分
|
||||
resolution = (double)SampleRate / vecWave.size();
|
||||
Calculation::Integration(vecWave, IntegrationWave, resolution);
|
||||
Calculation::FFTSpec(IntegrationWave, fftWave);
|
||||
sampleRateReference = 1000;
|
||||
|
||||
}
|
||||
if (res[17] == "01") {
|
||||
zlog_info(zct,"sample_rate=%d", SampleRate);
|
||||
resolution = (((double)SampleRate / 1000) * 1016) / vecWave.size();
|
||||
} else {
|
||||
while (inFile.read((char *)&fTemp, sizeof(fTemp))) { // 取8K进行计算
|
||||
|
||||
} else if (res[17] == "02") {
|
||||
std::string::size_type comper = param.mChannelId.find("Z");
|
||||
if (comper != std::string::npos) {
|
||||
SampleRate = atoi(res[23].c_str());
|
||||
resolution = (double)SampleRate / vecWave.size();
|
||||
vecWave.push_back(fTemp);
|
||||
|
||||
zlog_info(zct,"sample_rate=%d,resolution = %f", SampleRate, resolution);
|
||||
} else {
|
||||
SampleRate = 8192;
|
||||
}
|
||||
if (res[17] == "01") {
|
||||
zlog_info(zct,"sample_rate=%d", SampleRate);
|
||||
if (vecWave.size() < 8192) {
|
||||
resolution = (((double)SampleRate / 1000) * 1016) / vecWave.size();
|
||||
|
||||
} else if (res[17] == "02") {
|
||||
std::string::size_type comper = param.mChannelId.find("Z");
|
||||
if (comper != std::string::npos) {
|
||||
SampleRate = atoi(res[23].c_str());
|
||||
resolution = (double)SampleRate / vecWave.size();
|
||||
|
||||
zlog_info(zct,"sample_rate=%d,resolution = %f", SampleRate, resolution);
|
||||
} else {
|
||||
resolution = (double)SampleRate / 8192;
|
||||
SampleRate = 8192;
|
||||
zlog_info(zct,"sample_rate=%d", SampleRate);
|
||||
if (vecWave.size() < 8192) {
|
||||
resolution = (double)SampleRate / vecWave.size();
|
||||
} else {
|
||||
resolution = (double)SampleRate / 8192;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 积分
|
||||
Calculation::Integration(vecWave, IntegrationWave, resolution);
|
||||
Calculation::FFTSpec(IntegrationWave, fftWave);
|
||||
|
||||
sampleRateReference = 1024;
|
||||
}
|
||||
zlog_info(zct,"2---------------------------------------------->vecWave = %zu,fftWave = %zu", vecWave.size(), fftWave.size());
|
||||
|
||||
int flag = param.mPackageFlag;
|
||||
flag = (flag + 1) * sampleRateReference;
|
||||
int number = fftWave.size();
|
||||
zlog_info(zct,"number---------------------------------------------->%d", number);
|
||||
int start = param.mPackageFlag * sampleRateReference;
|
||||
zlog_info(zct,"param.mPackageFlag = %d", param.mPackageFlag);
|
||||
zlog_info(zct,"param.start = %d", start);
|
||||
zlog_info(zct,"param.flag = %d", flag);
|
||||
if (number < sampleRateReference) {
|
||||
flag = number;
|
||||
start = 0;
|
||||
}
|
||||
char buf[32];
|
||||
for (int i = start; i < flag; i++) {
|
||||
if (i == start) {
|
||||
memset(buf, 0, 32);
|
||||
sprintf(buf, "%.6f", fftWave[i]);
|
||||
std::string waveTemp(buf);
|
||||
strWaveData = waveTemp;
|
||||
|
||||
} else {
|
||||
memset(buf, 0, 32);
|
||||
sprintf(buf, "%.6f", fftWave[i]);
|
||||
std::string waveTemp(buf);
|
||||
strWaveData = strWaveData + "," + waveTemp;
|
||||
}
|
||||
}
|
||||
|
||||
// 积分
|
||||
int max = number / sampleRateReference;
|
||||
if (max == 0 && number > 0) {
|
||||
max = 1;
|
||||
}
|
||||
|
||||
jsBody["packageMax"] = max;
|
||||
}
|
||||
} else {
|
||||
jsonVal["success"] = false;
|
||||
jsonVal["message"] = "没有数据文件";
|
||||
}
|
||||
}else{
|
||||
filename = "/opt/data/" + param.mChannelId + "-LF.dat";
|
||||
if (access(filename.c_str(), 0) >= 0) {
|
||||
std::ifstream inFile(filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if (!inFile) {
|
||||
zlog_error(zct, "read channel data error, filename:%s", filename.c_str());
|
||||
jsonVal["success"] = false;
|
||||
jsonVal["message"] = "error";
|
||||
} else {
|
||||
float fTemp = 0;
|
||||
std::vector<float> hanningWave;
|
||||
inFile.read((char *)localtimestamp, sizeof(localtimestamp));
|
||||
while (inFile.read((char *)&fTemp, sizeof(fTemp))) {
|
||||
vecWave.push_back(fTemp);
|
||||
}
|
||||
resolution = 1 / 3.2 ;
|
||||
|
||||
//积分
|
||||
Calculation::Integration(vecWave, IntegrationWave, resolution);
|
||||
Calculation::FFTSpec(IntegrationWave, fftWave);
|
||||
|
||||
sampleRateReference = 1024;
|
||||
}
|
||||
zlog_info(zct,"2---------------------------------------------->vecWave = %zu,fftWave = %zu", vecWave.size(), fftWave.size());
|
||||
|
||||
int flag = param.mPackageFlag;
|
||||
flag = (flag + 1) * sampleRateReference;
|
||||
int number = fftWave.size();
|
||||
zlog_info(zct,"number---------------------------------------------->%d", number);
|
||||
int start = param.mPackageFlag * sampleRateReference;
|
||||
zlog_info(zct,"param.mPackageFlag = %d", param.mPackageFlag);
|
||||
zlog_info(zct,"param.start = %d", start);
|
||||
zlog_info(zct,"param.flag = %d", flag);
|
||||
if (number < sampleRateReference) {
|
||||
flag = number;
|
||||
start = 0;
|
||||
}
|
||||
char buf[32];
|
||||
for (int i = start; i < flag; i++) {
|
||||
if (i == start) {
|
||||
memset(buf, 0, 32);
|
||||
sprintf(buf, "%.6f", fftWave[i]);
|
||||
std::string waveTemp(buf);
|
||||
strWaveData = waveTemp;
|
||||
|
||||
} else {
|
||||
memset(buf, 0, 32);
|
||||
sprintf(buf, "%.6f", fftWave[i]);
|
||||
std::string waveTemp(buf);
|
||||
strWaveData = strWaveData + "," + waveTemp;
|
||||
int flag = param.mPackageFlag;
|
||||
flag = (flag + 1) * 1024;
|
||||
int number = fftWave.size();
|
||||
int start = param.mPackageFlag * 1024;
|
||||
if (number < 1024) {
|
||||
flag = number;
|
||||
start = 0;
|
||||
}
|
||||
}
|
||||
char buf[32];
|
||||
for (int i = start; i < flag; i++) {
|
||||
if (i == start) {
|
||||
memset(buf, 0, 32);
|
||||
sprintf(buf, "%.2f", fftWave[i]);
|
||||
std::string waveTemp(buf);
|
||||
strWaveData = waveTemp;
|
||||
|
||||
int max = number / sampleRateReference;
|
||||
if (max == 0 && number > 0) {
|
||||
max = 1;
|
||||
}
|
||||
} else {
|
||||
memset(buf, 0, 32);
|
||||
sprintf(buf, "%.2f", fftWave[i]);
|
||||
std::string waveTemp(buf);
|
||||
strWaveData = strWaveData + "," + waveTemp;
|
||||
}
|
||||
}
|
||||
|
||||
jsBody["packageMax"] = max;
|
||||
int max = number / 1024;
|
||||
if (max == 0 && number > 0) {
|
||||
max = 1;
|
||||
}
|
||||
jsBody["packageMax"] = max;
|
||||
}
|
||||
} else {
|
||||
jsonVal["success"] = false;
|
||||
jsonVal["message"] = "没有数据文件";
|
||||
}
|
||||
} else {
|
||||
jsonVal["success"] = false;
|
||||
jsonVal["message"] = "没有数据文件";
|
||||
}
|
||||
|
||||
jsBody["channelId"] = param.mChannelId;
|
||||
@ -1201,6 +1258,7 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 ¶m){
|
||||
char count_sql[1024] = {0};
|
||||
int recive_feature = 0, send_feature = 0,resend_feature = 0;
|
||||
int recive_x = 0, recive_y = 0, recive_z = 0,resend_z = 0;
|
||||
float rssi = 0.0;
|
||||
//int send_x = 0, send_y = 0, send_z = 0;
|
||||
for (size_t i = 0; i < nSize; i++)
|
||||
{
|
||||
@ -1291,15 +1349,21 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 ¶m){
|
||||
iTem.append(0);
|
||||
iTem.append(0);
|
||||
iTem.append(0);
|
||||
std::vector<std::string> vRssi;
|
||||
boost::split(vRssi, vetRes[i][2], boost::is_any_of(","), boost::token_compress_on);
|
||||
if (vRssi.size() > 0 ){
|
||||
iTem.append(atof(vRssi[0].c_str())/float(255));
|
||||
iTem.append(atof(vRssi[1].c_str())/float(255));
|
||||
std::vector<std::string> vParamRSSI;
|
||||
boost::split(vParamRSSI, vetRes[i][2], boost::is_any_of(","), boost::token_compress_on);
|
||||
if (vParamRSSI.size() > 1) {
|
||||
iTem.append(atof(vParamRSSI[1].c_str()) / 255.0 );
|
||||
iTem.append(0);
|
||||
rssi = atof(vParamRSSI[1].c_str()) / 255.0 ;
|
||||
} else {
|
||||
iTem.append(atof(vetRes[i][2].c_str()));
|
||||
iTem.append(0);
|
||||
rssi = atof(vetRes[i][2].c_str());
|
||||
}
|
||||
|
||||
iTem.append(resend_feature);
|
||||
iTem.append(resend_z);
|
||||
iTem.append(60); //信号
|
||||
iTem.append(rssi); //信号
|
||||
iTem.append(vetRes[i][3]); //电池
|
||||
sprintf(whereCon,"timeStamp <> '' order by timeStamp desc limit 0,1 ");
|
||||
memset(szTableName,0,sizeof(szTableName));
|
||||
@ -1411,6 +1475,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
||||
}
|
||||
}else if(param.mMode == 1){//启动传感器调试
|
||||
if(param.measurementID.size() > 0){
|
||||
std::vector<uint16_t> short_addr_list;
|
||||
for (size_t i = 0; i < param.measurementID.size(); i++)
|
||||
{
|
||||
char whereCon[512] = {0};
|
||||
@ -1418,29 +1483,21 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
||||
sprintf(whereCon, " MeasurementID = '%s' ", param.measurementID[i].c_str());
|
||||
sprintf(updateSql, " status = '%d' ", 1);// 0 未调试,1 调试中,2 调试完成
|
||||
sqlite_db_ctrl::instance().UpdateTableData("t_debug_info", updateSql, whereCon);
|
||||
//uint16_t short_addr;
|
||||
//char *end_ptr = NULL;
|
||||
//vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " zigbeeShortAddr ", whereCon);
|
||||
//short_addr = strtol(vecResult[0].c_str(), &end_ptr, 16);
|
||||
//scheduler::instance().StartSensorDebug(short_addr);
|
||||
uint16_t short_addr;
|
||||
char *end_ptr = NULL;
|
||||
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " zigbeeShortAddr ", whereCon);
|
||||
short_addr = strtol(vecResult[0].c_str(), &end_ptr, 16);
|
||||
short_addr_list.push_back(short_addr);
|
||||
}
|
||||
scheduler::instance().OpenDebugMode(short_addr_list);
|
||||
}
|
||||
}else if(param.mMode == 2){ // 停止调试
|
||||
if(param.measurementID.size() > 0){
|
||||
for (size_t i = 0; i < param.measurementID.size(); i++)
|
||||
{
|
||||
char whereCon[512] = {0};
|
||||
char updateSql[256] = {0};
|
||||
sprintf(whereCon, " MeasurementID = '%s' ", param.measurementID[i].c_str());
|
||||
sprintf(updateSql, " status = '%d' ", 1);// 0 未调试,1 调试中,2 调试完成
|
||||
sqlite_db_ctrl::instance().UpdateTableData("t_debug_info", updateSql, whereCon);
|
||||
//uint16_t short_addr;
|
||||
//char *end_ptr = NULL;
|
||||
//vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " zigbeeShortAddr ", whereCon);
|
||||
//short_addr = strtol(vecResult[0].c_str(), &end_ptr, 16);
|
||||
//scheduler::instance().StartSensorDebug(short_addr);
|
||||
}
|
||||
}
|
||||
char whereCon[512] = {0};
|
||||
char updateSql[256] = {0};
|
||||
sprintf(whereCon, " status = '1' ");
|
||||
sprintf(updateSql, " status = '%d' ", 0);// 0 未调试,1 调试中,2 调试完成
|
||||
sqlite_db_ctrl::instance().UpdateTableData("t_debug_info", updateSql, whereCon);
|
||||
scheduler::instance().CloseDebugMode();
|
||||
}
|
||||
return show_value_.write(jsonVal);
|
||||
}
|
||||
|
||||
@ -174,13 +174,21 @@ std::string LocalServer::HandleCgi_cmd(std::string &pData) {
|
||||
} break;
|
||||
case kWebDeleteTransducerInfo: {
|
||||
std::vector<Param_27> param;
|
||||
for (size_t i = 0; i < recvBody.size(); i++) {
|
||||
Param_27 p;
|
||||
p.mDataNodeNo = recvBody[i]["dataNodeNo"].asString();
|
||||
p.mShortAddr = recvBody[i]["shortAddr"].asString();
|
||||
p.mMeasurementID = recvBody[i]["MeasurementID"].asString();
|
||||
p.mType = recvBody[i]["type"].asString();
|
||||
param.push_back(p);
|
||||
std::string type = recvBody["type"].asString();
|
||||
Json::Value recvBodyTemp;
|
||||
Json::Value recvDataNodeNo = recvBody["dataNodeNo"];
|
||||
if (recvDataNodeNo.size() > 0)
|
||||
{
|
||||
for (size_t i = 0; i < recvDataNodeNo.size(); i++) {
|
||||
Param_27 param_27;
|
||||
Json::Value node = recvDataNodeNo[i];
|
||||
param_27.mDataNodeNo = node[0u].asString();
|
||||
param_27.mMeasurementID = node[1u].asString();
|
||||
param_27.mShortAddr = node[2u].asString();
|
||||
param_27.mType = type;
|
||||
|
||||
param.push_back(param_27);
|
||||
}
|
||||
}
|
||||
JsonData jd;
|
||||
std::string data = jd.JsonCmd_Cgi_27(param);
|
||||
@ -630,14 +638,13 @@ std::string LocalServer::HandleCgi_cmd(std::string &pData) {
|
||||
{
|
||||
for (size_t i = 0; i < recvDataNodeNo.size(); i++) {
|
||||
Param_69_info vecParam;
|
||||
for (size_t j = 0; j < recvDataNodeNo[i].size(); j++)
|
||||
{
|
||||
vecParam.measurementID = recvDataNodeNo[i][j].asString();
|
||||
vecParam.status = recvDataNodeNo[i][j].asInt();
|
||||
vecParam.trigerType = recvDataNodeNo[i][j].asInt();
|
||||
vecParam.statisticType = recvDataNodeNo[i][j].asInt();
|
||||
vecParam.threshold = recvDataNodeNo[i][j].asDouble();
|
||||
}
|
||||
Json::Value node = recvDataNodeNo[i];
|
||||
vecParam.measurementID = node[0u].asString();
|
||||
vecParam.status = node[1u].asInt();
|
||||
vecParam.trigerType = node[2u].asInt();
|
||||
vecParam.statisticType = node[3u].asInt();
|
||||
vecParam.threshold = node[4u].asDouble();
|
||||
|
||||
param.vecParam69.push_back(vecParam);
|
||||
}
|
||||
}
|
||||
|
||||
@ -733,6 +733,7 @@ init_config:
|
||||
return;
|
||||
}
|
||||
}
|
||||
zlog_warn(zbt,"init end ");
|
||||
}
|
||||
|
||||
int SensorScheduler::WaveError(uint16_t short_addr, bool z) {
|
||||
@ -1256,11 +1257,12 @@ void SensorScheduler::UseDefaultConfig() {
|
||||
int max_sensor_num = 32;
|
||||
int wave_resend_num = 3;
|
||||
|
||||
// int eigen_value_send_interval = 120;
|
||||
// int wave_form_send_interval = 240;
|
||||
// int eigen_value_send_interval = 300;
|
||||
// int wave_form_send_interval = 1200;
|
||||
// int eigen_value_send_duration = 2; // 固定的
|
||||
// int wave_form_send_duration = 60; // 固定的
|
||||
// int max_sensor_num = 4;
|
||||
// int wave_resend_num = 3;
|
||||
std::string error_msg;
|
||||
Config(eigen_value_send_interval,
|
||||
wave_form_send_interval,
|
||||
|
||||
@ -47,8 +47,7 @@ int Uart::UartRecv(int fd, char srcshow, char *buffer) {
|
||||
ret = read_data(fd, buff, BUF_LENGTH, 10);
|
||||
if (ret <= 0) {
|
||||
timeoutflag++;
|
||||
if (timeoutflag > 200) {
|
||||
DealReviveDuration(wave_shortAddr);
|
||||
if (timeoutflag > 150) {
|
||||
zlog_warn(zct, "===============0x9999 timeout= %d offSize = %d===============shortAddr = %02x%02x", timeoutflag, offSize,UINT16_HIGH(wave_shortAddr),UINT16_LOW(wave_shortAddr));
|
||||
// zlog_warn(zct, "0x9999 timeout %d===============Size = %d", timeoutflag, offSize);
|
||||
// printf("=============offSize = %d\n",offSize);
|
||||
@ -381,7 +380,7 @@ int Uart::DealAskTask(uint16_t ushortAdd){
|
||||
bool z = false;
|
||||
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration,z, next_task_id);
|
||||
current_z = z;
|
||||
zlog_info(zct, "taskID = %d next_duration = %d next_task_id = %d", taskID, next_duration, next_task_id);
|
||||
zlog_info(zct, "taskID = %d next_duration = %d next_task_id = %d,current_z = %d", taskID, next_duration, next_task_id,current_z);
|
||||
if (taskID == kScheduleConfigSensor)
|
||||
{
|
||||
scheduleTask.cmd = CONFIG;
|
||||
@ -454,7 +453,7 @@ int Uart::DealReviveDuration(uint16_t ushortAdd){
|
||||
int next_taskID = 0;
|
||||
bool z = false;
|
||||
uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd,z,next_taskID);
|
||||
zlog_info(zct, "next_duration = %d next_taskID = %d", next_duration,next_taskID);
|
||||
zlog_info(zct, "next_duration = %d next_taskID = %d,z = %d", next_duration,next_taskID,z);
|
||||
scheduleTask.cmd = REVIVE_DURATION;
|
||||
scheduleTask.shortAddr = ushortAdd;
|
||||
scheduleTask.duration = next_duration;
|
||||
@ -517,7 +516,13 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
std::string productNo = res[17];
|
||||
compressWaveChannel tempchannel;
|
||||
if ((compareVersions(softVersion, "2.6") == -1 && productNo == "02") || productNo == "01"){ // DN101所有版本和DN102 2.6以前版本
|
||||
WaveResp(ushortAdd);
|
||||
ScheduleStatus schedule_status = scheduler::instance().GetScheduleStatus();
|
||||
if(schedule_status == kScheduleStatusDebug || schedule_status == kScheduleStatusUpgrade){
|
||||
zlog_warn(zct, "ScheduleStatus not meet condition ,shortAddr = %s,schedule_status = %d",shortAdd,schedule_status);
|
||||
scheduler::instance().WaveSuccess(ushortAdd,true);
|
||||
return 1;
|
||||
}
|
||||
WaveResp(ushortAdd);// 响应超时和传感器配值的重试次数有关,重试10次是1s
|
||||
tempchannel.compressChannelX = pData[7];
|
||||
tempchannel.compressChannelY = pData[8];
|
||||
tempchannel.compressChannelZ = pData[9];
|
||||
@ -527,12 +532,18 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
tempchannel.CountZ = BUILD_UINT32(pData[21], pData[20],pData[19],pData[18]);
|
||||
sprintf(sensor_rssi, "%02d", pData[22] & 0xFF);
|
||||
}else{
|
||||
int ret = WaveSendCondition(shortAdd);
|
||||
int ret = 0;//= WaveSendCondition(shortAdd);
|
||||
if(ret == 1){
|
||||
zlog_warn(zct, "WaveSendCondition not meet condition ,shortAddr = %s",shortAdd);
|
||||
scheduler::instance().WaveSuccess(ushortAdd,true);
|
||||
return 1;
|
||||
}else{
|
||||
ScheduleStatus schedule_status = scheduler::instance().GetScheduleStatus();
|
||||
if(schedule_status == kScheduleStatusUpgrade){
|
||||
zlog_warn(zct, "ScheduleStatus not meet condition ,shortAddr = %s,schedule_status = %d",shortAdd,schedule_status);
|
||||
scheduler::instance().WaveSuccess(ushortAdd,true);
|
||||
return 1;
|
||||
}
|
||||
WaveResp(ushortAdd);
|
||||
}
|
||||
sprintf(sensor_rssi, "%02d", pData[7] & 0xFF);
|
||||
@ -581,7 +592,7 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, 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_warn(zct, "count X = %d,Y = %d,Z = %d,vol X = %d,vol Y = %d,vol Z = %d short_add = %s", tempchannel.CountX, tempchannel.CountY, tempchannel.CountZ,tempchannel.CountVolX,tempchannel.CountVolY,tempchannel.CountVolZ,strShortAddr.c_str());
|
||||
zlog_info(zct, "compress X = %d,Y = %d,Z = %d ", tempchannel.compressChannelX, tempchannel.compressChannelY, tempchannel.compressChannelZ);
|
||||
zlog_info(zct, "compress vol X = %d,vol Y = %d,vol Z = %d ", tempchannel.compressChannelVolX, tempchannel.compressChannelVolY, tempchannel.compressChannelVolZ);
|
||||
zlog_info(zct, "samplerate X = %d,Y = %d,Z = %d ", tempchannel.samplerateX, tempchannel.samplerateY, tempchannel.samplerateZ);
|
||||
@ -691,16 +702,18 @@ int Uart::DealAskTaskOld(uint16_t ushortAdd){
|
||||
ScheduleTask scheduleTask;
|
||||
bool z = false;
|
||||
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration,z, next_task_id);
|
||||
zlog_info(zct, "DealAskTaskOld taskID = %d next_duration = %d next_task_id = %d", taskID, next_duration, next_task_id);
|
||||
if(next_task_id == kScheduleUpgrade){
|
||||
scheduleTask.cmd = REVIVE_DURATION;
|
||||
scheduleTask.shortAddr = ushortAdd;
|
||||
scheduleTask.duration = next_duration;
|
||||
scheduleTask.next_taskID = UPGRADE;
|
||||
TaskResp(scheduleTask);
|
||||
zlog_warn(zct, "DealAskTaskOld taskID = %d next_duration = %d next_task_id = %d", taskID, next_duration, next_task_id);
|
||||
//if(next_task_id == kScheduleUpgrade)
|
||||
{
|
||||
// scheduleTask.cmd = REVIVE_DURATION;
|
||||
// scheduleTask.shortAddr = ushortAdd;
|
||||
// scheduleTask.duration = next_duration;
|
||||
// scheduleTask.next_taskID = UPGRADE;
|
||||
// TaskResp(scheduleTask);
|
||||
UpdateWirelessNode(ushortAdd);
|
||||
}
|
||||
if (taskID == kScheduleUpgrade){
|
||||
UpdateWirelessNode(ushortAdd);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ enum InteractiveCommand {
|
||||
CONFIG_INF2 = 10, // 配置 只从无线网关发出 测点名称,测点编号
|
||||
DEVICE_INF2 = 11, // 测点名称,测点编号
|
||||
UPGRADE = 12, // 升级, 升级给这条信息
|
||||
SIGNAL_STRENGTH = 13, // 信号强度 --不再使用
|
||||
SIGNAL_STRENGTH = 13, // 信号强度 --不再使用(2026-02-12)
|
||||
DEVICE_EXCEPTION = 14, // 异常: 外设
|
||||
WAVE_COMPRESS = 15, // 波形数据压缩
|
||||
UPGRADE_FIRMWARE = 16, //固件升级内容
|
||||
|
||||
@ -991,13 +991,13 @@ std::vector<float> Uart::DealData(int iChannel, float coe, unsigned int sampleRa
|
||||
break;
|
||||
}
|
||||
}else if( version == 0){
|
||||
if (vecData.size() == 8192 && iChannel == WAVE_X) { //过滤数据包结尾空数据
|
||||
if (vecData.size() == 13108 && iChannel == WAVE_X) { //过滤数据包结尾空数据
|
||||
break;
|
||||
}
|
||||
if (vecData.size() == 8192 && iChannel == WAVE_Y) { //过滤数据包结尾空数据
|
||||
if (vecData.size() == 13108 && iChannel == WAVE_Y) { //过滤数据包结尾空数据
|
||||
break;
|
||||
}
|
||||
if (vecData.size() == 24000 && iChannel == WAVE_Z) { //过滤数据包结尾空数据
|
||||
if (vecData.size() == 30720 && iChannel == WAVE_Z) { //过滤数据包结尾空数据
|
||||
break;
|
||||
}
|
||||
if (vecData.size() == 13108 && iChannel == WAVE_LF_X) { //过滤数据包结尾空数据
|
||||
@ -1077,6 +1077,21 @@ void Uart::DealWave() {
|
||||
coe = Calcoe(n, WAVE_X, strProduct, range);
|
||||
|
||||
vecDataX = DealData(WAVE_X, coe, sampleRate, accSampleTimeXY, strProduct,version);
|
||||
if(vecDataX.size() > 0 && g_mapCompress[strShortAddr].CountX > 0){
|
||||
scheduler::instance().WaveSuccess(wave_shortAddr,false);
|
||||
zlog_info(zct, "WaveSuccess shortAddr = %02x%02x,channel = %d", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,WAVE_X);
|
||||
}else{
|
||||
int iRet = scheduler::instance().WaveError(wave_shortAddr,false);
|
||||
if (iRet != 0) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
char updateSql[1024] = { 0 };
|
||||
sprintf(updateSql, "resend = '%d'", iRet);
|
||||
sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
}
|
||||
}
|
||||
zlog_info(zct,"DealReviveDuration start shortAddr = %02x%02x,channel = %d", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,WAVE_X);
|
||||
DealReviveDuration(wave_shortAddr);
|
||||
WriteDatFile(sampleRate, strMeasurementID, WAVE_X, vecDataX,strProduct,accSampleTimeXY,version);
|
||||
m_waveCountX = 0;
|
||||
g_VecWaveDataX.clear();
|
||||
@ -1096,6 +1111,20 @@ void Uart::DealWave() {
|
||||
zlog_info(zct, "m_waveCountZ = %d,VecWaveDataZ = %zu", m_waveCountZ, VecWaveDataZ.size());
|
||||
coe = Calcoe(n, WAVE_Z, strProduct, range);
|
||||
vecDataZ = DealData(WAVE_Z, coe, sampleRate, accSampleTimeZ, strProduct,version);
|
||||
if(vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0){
|
||||
scheduler::instance().WaveSuccess(wave_shortAddr,true);
|
||||
}else{
|
||||
int iRet = scheduler::instance().WaveError(wave_shortAddr,true);
|
||||
if (iRet != 0) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
char updateSql[1024] = { 0 };
|
||||
sprintf(updateSql, "resend = '%d'", iRet);
|
||||
sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
}
|
||||
}
|
||||
zlog_info(zct,"DealReviveDuration start shortAddr = %02x%02x,channel = %d", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,WAVE_X);
|
||||
DealReviveDuration(wave_shortAddr);
|
||||
WriteDatFile(sampleRate, strMeasurementID, WAVE_Z, vecDataZ,strProduct,accSampleTimeZ,version);
|
||||
m_waveCountZ = 0;
|
||||
g_VecWaveDataZ.clear();
|
||||
@ -1148,63 +1177,63 @@ void Uart::DealWave() {
|
||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||
}
|
||||
zlog_warn(zct,"waveCountX = %zu, waveCountY = %zu, waveCountZ = %zu", vecDataX.size() , vecDataY.size(), vecDataZ.size());
|
||||
zlog_warn(zct,"CountX = %d, CountY = %d, CountZ = %d", g_mapCompress[strShortAddr].CountX , g_mapCompress[strShortAddr].CountY, g_mapCompress[strShortAddr].CountZ);
|
||||
if ((vecDataX.size() <= 0 && g_mapCompress[strShortAddr].CountX > 0) ||
|
||||
(vecDataY.size() <= 0 && g_mapCompress[strShortAddr].CountY > 0) ||
|
||||
(vecDataZ.size() <= 0 && g_mapCompress[strShortAddr].CountZ > 0))
|
||||
{
|
||||
int iRet = -1;
|
||||
if (vecDataZ.size() <= 0 && g_mapCompress[strShortAddr].CountZ > 0)
|
||||
{
|
||||
iRet = scheduler::instance().WaveError(wave_shortAddr,true);
|
||||
}else{
|
||||
iRet = scheduler::instance().WaveError(wave_shortAddr,false);
|
||||
}
|
||||
if (iRet != 0) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
char updateSql[1024] = { 0 };
|
||||
sprintf(updateSql, "resend = '%d'", iRet);
|
||||
sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
}
|
||||
}else if ((vecDataX.size() > 0 && g_mapCompress[strShortAddr].CountX > 0) ||
|
||||
(vecDataY.size() > 0 && g_mapCompress[strShortAddr].CountY > 0) ||
|
||||
(vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0))
|
||||
{
|
||||
if(vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0){
|
||||
scheduler::instance().WaveSuccess(wave_shortAddr,true);
|
||||
}else{
|
||||
scheduler::instance().WaveSuccess(wave_shortAddr,false);
|
||||
}
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
char updateSql[1024] = { 0 };
|
||||
sprintf(updateSql, "resend = '%d'", 1);
|
||||
sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
zlog_warn(zct,"CountX = %d, CountY = %d, CountZ = %d,strShortAddr = %s", g_mapCompress[strShortAddr].CountX , g_mapCompress[strShortAddr].CountY, g_mapCompress[strShortAddr].CountZ,strShortAddr.c_str());
|
||||
// if ((vecDataX.size() <= 0 && g_mapCompress[strShortAddr].CountX > 0) ||
|
||||
// (vecDataY.size() <= 0 && g_mapCompress[strShortAddr].CountY > 0) ||
|
||||
// (vecDataZ.size() <= 0 && g_mapCompress[strShortAddr].CountZ > 0))
|
||||
// {
|
||||
// int iRet = -1;
|
||||
// if (vecDataZ.size() <= 0 && g_mapCompress[strShortAddr].CountZ > 0)
|
||||
// {
|
||||
// iRet = scheduler::instance().WaveError(wave_shortAddr,true);
|
||||
// }else{
|
||||
// iRet = scheduler::instance().WaveError(wave_shortAddr,false);
|
||||
// }
|
||||
// if (iRet != 0) {
|
||||
// memset(whereCon, 0x00, sizeof(whereCon));
|
||||
// char updateSql[1024] = { 0 };
|
||||
// sprintf(updateSql, "resend = '%d'", iRet);
|
||||
// sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
// sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
// }
|
||||
// }else if ((vecDataX.size() > 0 && g_mapCompress[strShortAddr].CountX > 0) ||
|
||||
// (vecDataY.size() > 0 && g_mapCompress[strShortAddr].CountY > 0) ||
|
||||
// (vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0))
|
||||
// {
|
||||
// if(vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0){
|
||||
// scheduler::instance().WaveSuccess(wave_shortAddr,true);
|
||||
// }else{
|
||||
// scheduler::instance().WaveSuccess(wave_shortAddr,false);
|
||||
// }
|
||||
// memset(whereCon, 0x00, sizeof(whereCon));
|
||||
// char updateSql[1024] = { 0 };
|
||||
// sprintf(updateSql, "resend = '%d'", 1);
|
||||
// sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
// sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
|
||||
}
|
||||
if (g_mapCompress[strShortAddr].CountX <= 0 && g_mapCompress[strShortAddr].CountY <= 0 && !current_z)
|
||||
{
|
||||
int iRet = scheduler::instance().WaveError(wave_shortAddr,false);
|
||||
if (iRet != 0) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
char updateSql[1024] = { 0 };
|
||||
sprintf(updateSql, "resend = '%d'", iRet);
|
||||
sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
}
|
||||
}
|
||||
if (current_z && g_mapCompress[strShortAddr].CountZ <= 0)
|
||||
{
|
||||
int iRet = scheduler::instance().WaveError(wave_shortAddr,true);
|
||||
if (iRet != 0) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
char updateSql[1024] = { 0 };
|
||||
sprintf(updateSql, "resend = '%d'", iRet);
|
||||
sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
}
|
||||
}
|
||||
// }
|
||||
// if (g_mapCompress[strShortAddr].CountX <= 0 && g_mapCompress[strShortAddr].CountY <= 0 && !current_z)
|
||||
// {
|
||||
// int iRet = scheduler::instance().WaveError(wave_shortAddr,false);
|
||||
// if (iRet != 0) {
|
||||
// memset(whereCon, 0x00, sizeof(whereCon));
|
||||
// char updateSql[1024] = { 0 };
|
||||
// sprintf(updateSql, "resend = '%d'", iRet);
|
||||
// sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
// sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
// }
|
||||
// }
|
||||
// if (current_z && g_mapCompress[strShortAddr].CountZ <= 0)
|
||||
// {
|
||||
// int iRet = scheduler::instance().WaveError(wave_shortAddr,true);
|
||||
// if (iRet != 0) {
|
||||
// memset(whereCon, 0x00, sizeof(whereCon));
|
||||
// char updateSql[1024] = { 0 };
|
||||
// sprintf(updateSql, "resend = '%d'", iRet);
|
||||
// sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,(char*)timestamp_last.c_str());
|
||||
// sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
|
||||
// }
|
||||
// }
|
||||
|
||||
g_mapCompress[strShortAddr].CountX = 0;
|
||||
g_mapCompress[strShortAddr].CountY = 0;
|
||||
@ -1225,7 +1254,10 @@ void Uart::DealWave() {
|
||||
std::vector<float>().swap(vecDataVolY);
|
||||
std::vector<float>().swap(vecDataVolZ);
|
||||
wave_trans_ = false;
|
||||
zlog_warn(zct,"DealWave end, wave_shortAddr = %02x%02x", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF);
|
||||
//DealReviveDuration(wave_shortAddr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float Uart::Calcoe(int ran, int iChannel, std::string &product, int range) {
|
||||
|
||||
@ -66,6 +66,9 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
||||
memset(wherecon,0,sizeof(wherecon));
|
||||
sprintf(wherecon," zigbeeShortAddr = '%02x%02x' ",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " hardVersion,softVersion,ProductNo,upgradeStatus ", wherecon);
|
||||
if(vecResult.size() < 1){
|
||||
return ;
|
||||
}
|
||||
if (vecResult[3] == "2"){
|
||||
zlog_warn(zbt, "UpdateWirelessNode already ,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user