fix divide 0 bugs
This commit is contained in:
parent
1d8dd06e40
commit
56de40bd47
@ -14,7 +14,7 @@
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="cdt.managedbuild.config.gnu.cross.exe.debug.534720554" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="cdt.managedbuild.config.gnu.cross.exe.debug" postannouncebuildStep="" postbuildStep="cp WLG Cidn-SH;arm-linux-gnueabihf-strip Cidn-SH" preannouncebuildStep="" prebuildStep="">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="cdt.managedbuild.config.gnu.cross.exe.debug.534720554" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="cdt.managedbuild.config.gnu.cross.exe.debug" postannouncebuildStep="" postbuildStep="cp WirelessGateway Cidn-SH;arm-linux-gnueabihf-strip Cidn-SH" preannouncebuildStep="" prebuildStep="">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.534720554." name="/" resourcePath="">
|
||||
<toolChain errorParsers="" id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.414193457" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
|
||||
<option id="cdt.managedbuild.option.gnu.cross.prefix.1212588849" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix" useByScannerDiscovery="false" value="arm-linux-gnueabihf-" valueType="string"/>
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "mqttclient/mqtt_client.h"
|
||||
#include "common/global.hpp"
|
||||
#include "utility/calculation.hpp"
|
||||
#include "scheduler/schedule.hpp"
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
extern zlog_category_t *zbt;
|
||||
@ -1346,13 +1347,20 @@ int SqliteDB::QueryofflineData() {
|
||||
|
||||
int SqliteDB::CalculateData() {
|
||||
int res = 0;
|
||||
int featureInterVal = 0;
|
||||
int featureInterTime = 0;
|
||||
int waveInterVal = 0;
|
||||
int waveInterTime = 0;
|
||||
int maxSensorNum = 0;
|
||||
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum);
|
||||
|
||||
array_t vecRet = GetDataMultiLine(T_SENSOR_INFO(TNAME), " dataNodeNo,MeasurementID,NodeWaveSend,featureInterVal,waveInterVal,ZigbeePower ", NULL);
|
||||
if (vecRet.size() > 0) {
|
||||
int planCount = 0, planCountStatistic = 0, StatisticCountTotal = 0, SixCountTotal = 0, TimingCountTotal = 0, CountWaveXTotal = 0, waveInterVal = 0, featureInterVal = 0;
|
||||
int planCount = 0, planCountStatistic = 0, StatisticCountTotal = 0,CountWaveXTotal = 0;
|
||||
int CountWaveYTotal = 0, CountWaveZTotal = 0;
|
||||
for (size_t i = 0; i < vecRet.size(); i++) {
|
||||
planCount = 1440 / atoi(vecRet[i][4].c_str());
|
||||
planCountStatistic = 1440 / atoi(vecRet[i][3].c_str());
|
||||
planCount = 1440 / waveInterVal;
|
||||
planCountStatistic = 1440 / featureInterVal;
|
||||
int rate = readIntValue("config", "waveRate", (char *)GlobalConfig::Config_G.c_str());
|
||||
char tableName[50] = {0x00};
|
||||
char whereCon[128] = {0x00};
|
||||
@ -1361,12 +1369,7 @@ int SqliteDB::CalculateData() {
|
||||
"AND timestamp < strftime('%s', 'now', '-1 day','start of day','utc','+24 hours') ";
|
||||
int StatisticCount = GetTableRows(tableName, sql);
|
||||
|
||||
sql = "timeStamp >= strftime('%s', 'now', '-1 day', 'start of day','utc') AND timeStamp < strftime('%s', 'now', '-1 day','start of day','utc','+24 hours') and statisticType = '1' ";
|
||||
int SixCount = GetTableRows(tableName, sql);
|
||||
|
||||
sql = "timeStamp >= strftime('%s', 'now', '-1 day', 'start of day','utc') AND timeStamp < strftime('%s', 'now', '-1 day','start of day','utc','+24 hours') and statisticType = '1' and timing = '0'";
|
||||
int TimingCount = GetTableRows(tableName, sql);
|
||||
zlog_info(zct, "nodeWaveSend = %s,waveInterVal = %s", vecRet[i][2].c_str(), vecRet[i][4].c_str());
|
||||
zlog_info(zct, "nodeWaveSend = %s,waveInterVal = %d", vecRet[i][2].c_str(), waveInterVal);
|
||||
if (vecRet[i][2] == "") continue;
|
||||
std::vector<std::string> nodeWaveSend;
|
||||
boost::split(nodeWaveSend, vecRet[i][2], boost::is_any_of(","), boost::token_compress_on);
|
||||
@ -1438,13 +1441,11 @@ int SqliteDB::CalculateData() {
|
||||
}
|
||||
}
|
||||
StatisticCountTotal += StatisticCount;
|
||||
SixCountTotal += SixCount;
|
||||
TimingCountTotal += TimingCount;
|
||||
CountWaveXTotal += CountWaveX;
|
||||
CountWaveYTotal += CountWaveY;
|
||||
CountWaveZTotal += CountWaveZ;
|
||||
zlog_info(zct, "dataNodeNo = %s , Statistic Count = %d , 06 Count = %d , Timing Count = %d , CountWaveX = %d , CountWaveY = %d , CountWaveZ = %d , featureInterVal = %s , waveInterVal = %s , NodeWaveSend = %s", vecRet[i][0].c_str(), StatisticCount, SixCount,
|
||||
TimingCount, CountWaveX, CountWaveY, CountWaveZ, vecRet[i][3].c_str(), vecRet[i][4].c_str(), vecRet[i][2].c_str());
|
||||
zlog_info(zct, "dataNodeNo = %s , Statistic Count = %d , CountWaveX = %d , CountWaveY = %d , CountWaveZ = %d , featureInterVal = %d , waveInterVal = %d , NodeWaveSend = %s", vecRet[i][0].c_str(), StatisticCount
|
||||
, CountWaveX, CountWaveY, CountWaveZ, featureInterVal, waveInterVal, vecRet[i][2].c_str());
|
||||
|
||||
int zigbeepowerEnable = readIntValue("config", "zigbeepowerEnable", (char *)GlobalConfig::Config_G.c_str());
|
||||
if (zigbeepowerEnable) {
|
||||
@ -1473,12 +1474,10 @@ int SqliteDB::CalculateData() {
|
||||
zlog_info(zct, "3 update ZigbeePower ");
|
||||
}
|
||||
}
|
||||
featureInterVal = atoi(vecRet[i][3].c_str());
|
||||
waveInterVal = atoi(vecRet[i][4].c_str());
|
||||
}
|
||||
zlog_info(zct, "Node Count = %d , featureInterVal = %d , waveInterVal = %d", vecRet.size(), featureInterVal, waveInterVal);
|
||||
zlog_info(zct, "plan Statistic Count = %d , 06 Count = %d , Timing Count = %d , CountWaveX = %d ", planCountStatistic * vecRet.size(), planCount * vecRet.size(), planCount * vecRet.size(), planCount * vecRet.size());
|
||||
zlog_info(zct, "reality Statistic Count = %d , 06 Count = %d , Timing Count = %d , CountWaveX = %d ,CountWaveY = %d ,CountWaveZ = %d ", StatisticCountTotal, SixCountTotal, TimingCountTotal, CountWaveXTotal, CountWaveYTotal, CountWaveZTotal);
|
||||
zlog_info(zct, "plan Statistic Count = %d , CountWaveX = %d ", planCountStatistic * vecRet.size(), planCount * vecRet.size());
|
||||
zlog_info(zct, "reality Statistic Count = %d , CountWaveX = %d ,CountWaveY = %d ,CountWaveZ = %d ", StatisticCountTotal, CountWaveXTotal, CountWaveYTotal, CountWaveZTotal);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user