Compare commits

...

3 Commits

6 changed files with 39 additions and 16 deletions

View File

@ -333,9 +333,9 @@ std::string JsonData::JsonCmd_Cgi_10(Param_10 &param) {
memset(whereCon, 0x00, sizeof(whereCon)); memset(whereCon, 0x00, sizeof(whereCon));
if (param.timeEnd == "") { if (param.timeEnd == "") {
sprintf(whereCon, "channelID like '%%%s%%' and %s <> '' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.strStatic.c_str(), 550, packgeNum); sprintf(whereCon, "channelID like '%%%s%%' and %s <> '' and nodeResend = 0 order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.strStatic.c_str(), 550, packgeNum);
} else { } else {
sprintf(whereCon, "channelID like '%%%s%%' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.strStatic.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum); sprintf(whereCon, "channelID like '%%%s%%' and %s <> '' and nodeResend = 0 and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.strStatic.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
} }
array_t vecRes; array_t vecRes;

View File

@ -497,7 +497,8 @@ int SensorScheduler::GetNextDuration(uint16_t short_addr, bool &z, int &next_tas
duration = 120; duration = 120;
return duration; return duration;
} }
zlog_debug(zbt, "[Nxt] [%d:%x] next duration is %d", id, short_addr, duration); zlog_debug(zbt, "[Nxt] [%d:%x] next duration is %d,next_task_id = %d,z = %d,ScheduleStatus = %d", id, short_addr, duration,next_task_id,z,GetScheduleStatus());
return duration; return duration;
} }

View File

