add parse eigen,wave and new scheduler
This commit is contained in:
parent
5b5c08cbde
commit
7fc05f4818
@ -61,16 +61,40 @@ struct compressWaveChannel {
|
||||
int compressChannelX;
|
||||
int compressChannelY;
|
||||
int compressChannelZ;
|
||||
int compressChannelVolX;
|
||||
int compressChannelVolY;
|
||||
int compressChannelVolZ;
|
||||
int CountX;
|
||||
int CountY;
|
||||
int CountZ;
|
||||
int CountVolX;
|
||||
int CountVolY;
|
||||
int CountVolZ;
|
||||
int samplerateX;
|
||||
int samplerateY;
|
||||
int samplerateZ;
|
||||
int samplerateVolX;
|
||||
int samplerateVolY;
|
||||
int samplerateVolZ;
|
||||
compressWaveChannel() {
|
||||
compressChannelX = 0;
|
||||
compressChannelY = 0;
|
||||
compressChannelZ = 0;
|
||||
compressChannelVolX = 0;
|
||||
compressChannelVolY = 0;
|
||||
compressChannelVolZ = 0;
|
||||
CountX = 0;
|
||||
CountY = 0;
|
||||
CountZ = 0;
|
||||
CountVolX = 0;
|
||||
CountVolY = 0;
|
||||
CountVolZ = 0;
|
||||
samplerateX = 0;
|
||||
samplerateY = 0;
|
||||
samplerateZ = 0;
|
||||
samplerateVolX = 0;
|
||||
samplerateVolY = 0;
|
||||
samplerateVolZ = 0;
|
||||
}
|
||||
};
|
||||
struct WaveChannel {
|
||||
@ -84,6 +108,17 @@ struct WaveChannel {
|
||||
WaveChannelZ.reserve(48000);
|
||||
}
|
||||
};
|
||||
struct WaveVolChannel {
|
||||
std::vector<float> WaveChannelVolX;
|
||||
std::vector<float> WaveChannelVolY;
|
||||
std::vector<float> WaveChannelVolZ;
|
||||
std::string wave_timestamp;
|
||||
WaveVolChannel() {
|
||||
WaveChannelVolX.reserve(25600);
|
||||
WaveChannelVolY.reserve(25600);
|
||||
WaveChannelVolZ.reserve(48000);
|
||||
}
|
||||
};
|
||||
struct DevDataOfGwid {
|
||||
std::string mDevdata;
|
||||
std::string mDevid;
|
||||
@ -213,6 +248,8 @@ typedef struct {
|
||||
float Phase2;
|
||||
float Phase3;
|
||||
float Phase4;
|
||||
float kurtosis;
|
||||
float IntegratRMSMENS;
|
||||
}DataRecvDym;
|
||||
|
||||
struct TopicList {
|
||||
|
||||
@ -307,12 +307,12 @@ struct Param_57 {
|
||||
struct Param_58 {
|
||||
int mMode;
|
||||
int featureInterVal;
|
||||
int featureInterTime;
|
||||
int waveInterVal;
|
||||
int waveInterTime;
|
||||
int maxSensorNum;
|
||||
int sensorCount;
|
||||
Param_58() : mMode(0),featureInterVal(0),featureInterTime(0),waveInterVal(0),waveInterTime(0),maxSensorNum(0),sensorCount(0){};
|
||||
int waveResendNum;
|
||||
int resend;
|
||||
Param_58() : mMode(0),featureInterVal(0),waveInterVal(0),maxSensorNum(0),sensorCount(0),waveResendNum(0),resend(0){};
|
||||
};
|
||||
|
||||
struct Param_59 {
|
||||
|
||||
@ -171,6 +171,14 @@ void SqliteDB::SqliteInit(const char *pDbName) {
|
||||
if(iRet == 0){
|
||||
CreateTable("ALTER TABLE t_data_info ADD COLUMN 'nodeTimeStamp'");
|
||||
}
|
||||
iRet = GetTableRows(" sqlite_master "," name = 't_data_info' and sql LIKE '%kurtosis%' ");
|
||||
if(iRet == 0){
|
||||
CreateTable("ALTER TABLE t_data_info ADD COLUMN 'kurtosis'");
|
||||
}
|
||||
iRet = GetTableRows(" sqlite_master "," name = 't_data_info' and sql LIKE '%IntegratRMSMENS%' ");
|
||||
if(iRet == 0){
|
||||
CreateTable("ALTER TABLE t_data_info ADD COLUMN 'IntegratRMSMENS'");
|
||||
}
|
||||
|
||||
// 创建传感器静态数据存储表
|
||||
memset(sql_exec, 0, 2048);
|
||||
@ -328,9 +336,9 @@ void SqliteDB::Createtable(const char *ptableName) {
|
||||
char sql_exec[2048];
|
||||
// 创建传感器数据存储表
|
||||
memset(sql_exec, 0, 2048);
|
||||
sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s integer,%s,%s,%s,%s);", ptableName, T_DATA_INFO(DATANODENO), T_DATA_INFO(CHANNELID), T_DATA_INFO(DIAGNOSISEAK), T_DATA_INFO(INTEGRATPK), T_DATA_INFO(INTEGRATRMS),
|
||||
sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s integer,%s,%s,%s,%s,%s,%s);", ptableName, T_DATA_INFO(DATANODENO), T_DATA_INFO(CHANNELID), T_DATA_INFO(DIAGNOSISEAK), T_DATA_INFO(INTEGRATPK), T_DATA_INFO(INTEGRATRMS),
|
||||
T_DATA_INFO(RMSVALUES), T_DATA_INFO(ENVELOPNERGY), T_DATA_INFO(AMP1), T_DATA_INFO(AMP2), T_DATA_INFO(AMP3), T_DATA_INFO(AMP4), T_DATA_INFO(AMP5), T_DATA_INFO(PHASE1), T_DATA_INFO(PHASE2), T_DATA_INFO(PHASE3), T_DATA_INFO(PHASE4), "StaticIndex", T_DATA_INFO(TIMESTAMP),
|
||||
"sendMsg", "nodeResend", "nodeTimestamp");
|
||||
"sendMsg", "nodeResend", "nodeTimestamp","kurtosis","IntegratRMSMENS");
|
||||
CreateTable(sql_exec);
|
||||
memset(sql_exec, 0, 2048);
|
||||
sprintf(sql_exec, "CREATE INDEX %s_1 ON %s (%s)", ptableName, ptableName, T_DATA_INFO(DATANODENO));
|
||||
|
||||
@ -48,9 +48,8 @@ void JsonData::CmtCmd_80(char* send_data,int& send_length)
|
||||
void JsonData::CmtCmd_81(char* recv_body,int& count,char* send_data,int& send_length)
|
||||
{
|
||||
int featureInterVal;
|
||||
int featureInterTime;
|
||||
int waveInterVal;
|
||||
int waveInterTime;
|
||||
int waveResendNum;
|
||||
int maxSensorNum;
|
||||
int sensorCount;
|
||||
array_t arrRes;
|
||||
@ -159,7 +158,7 @@ void JsonData::CmtCmd_81(char* recv_body,int& count,char* send_data,int& send_le
|
||||
strsql = std::string(sql) + std::string(whereCon);
|
||||
int static_Count = sqlite_db_ctrl::instance().GetTableRows(szTableName,strsql.c_str());
|
||||
|
||||
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum);
|
||||
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,waveResendNum,maxSensorNum);
|
||||
zlog_info(zct,"wavex = %d,featureInterVal = %d,waveInterVal = %d",waveX_Count,featureInterVal,waveInterVal);
|
||||
int day_count = 86400 / waveInterVal;
|
||||
|
||||
@ -505,8 +504,10 @@ void JsonData::CmtCmd_86(char* recv_body,int& count,char* filename,char* file_m
|
||||
zlog_info(zct,"sum = %x\n",sum % 256);
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
std::vector<UpgradeParameter> param_list;
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
UpgradeParameter upgrade_parameter;
|
||||
char wherecon[100] = {0};
|
||||
char insertSql[200] = {0};
|
||||
char updateSql[100] = {0};
|
||||
@ -532,8 +533,14 @@ void JsonData::CmtCmd_86(char* recv_body,int& count,char* filename,char* file_m
|
||||
uint16_t short_addr;
|
||||
char *end_ptr = NULL;
|
||||
short_addr = strtol(vecResult[3].c_str(), &end_ptr, 16);
|
||||
int res = scheduler::instance().UpgradeSensor(short_addr,std::string(sensor_type),atoi(vecResult[0].c_str()),vecResult[1],std::string(sf_version));
|
||||
}
|
||||
upgrade_parameter.short_addr = short_addr;
|
||||
upgrade_parameter.sensor_type = std::string(sensor_type);
|
||||
upgrade_parameter.hw_version = atoi(vecResult[0].c_str());
|
||||
upgrade_parameter.current_sw_version = vecResult[1];
|
||||
upgrade_parameter.upgrade_sw_version = std::string(sf_version);
|
||||
param_list.push_back(upgrade_parameter);
|
||||
}
|
||||
int res = scheduler::instance().UpgradeSensor(param_list);
|
||||
free(buffer);
|
||||
}
|
||||
void JsonData::CmtCmd_87(char* MeasurementID,char* send_data,int& send_length)
|
||||
|
||||
@ -628,19 +628,18 @@ int JsonData::JsonCmd_31(){
|
||||
jsonVal["cmd"] = "31";
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = "";
|
||||
int sensorCount = 0;
|
||||
int featureInterVal = 0;
|
||||
int featureInterTime = 0;
|
||||
int waveInterVal = 0;
|
||||
int waveInterTime = 0;
|
||||
int maxSensorNum = 0;
|
||||
int featureInterVal;
|
||||
int waveInterVal;
|
||||
int waveResendNum;
|
||||
int maxSensorNum;
|
||||
int sensorCount;
|
||||
|
||||
sensorCount = sqlite_db_ctrl::instance().GetTableRows(T_SENSOR_INFO(TNAME), NULL);
|
||||
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum);
|
||||
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,waveResendNum,maxSensorNum);
|
||||
jsBody["featureInterVal"] = featureInterVal;
|
||||
jsBody["featureInterTime"] = featureInterTime;
|
||||
jsBody["featureInterTime"] = 0;
|
||||
jsBody["waveInterVal"] = waveInterVal;
|
||||
jsBody["waveInterTime"] = waveInterTime;
|
||||
jsBody["waveInterTime"] = 0;
|
||||
jsBody["maxSensorNum"] = maxSensorNum;
|
||||
jsBody["sensorCount"] = sensorCount;
|
||||
jsonVal["cmdBody"] = jsBody;
|
||||
|
||||
@ -531,19 +531,18 @@ std::string JsonData::JsonCmd_Cgi_58(Param_58 ¶m) {
|
||||
std::string error_msg = "";
|
||||
if (param.mMode == 1)
|
||||
{
|
||||
ret = scheduler::instance().Config(param.featureInterVal,param.waveInterVal,param.featureInterTime,param.waveInterTime,param.maxSensorNum,error_msg);
|
||||
ret = scheduler::instance().Config(param.featureInterVal,param.waveInterVal,param.maxSensorNum,param.waveResendNum,error_msg);
|
||||
}else if (param.mMode == 0)
|
||||
{
|
||||
sensorCount = sqlite_db_ctrl::instance().GetTableRows(T_SENSOR_INFO(TNAME), NULL);
|
||||
ret = scheduler::instance().GetScheduleConfig(param.featureInterVal,param.waveInterVal,param.featureInterTime,param.waveInterTime,param.maxSensorNum);
|
||||
ret = scheduler::instance().GetScheduleConfig(param.featureInterVal,param.waveInterVal,param.waveResendNum,param.maxSensorNum);
|
||||
}
|
||||
if (ret == 0)
|
||||
{
|
||||
jsBody["featureInterVal"] = param.featureInterVal;
|
||||
jsBody["featureInterTime"] = param.featureInterTime;
|
||||
jsBody["waveInterVal"] = param.waveInterVal;
|
||||
jsBody["waveInterTime"] = param.waveInterTime;
|
||||
jsBody["maxSensorNum"] = param.maxSensorNum;
|
||||
jsBody["resend"] = param.resend;
|
||||
jsBody["sensorCount"] = sensorCount;
|
||||
}else{
|
||||
jsonVal["success"] = false;
|
||||
@ -562,11 +561,11 @@ std::string JsonData::JsonCmd_Cgi_59(Param_59 ¶m) {
|
||||
char table_name[50] ={0};
|
||||
char sql[1024]={0};
|
||||
int featureInterVal = 0;
|
||||
int featureInterTime = 0;
|
||||
int waveInterVal = 0;
|
||||
int waveInterTime = 0;
|
||||
int waveResendNum = 0;
|
||||
int maxSensorNum = 0;
|
||||
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum);
|
||||
int sensorCount = 0;
|
||||
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,waveResendNum,maxSensorNum);
|
||||
|
||||
if (param.mMode == 1)
|
||||
{
|
||||
@ -726,8 +725,10 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
||||
zlog_info(zct,"sum = %x\n",sum % 256);
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
std::vector<UpgradeParameter> param_list;
|
||||
for (size_t i = 0; i < param.dataNodeNo.size(); i++)
|
||||
{
|
||||
UpgradeParameter upgrade_parameter;
|
||||
char wherecon[100] = {0};
|
||||
char insertSql[200] = {0};
|
||||
char updateSql[100] = {0};
|
||||
@ -751,7 +752,14 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
||||
uint16_t short_addr;
|
||||
char *end_ptr = NULL;
|
||||
short_addr = strtol(vecResult[3].c_str(), &end_ptr, 16);
|
||||
int res = scheduler::instance().UpgradeSensor(short_addr,std::string(sensor_type),atoi(vecResult[0].c_str()),vecResult[1],std::string(sf_version));
|
||||
upgrade_parameter.short_addr = short_addr;
|
||||
upgrade_parameter.sensor_type = std::string(sensor_type);
|
||||
upgrade_parameter.hw_version = atoi(vecResult[0].c_str());
|
||||
upgrade_parameter.current_sw_version = vecResult[1];
|
||||
upgrade_parameter.upgrade_sw_version = std::string(sf_version);
|
||||
param_list.push_back(upgrade_parameter);
|
||||
}
|
||||
int res = scheduler::instance().UpgradeSensor(param_list);
|
||||
if (res != 0)
|
||||
{
|
||||
jsonVal["success"] = false;
|
||||
@ -759,8 +767,6 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
||||
free(buffer);
|
||||
return show_value_.write(jsonVal);
|
||||
}
|
||||
|
||||
}
|
||||
free(buffer);
|
||||
return show_value_.write(jsonVal);
|
||||
|
||||
@ -1096,8 +1102,8 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 ¶m){
|
||||
if (nSize > 0) {
|
||||
|
||||
int interval = atol(param.timeEnd.c_str()) - atol(param.timeStart.c_str());
|
||||
int featureInterVal = 0,waveInterVal = 0,featureInterTime = 0,waveInterTime = 0,maxSensorNum = 0;
|
||||
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum);
|
||||
int featureInterVal = 0,waveInterVal = 0,waveRsendNum = 0,maxSensorNum = 0;
|
||||
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,waveRsendNum,maxSensorNum);
|
||||
Json::Value jsBody;
|
||||
char count_sql[1024] = {0};
|
||||
int recive_feature = 0, send_feature = 0,resend_feature = 0;
|
||||
@ -1277,7 +1283,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
||||
char column[128] = {0};
|
||||
char tablename[256] = {0};
|
||||
sprintf(selectCon, " t_sensor_info.MeasurementID='%s' ", strMeasurementID.c_str());
|
||||
sprintf(column, " _debug_info.*,t_sensor_info.status,t_sensor_info.dataNodeName ");
|
||||
sprintf(column, " t_debug_info.*,t_sensor_info.status,t_sensor_info.dataNodeName ");
|
||||
sprintf(tablename, " t_debug_info LEFT JOIN t_sensor_info ");
|
||||
array_t arrRes;
|
||||
arrRes = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(tablename, "*", selectCon);
|
||||
@ -1285,7 +1291,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
||||
if (iResult > 0) {
|
||||
for (int j = 0; j < iResult; j++) {
|
||||
Json::Value jsChannelData;
|
||||
jsChannelData["dataNodeName"] = arrRes[j][9];
|
||||
jsChannelData["dataNodeName"] = arrRes[j][10];
|
||||
jsChannelData["zigbeeAddr"] = arrRes[j][1];
|
||||
jsChannelData["MeasurementID"] = arrRes[j][0];
|
||||
jsChannelData["status"] = atoi(arrRes[j][0].c_str());
|
||||
@ -1304,7 +1310,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
||||
jsonVal["success"] = false;
|
||||
jsonVal["content"].resize(0);
|
||||
} else {
|
||||
jsonVal["content"] = (jsSensor);
|
||||
jsonVal["content"]["dataNodeArray"] = (jsSensor);
|
||||
}
|
||||
}else {
|
||||
jsonVal["success"] = false;
|
||||
@ -1318,7 +1324,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
||||
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_SENSOR_INFO(TNAME), updateSql, whereCon);
|
||||
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);
|
||||
@ -1339,6 +1345,8 @@ std::string JsonData::JsonCmd_Cgi_68(Param_68 ¶m){
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = " ";
|
||||
int lowSignal = -1, signalThreshold = -1, lowBatteryLevel = -1, batteryLevelThreshold = -1;
|
||||
char whereCon[512] = {0};
|
||||
char updateSql[256] = {0};
|
||||
if (param.mMode == 1) {
|
||||
lowSignal = writeIntValue("config", "lowSignal", param.lowSignal, (char *)GlobalConfig::Config_G.c_str());
|
||||
signalThreshold = writeIntValue("config", "signalThreshold", param.signalThreshold, (char *)GlobalConfig::Config_G.c_str());
|
||||
@ -1348,8 +1356,8 @@ std::string JsonData::JsonCmd_Cgi_68(Param_68 ¶m){
|
||||
if(param.vecParam68.size() > 0){
|
||||
for (size_t i = 0; i < param.vecParam68.size(); i++)
|
||||
{
|
||||
char whereCon[512] = {0};
|
||||
char updateSql[256] = {0};
|
||||
memset(whereCon,0,sizeof(whereCon));
|
||||
memset(updateSql,0,sizeof(updateSql));
|
||||
sprintf(whereCon, " MeasurementID = '%s' ", param.vecParam68[i].measurementID.c_str());
|
||||
sprintf(updateSql, " status = '%d',statisticType = '%d', threshold = '%f'",param.vecParam68[i].status,param.vecParam68[i].statisticType,param.vecParam68[i].threshold);
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" t_waveUploadRule_info ", updateSql, whereCon);
|
||||
@ -1360,7 +1368,7 @@ std::string JsonData::JsonCmd_Cgi_68(Param_68 ¶m){
|
||||
signalThreshold = readIntValue("config", "signalThreshold", (char *)GlobalConfig::Config_G.c_str());
|
||||
lowBatteryLevel = readIntValue("config", "lowBatteryLevel", (char *)GlobalConfig::Config_G.c_str());
|
||||
batteryLevelThreshold = readIntValue("config", "batteryLevelThreshold", (char *)GlobalConfig::Config_G.c_str());
|
||||
array_t arrRes = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(" t_waveUploadRule_info ", " * ", NULL);
|
||||
array_t arrRes = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(" t_waveUploadRule_info LEFT JOIN t_sensor_info ", " t_waveUploadRule_info.*,t_sensor_info.dataNodeName ", "t_waveUploadRule_info.MeasurementID = t_sensor_info.MeasurementID");
|
||||
if (arrRes.size() > 0) {
|
||||
for (size_t i = 0; i < arrRes.size(); i++)
|
||||
{
|
||||
@ -1369,6 +1377,7 @@ std::string JsonData::JsonCmd_Cgi_68(Param_68 ¶m){
|
||||
iTem.append(atoi(arrRes[i][2].c_str()));
|
||||
iTem.append(atoi(arrRes[i][3].c_str()));
|
||||
iTem.append(atof(arrRes[i][4].c_str()));
|
||||
iTem.append(atof(arrRes[i][5].c_str()));
|
||||
dataNodeArray.append(iTem);
|
||||
}
|
||||
}
|
||||
@ -1395,13 +1404,15 @@ std::string JsonData::JsonCmd_Cgi_69(Param_69 ¶m){
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = " ";
|
||||
int trigerThresholdEnable = -1;
|
||||
char whereCon[512] = {0};
|
||||
char updateSql[256] = {0};
|
||||
if (param.mMode == 1) {
|
||||
trigerThresholdEnable = writeIntValue("config", "trigerThresholdEnable", param.trigerThresholdEnable, (char *)GlobalConfig::Config_G.c_str());
|
||||
if(param.vecParam69.size() > 0){
|
||||
for (size_t i = 0; i < param.vecParam69.size(); i++)
|
||||
{
|
||||
char whereCon[512] = {0};
|
||||
char updateSql[256] = {0};
|
||||
memset(whereCon,0,sizeof(whereCon));
|
||||
memset(updateSql,0,sizeof(updateSql));
|
||||
sprintf(whereCon, " MeasurementID = '%s' ", param.vecParam69[i].measurementID.c_str());
|
||||
sprintf(updateSql, " status = '%d',trigerType = '%d',statisticType = '%d', threshold = '%f'",param.vecParam69[i].status,param.vecParam69[i].trigerType,param.vecParam69[i].statisticType,param.vecParam69[i].threshold);
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" t_waveTriger_info ", updateSql, whereCon);
|
||||
@ -1409,7 +1420,7 @@ std::string JsonData::JsonCmd_Cgi_69(Param_69 ¶m){
|
||||
}
|
||||
} else if (param.mMode == 0) {
|
||||
trigerThresholdEnable = readIntValue("config", "trigerThresholdEnable", (char *)GlobalConfig::Config_G.c_str());
|
||||
array_t arrRes = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(" t_wave_triger_info ", " * ", NULL);
|
||||
array_t arrRes = sqlite_db_ctrl::instance().GetDataMultiLine(" t_wave_triger_info LEFT JOIN t_sensor_info ", " t_wave_triger_info.*,t_sensor_info.dataNodeName ", "t_wave_triger_info.MeasurementID = t_sensor_info.MeasurementID");
|
||||
if (arrRes.size() > 0) {
|
||||
for (size_t i = 0; i < arrRes.size(); i++)
|
||||
{
|
||||
@ -1419,7 +1430,9 @@ std::string JsonData::JsonCmd_Cgi_69(Param_69 ¶m){
|
||||
iTem.append(atoi(arrRes[i][3].c_str()));
|
||||
iTem.append(atoi(arrRes[i][4].c_str()));
|
||||
iTem.append(atof(arrRes[i][5].c_str()));
|
||||
jsonVal["content"]["dataNodeArray"].append(iTem);
|
||||
iTem.append(arrRes[i][6]);
|
||||
dataNodeArray.append(iTem);
|
||||
|
||||
}
|
||||
}
|
||||
if (dataNodeArray.size() == 0) {
|
||||
@ -1428,6 +1441,7 @@ std::string JsonData::JsonCmd_Cgi_69(Param_69 ¶m){
|
||||
}
|
||||
}
|
||||
jsonVal["content"]["trigerThresholdEnable"] = trigerThresholdEnable;
|
||||
jsonVal["content"]["dataNodeArray"] = dataNodeArray;
|
||||
return show_value_.write(jsonVal);
|
||||
}
|
||||
std::string JsonData::JsonCmd_Cgi_70(Param_70 ¶m){
|
||||
|
||||
@ -389,10 +389,10 @@ std::string LocalServer::HandleCgi_cmd(std::string &pData) {
|
||||
param.mMode = 0;
|
||||
}
|
||||
param.featureInterVal = recvBody["featureInterVal"].asInt();
|
||||
param.featureInterTime = recvBody["featureInterTime"].asInt();
|
||||
param.waveInterVal = recvBody["waveInterVal"].asInt();
|
||||
param.waveInterTime = recvBody["waveInterTime"].asInt();
|
||||
param.maxSensorNum = recvBody["maxSensorNum"].asInt();
|
||||
param.waveResendNum = recvBody["waveResendNum"].asInt();
|
||||
param.resend = recvBody["resend"].asInt();
|
||||
std::string data = jd.JsonCmd_Cgi_58(param);
|
||||
return data;
|
||||
}break;
|
||||
|
||||
7
main.cpp
7
main.cpp
@ -22,7 +22,9 @@
|
||||
extern std::vector<RecvData> g_VecWaveDataX;
|
||||
extern std::vector<RecvData> g_VecWaveDataY;
|
||||
extern std::vector<RecvData> g_VecWaveDataZ;
|
||||
|
||||
extern std::vector<RecvData> g_VecWaveDataVolX;
|
||||
extern std::vector<RecvData> g_VecWaveDataVolY;
|
||||
extern std::vector<RecvData> g_VecWaveDataVolZ;
|
||||
zlog_category_t *zct = NULL;
|
||||
zlog_category_t *zbt = NULL;
|
||||
|
||||
@ -47,6 +49,9 @@ int main(int argc, char *argv[]) {
|
||||
g_VecWaveDataX.reserve(1000);
|
||||
g_VecWaveDataY.reserve(1000);
|
||||
g_VecWaveDataZ.reserve(1500);
|
||||
g_VecWaveDataVolX.reserve(1000);
|
||||
g_VecWaveDataVolY.reserve(1000);
|
||||
g_VecWaveDataVolZ.reserve(1500);
|
||||
boost::thread::attributes attrs;
|
||||
attrs.set_stack_size(1024 * 1024);
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ int GlobalConfig::LinkStatus_G = 0;
|
||||
int GlobalConfig::LinkCount = 0;
|
||||
int GlobalConfig::net0Status = 1;
|
||||
|
||||
std::string GlobalConfig::Version = "5.7.1";
|
||||
std::string GlobalConfig::Version = "5.8";
|
||||
std::string GlobalConfig::MacAddr_G = "";
|
||||
std::string GlobalConfig::MacAddr_G2 = "";
|
||||
std::string GlobalConfig::IpAddr_G = "";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,12 +4,18 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <boost/container/detail/singleton.hpp>
|
||||
#include "upgrade_cfg.hpp"
|
||||
#include "status_mgr.hpp"
|
||||
|
||||
#define SCHEDULE_CONFIG "/opt/configenv/schedule.json"
|
||||
#define DEBUG_SCHEDULE_CONFIG "/opt/configenv/debug_schedule.json"
|
||||
#define UPGRADE_SCHEDULE_CONFIG "/opt/configenv/upgrade_schedule.json"
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
kScheduleResultNone = 0,
|
||||
@ -30,57 +36,45 @@ typedef enum {
|
||||
kUpgradeDoneBefore = 5 // 当前就是这个版本,不需要升级了
|
||||
} FirmFileCheckResult;
|
||||
|
||||
typedef struct {
|
||||
uint16_t short_addr;
|
||||
std::string sensor_type;
|
||||
int hw_version;
|
||||
std::string current_sw_version;
|
||||
std::string upgrade_sw_version;
|
||||
} UpgradeParameter;
|
||||
|
||||
class SensorScheduler {
|
||||
public:
|
||||
SensorScheduler();
|
||||
|
||||
void SetScheduleStatus(ScheduleStatus status);
|
||||
// kScheduleConfigSensor kScheduleUpgrade 等有结果,调我接口通知结果
|
||||
// kScheduleEigenValue kScheduleWaveForm
|
||||
// 上面4个结束,调GetNextDuration()获取休眠时间
|
||||
// 如果是kScheduleWrongTime, 此函数next_duration表明休眠时间
|
||||
int StartSchedule(int short_addr, int &next_duration, int &next_task_id);
|
||||
int GetNextDuration(int short_addr,int &next_task_id);
|
||||
// int GetNextDuration(int short_addr);
|
||||
int StartSchedule(uint16_t short_addr, int &next_duration, bool &z);
|
||||
int GetNextDuration(uint16_t short_addr);
|
||||
|
||||
int WaveError(uint16_t short_addr);
|
||||
int WaveSuccess(uint16_t short_addr);
|
||||
long GetBaseTimestamp(int id);
|
||||
long CalcNextTimestamp(int id, uint16_t short_addr, int& next_task_id);
|
||||
// z用于说明是z轴波形,还是xy轴波形
|
||||
int WaveError(uint16_t short_addr, bool z);
|
||||
void WaveSuccess(uint16_t short_addr, bool z);
|
||||
// long GetBaseTimestamp(int id);
|
||||
long CalcNextTimestamp(int id, uint16_t short_addr);
|
||||
|
||||
// 当有传感器需要更新配置时调用
|
||||
int UpdateSensorConfig(int short_addr);
|
||||
int UpdateSensorConfig(uint16_t short_addr);
|
||||
// 当更新结束后,调用此接口,result为0是成功,其它值为失败
|
||||
int UpdateConfigResult(int short_addr, int result);
|
||||
|
||||
/**
|
||||
* @brief 当有传感器需要升级时调用
|
||||
* sensor_type: DN101, DN102
|
||||
* hw_version: 3, 4
|
||||
* current_sw_version: 1.1
|
||||
* upgrade_sw_version: 1.2
|
||||
*/
|
||||
int UpgradeSensor(int short_addr, std::string sensor_type, int hw_version,
|
||||
std::string current_sw_version, std::string upgrade_sw_version);
|
||||
/**
|
||||
* @brief 升级后,无线传感器发回来的返回值
|
||||
*
|
||||
* @param short_addr
|
||||
* @param result 参考:FirmFileCheckResult
|
||||
* 返回值表明操作是否成功,0成功,其它失败
|
||||
*/
|
||||
int UpgradeResult(int short_addr, int result);
|
||||
int UpdateConfigResult(uint16_t short_addr, int result);
|
||||
|
||||
int Config(int eigen_value_send_interval, int wave_form_send_interval,
|
||||
int eigen_value_send_duration, int wave_form_send_duration,
|
||||
int max_sensor_num, std::string &error_msg);
|
||||
int Config(int eigen_value_send_interval, int wave_form_send_interval,
|
||||
int max_sensor_num, int wave_resend_num, std::string &error_msg);
|
||||
|
||||
int CalcAvailableSlice(int eigen_value_send_interval, int wave_form_send_interval,
|
||||
int eigen_value_send_duration, int wave_form_send_duration,
|
||||
int CalcAvailableSlice(int eigen_value_send_interval, int wave_form_send_interval,
|
||||
int max_sensor_num, int &available_slice, int &free_slice,
|
||||
std::string &error_msg);
|
||||
|
||||
int GetScheduleConfig(int &eigen_value_send_interval, int &wave_form_send_interval,
|
||||
int &eigen_value_send_duration, int &wave_form_send_duration,
|
||||
int GetScheduleConfig(int &eigen_value_send_interval, int &wave_form_send_interval, int &wave_resend_num,
|
||||
int &max_sensor_num);
|
||||
// ======schedule.json操作开始======
|
||||
// 无线网关程序重启时
|
||||
@ -92,20 +86,47 @@ public:
|
||||
void ModifyScheduleTs(int diff_ts);
|
||||
|
||||
// 当接入传感器时,设置为不可修改; 当停用所有传感器后,修改为可修改
|
||||
void AdjustSupportModification(bool support_modification);
|
||||
// void AdjustSupportModification(bool support_modification);
|
||||
// ======schedule.json操作结束======
|
||||
|
||||
void ClearScheduleCfg(int short_addr = 0);
|
||||
void ClearScheduleCfg(uint16_t short_addr = 0);
|
||||
|
||||
long GetLocalTs();
|
||||
long GetLocalWorldTime(std::string &world_time);
|
||||
std::string GetUTCTime(long ts);
|
||||
int GetAvailableId(int short_addr);
|
||||
int GetAvailableId(uint16_t short_addr);
|
||||
|
||||
// 调试模式相关接口
|
||||
// 此接口可多次调用,但是总是以最后一次调用为准
|
||||
int OpenDebugMode(std::vector<uint16_t> short_addr_list);
|
||||
int CloseDebugMode();
|
||||
|
||||
// 升级模式相关接口
|
||||
/**
|
||||
* @brief 当有传感器需要升级时调用, 此接口也会打开升级模式,可重复调用
|
||||
* sensor_type: DN101, DN102
|
||||
* hw_version: 3, 4
|
||||
* current_sw_version: 1.1
|
||||
* upgrade_sw_version: 1.2
|
||||
*/
|
||||
int UpgradeSensor(std::vector<UpgradeParameter> ¶m_list);
|
||||
int CancelUpgradeSensor(std::vector<uint16_t> short_addr_list);
|
||||
int CloseUpgradeMode();
|
||||
/**
|
||||
* @brief 升级后,无线传感器发回来的返回值
|
||||
*
|
||||
* @param short_addr
|
||||
* @param result 参考:FirmFileCheckResult
|
||||
* 返回值表明操作是否成功,0成功,其它失败
|
||||
*/
|
||||
int UpgradeResult(uint16_t short_addr, int result);
|
||||
|
||||
private:
|
||||
void UpdateUpgradeInfo(int id);
|
||||
void CleanIdleOccupiedSet(long ts);
|
||||
void UseDefaultConfig();
|
||||
int GetDebugUpgradeNextDuration(uint16_t short_addr);
|
||||
long GetDebugUpgradeNextTS(uint16_t short_addr);
|
||||
|
||||
// user config
|
||||
int eigen_value_send_interval_;
|
||||
@ -113,6 +134,7 @@ private:
|
||||
int wave_form_send_interval_;
|
||||
int wave_form_send_duration_;
|
||||
int max_sensor_num_;
|
||||
int wave_resend_num_;
|
||||
|
||||
// calc result
|
||||
long start_timestamp_;
|
||||
@ -122,19 +144,23 @@ private:
|
||||
int wave_slice_num_per_eigen_interval_; // 每个特征值窗口中有几个波形发送窗口
|
||||
int seconds_per_wave_slice_; // 波形窗口时长
|
||||
int eigen_value_slice_total_seconds_; // 特征值窗口总时长
|
||||
std::vector<int> slice_sensor_id_; // 每个时间窗是哪个传感器使用的
|
||||
|
||||
bool support_modification_;
|
||||
std::map<int, int> sensor_id_nth_slice_; // 传感器编号与第几个波形发送窗口对应关系
|
||||
int *slice_sensor_id_; // 每个时间窗是哪个传感器使用的
|
||||
uint8_t *slice_is_z_wave_; // 表明此窗口是z轴波形还是xy的
|
||||
std::unordered_map<int, std::pair<int,int>> sensor_id_nth_slice_; // 传感器编号与z,xy波形发送窗口对应关系
|
||||
std::map<uint16_t, int> short_addr_map_; // base_relation.json
|
||||
|
||||
// 存储当前2小时内失败与成功的传感器
|
||||
std::map<uint16_t, int> failure_map_;
|
||||
std::unordered_set<uint16_t> success_set_;
|
||||
std::unordered_set<uint16_t> patch_set_; // 漏传的补传
|
||||
std::map<uint16_t, int> z_failure_map_;
|
||||
std::map<uint16_t, int> xy_failure_map_;
|
||||
std::unordered_set<uint16_t> z_success_set_;
|
||||
std::unordered_set<uint16_t> xy_success_set_;
|
||||
std::unordered_set<uint16_t> z_patch_set_; // 漏传的补传
|
||||
std::unordered_set<uint16_t> xy_patch_set_; // 漏传的补传
|
||||
void ClearFailureSuccessMap();
|
||||
bool RetransferWave(uint16_t short_addr);
|
||||
bool MissedWave(uint16_t short_addr);
|
||||
bool ZRetransferWave(uint16_t short_addr);
|
||||
bool ZMissedWave(uint16_t short_addr);
|
||||
bool XYRetransferWave(uint16_t short_addr);
|
||||
bool XYMissedWave(uint16_t short_addr);
|
||||
|
||||
// 空闲时间戳被占用
|
||||
std::unordered_set<long> free_slice_ocuppied_;
|
||||
@ -157,8 +183,23 @@ private:
|
||||
int nth_wave_slice_; // 如果ts_in_eigen_slice_是假的话,此值表明是第几个波形窗口
|
||||
|
||||
int current_request_;
|
||||
ScheduleStatus current_schedule_status_;
|
||||
|
||||
|
||||
// debug mode
|
||||
std::map<int, int> debug_sensor_id_nth_slice_; // 调度模式下传感器编号与z波形发送窗口对应关系
|
||||
uint16_t *debug_slice_sensor_id_; // 每个时间窗是哪个传感器使用的
|
||||
// std::vector<int> debug_short_addr_list_;
|
||||
std::unordered_set<uint16_t> debug_list_;
|
||||
void GenerateDebugSchedule(std::vector<uint16_t> short_addr_list);
|
||||
|
||||
// upgrade mode
|
||||
std::map<int, int> upgrade_sensor_id_nth_slice_; // 升级模式下传感器编号与升级发送窗口对应关系
|
||||
std::unordered_set<uint16_t> upgrade_list_;
|
||||
uint16_t *upgrade_slice_sensor_id_; // 每个时间窗是哪个传感器使用的
|
||||
void GenerateUpgradeSchedule();
|
||||
};
|
||||
|
||||
typedef boost::container::dtl::singleton_default<SensorScheduler> scheduler;
|
||||
|
||||
#endif // SCHEDULE_HPP_
|
||||
#endif // SCHEDULE_HPP_
|
||||
124
scheduler/status_mgr.cpp
Normal file
124
scheduler/status_mgr.cpp
Normal file
@ -0,0 +1,124 @@
|
||||
#include "status_mgr.hpp"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <json/json.h>
|
||||
#include <json/reader.h>
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
|
||||
ScheduleStatus get_schedule_status() {
|
||||
// std::ifstream status_file("/opt/configenv/status.json");
|
||||
// Json::Value json_data;
|
||||
// Json::CharReaderBuilder reader;
|
||||
// std::string errs;
|
||||
|
||||
// if (status_file.is_open()) {
|
||||
// if (Json::parseFromStream(reader, status_file, &json_data, &errs)) {
|
||||
// std::string status = json_data["status"].asString();
|
||||
|
||||
// if (status == "debug") {
|
||||
// status_file.close();
|
||||
// return kScheduleStatusDebug;
|
||||
// } else if (status == "normal") {
|
||||
// status_file.close();
|
||||
// return kScheduleStatusNormal;
|
||||
// } else if (status == "upgrade") {
|
||||
// status_file.close();
|
||||
// return kScheduleStatusUpgrade;
|
||||
// }
|
||||
// } else {
|
||||
// std::cerr << "Failed to parse JSON: " << errs << std::endl;
|
||||
// }
|
||||
// status_file.close();
|
||||
// } else {
|
||||
// std::cerr << "Unable to open status.json" << std::endl;
|
||||
// }
|
||||
|
||||
return kScheduleStatusNormal;
|
||||
}
|
||||
|
||||
void set_schedule_status(ScheduleStatus status) {
|
||||
std::string status_str;
|
||||
switch (status) {
|
||||
case kScheduleStatusNormal:
|
||||
status_str = "normal";
|
||||
break;
|
||||
case kScheduleStatusDebug:
|
||||
status_str = "debug";
|
||||
break;
|
||||
case kScheduleStatusUpgrade:
|
||||
status_str = "upgrade";
|
||||
break;
|
||||
}
|
||||
|
||||
// Write to status.json
|
||||
Json::Value json_data;
|
||||
json_data["status"] = status_str;
|
||||
|
||||
std::ofstream status_file("/opt/configenv/status.json");
|
||||
if (status_file.is_open()) {
|
||||
status_file << json_data;
|
||||
status_file.close();
|
||||
} else {
|
||||
std::cerr << "Unable to open status.json for writing" << std::endl;
|
||||
}
|
||||
|
||||
// Append to status_history.json
|
||||
Json::Value history_data;
|
||||
// std::ifstream history_file("/opt/configenv/status_history.json");
|
||||
// if (history_file.is_open()) {
|
||||
// if (Json::parseFromStream(Json::CharReaderBuilder(), history_file, &history_data, nullptr)) {
|
||||
// // successfully read existing history
|
||||
// }
|
||||
// history_file.close();
|
||||
// }
|
||||
|
||||
// Get the current time
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto now_c = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm* now_tm = std::localtime(&now_c);
|
||||
|
||||
// Format time as "YYYY-MM-DD HH:MM:SS"
|
||||
char time_buffer[20];
|
||||
std::strftime(time_buffer, sizeof(time_buffer), "%Y-%m-%d %H:%M:%S", now_tm);
|
||||
|
||||
// Add the new status and time to history
|
||||
Json::Value new_entry;
|
||||
new_entry["status"] = status_str;
|
||||
new_entry["time"] = time_buffer;
|
||||
history_data.append(new_entry);
|
||||
|
||||
// Write back to status_history.json
|
||||
std::ofstream history_file_out("/opt/configenv/status_history.json");
|
||||
if (history_file_out.is_open()) {
|
||||
history_file_out << history_data;
|
||||
history_file_out.close();
|
||||
} else {
|
||||
std::cerr << "Unable to open status_history.json for writing" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::string get_status_desc(ScheduleStatus status) {
|
||||
std::string status_str;
|
||||
switch (status) {
|
||||
case kScheduleStatusNormal:
|
||||
status_str = "normal";
|
||||
break;
|
||||
case kScheduleStatusDebug:
|
||||
status_str = "debug";
|
||||
break;
|
||||
case kScheduleStatusUpgrade:
|
||||
status_str = "upgrade";
|
||||
break;
|
||||
default:
|
||||
status_str = "normal";
|
||||
zlog_error(zct, "fail to get status desc:%d", status);
|
||||
break;
|
||||
}
|
||||
return status_str;
|
||||
}
|
||||
23
scheduler/status_mgr.hpp
Normal file
23
scheduler/status_mgr.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef STATUS_MGR_HPP_
|
||||
#define STATUS_MGR_HPP_
|
||||
#include <string>
|
||||
/**
|
||||
* @brief 对调度状态切换进行管理,并对调度切换时历史进行记录
|
||||
*
|
||||
* @version 0.1
|
||||
* @author pandx (dxpan2002@163.com)
|
||||
* @date 2026-01-21
|
||||
* @copyright Copyright (c) 2026
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
kScheduleStatusNormal = 1,
|
||||
kScheduleStatusDebug = 2,
|
||||
kScheduleStatusUpgrade = 3
|
||||
} ScheduleStatus;
|
||||
|
||||
ScheduleStatus get_schedule_status();
|
||||
void set_schedule_status(ScheduleStatus status);
|
||||
std::string get_status_desc(ScheduleStatus status);
|
||||
|
||||
#endif
|
||||
@ -29,6 +29,9 @@ pTestRecvCallBack pTestRecv;
|
||||
extern std::vector<RecvData> g_VecWaveDataX;
|
||||
extern std::vector<RecvData> g_VecWaveDataY;
|
||||
extern std::vector<RecvData> g_VecWaveDataZ;
|
||||
extern std::vector<RecvData> g_VecWaveDataVolX;
|
||||
extern std::vector<RecvData> g_VecWaveDataVolY;
|
||||
extern std::vector<RecvData> g_VecWaveDataVolZ;
|
||||
|
||||
int Uart::UartRecv(int fd, char srcshow, char *buffer) {
|
||||
char buff[BUF_LENGTH];
|
||||
@ -145,6 +148,12 @@ Uart::Uart() : mUart(mIoSev), mStrand(mIoSev) {
|
||||
VecWaveDataX.reserve(1000);
|
||||
VecWaveDataY.reserve(1000);
|
||||
VecWaveDataZ.reserve(1500);
|
||||
m_waveCountVolX = 0;
|
||||
m_waveCountVolY = 0;
|
||||
m_waveCountVolZ = 0;
|
||||
VecWaveDataVolX.reserve(1000);
|
||||
VecWaveDataVolY.reserve(1000);
|
||||
VecWaveDataVolZ.reserve(1500);
|
||||
memset(send_data, 0, sizeof(send_data));
|
||||
last_short_addr = 0;
|
||||
last_time = 0;
|
||||
@ -368,7 +377,8 @@ int Uart::DealAskTask(uint16_t ushortAdd){
|
||||
int next_duration = 0,next_task_id = 0;
|
||||
int taskID;
|
||||
ScheduleTask scheduleTask;
|
||||
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration, next_task_id);
|
||||
bool z = false;
|
||||
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration, z);
|
||||
zlog_info(zct, "taskID = %d next_duration = %d next_task_id = %d", taskID, next_duration, next_task_id);
|
||||
if (taskID == kScheduleConfigSensor)
|
||||
{
|
||||
@ -439,7 +449,7 @@ int Uart::DealReviveDuration(uint16_t ushortAdd){
|
||||
|
||||
ScheduleTask scheduleTask;
|
||||
int next_taskID = 0;
|
||||
uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd,next_taskID);
|
||||
uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd);
|
||||
zlog_info(zct, "next_duration = %d next_taskID = %d", next_duration,next_taskID);
|
||||
scheduleTask.cmd = REVIVE_DURATION;
|
||||
scheduleTask.shortAddr = ushortAdd;
|
||||
@ -468,18 +478,31 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
sprintf(buf, "%02x%02x", (ushortAdd >> 8) & 0xFF, ushortAdd & 0xFF);
|
||||
std::string strShortAddr = std::string(buf);
|
||||
compressWaveChannel tempchannel;
|
||||
tempchannel.compressChannelX = pData[7];
|
||||
tempchannel.compressChannelY = pData[8];
|
||||
tempchannel.compressChannelZ = pData[9];
|
||||
tempchannel.compressChannelX = pData[8];
|
||||
tempchannel.compressChannelY = pData[9];
|
||||
tempchannel.compressChannelZ = pData[10];
|
||||
tempchannel.compressChannelVolX = pData[23];
|
||||
tempchannel.compressChannelVolY = pData[24];
|
||||
tempchannel.compressChannelVolZ = pData[25];
|
||||
|
||||
tempchannel.CountX = BUILD_UINT32(pData[13], pData[12],pData[11],pData[10]);
|
||||
tempchannel.CountY = BUILD_UINT32(pData[17], pData[16],pData[15],pData[14]);
|
||||
tempchannel.CountZ = BUILD_UINT32(pData[21], pData[20],pData[19],pData[18]);
|
||||
tempchannel.CountX = BUILD_UINT32(pData[14], pData[13],pData[12],pData[11]);
|
||||
tempchannel.CountY = BUILD_UINT32(pData[18], pData[17],pData[16],pData[15]);
|
||||
tempchannel.CountZ = BUILD_UINT32(pData[22], pData[21],pData[20],pData[19]);
|
||||
tempchannel.CountVolX = BUILD_UINT32(pData[29], pData[28],pData[27],pData[26]);
|
||||
tempchannel.CountVolY = BUILD_UINT32(pData[33], pData[32],pData[31],pData[30]);
|
||||
tempchannel.CountVolZ = BUILD_UINT32(pData[37], pData[36],pData[35],pData[34]);
|
||||
|
||||
tempchannel.samplerateX = BUILD_UINT32(pData[41], pData[40],pData[39],pData[38]);
|
||||
tempchannel.samplerateY = BUILD_UINT32(pData[45], pData[44],pData[43],pData[42]);
|
||||
tempchannel.samplerateZ = BUILD_UINT32(pData[49], pData[48],pData[47],pData[46]);
|
||||
tempchannel.samplerateVolX = BUILD_UINT32(pData[53], pData[52],pData[51],pData[50]);
|
||||
tempchannel.samplerateVolY = BUILD_UINT32(pData[57], pData[56],pData[55],pData[54]);
|
||||
tempchannel.samplerateVolZ = BUILD_UINT32(pData[61], pData[60],pData[59],pData[58]);
|
||||
|
||||
g_mapCompress[strShortAddr] = tempchannel;
|
||||
wave_shortAddr = ushortAdd;
|
||||
char sensor_rssi[10] = {0x00};
|
||||
sprintf(sensor_rssi, "%02d", pData[22] & 0xFF);
|
||||
sprintf(sensor_rssi, "%02d", pData[7] & 0xFF);
|
||||
if (!strcmp(sensor_rssi, "00") || !strcmp(sensor_rssi, "0")) {
|
||||
char errorInfo[100] = {0x00};
|
||||
sprintf(errorInfo, "No RSSI %s", sensor_rssi);
|
||||
@ -617,7 +640,8 @@ int Uart::DealAskTaskOld(uint16_t ushortAdd){
|
||||
int next_duration = 0,next_task_id = 0;
|
||||
int taskID;
|
||||
ScheduleTask scheduleTask;
|
||||
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration, next_task_id);
|
||||
bool z = false;
|
||||
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration, z);
|
||||
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;
|
||||
@ -639,6 +663,7 @@ void Uart::DealRecvData(const char *pData) {
|
||||
int next_duration = 0,next_task_id = 0;
|
||||
int taskID = 0;
|
||||
ScheduleTask scheduleTask;
|
||||
bool z = false;
|
||||
zlog_info(zct, "shortAdd = %02x%02x,command = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command);
|
||||
if (command == WAVE_COMPRESS || command == UPGRADE_ASK)
|
||||
{
|
||||
@ -708,7 +733,7 @@ void Uart::DealRecvData(const char *pData) {
|
||||
break;
|
||||
case UPGRADE_ASK:
|
||||
mssleep(50000);
|
||||
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration, next_task_id);
|
||||
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration, z);
|
||||
taskID = kScheduleUpgrade;
|
||||
if (taskID == kScheduleUpgrade){
|
||||
UpdateWirelessNode(ushortAdd);
|
||||
@ -835,15 +860,15 @@ void Uart::DealDataNodeName(const char *pData) {
|
||||
|
||||
char insertSql[1024] = {0};
|
||||
sprintf(insertSql, " '%s','%s','','','','','','0',''",
|
||||
MeasurementID, shortAdd);
|
||||
MeasurementID, szShortAdd);
|
||||
sqlite_db_ctrl::instance().InsertData("t_debug_info", insertSql);
|
||||
memset(insertSql,0,sizeof(insertSql));
|
||||
sprintf(insertSql, " '%s','%s','0','0','0'",
|
||||
MeasurementID, shortAdd);
|
||||
MeasurementID, szShortAdd);
|
||||
sqlite_db_ctrl::instance().InsertData("t_wave_upload_rule_info", insertSql);
|
||||
memset(insertSql,0,sizeof(insertSql));
|
||||
sprintf(insertSql, " '%s','%s','0','0','0','0'",
|
||||
MeasurementID, shortAdd);
|
||||
MeasurementID, szShortAdd);
|
||||
sqlite_db_ctrl::instance().InsertData("t_wave_triger_info", insertSql);
|
||||
}
|
||||
|
||||
@ -1258,13 +1283,17 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
||||
g_VecWaveDataZ.clear();
|
||||
break;
|
||||
}
|
||||
if ((mPackgeIndex == -1 || (unsigned int)UartRecvBuf[i + 6] == 0) && (command == WAVE_X || command == WAVE_Y || command == WAVE_Z) && now_task == WAVE_CMD) {
|
||||
if ((mPackgeIndex == -1 || (unsigned int)UartRecvBuf[i + 6] == 0) && \
|
||||
(command == WAVE_X || command == WAVE_Y || command == WAVE_Z || command == WAVE_VOL_X || command == WAVE_VOL_Y || command == WAVE_VOL_Z) && \
|
||||
now_task == WAVE_CMD) {
|
||||
mPackgeIndex = UartRecvBuf[i + 6] & 0xFF;
|
||||
} else if ((unsigned int)mPackgeIndex == (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && command != 2 && (command == WAVE_X || command == WAVE_Y || command == WAVE_Z) && now_task == WAVE_CMD) {
|
||||
} else if ((unsigned int)mPackgeIndex == (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && command != 2 && \
|
||||
(command == WAVE_X || command == WAVE_Y || command == WAVE_Z || command == WAVE_VOL_X || command == WAVE_VOL_Y || command == WAVE_VOL_Z) && \
|
||||
now_task == WAVE_CMD) {
|
||||
zlog_warn(zct, "mPackgeIndex same index1:%d,index2:%02d ShortAddr :%s ", mPackgeIndex, UartRecvBuf[i + 6] & 0xff, strShortAddr.c_str());
|
||||
continue;
|
||||
|
||||
} else if ((unsigned int)mPackgeIndex + 1 != (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && command != 2 && (command == WAVE_X || command == WAVE_Y || command == WAVE_Z) && now_task == WAVE_CMD) {
|
||||
} else if ((unsigned int)mPackgeIndex + 1 != (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && command != 2 && (command == WAVE_X || command == WAVE_Y || command == WAVE_Z || command == WAVE_VOL_X || command == WAVE_VOL_Y || command == WAVE_VOL_Z) && now_task == WAVE_CMD) {
|
||||
|
||||
zlog_warn(zct, "mPackgeIndex error index1:%d,index2:%02d ShortAddr :%s ,now_task = %d", mPackgeIndex, UartRecvBuf[i + 6] & 0xff, strShortAddr.c_str(),now_task);
|
||||
zlog_warn(zct, "mPackgeIndex error ShortAddr :%s", strShortAddr.c_str());
|
||||
@ -1307,7 +1336,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (now_task == WAVE_CMD && (command == WAVE_X || command == WAVE_Y || command == WAVE_Z)) {
|
||||
if (now_task == WAVE_CMD && (command == WAVE_X || command == WAVE_Y || command == WAVE_Z || command == WAVE_VOL_X || command == WAVE_VOL_Y || command == WAVE_VOL_Z)) {
|
||||
if (!CheckCrc(&UartRecvBuf[i], 99)) {
|
||||
zlog_warn(zct, "CheckCrc error ShortAddr :%s command = %d", strShortAddr.c_str(), command);
|
||||
char tmp[10] = {0x00};
|
||||
|
||||
@ -31,7 +31,10 @@ enum InteractiveCommand {
|
||||
WAVE_COMPRESS = 15, // 波形数据压缩
|
||||
UPGRADE_FIRMWARE = 16, //固件升级内容
|
||||
UPGRADE_ASK = 17, //固件升级请求
|
||||
WAVE_RESP = 18 // 波形数据回复
|
||||
WAVE_RESP = 18, // 波形数据回复
|
||||
WAVE_VOL_X = 19,
|
||||
WAVE_VOL_Y = 20,
|
||||
WAVE_VOL_Z = 21
|
||||
};
|
||||
|
||||
// 无线传感器请求任务
|
||||
@ -263,9 +266,15 @@ private:
|
||||
int m_waveCountX;
|
||||
int m_waveCountY;
|
||||
int m_waveCountZ;
|
||||
int m_waveCountVolX;
|
||||
int m_waveCountVolY;
|
||||
int m_waveCountVolZ;
|
||||
std::vector<RecvData> VecWaveDataX;
|
||||
std::vector<RecvData> VecWaveDataY;
|
||||
std::vector<RecvData> VecWaveDataZ;
|
||||
std::vector<RecvData> VecWaveDataVolX;
|
||||
std::vector<RecvData> VecWaveDataVolY;
|
||||
std::vector<RecvData> VecWaveDataVolZ;
|
||||
|
||||
uint8_t send_data[100];
|
||||
uint16_t last_short_addr;
|
||||
|
||||
@ -20,6 +20,9 @@ extern zlog_category_t *zbt;
|
||||
std::vector<RecvData> g_VecWaveDataX;
|
||||
std::vector<RecvData> g_VecWaveDataY;
|
||||
std::vector<RecvData> g_VecWaveDataZ;
|
||||
std::vector<RecvData> g_VecWaveDataVolX;
|
||||
std::vector<RecvData> g_VecWaveDataVolY;
|
||||
std::vector<RecvData> g_VecWaveDataVolZ;
|
||||
std::map<std::string, compressWaveChannel> g_mapCompress;
|
||||
std::map<std::string, WaveChannel> g_mapWaveChannel;
|
||||
|
||||
@ -366,6 +369,9 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
DataExtract(pRecvData, 24, lowbit, n);
|
||||
dataDymX.Amp5 = lowbit * n;
|
||||
|
||||
DataExtract(pRecvData, 84, lowbit, n);
|
||||
dataDymX.kurtosis = lowbit * n;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
dataDymX.EnvelopEnergy = 0;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
@ -384,14 +390,14 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-X").c_str());
|
||||
memset(updateSql, 0, 1024);
|
||||
sprintf(updateSql, "diagnosisPk='%f',integratPk='%f',integratRMS='%f',rmsValues='%f',envelopEnergy='%f',\
|
||||
Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d, nodeTimestamp = '%s' ",
|
||||
Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d, nodeTimestamp = '%s',kurtosis = '%f'",
|
||||
dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues, dataDymX.EnvelopEnergy, dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5, dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4,
|
||||
nowTimetamp.c_str(), staticIndex, nodeResend,nodetimestamp);
|
||||
nowTimetamp.c_str(), staticIndex, nodeResend,nodetimestamp,dataDymX.kurtosis);
|
||||
if ((Count * 3 < SAVE_COUNT && lTime < OneWeek) || strTime.size() == 0 || nodeResend != 0) { // 1 week
|
||||
char insertSql[1024] = {0};
|
||||
memset(insertSql, 0x00, sizeof(insertSql));
|
||||
sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d,'%s'", strMeasurementID.c_str(), (strMeasurementID + "-X").c_str(), dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues,
|
||||
dataDymX.EnvelopEnergy, dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5, dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4, staticIndex, nowTimetamp.c_str(), nodeResend,nodetimestamp);
|
||||
sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d,'%s','%f',0", strMeasurementID.c_str(), (strMeasurementID + "-X").c_str(), dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues,
|
||||
dataDymX.EnvelopEnergy, dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5, dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4, staticIndex, nowTimetamp.c_str(), nodeResend,nodetimestamp,dataDymX.kurtosis);
|
||||
sqlite_db_ctrl::instance().InsertData(szTableName, insertSql);
|
||||
|
||||
if (0 == sqlite_db_ctrl::instance().GetTableRows(T_DATA_INFO(TNAME), whereCon))
|
||||
@ -428,6 +434,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
valNodeFeature["Phase2"] = dataDymX.Phase2;
|
||||
valNodeFeature["Phase3"] = dataDymX.Phase3;
|
||||
valNodeFeature["Phase4"] = dataDymX.Phase4;
|
||||
valNodeFeature["kurtosis"] = dataDymX.kurtosis;
|
||||
valNodeFeature["timeStamp"] = localtimestamp;
|
||||
if (Feature_x)
|
||||
{
|
||||
@ -462,6 +469,9 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
DataExtract(pRecvData, 50, lowbit, n);
|
||||
dataDymY.Amp5 = lowbit * n;
|
||||
|
||||
DataExtract(pRecvData, 86, lowbit, n);
|
||||
dataDymY.kurtosis = lowbit * n;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
dataDymY.EnvelopEnergy = 0;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
@ -477,14 +487,14 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Y").c_str());
|
||||
memset(updateSql, 0, 1024);
|
||||
sprintf(updateSql, "diagnosisPk='%f',integratPk='%f',integratRMS='%f',rmsValues='%f',envelopEnergy='%f',\
|
||||
Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d, nodeTimestamp = '%s' ",
|
||||
Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d, nodeTimestamp = '%s',kurtosis = '%f' ",
|
||||
dataDymY.DiagnosisPk, dataDymY.IntegratPk, dataDymY.IntegratRMS, dataDymY.RmsValues, dataDymY.EnvelopEnergy, dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5, dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4,
|
||||
nowTimetamp.c_str(), staticIndex, nodeResend,nodetimestamp);
|
||||
nowTimetamp.c_str(), staticIndex, nodeResend,nodetimestamp,dataDymY.kurtosis);
|
||||
if (/*0 == sqlite_db_ctrl::instance().GetTableRows(T_DATA_INFO(TNAME), whereCon)*/ (Count * 3 < SAVE_COUNT && lTime < OneWeek) || strTime.size() == 0 ) {
|
||||
char insertSql[1024] = {0};
|
||||
memset(insertSql, 0x00, sizeof(insertSql));
|
||||
sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d,%s", strMeasurementID.c_str(), (strMeasurementID + "-Y").c_str(), dataDymY.DiagnosisPk, dataDymY.IntegratPk, dataDymY.IntegratRMS, dataDymY.RmsValues,
|
||||
dataDymY.EnvelopEnergy, dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5, dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4, staticIndex, nowTimetamp.c_str(), nodeResend,nodetimestamp);
|
||||
sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d,%s,%f,0", strMeasurementID.c_str(), (strMeasurementID + "-Y").c_str(), dataDymY.DiagnosisPk, dataDymY.IntegratPk, dataDymY.IntegratRMS, dataDymY.RmsValues,
|
||||
dataDymY.EnvelopEnergy, dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5, dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4, staticIndex, nowTimetamp.c_str(), nodeResend,nodetimestamp,dataDymY.kurtosis);
|
||||
sqlite_db_ctrl::instance().InsertData(szTableName, insertSql);
|
||||
|
||||
if (0 == sqlite_db_ctrl::instance().GetTableRows(T_DATA_INFO(TNAME), whereCon))
|
||||
@ -499,8 +509,8 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Y").c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon);
|
||||
}
|
||||
zlog_info(zct, "y: %s,%s,diagnosisPk=%f,integratPk=%f,integratRMS=%f,rmsValues=%f,envelopEnergy=%f,Amp1=%f,Amp2=%f,Amp3=%f,Amp4=%f,Amp5=%f,Phase1=%f,Phase2=%f,Phase3=%f,Phase4=%f,timeStamp=%s", strMeasurementID.c_str(), (strMeasurementID + "-Y").c_str(), dataDymY.DiagnosisPk,
|
||||
dataDymY.IntegratPk, dataDymY.IntegratRMS, dataDymY.RmsValues, dataDymY.EnvelopEnergy, dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5, dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4, nowTimetamp.c_str());
|
||||
zlog_info(zct, "y: %s,%s,diagnosisPk=%f,integratPk=%f,integratRMS=%f,rmsValues=%f,envelopEnergy=%f,Amp1=%f,Amp2=%f,Amp3=%f,Amp4=%f,Amp5=%f,Phase1=%f,Phase2=%f,Phase3=%f,Phase4=%f,timeStamp=%s,,kurtosis = %f", strMeasurementID.c_str(), (strMeasurementID + "-Y").c_str(), dataDymY.DiagnosisPk,
|
||||
dataDymY.IntegratPk, dataDymY.IntegratRMS, dataDymY.RmsValues, dataDymY.EnvelopEnergy, dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5, dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4, nowTimetamp.c_str(),dataDymY.kurtosis);
|
||||
|
||||
valNodeFeature["dataNodeNo"] = strMeasurementID;
|
||||
valNodeFeature["ChannelId"] = strMeasurementID + "-Y";
|
||||
@ -518,6 +528,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
valNodeFeature["Phase2"] = dataDymY.Phase2;
|
||||
valNodeFeature["Phase3"] = dataDymY.Phase3;
|
||||
valNodeFeature["Phase4"] = dataDymY.Phase4;
|
||||
valNodeFeature["kurtosis"] = dataDymY.kurtosis;
|
||||
valNodeFeature["timeStamp"] = localtimestamp;
|
||||
if (Feature_y)
|
||||
{
|
||||
@ -567,19 +578,26 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
DataExtract(pRecvData, 78, lowbit, n);
|
||||
dataDymZ.Phase4 = lowbit * n;
|
||||
|
||||
DataExtract(pRecvData, 88, lowbit, n);
|
||||
dataDymZ.kurtosis = lowbit * n;
|
||||
|
||||
DataExtract(pRecvData, 90, lowbit, n);
|
||||
dataDymZ.IntegratRMSMENS = lowbit * n;
|
||||
|
||||
|
||||
memset(whereCon, 0, 1024);
|
||||
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Z").c_str());
|
||||
memset(updateSql, 0, 1024);
|
||||
|
||||
sprintf(updateSql, "diagnosisPk='%f',integratPk='%f',integratRMS='%f',rmsValues='%f',envelopEnergy='%f',\
|
||||
Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d, nodeTimestamp = '%s' ",
|
||||
Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d, nodeTimestamp = '%s',kurtosis = '%f',integratRMSMENS = '%f' ",
|
||||
dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, dataDymZ.EnvelopEnergy, dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5, dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4,
|
||||
nowTimetamp.c_str(), staticIndex, nodeResend,nodetimestamp);
|
||||
nowTimetamp.c_str(), staticIndex, nodeResend,nodetimestamp,dataDymZ.kurtosis,dataDymZ.IntegratRMSMENS);
|
||||
if (/*0 == sqlite_db_ctrl::instance().GetTableRows(T_DATA_INFO(TNAME), whereCon)*/ (Count * 3 < SAVE_COUNT && lTime < OneWeek) || strTime.size() == 0 ) {
|
||||
char insertSql[1024] = {0};
|
||||
memset(insertSql, 0x00, sizeof(insertSql));
|
||||
sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d,'%s'", strMeasurementID.c_str(), (strMeasurementID + "-Z").c_str(), dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues,
|
||||
dataDymZ.EnvelopEnergy, dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5, dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, staticIndex, nowTimetamp.c_str(), nodeResend,nodetimestamp);
|
||||
sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d,'%s','%f','%f'", strMeasurementID.c_str(), (strMeasurementID + "-Z").c_str(), dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues,
|
||||
dataDymZ.EnvelopEnergy, dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5, dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, staticIndex, nowTimetamp.c_str(), nodeResend,nodetimestamp,dataDymZ.kurtosis,dataDymZ.IntegratRMSMENS);
|
||||
sqlite_db_ctrl::instance().InsertData(szTableName, insertSql);
|
||||
|
||||
if (0 == sqlite_db_ctrl::instance().GetTableRows(T_DATA_INFO(TNAME), whereCon))
|
||||
@ -594,8 +612,8 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Z").c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon);
|
||||
}
|
||||
zlog_info(zct, "Z: %s,%s,diagnosisPk=%f,integratPk=%f,integratRMS=%f,rmsValues=%f,envelopEnergy=%f,Amp1=%f,Amp2=%f,Amp3=%f,Amp4=%f,Amp5=%f,Phase1=%f,Phase2=%f,Phase3=%f,Phase4=%f,timeStamp=%s", strMeasurementID.c_str(), (strMeasurementID + "-Z").c_str(), dataDymZ.DiagnosisPk,
|
||||
dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, dataDymZ.EnvelopEnergy, dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5, dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, nowTimetamp.c_str());
|
||||
zlog_info(zct, "Z: %s,%s,diagnosisPk=%f,integratPk=%f,integratRMS=%f,rmsValues=%f,envelopEnergy=%f,Amp1=%f,Amp2=%f,Amp3=%f,Amp4=%f,Amp5=%f,Phase1=%f,Phase2=%f,Phase3=%f,Phase4=%f,timeStamp=%s,kurtosis = %f,integratRMSMENS = %f", strMeasurementID.c_str(), (strMeasurementID + "-Z").c_str(), dataDymZ.DiagnosisPk,
|
||||
dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, dataDymZ.EnvelopEnergy, dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5, dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, nowTimetamp.c_str(),dataDymZ.kurtosis,dataDymZ.IntegratRMSMENS);
|
||||
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
sprintf(whereCon, "MeasurementID='%s'", strMeasurementID.c_str());
|
||||
@ -618,6 +636,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
valNodeFeature["Phase2"] = dataDymZ.Phase2;
|
||||
valNodeFeature["Phase3"] = dataDymZ.Phase3;
|
||||
valNodeFeature["Phase4"] = dataDymZ.Phase4;
|
||||
valNodeFeature["kurtosis"] = dataDymZ.kurtosis;
|
||||
valNodeFeature["timeStamp"] = localtimestamp;
|
||||
if (Feature_z)
|
||||
{
|
||||
@ -696,6 +715,12 @@ void Uart::DealDataNodeWave(const char *pData, int comand) {
|
||||
VecWaveDataY.push_back(*pRecvData);
|
||||
} else if (comand == WAVE_Z) {
|
||||
VecWaveDataZ.push_back(*pRecvData);
|
||||
}else if (comand == WAVE_VOL_X) {
|
||||
VecWaveDataVolX.push_back(*pRecvData);
|
||||
}else if (comand == WAVE_VOL_Y) {
|
||||
VecWaveDataVolY.push_back(*pRecvData);
|
||||
}else if (comand == WAVE_VOL_Z) {
|
||||
VecWaveDataVolZ.push_back(*pRecvData);
|
||||
}
|
||||
} else {
|
||||
if (comand == WAVE_X) {
|
||||
@ -707,6 +732,15 @@ void Uart::DealDataNodeWave(const char *pData, int comand) {
|
||||
} else if (comand == WAVE_Z) {
|
||||
g_VecWaveDataZ[m_waveCountZ] = *pRecvData;
|
||||
m_waveCountZ++;
|
||||
}else if (comand == WAVE_VOL_X) {
|
||||
g_VecWaveDataVolX[m_waveCountVolX] = *pRecvData;
|
||||
m_waveCountVolX++;
|
||||
}else if (comand == WAVE_VOL_Y) {
|
||||
g_VecWaveDataVolY[m_waveCountVolY] = *pRecvData;
|
||||
m_waveCountVolY++;
|
||||
}else if (comand == WAVE_VOL_Z) {
|
||||
g_VecWaveDataVolZ[m_waveCountVolZ] = *pRecvData;
|
||||
m_waveCountVolZ++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -784,6 +818,54 @@ std::vector<float> Uart::DealData(int iChannel, float coe, unsigned int sampleRa
|
||||
compress = g_mapCompress[strShortAddr].compressChannelZ;
|
||||
count = g_mapCompress[strShortAddr].CountZ;
|
||||
}
|
||||
if (iChannel == WAVE_VOL_X) {
|
||||
if (VecWaveDataVolX.size() > 0) {
|
||||
g_VecWaveDataVolX.assign(VecWaveDataVolX.begin(), VecWaveDataVolX.end());
|
||||
waveCount = VecWaveDataVolX.size();
|
||||
}
|
||||
waveCount = m_waveCountVolX;
|
||||
for (; j < waveCount; j++) {
|
||||
RecvData recvData = g_VecWaveDataVolX[j];
|
||||
memcpy(data + j * 92, recvData.Data, 92);
|
||||
}
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
sprintf(buf, "%02x%02x", g_VecWaveDataVolX[0].ShortAddr[0], g_VecWaveDataVolX[0].ShortAddr[1]);
|
||||
strShortAddr = std::string(buf);
|
||||
compress = g_mapCompress[strShortAddr].compressChannelVolX;
|
||||
count = g_mapCompress[strShortAddr].CountVolX;
|
||||
}
|
||||
if (iChannel == WAVE_VOL_Y) {
|
||||
if (VecWaveDataVolY.size() > 0) {
|
||||
g_VecWaveDataVolY.assign(VecWaveDataVolY.begin(), VecWaveDataVolY.end());
|
||||
waveCount = VecWaveDataVolY.size();
|
||||
}
|
||||
waveCount = m_waveCountVolY;
|
||||
for (; j < waveCount; j++) {
|
||||
RecvData recvData = g_VecWaveDataVolY[j];
|
||||
memcpy(data + j * 92, recvData.Data, 92);
|
||||
}
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
sprintf(buf, "%02x%02x", g_VecWaveDataVolY[0].ShortAddr[0], g_VecWaveDataVolY[0].ShortAddr[1]);
|
||||
strShortAddr = std::string(buf);
|
||||
compress = g_mapCompress[strShortAddr].compressChannelVolY;
|
||||
count = g_mapCompress[strShortAddr].CountVolY;
|
||||
}
|
||||
if (iChannel == WAVE_VOL_Z) {
|
||||
if (VecWaveDataVolZ.size() > 0) {
|
||||
g_VecWaveDataVolZ.assign(VecWaveDataVolZ.begin(), VecWaveDataVolZ.end());
|
||||
waveCount = VecWaveDataVolZ.size();
|
||||
}
|
||||
waveCount = m_waveCountVolZ;
|
||||
for (; j < waveCount; j++) {
|
||||
RecvData recvData = g_VecWaveDataVolZ[j];
|
||||
memcpy(data + j * 92, recvData.Data, 92);
|
||||
}
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
sprintf(buf, "%02x%02x", g_VecWaveDataVolZ[0].ShortAddr[0], g_VecWaveDataVolZ[0].ShortAddr[1]);
|
||||
strShortAddr = std::string(buf);
|
||||
compress = g_mapCompress[strShortAddr].compressChannelVolZ;
|
||||
count = g_mapCompress[strShortAddr].CountVolZ;
|
||||
}
|
||||
zlog_info(zct, "len = %d,data = %02x,iChannel = %d,compress = %d,count = %d", j, data[0], iChannel, compress, count);
|
||||
if (j * 92 < count) return vecData;
|
||||
|
||||
@ -852,6 +934,7 @@ void Uart::DealWave() {
|
||||
std::string strFileName = "";
|
||||
std::string strProduct = "";
|
||||
std::vector<float> vecDataX, vecDataY, vecDataZ;
|
||||
bool z = false;
|
||||
if (wave_trans_) { //对每个传感器的每个通道进行遍历然后处理数据,例如:传感器1x轴的数据处理完后,再去处理y轴的。传感器1的所有数据处理完后,再处理传感器2的
|
||||
|
||||
char getzigbeeShortAddr[32] = {0}, tableName[64] = {0}, whereCon[128] = {0};
|
||||
@ -942,7 +1025,7 @@ void Uart::DealWave() {
|
||||
(vecDataY.size() <= 0 && g_mapCompress[strShortAddr].CountY > 0) ||
|
||||
(vecDataZ.size() <= 0 && g_mapCompress[strShortAddr].CountZ > 0))
|
||||
{
|
||||
int iRet = scheduler::instance().WaveError(wave_shortAddr);
|
||||
int iRet = scheduler::instance().WaveError(wave_shortAddr,z);
|
||||
if (iRet != 0) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
char updateSql[1024] = { 0 };
|
||||
@ -954,18 +1037,17 @@ void Uart::DealWave() {
|
||||
(vecDataY.size() > 0 && g_mapCompress[strShortAddr].CountY > 0) ||
|
||||
(vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0))
|
||||
{
|
||||
int iRet = scheduler::instance().WaveSuccess(wave_shortAddr);
|
||||
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);
|
||||
}
|
||||
scheduler::instance().WaveSuccess(wave_shortAddr,z);
|
||||
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 && g_mapCompress[strShortAddr].CountZ <= 0)
|
||||
{
|
||||
int iRet = scheduler::instance().WaveError(wave_shortAddr);
|
||||
int iRet = scheduler::instance().WaveError(wave_shortAddr,z);
|
||||
if (iRet != 0) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
char updateSql[1024] = { 0 };
|
||||
|
||||
@ -50,7 +50,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
char insertSql[100] = {0};
|
||||
char wherecon[100] = {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));
|
||||
std::string spend_count = sqlite_db_ctrl::instance().GetData(" firmware_upgrade ","spend_count",wherecon);
|
||||
if (atoi(spend_count.c_str()) >= 10){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user