sync dg102 code
This commit is contained in:
parent
dece1b2ebb
commit
802eed070e
@ -1368,7 +1368,7 @@ int SqliteDB::QueryofflineData() {
|
||||
}
|
||||
}
|
||||
|
||||
float frTemp = 0.0f;
|
||||
/*float frTemp = 0.0f;
|
||||
std::string sample;
|
||||
char whereCon[1024] = {0x00};
|
||||
char buf[30]={0};
|
||||
@ -1436,7 +1436,7 @@ int SqliteDB::QueryofflineData() {
|
||||
zlog_error(zct, "data_publish res = %d", res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return res;
|
||||
}
|
||||
int SqliteDB::ClearExpireData(){
|
||||
|
||||
@ -301,7 +301,7 @@ std::string JsonData::JsonCmd_Cgi_10(Param_10 ¶m) {
|
||||
sprintf(whereCon, "channelID like '%%%s%%' and %s <> ''", param.MeasurementID.c_str(), param.strStatic.c_str());
|
||||
|
||||
} else {
|
||||
sprintf(whereCon, " channelID like '%%%s%%' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' and nodeResend = 0 ", param.MeasurementID.c_str(), param.strStatic.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
||||
sprintf(whereCon, " channelID like '%%%s%%' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' and nodeResend IN (0, 1, 2)", param.MeasurementID.c_str(), param.strStatic.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
||||
}
|
||||
|
||||
int rows = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon);
|
||||
@ -333,9 +333,9 @@ std::string JsonData::JsonCmd_Cgi_10(Param_10 ¶m) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
|
||||
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 IN (0, 1, 2) order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.strStatic.c_str(), 550, packgeNum);
|
||||
} else {
|
||||
sprintf(whereCon, "channelID like '%%%s%%' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' and nodeResend = 0 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 IN (0, 1, 2) 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;
|
||||
|
||||
|
||||
@ -132,18 +132,18 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) {
|
||||
effect = vecResult[5];
|
||||
}
|
||||
|
||||
|
||||
jsSensorData["waveStatus"] = 3;
|
||||
//同时满足时的优先级:低电量>低信号>停机
|
||||
if(effect == "1"){
|
||||
jsSensorData["waveStatus"] = 0; //灰色
|
||||
}
|
||||
if(lowSignal == 1 && atof(rssi.c_str()) < signalThreshold){
|
||||
if(lowSignal == 1 && atof(rssi.c_str()) < signalThreshold / 100.0){
|
||||
jsSensorData["waveStatus"] = 1;//红色
|
||||
}
|
||||
if(lowBatteryLevel == 1 && fBatteryPower < batteryLevelThreshold){
|
||||
if(lowBatteryLevel == 1 && ((fBatteryPower * 100) < batteryLevelThreshold)){
|
||||
jsSensorData["waveStatus"] = 2;//红色
|
||||
}
|
||||
|
||||
|
||||
jsSensorData["update"] = atoi(arrRes[j][41].c_str());
|
||||
jsSensorData["MeasurementID"] = arrRes[j][44];
|
||||
jsSensorData["battery"] = arrRes[j][43];
|
||||
|
||||
@ -1462,7 +1462,16 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
||||
jsChannelData["dataNodeRssi"] = atoi(arrRes[j][3].c_str());
|
||||
jsChannelData["comprehensiveRssi"] = atof(arrRes[j][4].c_str());
|
||||
jsChannelData["minimumVoltage"] = atof(arrRes[j][5].c_str());
|
||||
jsChannelData["currentBatteryLevel"] = atof(arrRes[j][6].c_str());
|
||||
batteryPower = arrRes[j][11];
|
||||
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());
|
||||
}
|
||||
}
|
||||
jsChannelData["currentBatteryLevel"] = fBatteryPower * 100;
|
||||
jsChannelData["debugStatus"] = atoi(arrRes[j][7].c_str());
|
||||
jsChannelData["TimeStamp"] = arrRes[j][8];
|
||||
jsSensor.append(jsChannelData);
|
||||
|
||||
@ -488,7 +488,7 @@ long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr, bool &z, in
|
||||
}
|
||||
|
||||
// 如果是在当前波形时间窗中,不管是空闲时间窗,还是发送波形的时间窗,下一个时间窗是特征值
|
||||
int eigen_send_ts = (id - 1) * 4;
|
||||
int eigen_send_ts = (id - 1) * 6;
|
||||
if (eigen_send_ts > 57) {
|
||||
eigen_send_ts = eigen_send_ts % 57;
|
||||
}
|
||||
|
||||
@ -656,20 +656,25 @@ int Uart::DealFeatureValue(const char *pData,uint16_t ushortAdd){
|
||||
long now_time = atol(nowTimetamp.c_str());
|
||||
zlog_info(zct, "DealFeatureValue1 short_addr_last = %02x%02x,timestamp_last = %ld,nowTime = %ld",UINT16_HIGH(ushortAdd), UINT16_LOW(ushortAdd),last_time,now_time);
|
||||
if(ushortAdd == last_short_addr && (now_time - last_time) < 5){
|
||||
zlog_warn(zct, "DealFeatureValue2 short_addr_last = %02x%02x,timestamp_last = %ld,nowTime = %ld",UINT16_HIGH(ushortAdd), UINT16_LOW(ushortAdd),last_time,now_time);
|
||||
int iRet = DealDataNodeFeature(pData, 0);
|
||||
zlog_warn(zct, "DealFeatureValue short_addr_last = %02x%02x,timestamp_last = %ld,nowTime = %ld",UINT16_HIGH(ushortAdd), UINT16_LOW(ushortAdd),last_time,now_time);
|
||||
int iRet = DealDataNodeFeature(pData, 1);
|
||||
if (iRet != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
// 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);
|
||||
char logInfo[100] = {0x00};
|
||||
std::vector<uint8_t>& data_vec = map_send_data[ushortAdd];
|
||||
if (data_vec.size() > 0)
|
||||
{
|
||||
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 {
|
||||
DealAskTask(ushortAdd);
|
||||
DealDataNodeFeature(pData, 0);
|
||||
@ -1152,12 +1157,12 @@ void Uart::DealDataNodeInfo(const char *pData) {
|
||||
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',\
|
||||
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.SerialNo.c_str(), dataNodeInfo.FirstPowerTime.c_str(), dataNodeInfo.WakeupTime, dataNodeInfo.StaticTime, dataNodeInfo.WaveTime, dataNodeInfo.BateryV, dataNodeInfo.ProductNo.c_str(), dataNodeInfo.ConfigFlag, dataNodeInfo.StartBrands.c_str(),
|
||||
dataNodeInfo.StopBrands.c_str(), dataNodeInfo.FeatureInterVal, dataNodeInfo.WaveInterVal, dataNodeInfo.SamplingRate, "", dataNodeInfo.Range, dataNodeInfo.EnvelopeBandPass.c_str(), dataNodeInfo.FaultFrequency.c_str(), dataNodeInfo.ZigbeePanId.c_str(),
|
||||
dataNodeInfo.ZigbeeChannel, dataNodeInfo.ZigbeeShortAddr.c_str(), dataNodeInfo.ZigbeeLongAddr.c_str(), dataNodeInfo.ZigbeeDesAddr.c_str(), dataNodeInfo.ZigbeePower, dataNodeInfo.ZigbeeRetry, dataNodeInfo.ZigbeeRetryGap, dataNodeInfo.ACCSampleTime, "1",
|
||||
dataNodeInfo.ConfigDate.c_str(), dataNodeInfo.VIntegralFilterFrequency, dataNodeInfo.RSSI);
|
||||
dataNodeInfo.ConfigDate.c_str(), dataNodeInfo.VIntegralFilterFrequency);
|
||||
sprintf(whereCon, "dataNodeNo = '%s'", dataNodeInfo.ZigbeeLongAddr.c_str());
|
||||
res = sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
||||
if(res !=0 ){
|
||||
@ -1170,7 +1175,7 @@ void Uart::DealDataNodeInfo(const char *pData) {
|
||||
'%d','%d','%d','%s','%d','%s',\
|
||||
'%s','%u','%d','%d','%s','%d', '%s', '%s',\
|
||||
'%s','%d','%s','%s','%s',\
|
||||
'%d','%d','%d','%d','%s','%s', '%d', '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.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(),
|
||||
|
||||
@ -97,6 +97,22 @@ void Uart::RecordBattery(std::string &strLongAddr, DataRecvStatic &dataStatic, s
|
||||
sprintf(tableName, "t_debug_info");
|
||||
sprintf(updateSql, " comprehensiveRSSI = '%f',minnumVoltage = '%d',status = '2',timeStamp = '%s' ", comprehensiveRSSI,dataStatic.instantaneousBatteryVoltage,localtimestamp);
|
||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||
|
||||
memset(whereCon,0x00,sizeof(whereCon));
|
||||
sprintf(whereCon,"status = '1'");
|
||||
uint16_t short_addr;
|
||||
char *end_ptr = NULL;
|
||||
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " zigbeeShortAddr ", whereCon);
|
||||
if (vecResult.size() > 0)
|
||||
{
|
||||
std::vector<uint16_t> short_addr_list;
|
||||
for (size_t i = 0; i < vecResult.size(); i++)
|
||||
{
|
||||
short_addr = strtol(vecResult[0].c_str(), &end_ptr, 16);
|
||||
short_addr_list.push_back(short_addr);
|
||||
}
|
||||
scheduler::instance().OpenDebugMode(short_addr_list);
|
||||
}
|
||||
memset(whereCon,0x00,sizeof(whereCon));
|
||||
sprintf(whereCon,"status = '1'");
|
||||
int count = sqlite_db_ctrl::instance().GetTableRows(tableName, whereCon);
|
||||
@ -421,8 +437,8 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
|
||||
zlog_info(zct, "dataStatic.TemTop : %f dataStatic.TemBot : %f dataStatic.Dip :%d dataStatic.Voltage : %d", dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage);
|
||||
|
||||
sprintf(updateSql, "temTop='%f',temBot='%f',dip='%d',voltage='%d',timeStamp='%s',StaticIndex = %ld, nodeResend = %d,zigbeeSignal = '',zigbeeSignalNode = '',statisticType = '%d',timing = '%d',nodeTimestamp = '%s',minmumBatteryVoltageType = '%d',instantaneousBatteryVoltage = '%d' ", dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage,
|
||||
nowTimetamp.c_str(), staticIndex, nodeResend, flag, timing, nodetimestamp, dataStatic.minmumBatteryVoltageType, dataStatic.instantaneousBatteryVoltage);
|
||||
sprintf(updateSql, "temTop='%f',temBot='%f',dip='%d',voltage='%d',timeStamp='%s',StaticIndex = %ld, nodeResend = %d,zigbeeSignal = '',zigbeeSignalNode = '',statisticType = '0',timing = '%d',nodeTimestamp = '%s',minmumBatteryVoltageType = '%d',instantaneousBatteryVoltage = '%d' ", dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage,
|
||||
nowTimetamp.c_str(), staticIndex, nodeResend, timing, nodetimestamp, dataStatic.minmumBatteryVoltageType, dataStatic.instantaneousBatteryVoltage);
|
||||
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-S").c_str());
|
||||
if (/*0 == sqlite_db_ctrl::instance().GetTableRows(T_DATASTATIC_INFO(TNAME), whereCon)*/ (Count * 3 < SAVE_COUNT && lTime < OneWeek) || strTime.size() == 0) {
|
||||
zlog_info(zct, "insert static data to sql");
|
||||
@ -521,7 +537,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon);
|
||||
} else {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
sprintf(whereCon, "channelID='%s' and timeStamp = '%s' and nodeResend = 0 and nodeTimestamp = '%s'", (strMeasurementID + "-X").c_str(), strTime.c_str(),nodetimestamp);
|
||||
sprintf(whereCon, "channelID='%s' and timeStamp = '%s' and nodeResend = 0 ", (strMeasurementID + "-X").c_str(), strTime.c_str());
|
||||
|
||||
sqlite_db_ctrl::instance().UpdateTableData(szTableName, updateSql, whereCon);
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
@ -618,7 +634,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon);
|
||||
} else {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
sprintf(whereCon, "channelID='%s' and timeStamp = '%s' and nodeResend = 0 and nodeTimestamp = '%s'", (strMeasurementID + "-Y").c_str(), strTime.c_str(),nodetimestamp);
|
||||
sprintf(whereCon, "channelID='%s' and timeStamp = '%s' and nodeResend = 0 ", (strMeasurementID + "-Y").c_str(), strTime.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(szTableName, updateSql, whereCon);
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Y").c_str());
|
||||
@ -721,7 +737,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon);
|
||||
} else {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
sprintf(whereCon, "channelID='%s' and timeStamp = '%s' and nodeResend = 0 and nodeTimestamp = '%s'", (strMeasurementID + "-Z").c_str(), strTime.c_str(),nodetimestamp);
|
||||
sprintf(whereCon, "channelID='%s' and timeStamp = '%s' and nodeResend = 0 ", (strMeasurementID + "-Z").c_str(), strTime.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(szTableName, updateSql, whereCon);
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Z").c_str());
|
||||
@ -797,6 +813,10 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
Json::FastWriter featureValue;
|
||||
std::string strstatisticData = featureValue.write(root);
|
||||
|
||||
if(flag == 1){
|
||||
zlog_info(zct, "resend data,dont send to mqtt");
|
||||
return;
|
||||
}
|
||||
int iRet = data_publish(strstatisticData.c_str(), GlobalConfig::Topic_G.mPubData.c_str());
|
||||
zlog_info(zct, "dataNodeNo = '%s' and TimeStamp = '%s',MQTT ret = %d", strMeasurementID.c_str(), nowTimetamp.c_str(), iRet);
|
||||
if (iRet != 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user