@ -85,7 +85,6 @@ void CheckThread() {
gpio_set(GlobalConfig::GPIO_G.commPower,1); gpio_set(GlobalConfig::GPIO_G.commPower,1);
zlog_warn(zct,"commPower End\n"); zlog_warn(zct,"commPower End\n");
sleep(2); sleep(2);
char localtimestamp[32] = { 0 };
GetTimeNet(localtimestamp, 1); GetTimeNet(localtimestamp, 1);
memset(insertSql,0,sizeof(insertSql)); memset(insertSql,0,sizeof(insertSql));
sprintf(insertSql, " '2','4G module reset','%s'",localtimestamp); sprintf(insertSql, " '2','4G module reset','%s'",localtimestamp);
@ -104,7 +103,6 @@ void CheckThread() {
sleep(2); sleep(2);
gpio_set(GlobalConfig::GPIO_G.commPower, 1); gpio_set(GlobalConfig::GPIO_G.commPower, 1);
zlog_warn(zct, "commPower End"); zlog_warn(zct, "commPower End");
char localtimestamp[32] = { 0 };
GetTimeNet(localtimestamp, 1); GetTimeNet(localtimestamp, 1);
memset(insertSql,0,sizeof(insertSql)); memset(insertSql,0,sizeof(insertSql));
sprintf(insertSql, " '2','5G module reset','%s'",localtimestamp); sprintf(insertSql, " '2','5G module reset','%s'",localtimestamp);
@ -129,7 +127,6 @@ void CheckThread() {
gpio_set(GlobalConfig::GPIO_G.wifiReset, 1); gpio_set(GlobalConfig::GPIO_G.wifiReset, 1);
sleep(5); sleep(5);
gpio_set(GlobalConfig::GPIO_G.wifiReset, 0); gpio_set(GlobalConfig::GPIO_G.wifiReset, 0);
char localtimestamp[32] = { 0 };
GetTimeNet(localtimestamp, 1); GetTimeNet(localtimestamp, 1);
memset(insertSql,0,sizeof(insertSql)); memset(insertSql,0,sizeof(insertSql));
sprintf(insertSql, " '2','WiFi module reset','%s'",localtimestamp); sprintf(insertSql, " '2','WiFi module reset','%s'",localtimestamp);

View File

@ -379,7 +379,6 @@ int Uart::DealAskTask(uint16_t ushortAdd){
ScheduleTask scheduleTask; ScheduleTask scheduleTask;
bool z = false; bool z = false;
//taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration,z, next_task_id); //taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration,z, next_task_id);
current_z = z;
if (scheduler::instance().StartSchedule(ushortAdd,next_duration_,z, next_task_id) == kScheduleConfigSensor) if (scheduler::instance().StartSchedule(ushortAdd,next_duration_,z, next_task_id) == kScheduleConfigSensor)
{ {
scheduleTask.cmd = CONFIG; scheduleTask.cmd = CONFIG;
@ -391,13 +390,14 @@ int Uart::DealAskTask(uint16_t ushortAdd){
UpdateConfig(ushortAdd); UpdateConfig(ushortAdd);
} }
uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd,z,next_task_id); uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd,z,next_task_id);
current_z = z;
zlog_info(zct, "taskID = %d next_duration = %d next_task_id = %d,current_z = %d", taskID, next_duration, next_task_id,current_z); zlog_info(zct, "taskID = %d next_duration = %d next_task_id = %d,current_z = %d", taskID, next_duration, next_task_id,current_z);
if(next_task_id == kScheduleWaveForm){ if(next_task_id == kScheduleWaveForm){
scheduleTask.cmd = REVIVE_DURATION; scheduleTask.cmd = REVIVE_DURATION;
scheduleTask.shortAddr = ushortAdd; scheduleTask.shortAddr = ushortAdd;
scheduleTask.duration = next_duration; scheduleTask.duration = next_duration;
scheduleTask.z = z; scheduleTask.z = current_z;
scheduleTask.next_taskID = WAVE_CMD; scheduleTask.next_taskID = WAVE_CMD;
TaskResp(scheduleTask); TaskResp(scheduleTask);
}else if (next_task_id == kScheduleEigenValue) { }else if (next_task_id == kScheduleEigenValue) {
@ -459,6 +459,7 @@ int Uart::DealReviveDuration(uint16_t ushortAdd){
scheduleTask.cmd = REVIVE_DURATION; scheduleTask.cmd = REVIVE_DURATION;
scheduleTask.shortAddr = ushortAdd; scheduleTask.shortAddr = ushortAdd;
scheduleTask.duration = next_duration; scheduleTask.duration = next_duration;
scheduleTask.z = z;
scheduleTask.next_taskID = next_taskID & 0xFF; scheduleTask.next_taskID = next_taskID & 0xFF;
TaskResp(scheduleTask); TaskResp(scheduleTask);
return 0; return 0;
@ -476,6 +477,11 @@ int Uart::DealConfig(uint16_t ushortAdd){
} }
// 判断综合信号强度,低电量,停机状态,任一条件满足都不调度波形 // 判断综合信号强度,低电量,停机状态,任一条件满足都不调度波形
int Uart::WaveSendCondition(char* shortAddr){ int Uart::WaveSendCondition(char* shortAddr){
if (schedule_status == kScheduleStatusDebug)
{
return 0;
}
int lowSignal = -1, signalThreshold = -1, lowBatteryLevel = -1, batteryLevelThreshold = -1; int lowSignal = -1, signalThreshold = -1, lowBatteryLevel = -1, batteryLevelThreshold = -1;
char whereCon[100] = {0}; char whereCon[100] = {0};
std::string effect = "",rssi = "",batteryPower = ""; std::string effect = "",rssi = "",batteryPower = "";
@ -517,8 +523,8 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
std::string softVersion = res[9]; std::string softVersion = res[9];
std::string productNo = res[17]; std::string productNo = res[17];
compressWaveChannel tempchannel; compressWaveChannel tempchannel;
if ((compareVersions(softVersion, "2.6") == -1 && productNo == "02") || productNo == "01"){ // DN101所有版本和DN102 2.6以前版本
schedule_status = scheduler::instance().GetScheduleStatus(); schedule_status = scheduler::instance().GetScheduleStatus();
if ((compareVersions(softVersion, "2.6") == -1 && productNo == "02") || productNo == "01"){ // DN101所有版本和DN102 2.6以前版本
if(schedule_status == kScheduleStatusDebug || schedule_status == kScheduleStatusUpgrade){ if(schedule_status == kScheduleStatusDebug || schedule_status == kScheduleStatusUpgrade){
zlog_warn(zct, "ScheduleStatus not meet condition ,shortAddr = %s,schedule_status = %d",shortAdd,schedule_status); zlog_warn(zct, "ScheduleStatus not meet condition ,shortAddr = %s,schedule_status = %d",shortAdd,schedule_status);
scheduler::instance().WaveSuccess(ushortAdd,true); scheduler::instance().WaveSuccess(ushortAdd,true);
@ -541,7 +547,6 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
scheduler::instance().WaveSuccess(ushortAdd,true); scheduler::instance().WaveSuccess(ushortAdd,true);
return 1; return 1;
}else{ }else{
schedule_status = scheduler::instance().GetScheduleStatus();
if(schedule_status == kScheduleStatusUpgrade){ if(schedule_status == kScheduleStatusUpgrade){
zlog_warn(zct, "ScheduleStatus not meet condition ,shortAddr = %s,schedule_status = %d",shortAdd,schedule_status); zlog_warn(zct, "ScheduleStatus not meet condition ,shortAddr = %s,schedule_status = %d",shortAdd,schedule_status);
scheduler::instance().WaveSuccess(ushortAdd,true); scheduler::instance().WaveSuccess(ushortAdd,true);
@ -1132,12 +1137,12 @@ void Uart::DealDataNodeInfo(const char *pData) {
StaticTime = '%d',WaveTime = '%d',BateryV = '%d',ProductNo = '%s',configFlag = '%d',startBrands = '%s',\ StaticTime = '%d',WaveTime = '%d',BateryV = '%d',ProductNo = '%s',configFlag = '%d',startBrands = '%s',\
stopBrands = '%s',featureInterVal = '%u',waveInterVal = '%d',samplingRate = '%d',scope = '%s',range = '%d',envelopeBandPass = '%s',faultFrequency = '%s',\ stopBrands = '%s',featureInterVal = '%u',waveInterVal = '%d',samplingRate = '%d',scope = '%s',range = '%d',envelopeBandPass = '%s',faultFrequency = '%s',\
zigbeePanId = '%s',zigbeeChannel = '%d',zigbeeShortAddr = '%s',zigbeeLongAddr = '%s',zigbeeDesAddr = '%s',\ zigbeePanId = '%s',zigbeeChannel = '%d',zigbeeShortAddr = '%s',zigbeeLongAddr = '%s',zigbeeDesAddr = '%s',\
ZigbeePower = '%d',ZigbeeRetry = '%d',ZigbeeRetryGap = '%d',ACCSampleTime = '%d',status = '%s',timeStamp = '%s',viff = '%d',RSSI = '0,%d',UpdateFlag = 1", ZigbeePower = '%d',ZigbeeRetry = '%d',ZigbeeRetryGap = '%d',ACCSampleTime = '%d',status = '%s',timeStamp = '%s',viff = '%d',RSSI = '1',UpdateFlag = 1",
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.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, dataNodeInfo.StaticTime, dataNodeInfo.WaveTime, dataNodeInfo.BateryV, dataNodeInfo.ProductNo.c_str(), dataNodeInfo.ConfigFlag, dataNodeInfo.StartBrands.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.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.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); dataNodeInfo.ConfigDate.c_str(), dataNodeInfo.VIntegralFilterFrequency);
sprintf(whereCon, "dataNodeNo = '%s'", dataNodeInfo.ZigbeeLongAddr.c_str()); sprintf(whereCon, "dataNodeNo = '%s'", dataNodeInfo.ZigbeeLongAddr.c_str());
res = sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); res = sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
if(res !=0 ){ if(res !=0 ){
@ -1150,7 +1155,7 @@ void Uart::DealDataNodeInfo(const char *pData) {
'%d','%d','%d','%s','%d','%s',\ '%d','%d','%d','%s','%d','%s',\
'%s','%u','%d','%d','%s','%d', '%s', '%s',\ '%s','%u','%d','%d','%s','%d', '%s', '%s',\
'%s','%d','%s','%s','%s',\ '%s','%d','%s','%s','%s',\
'%d','%d','%d','%d','%s','%s', '%d', '0,%d','1','0,0','','','',0", '%d','%d','%d','%d','%s','%s', '%d', '0,%d','1','1','','','',0",
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.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, dataNodeInfo.StaticTime, dataNodeInfo.WaveTime, dataNodeInfo.BateryV, dataNodeInfo.ProductNo.c_str(), dataNodeInfo.ConfigFlag, 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.StartBrands.c_str(), dataNodeInfo.StopBrands.c_str(), dataNodeInfo.FeatureInterVal, dataNodeInfo.WaveInterVal, dataNodeInfo.SamplingRate, "", dataNodeInfo.Range, dataNodeInfo.EnvelopeBandPass.c_str(), dataNodeInfo.FaultFrequency.c_str(),

View File

@ -68,7 +68,7 @@ void Uart::RecordBattery(std::string &strLongAddr, DataRecvStatic &dataStatic, s
if (dataStatic.nodeSendTime > 0){ if (dataStatic.nodeSendTime > 0){
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) * (standardRate / actualRate);
if (comprehensiveRSSI > 1.0f) { if (comprehensiveRSSI > 1.0f) {
comprehensiveRSSI = 1.0f; //综合信号强度最大为1 comprehensiveRSSI = 1.0f; //综合信号强度最大为1
} }
@ -124,6 +124,12 @@ void Uart::DealTriger(uint16_t ushortAdd,std::string & measurementID){
scheduler::instance().TriggerWave(ushortAdd, 1, 0); scheduler::instance().TriggerWave(ushortAdd, 1, 0);
} }
} }
if (vecTrigger[4] == "0")
{
memset(whereCon, 0x00, sizeof(whereCon));
sprintf(whereCon,"MeasurementID = '%s'",measurementID.c_str());
sqlite_db_ctrl::instance().UpdateTableData(" t_wave_triger_info ", " status = '0' ", whereCon);
}
} }
}else if (vecTrigger[3] == "1"){// 速度有效值 }else if (vecTrigger[3] == "1"){// 速度有效值
array_t arrValue = sqlite_db_ctrl::instance().GetDataMultiLine(tablename, " channelID,integratRMS ", whereCon); array_t arrValue = sqlite_db_ctrl::instance().GetDataMultiLine(tablename, " channelID,integratRMS ", whereCon);
@ -140,6 +146,12 @@ void Uart::DealTriger(uint16_t ushortAdd,std::string & measurementID){
scheduler::instance().TriggerWave(ushortAdd, 1, 0); scheduler::instance().TriggerWave(ushortAdd, 1, 0);
} }
} }
if (vecTrigger[4] == "0")
{
memset(whereCon, 0x00, sizeof(whereCon));
sprintf(whereCon,"MeasurementID = '%s'",measurementID.c_str());
sqlite_db_ctrl::instance().UpdateTableData(" t_wave_triger_info ", " status = '0' ", whereCon);
}
} }
} }
} }
@ -1393,10 +1405,18 @@ void Uart::WriteDatFile(int sampleRate, std::string &strMeasurementID, int iChan
outputData.push_back(outputData2[i]); outputData.push_back(outputData2[i]);
} }
}else if(std::fabs(ACCSampleTime - 1.28) < epsilon){ }else if(std::fabs(ACCSampleTime - 1.28) < epsilon){
outSize = 32768;
sampleRate = 25600;
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 ,ACCSampleTime %f", outputData.size(),ACCSampleTime);
}else if(std::fabs(ACCSampleTime - 3.2) < epsilon){ }else if(std::fabs(ACCSampleTime - 3.2) < epsilon){
outSize = 8192; outSize = 8192;
sampleRate = 2560;
outputData = Calculation::fftInterpolate(vecData, outSize);
zlog_info(zct, " outputData_size %zu ,ACCSampleTime %f", outputData.size(),ACCSampleTime);
}else if(std::fabs(ACCSampleTime - 1.6) < epsilon){
outSize = 5120;
sampleRate = 5120;
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 ,ACCSampleTime %f", outputData.size(),ACCSampleTime);
} }

View File

@ -593,7 +593,7 @@ int Uart::TaskResp(ScheduleTask scheduleTask){
y = 1; y = 1;
z = 0; z = 0;
} }
zlog_info(zct,"wave x = %d,y = %d,z = %d\n",x,y,z); zlog_info(zct,"wave x = %d,y = %d,z = %d,scheduleTask.z = %d\n",x,y,z,scheduleTask.z);
send_data[17] = x; send_data[17] = x;
send_data[18] = y; send_data[18] = y;
send_data[19] = z; send_data[19] = z;