add web code and add data sql
This commit is contained in:
parent
0de695ed4c
commit
6a0fcb53e9
@ -381,27 +381,53 @@ struct Param_67 {
|
|||||||
Param_67() : mMode(0),mPackageFlag(0){};
|
Param_67() : mMode(0),mPackageFlag(0){};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//0 关闭,1 开启
|
||||||
|
//0 加速度有效值,1 速度有效值
|
||||||
|
struct Param_68_info{
|
||||||
|
std::string measurementID;
|
||||||
|
int status; //0 关闭,1 开启
|
||||||
|
int statisticType; //0 加速度有效值,1 速度有效值
|
||||||
|
float threshold;
|
||||||
|
Param_68_info():measurementID(""),status(0),statisticType(0),threshold(0.0){};
|
||||||
|
};
|
||||||
|
|
||||||
struct Param_68 {
|
struct Param_68 {
|
||||||
|
int mMode;
|
||||||
int lowSignal;
|
int lowSignal;
|
||||||
int signalThreshold;
|
int signalThreshold;
|
||||||
int lowBatteryLevel;
|
int lowBatteryLevel;
|
||||||
int batteryThreshold;
|
int batteryLevelThreshold;
|
||||||
Param_68():lowSignal(0),signalThreshold(0),lowBatteryLevel(0),batteryThreshold(0){};
|
std::vector<Param_68_info> vecParam68;
|
||||||
|
Param_68():lowSignal(0),signalThreshold(0),lowBatteryLevel(0),batteryLevelThreshold(0){};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Param_69_info{
|
||||||
|
std::string measurementID;
|
||||||
|
int status; //0 关闭,1 开启
|
||||||
|
int trigerType; //0 单次触发,1 多次触发
|
||||||
|
int statisticType; //0 加速度有效值,1 速度有效值
|
||||||
|
float threshold;
|
||||||
|
Param_69_info():measurementID(""),status(0),trigerType(0),statisticType(0),threshold(0.0){};
|
||||||
|
};
|
||||||
struct Param_69{
|
struct Param_69{
|
||||||
int threshold;
|
int mMode;
|
||||||
Param_69():threshold(0){};
|
bool trigerThresholdEnable;
|
||||||
|
std::vector<Param_69_info> vecParam69;
|
||||||
|
Param_69():mMode(0),trigerThresholdEnable(0){};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Param_70{
|
struct Param_70{
|
||||||
int mPackageFlag;
|
int mPackageFlag;
|
||||||
Param_70():mPackageFlag(0){};
|
std::string timeStart;
|
||||||
|
std::string timeEnd;
|
||||||
|
Param_70():mPackageFlag(0),timeStart(""),timeEnd(""){};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Param_71{
|
struct Param_71{
|
||||||
int mPackageFlag;
|
int mPackageFlag;
|
||||||
Param_71():mPackageFlag(0){};
|
std::string timeStart;
|
||||||
|
std::string timeEnd;
|
||||||
|
Param_71():mPackageFlag(0),timeStart(""),timeEnd(""){};
|
||||||
};
|
};
|
||||||
|
|
||||||
// 无线温度传感器(蓝牙)
|
// 无线温度传感器(蓝牙)
|
||||||
|
|||||||
@ -286,6 +286,16 @@ void SqliteDB::SqliteInit(const char *pDbName) {
|
|||||||
|
|
||||||
execute_sql_file("/opt/configenv/t_sensor_bt_info.sql");
|
execute_sql_file("/opt/configenv/t_sensor_bt_info.sql");
|
||||||
|
|
||||||
|
execute_sql_file("/opt/configenv/t_system_info.sql");
|
||||||
|
|
||||||
|
execute_sql_file("/opt/configenv/t_process_info.sql");
|
||||||
|
|
||||||
|
execute_sql_file("/opt/configenv/t_wave_upload_rule_info.sql");
|
||||||
|
|
||||||
|
execute_sql_file("/opt/configenv/t_wave_triger_info.sql");
|
||||||
|
|
||||||
|
execute_sql_file("/opt/configenv/t_debug_info.sql");
|
||||||
|
|
||||||
vec_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), "MeasurementID", NULL);
|
vec_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), "MeasurementID", NULL);
|
||||||
for(size_t i = 0; i < vetRes.size() && vetRes.size() > 0; i++){
|
for(size_t i = 0; i < vetRes.size() && vetRes.size() > 0; i++){
|
||||||
std::string strMeasurementID = boost::algorithm::trim_copy(vetRes[i]);
|
std::string strMeasurementID = boost::algorithm::trim_copy(vetRes[i]);
|
||||||
@ -1452,6 +1462,21 @@ int SqliteDB::ClearExpireData(){
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int SqliteDB::SaveSystemHardStatus(){
|
||||||
|
Json::Value jsData;
|
||||||
|
std::string sysStatus = GetSysStatus(jsData);
|
||||||
|
char insertSql[1024] = {0};
|
||||||
|
int mem_use = jsData["memoryUse"].asInt();
|
||||||
|
int mem_free = jsData["memoryFree"].asInt();
|
||||||
|
int mem_total = jsData["memoryTotal"].asInt();
|
||||||
|
float mem_rate = float(mem_use / mem_total);
|
||||||
|
float disk_free = jsData["hardDiskFree"].asDouble();
|
||||||
|
float disk_total = jsData["hardDiskTotal"].asDouble();
|
||||||
|
float disk_use = jsData["hardDiskUse"].asDouble();
|
||||||
|
sprintf(insertSql, " '%s','%d','%d','%d','%f','%f','%f','%f','%s'",
|
||||||
|
jsData["cpuUserUse"].asString(),mem_use,mem_free,mem_rate,disk_use,disk_free,disk_use/disk_total,jsData["temperature"].asDouble(),jsData["updateTime"].asString());
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_system_info", insertSql);
|
||||||
|
}
|
||||||
int SqliteDB::TransBegin() { return sqlite3_exec(mDBAcess, "begin;", 0, 0, 0); }
|
int SqliteDB::TransBegin() { return sqlite3_exec(mDBAcess, "begin;", 0, 0, 0); }
|
||||||
|
|
||||||
int SqliteDB::TransRollback() { return sqlite3_exec(mDBAcess, "rollback;", 0, 0, 0); }
|
int SqliteDB::TransRollback() { return sqlite3_exec(mDBAcess, "rollback;", 0, 0, 0); }
|
||||||
|
|||||||
@ -72,6 +72,7 @@ public:
|
|||||||
int InintGateway();
|
int InintGateway();
|
||||||
int QueryofflineData();
|
int QueryofflineData();
|
||||||
int ClearExpireData();
|
int ClearExpireData();
|
||||||
|
int SaveSystemHardStatus();
|
||||||
std::string GetNodeConfigureInfor(const char *whereCon);
|
std::string GetNodeConfigureInfor(const char *whereCon);
|
||||||
int CloseDB();
|
int CloseDB();
|
||||||
|
|
||||||
|
|||||||
@ -240,6 +240,11 @@ std::string JsonData::JsonCmd_Cgi_27(std::vector<Param_27> ¶m) {
|
|||||||
sqlite_db_ctrl::instance().DeleteTableData(T_BATTERY_INFO(TNAME), whereCon);
|
sqlite_db_ctrl::instance().DeleteTableData(T_BATTERY_INFO(TNAME), whereCon);
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(" t_battery_history ", whereCon);
|
sqlite_db_ctrl::instance().DeleteTableData(" t_battery_history ", whereCon);
|
||||||
memset(whereCon,0,sizeof(whereCon));
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
|
sprintf(whereCon, "MeasurementID = '%s'", param[i].mMeasurementID.c_str());
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(" t_debug_info ", whereCon);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(" t_wave_upload_rule_info ", whereCon);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(" t_wave_triger_info ", whereCon);
|
||||||
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
sprintf(whereCon, "channelID like '%%%s%%'", param[i].mMeasurementID.c_str());
|
sprintf(whereCon, "channelID like '%%%s%%'", param[i].mMeasurementID.c_str());
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(" t_data_waveSend ", whereCon);
|
sqlite_db_ctrl::instance().DeleteTableData(" t_data_waveSend ", whereCon);
|
||||||
char szTableName[50] = {0x00};
|
char szTableName[50] = {0x00};
|
||||||
|
|||||||
@ -1272,7 +1272,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
|||||||
for (int i = packgeNo * 10; i < packgeNum; i++) {
|
for (int i = packgeNo * 10; i < packgeNum; i++) {
|
||||||
std::string strMeasurementID = arrResAll[i][1];
|
std::string strMeasurementID = arrResAll[i][1];
|
||||||
std::string strShortAddr = arrResAll[i][2];
|
std::string strShortAddr = arrResAll[i][2];
|
||||||
char whereCon[512] = {};
|
char whereCon[512] = {0};
|
||||||
char selectCon[128] = {0};
|
char selectCon[128] = {0};
|
||||||
char column[128] = {0};
|
char column[128] = {0};
|
||||||
char tablename[256] = {0};
|
char tablename[256] = {0};
|
||||||
@ -1294,7 +1294,8 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
|||||||
jsChannelData["comprehensiveRssi"] = atof(arrRes[j][4].c_str());
|
jsChannelData["comprehensiveRssi"] = atof(arrRes[j][4].c_str());
|
||||||
jsChannelData["minimumVoltage"] = atof(arrRes[j][5].c_str());
|
jsChannelData["minimumVoltage"] = atof(arrRes[j][5].c_str());
|
||||||
jsChannelData["currentBatteryLevel"] = atof(arrRes[j][6].c_str());
|
jsChannelData["currentBatteryLevel"] = atof(arrRes[j][6].c_str());
|
||||||
jsChannelData["TimeStamp"] = arrRes[j][7];
|
jsChannelData["debugStatus"] = atoi(arrRes[j][7].c_str());
|
||||||
|
jsChannelData["TimeStamp"] = arrRes[j][8];
|
||||||
jsSensor.append(jsChannelData);
|
jsSensor.append(jsChannelData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1310,20 +1311,246 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
|||||||
jsonVal["content"].resize(0);
|
jsonVal["content"].resize(0);
|
||||||
}
|
}
|
||||||
}else if(param.mMode == 1){//启动传感器调试
|
}else if(param.mMode == 1){//启动传感器调试
|
||||||
|
if(param.measurementID.size() > 0){
|
||||||
|
for (size_t i = 0; i < param.measurementID.size(); i++)
|
||||||
|
{
|
||||||
|
char whereCon[512] = {0};
|
||||||
|
char updateSql[256] = {0};
|
||||||
|
sprintf(whereCon, " MeasurementID = '%s' ", param.measurementID[i].c_str());
|
||||||
|
sprintf(updateSql, " status = '%d' ", 1);// 0 未调试,1 调试中,2 调试完成
|
||||||
|
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
||||||
|
//uint16_t short_addr;
|
||||||
|
//char *end_ptr = NULL;
|
||||||
|
//vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " zigbeeShortAddr ", whereCon);
|
||||||
|
//short_addr = strtol(vecResult[0].c_str(), &end_ptr, 16);
|
||||||
|
//scheduler::instance().StartSensorDebug(short_addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return show_value_.write(jsonVal);
|
return show_value_.write(jsonVal);
|
||||||
}
|
}
|
||||||
std::string JsonData::JsonCmd_Cgi_68(Param_68 ¶m){
|
std::string JsonData::JsonCmd_Cgi_68(Param_68 ¶m){
|
||||||
|
Json::Value jsonVal;
|
||||||
|
Json::Value dataNodeArray;
|
||||||
|
jsonVal.clear();
|
||||||
|
|
||||||
|
jsonVal[JSON_FIELD_CMD] = "68";
|
||||||
|
jsonVal["success"] = true;
|
||||||
|
jsonVal["message"] = " ";
|
||||||
|
int lowSignal = -1, signalThreshold = -1, lowBatteryLevel = -1, batteryLevelThreshold = -1;
|
||||||
|
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());
|
||||||
|
lowBatteryLevel = writeIntValue("config", "lowBatteryLevel", param.lowBatteryLevel, (char *)GlobalConfig::Config_G.c_str());
|
||||||
|
batteryLevelThreshold = writeIntValue("config", "batteryLevelThreshold", param.batteryLevelThreshold, (char *)GlobalConfig::Config_G.c_str());
|
||||||
|
|
||||||
|
if(param.vecParam68.size() > 0){
|
||||||
|
for (size_t i = 0; i < param.vecParam68.size(); i++)
|
||||||
|
{
|
||||||
|
char whereCon[512] = {0};
|
||||||
|
char updateSql[256] = {0};
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (param.mMode == 0) {
|
||||||
|
lowSignal = readIntValue("config", "lowSignal", (char *)GlobalConfig::Config_G.c_str());
|
||||||
|
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);
|
||||||
|
if (arrRes.size() > 0) {
|
||||||
|
for (size_t i = 0; i < arrRes.size(); i++)
|
||||||
|
{
|
||||||
|
Json::Value iTem;
|
||||||
|
iTem.append(arrRes[i][0]);
|
||||||
|
iTem.append(atoi(arrRes[i][2].c_str()));
|
||||||
|
iTem.append(atoi(arrRes[i][3].c_str()));
|
||||||
|
iTem.append(atof(arrRes[i][4].c_str()));
|
||||||
|
dataNodeArray.append(iTem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dataNodeArray.size() == 0) {
|
||||||
|
jsonVal["success"] = false;
|
||||||
|
jsonVal["content"].resize(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
jsonVal["content"]["lowSignal"] = lowSignal;
|
||||||
|
jsonVal["content"]["signalThreshold"] = signalThreshold;
|
||||||
|
jsonVal["content"]["lowBatteryLevel"] = lowBatteryLevel;
|
||||||
|
jsonVal["content"]["batteryLevelThreshold"] = batteryLevelThreshold;
|
||||||
|
jsonVal["content"]["dataNodeArray"] = dataNodeArray;
|
||||||
|
return show_value_.write(jsonVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string JsonData::JsonCmd_Cgi_69(Param_69 ¶m){
|
std::string JsonData::JsonCmd_Cgi_69(Param_69 ¶m){
|
||||||
|
Json::Value jsonVal;
|
||||||
|
Json::Value dataNodeArray;
|
||||||
|
jsonVal.clear();
|
||||||
|
|
||||||
|
jsonVal[JSON_FIELD_CMD] = "69";
|
||||||
|
jsonVal["success"] = true;
|
||||||
|
jsonVal["message"] = " ";
|
||||||
|
int trigerThresholdEnable = -1;
|
||||||
|
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};
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} 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);
|
||||||
|
if (arrRes.size() > 0) {
|
||||||
|
for (size_t i = 0; i < arrRes.size(); i++)
|
||||||
|
{
|
||||||
|
Json::Value iTem;
|
||||||
|
iTem.append(arrRes[i][0]);
|
||||||
|
iTem.append(atoi(arrRes[i][2].c_str()));
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dataNodeArray.size() == 0) {
|
||||||
|
jsonVal["success"] = false;
|
||||||
|
jsonVal["content"].resize(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsonVal["content"]["trigerThresholdEnable"] = trigerThresholdEnable;
|
||||||
|
return show_value_.write(jsonVal);
|
||||||
}
|
}
|
||||||
std::string JsonData::JsonCmd_Cgi_70(Param_70 ¶m){
|
std::string JsonData::JsonCmd_Cgi_70(Param_70 ¶m){
|
||||||
|
Json::Value jsonVal;
|
||||||
|
Json::Value dataNodeArray;
|
||||||
|
jsonVal.clear();
|
||||||
|
|
||||||
|
jsonVal[JSON_FIELD_CMD] = "70";
|
||||||
|
jsonVal["success"] = true;
|
||||||
|
jsonVal["message"] = " ";
|
||||||
|
char selectCon[256] = {0}, szTableName[100] = {0x00}, whereCon[256] = {0x00};
|
||||||
|
sprintf(szTableName,"t_abnormal_info");
|
||||||
|
int rows = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon);
|
||||||
|
int packgeNo = param.mPackageFlag;
|
||||||
|
int packgeMax = 0;
|
||||||
|
int packgeNum = 0;
|
||||||
|
jsonVal["package"] = packgeNo;
|
||||||
|
int lastSize = rows % 550;
|
||||||
|
int index = rows / 550;
|
||||||
|
if (lastSize > 0 && index > 0) {
|
||||||
|
packgeMax = index + 1;
|
||||||
|
if (packgeNo + 1 == packgeMax) {
|
||||||
|
packgeNum = rows - lastSize;
|
||||||
|
jsonVal["packageMax"] = index + 1;
|
||||||
|
} else {
|
||||||
|
packgeNum = (packgeNo)*550;
|
||||||
|
jsonVal["packageMax"] = index + 1;
|
||||||
|
}
|
||||||
|
} else if (lastSize == 0 && index > 0) {
|
||||||
|
packgeNum = (packgeNo + 1) * 550;
|
||||||
|
packgeMax = index;
|
||||||
|
jsonVal["packageMax"] = index;
|
||||||
|
} else if (lastSize > 0 && index == 0) {
|
||||||
|
packgeNum = 0;
|
||||||
|
packgeMax = index + 1;
|
||||||
|
jsonVal["packageMax"] = index;
|
||||||
|
}
|
||||||
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
|
sprintf(whereCon, "timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||||
|
array_t vecRes;
|
||||||
|
vecRes = sqlite_db_ctrl::instance().GetDataMultiLine(szTableName, "*", whereCon);
|
||||||
|
zlog_info(zct, "vecRes = %d", vecRes.size());
|
||||||
|
if (vecRes.size() > 0) {
|
||||||
|
Json::Value jsStaticData;
|
||||||
|
for (size_t i = 0; i < vecRes.size(); i++) {
|
||||||
|
Json::Value iTem;
|
||||||
|
iTem.append(vecRes[i][2]);
|
||||||
|
iTem.append(vecRes[i][0]);
|
||||||
|
iTem.append(vecRes[i][1]);
|
||||||
|
jsStaticData.append(iTem);
|
||||||
|
}
|
||||||
|
if (jsStaticData.size() == 0) {
|
||||||
|
jsonVal["success"] = false;
|
||||||
|
jsonVal["content"].resize(0);
|
||||||
|
} else {
|
||||||
|
jsonVal["content"] = jsStaticData;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jsonVal["success"] = false;
|
||||||
|
jsonVal["content"].resize(0);
|
||||||
|
}
|
||||||
|
return show_value_.write(jsonVal);
|
||||||
}
|
}
|
||||||
std::string JsonData::JsonCmd_Cgi_71(Param_71 ¶m){
|
std::string JsonData::JsonCmd_Cgi_71(Param_71 ¶m){
|
||||||
|
Json::Value jsonVal;
|
||||||
|
Json::Value dataNodeArray;
|
||||||
|
jsonVal.clear();
|
||||||
|
|
||||||
|
jsonVal[JSON_FIELD_CMD] = "71";
|
||||||
|
jsonVal["success"] = true;
|
||||||
|
jsonVal["message"] = " ";
|
||||||
|
char selectCon[256] = {0}, szTableName[100] = {0x00}, whereCon[256] = {0x00};
|
||||||
|
sprintf(szTableName,"t_system_info");
|
||||||
|
int rows = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon);
|
||||||
|
int packgeNo = param.mPackageFlag;
|
||||||
|
int packgeMax = 0;
|
||||||
|
int packgeNum = 0;
|
||||||
|
jsonVal["package"] = packgeNo;
|
||||||
|
int lastSize = rows % 550;
|
||||||
|
int index = rows / 550;
|
||||||
|
if (lastSize > 0 && index > 0) {
|
||||||
|
packgeMax = index + 1;
|
||||||
|
if (packgeNo + 1 == packgeMax) {
|
||||||
|
packgeNum = rows - lastSize;
|
||||||
|
jsonVal["packageMax"] = index + 1;
|
||||||
|
} else {
|
||||||
|
packgeNum = (packgeNo)*550;
|
||||||
|
jsonVal["packageMax"] = index + 1;
|
||||||
|
}
|
||||||
|
} else if (lastSize == 0 && index > 0) {
|
||||||
|
packgeNum = (packgeNo + 1) * 550;
|
||||||
|
packgeMax = index;
|
||||||
|
jsonVal["packageMax"] = index;
|
||||||
|
} else if (lastSize > 0 && index == 0) {
|
||||||
|
packgeNum = 0;
|
||||||
|
packgeMax = index + 1;
|
||||||
|
jsonVal["packageMax"] = index;
|
||||||
|
}
|
||||||
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
|
sprintf(whereCon, "timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||||
|
array_t vecRes;
|
||||||
|
vecRes = sqlite_db_ctrl::instance().GetDataMultiLine(szTableName, "*", whereCon);
|
||||||
|
zlog_info(zct, "vecRes = %d", vecRes.size());
|
||||||
|
if (vecRes.size() > 0) {
|
||||||
|
Json::Value jsStaticData;
|
||||||
|
for (size_t i = 0; i < vecRes.size(); i++) {
|
||||||
|
Json::Value iTem;
|
||||||
|
iTem.append(vecRes[i][10]);
|
||||||
|
iTem.append(vecRes[i][2]);
|
||||||
|
iTem.append(vecRes[i][5]);
|
||||||
|
iTem.append(vecRes[i][8]);
|
||||||
|
iTem.append(vecRes[i][9]);
|
||||||
|
jsStaticData.append(iTem);
|
||||||
|
}
|
||||||
|
if (jsStaticData.size() == 0) {
|
||||||
|
jsonVal["success"] = false;
|
||||||
|
jsonVal["content"].resize(0);
|
||||||
|
} else {
|
||||||
|
jsonVal["content"] = jsStaticData;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jsonVal["success"] = false;
|
||||||
|
jsonVal["content"].resize(0);
|
||||||
|
}
|
||||||
|
return show_value_.write(jsonVal);
|
||||||
}
|
}
|
||||||
@ -562,11 +562,80 @@ std::string LocalServer::HandleCgi_cmd(std::string &pData) {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case KWaveRule:{
|
||||||
|
JsonData jd;
|
||||||
|
Param_68 param;
|
||||||
|
std::string type = recvBody["type"].asString();
|
||||||
|
if (0 == type.compare("SET")) {
|
||||||
|
param.mMode = 1;
|
||||||
|
}else if (0 == type.compare("GET")) {
|
||||||
|
param.mMode = 0;
|
||||||
|
}
|
||||||
|
param.lowSignal = recvBody["lowSignal"].asInt();
|
||||||
|
param.signalThreshold = recvBody["signalThreshold"].asInt();
|
||||||
|
param.lowBatteryLevel = recvBody["lowBatteryLevel"].asInt();
|
||||||
|
param.batteryLevelThreshold = recvBody["batteryLevelThreshold"].asInt();
|
||||||
|
Json::Value recvDataNodeNo = recvBody["DataNodeNo"];
|
||||||
|
if (recvDataNodeNo.size() > 0)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < recvDataNodeNo.size(); i++) {
|
||||||
|
Param_68_info vecParam;
|
||||||
|
for (size_t j = 0; j < recvDataNodeNo[i].size(); j++)
|
||||||
|
{
|
||||||
|
vecParam.measurementID = recvDataNodeNo[i][j].asString();
|
||||||
|
vecParam.status = recvDataNodeNo[i][j].asInt();
|
||||||
|
vecParam.statisticType = recvDataNodeNo[i][j].asInt();
|
||||||
|
vecParam.threshold = recvDataNodeNo[i][j].asDouble();
|
||||||
|
}
|
||||||
|
param.vecParam68.push_back(vecParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string data = jd.JsonCmd_Cgi_68(param);
|
||||||
|
return data;
|
||||||
|
}break;
|
||||||
|
case KTrigerWaveUpload:{
|
||||||
|
JsonData jd;
|
||||||
|
Param_69 param;
|
||||||
|
std::string type = recvBody["type"].asString();
|
||||||
|
if (0 == type.compare("SET")) {
|
||||||
|
param.mMode = 1;
|
||||||
|
}else if (0 == type.compare("GET")) {
|
||||||
|
param.mMode = 0;
|
||||||
|
}
|
||||||
|
Json::Value recvDataNodeNo = recvBody["DataNodeNo"];
|
||||||
|
if (recvDataNodeNo.size() > 0)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < recvDataNodeNo.size(); i++) {
|
||||||
|
Param_69_info vecParam;
|
||||||
|
for (size_t j = 0; j < recvDataNodeNo[i].size(); j++)
|
||||||
|
{
|
||||||
|
vecParam.measurementID = recvDataNodeNo[i][j].asString();
|
||||||
|
vecParam.status = recvDataNodeNo[i][j].asInt();
|
||||||
|
vecParam.trigerType = recvDataNodeNo[i][j].asInt();
|
||||||
|
vecParam.statisticType = recvDataNodeNo[i][j].asInt();
|
||||||
|
vecParam.threshold = recvDataNodeNo[i][j].asDouble();
|
||||||
|
}
|
||||||
|
param.vecParam69.push_back(vecParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string data = jd.JsonCmd_Cgi_69(param);
|
||||||
|
return data;
|
||||||
|
}break;
|
||||||
|
case KProcessLog:{
|
||||||
|
JsonData jd;
|
||||||
|
Param_70 param;
|
||||||
|
param.mPackageFlag = recvBody["package"].asInt();
|
||||||
|
std::string data = jd.JsonCmd_Cgi_70(param);
|
||||||
|
return data;
|
||||||
|
}break;
|
||||||
|
case KSystemLog:{
|
||||||
|
|
||||||
|
}break;
|
||||||
case kGetSensorInfo:{
|
case kGetSensorInfo:{
|
||||||
JsonData jd;
|
JsonData jd;
|
||||||
Param_100 param;
|
Param_71 param;
|
||||||
param.mPackageFlag = recvBody["package"].asInt();
|
param.mPackageFlag = recvBody["package"].asInt();
|
||||||
std::string data = jd.JsonCmd_Cgi_100(param);
|
std::string data = jd.JsonCmd_Cgi_71(param);
|
||||||
return data;
|
return data;
|
||||||
}break;
|
}break;
|
||||||
case kGetFeatureSensorInfo:{
|
case kGetFeatureSensorInfo:{
|
||||||
|
|||||||
11
main.cpp
11
main.cpp
@ -53,6 +53,12 @@ int main(int argc, char *argv[]) {
|
|||||||
PlatformInit::Init();
|
PlatformInit::Init();
|
||||||
|
|
||||||
sqlite_db_ctrl::instance().InintGateway();
|
sqlite_db_ctrl::instance().InintGateway();
|
||||||
|
char localtimestamp[32] = { 0 };
|
||||||
|
char insertSql[128] = { 0 };
|
||||||
|
GetTimeNet(localtimestamp, 1);
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(insertSql, " '3','CIDNSOFT start','%s'",localtimestamp);
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
||||||
|
|
||||||
uart_inst::instance().InitZigbeeHW();
|
uart_inst::instance().InitZigbeeHW();
|
||||||
// UDP,接收客户端发来的组播消息,用于外接 QT 专家系统,屏蔽之
|
// UDP,接收客户端发来的组播消息,用于外接 QT 专家系统,屏蔽之
|
||||||
@ -160,6 +166,11 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
if (count >= 30) {
|
if (count >= 30) {
|
||||||
zlog_error(zbt, "===========threadStatus ========failed");
|
zlog_error(zbt, "===========threadStatus ========failed");
|
||||||
|
char localtimestamp[32] = { 0 };
|
||||||
|
GetTimeNet(localtimestamp, 1);
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(insertSql, " '1','CheckThread failed','%s'",localtimestamp);
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,10 +64,13 @@ void CheckThread() {
|
|||||||
iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubTiming.c_str());
|
iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubTiming.c_str());
|
||||||
iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||||
if (iRet != 0) {
|
if (iRet != 0) {
|
||||||
zlog_error(zct, "MQTT connect failed ,time check");
|
|
||||||
#ifdef Q4G_MODULE
|
|
||||||
char localtimestamp[32] = { 0 };
|
char localtimestamp[32] = { 0 };
|
||||||
GetTimeNet(localtimestamp, 1);
|
GetTimeNet(localtimestamp, 1);
|
||||||
|
char insertSql[1024] = {0};
|
||||||
|
sprintf(insertSql, " '1','MQTT connect failed','%s'",localtimestamp);
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
||||||
|
zlog_error(zct, "MQTT connect failed ,time check");
|
||||||
|
#ifdef Q4G_MODULE
|
||||||
char whereCon[100]={0};
|
char whereCon[100]={0};
|
||||||
sprintf(whereCon,"DATE(timestamp, 'unixepoch') = DATE('now') ORDER BY timeStamp DESC limit 0,1");
|
sprintf(whereCon,"DATE(timestamp, 'unixepoch') = DATE('now') ORDER BY timeStamp DESC limit 0,1");
|
||||||
std::string strCount = sqlite_db_ctrl::instance().GetData(" reboot_record ", "count", whereCon);
|
std::string strCount = sqlite_db_ctrl::instance().GetData(" reboot_record ", "count", whereCon);
|
||||||
@ -82,6 +85,12 @@ 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);
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(insertSql, " '2','4G module reset','%s'",localtimestamp);
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
||||||
|
zlog_error(zct, "MQTT connect failed ,time check");
|
||||||
system("reboot");
|
system("reboot");
|
||||||
}else{
|
}else{
|
||||||
zlog_error(zct,"Q4G_MODULE error\n");
|
zlog_error(zct,"Q4G_MODULE error\n");
|
||||||
@ -95,6 +104,11 @@ 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);
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(insertSql, " '2','5G module reset','%s'",localtimestamp);
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
||||||
sleep(20);
|
sleep(20);
|
||||||
connectCount++;
|
connectCount++;
|
||||||
if (connectCount > 10) {
|
if (connectCount > 10) {
|
||||||
@ -115,6 +129,11 @@ 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);
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(insertSql, " '2','WiFi module reset','%s'",localtimestamp);
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_process_info", insertSql);
|
||||||
sleep(30);
|
sleep(30);
|
||||||
wifi::WPAClient wpa;
|
wifi::WPAClient wpa;
|
||||||
wpa.ReconnectWiFi();
|
wpa.ReconnectWiFi();
|
||||||
@ -129,6 +148,7 @@ void CheckThread() {
|
|||||||
JsonData jd;
|
JsonData jd;
|
||||||
jd.JsonCmd_07();
|
jd.JsonCmd_07();
|
||||||
HardStatus = 0;
|
HardStatus = 0;
|
||||||
|
sqlite_db_ctrl::instance().SaveSystemHardStatus();
|
||||||
}
|
}
|
||||||
if(checkNet0 == 5){
|
if(checkNet0 == 5){
|
||||||
checkNet0 = 0;
|
checkNet0 = 0;
|
||||||
|
|||||||
@ -725,7 +725,36 @@ void Uart::DealRecvData(const char *pData) {
|
|||||||
}
|
}
|
||||||
last_short_addr = ushortAdd;
|
last_short_addr = ushortAdd;
|
||||||
}
|
}
|
||||||
|
void Uart::DelRepeatData(char *pShortAdd,char* dataNodeNo,char* measurementID){
|
||||||
|
char whereCon[64] = {0};
|
||||||
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
|
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), dataNodeNo);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(T_SENSOR_INFO(TNAME), whereCon);
|
||||||
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
|
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), measurementID);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(T_DATA_INFO(TNAME), whereCon);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(T_DATASTATIC_INFO(TNAME), whereCon);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(T_BATTERY_INFO(TNAME), whereCon);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(" t_battery_history ", whereCon);
|
||||||
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
|
sprintf(whereCon, "MeasurementID = '%s'", measurementID);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(" t_debug_info ", whereCon);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(" t_wave_upload_rule_info ", whereCon);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(" t_wave_triger_info ", whereCon);
|
||||||
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
|
sprintf(whereCon, "channelID like'%s'", measurementID);
|
||||||
|
sqlite_db_ctrl::instance().DeleteTableData(" t_data_waveSend ", whereCon);
|
||||||
|
char szTableName[50] = {0x00};
|
||||||
|
sprintf(szTableName, "DROP TABLE t_data_%s", measurementID);
|
||||||
|
sqlite_db_ctrl::instance().CreateTable(szTableName);
|
||||||
|
memset(szTableName, 0x00, sizeof(szTableName));
|
||||||
|
sprintf(szTableName, "DROP TABLE t_dataStatic_%s", measurementID);
|
||||||
|
sqlite_db_ctrl::instance().CreateTable(szTableName);
|
||||||
|
uint16_t short_addr;
|
||||||
|
char *end_ptr = NULL;
|
||||||
|
short_addr = strtol(pShortAdd, &end_ptr, 16);
|
||||||
|
scheduler::instance().ClearScheduleCfg(short_addr);
|
||||||
|
}
|
||||||
void Uart::DealDataNodeName(const char *pData) {
|
void Uart::DealDataNodeName(const char *pData) {
|
||||||
zlog_info(zct, "DealDataNodeName ");
|
zlog_info(zct, "DealDataNodeName ");
|
||||||
std::string strTime = GetLocalTimeWithMs();
|
std::string strTime = GetLocalTimeWithMs();
|
||||||
@ -753,34 +782,11 @@ void Uart::DealDataNodeName(const char *pData) {
|
|||||||
zlog_info(zct, "vecRes = %d", vecRes.size());
|
zlog_info(zct, "vecRes = %d", vecRes.size());
|
||||||
if (vecRes.size() > 1) {
|
if (vecRes.size() > 1) {
|
||||||
for (size_t i = 0; i < vecRes.size(); i++) {
|
for (size_t i = 0; i < vecRes.size(); i++) {
|
||||||
if (vecRes[i][1] != "") {
|
if (vecRes[i][1] != "") {//删除短地址重复的传感器,新增的传感器,通道编码此时为空,将不会删除。
|
||||||
memset(whereCon,0,sizeof(whereCon));
|
DelRepeatData(szShortAdd,vecRes[i][0].c_str(),vecRes[i][1].c_str());
|
||||||
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), vecRes[i][0].c_str());
|
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(T_SENSOR_INFO(TNAME), whereCon);
|
|
||||||
memset(whereCon,0,sizeof(whereCon));
|
|
||||||
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), vecRes[i][1].c_str());
|
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(T_DATA_INFO(TNAME), whereCon);
|
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(T_DATASTATIC_INFO(TNAME), whereCon);
|
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(T_BATTERY_INFO(TNAME), whereCon);
|
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(" t_battery_history ", whereCon);
|
|
||||||
memset(whereCon,0,sizeof(whereCon));
|
|
||||||
sprintf(whereCon, "channelID like'%s'", vecRes[i][1].c_str());
|
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(" t_data_waveSend ", whereCon);
|
|
||||||
char szTableName[50] = {0x00};
|
|
||||||
sprintf(szTableName, "DROP TABLE t_data_%s", vecRes[i][1].c_str());
|
|
||||||
sqlite_db_ctrl::instance().CreateTable(szTableName);
|
|
||||||
memset(szTableName, 0x00, sizeof(szTableName));
|
|
||||||
sprintf(szTableName, "DROP TABLE t_dataStatic_%s", vecRes[i][1].c_str());
|
|
||||||
sqlite_db_ctrl::instance().CreateTable(szTableName);
|
|
||||||
uint16_t short_addr;
|
|
||||||
char *end_ptr = NULL;
|
|
||||||
short_addr = strtol(szShortAdd, &end_ptr, 16);
|
|
||||||
scheduler::instance().ClearScheduleCfg(short_addr);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zlog_info(zct, "vecRes22 = %d", vecRes.size());
|
|
||||||
zlog_info(zct, "hardVersion = %s,softVersion = %s", vecRes[0][2].c_str(),vecRes[0][3].c_str());
|
zlog_info(zct, "hardVersion = %s,softVersion = %s", vecRes[0][2].c_str(),vecRes[0][3].c_str());
|
||||||
std::string hardVersion = vecRes[0][2];
|
std::string hardVersion = vecRes[0][2];
|
||||||
std::string softVersion = vecRes[0][3];
|
std::string softVersion = vecRes[0][3];
|
||||||
@ -788,14 +794,21 @@ void Uart::DealDataNodeName(const char *pData) {
|
|||||||
memcpy(MeasurementID, vecRes[0][0].c_str(), sizeof(MeasurementID));
|
memcpy(MeasurementID, vecRes[0][0].c_str(), sizeof(MeasurementID));
|
||||||
}
|
}
|
||||||
memset(whereCon,0,sizeof(whereCon));
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
|
sprintf(whereCon, "MeasurementID='%s'", MeasurementID);
|
||||||
|
array_t vecRes2 = sqlite_db_ctrl::instance().GetDataMultiLine(T_SENSOR_INFO(TNAME), " dataNodeNo, MeasurementID,hardVersion,softVersion", whereCon);
|
||||||
|
zlog_info(zct, "vecRes2 = %d", vecRes2.size());
|
||||||
|
if (vecRes2.size() > 1) {
|
||||||
|
for (size_t i = 0; i < vecRes2.size(); i++) {
|
||||||
|
if (vecRes2[i][1] != "") {//删除通道ID重复的传感器,新增的传感器,通道编码此时为空,将不会删除。
|
||||||
|
DelRepeatData(szShortAdd,vecRes2[i][0].c_str(),vecRes2[i][1].c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
sprintf(whereCon, "zigbeeShortAddr='%s'", szShortAdd);
|
sprintf(whereCon, "zigbeeShortAddr='%s'", szShortAdd);
|
||||||
std::string strNodeName(NodeName);
|
std::string strNodeName(NodeName);
|
||||||
zlog_info(zct, "strNodeName = %s", strNodeName.c_str());
|
|
||||||
//solve(gbkNodeName, NodeName);
|
|
||||||
hexToAscii(strNodeName.c_str(), gbkNodeName);
|
hexToAscii(strNodeName.c_str(), gbkNodeName);
|
||||||
zlog_info(zct, "gbkNodeName = %s", gbkNodeName);
|
|
||||||
zlog_info(zct, "NodeName = %s", NodeName);
|
|
||||||
zlog_info(zct, "whereCon = %s", whereCon);
|
|
||||||
sprintf(uplCon, "dataNodeName = '%s' , MeasurementID = '%s',NodeWaveSend = '%s'", gbkNodeName, MeasurementID, nodeWaveSend);
|
sprintf(uplCon, "dataNodeName = '%s' , MeasurementID = '%s',NodeWaveSend = '%s'", gbkNodeName, MeasurementID, nodeWaveSend);
|
||||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), uplCon, whereCon);
|
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), uplCon, whereCon);
|
||||||
std::string strData = sqlite_db_ctrl::instance().GetNodeConfigureInfor(whereCon);
|
std::string strData = sqlite_db_ctrl::instance().GetNodeConfigureInfor(whereCon);
|
||||||
@ -820,6 +833,18 @@ void Uart::DealDataNodeName(const char *pData) {
|
|||||||
sqlite_db_ctrl::instance().CreatedataStatictable(szTableName);
|
sqlite_db_ctrl::instance().CreatedataStatictable(szTableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char insertSql[1024] = {0};
|
||||||
|
sprintf(insertSql, " '%s','%s','','','','','','0',''",
|
||||||
|
MeasurementID, shortAdd);
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_debug_info", insertSql);
|
||||||
|
memset(insertSql,0,sizeof(insertSql));
|
||||||
|
sprintf(insertSql, " '%s','%s','0','0','0'",
|
||||||
|
MeasurementID, shortAdd);
|
||||||
|
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);
|
||||||
|
sqlite_db_ctrl::instance().InsertData("t_wave_triger_info", insertSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uart::DealDataNodeInfo(const char *pData) {
|
void Uart::DealDataNodeInfo(const char *pData) {
|
||||||
|
|||||||
@ -168,6 +168,7 @@ public:
|
|||||||
void UpdateZigbeeInfo(const char* pData);
|
void UpdateZigbeeInfo(const char* pData);
|
||||||
int DealAskTaskOld(uint16_t ushortAdd);
|
int DealAskTaskOld(uint16_t ushortAdd);
|
||||||
void DealRecvData(const char* pData);
|
void DealRecvData(const char* pData);
|
||||||
|
void DelRepeatData(char *pShortAdd,char* dataNodeNo,char* measurementID);
|
||||||
void DealDataNodeInfo(const char* pData);
|
void DealDataNodeInfo(const char* pData);
|
||||||
void DealDataNodeName(const char* pData);
|
void DealDataNodeName(const char* pData);
|
||||||
void ZigbeeParameterConfig();
|
void ZigbeeParameterConfig();
|
||||||
|
|||||||
@ -119,6 +119,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
|||||||
std::string strLongAddr = vecResult[1];
|
std::string strLongAddr = vecResult[1];
|
||||||
std::string strMeasurementID = vecResult[2];
|
std::string strMeasurementID = vecResult[2];
|
||||||
std::string strProductNo = vecResult[3];
|
std::string strProductNo = vecResult[3];
|
||||||
|
std::string softVersion = vecResult[0];
|
||||||
|
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
memset(updateSql, 0x00, sizeof(updateSql));
|
memset(updateSql, 0x00, sizeof(updateSql));
|
||||||
@ -189,6 +190,24 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
|||||||
zlog_info(zct, "nodeWorkTime = %f,nodeSendTime = %f", dataStatic.nodeWorkTime, dataStatic.nodeSendTime);
|
zlog_info(zct, "nodeWorkTime = %f,nodeSendTime = %f", dataStatic.nodeWorkTime, dataStatic.nodeSendTime);
|
||||||
RecordBattery(strMeasurementID, dataStatic, nowTimetamp);
|
RecordBattery(strMeasurementID, dataStatic, nowTimetamp);
|
||||||
|
|
||||||
|
if (compareVersions(softVersion, "2.4"))
|
||||||
|
{
|
||||||
|
char chTemp = pRecvData->Data[80]; //设备状态标志 1 byte
|
||||||
|
DataNodeInfo dataNodeInfo;
|
||||||
|
dataNodeInfo.EquipSta = GET_BIT(chTemp, 2);
|
||||||
|
dataNodeInfo.TemTopFlag = GET_BIT(chTemp, 3);
|
||||||
|
dataNodeInfo.TemBotFlag = GET_BIT(chTemp, 4);
|
||||||
|
dataNodeInfo.ZigbeeFlag = GET_BIT(chTemp, 5);
|
||||||
|
dataNodeInfo.AccFlag = GET_BIT(chTemp, 6);
|
||||||
|
dataNodeInfo.InitFlag = GET_BIT(chTemp, 7);
|
||||||
|
memset(updateSql, 0x00, sizeof(updateSql));
|
||||||
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
|
sprintf(updateSql, " initFlag = '%d',accFlag = '%d',zigbeeFlag = '%d',temTopFlag = '%d',temBotFlag = '%d',equipSta = '%d'",
|
||||||
|
dataNodeInfo.InitFlag, dataNodeInfo.AccFlag, dataNodeInfo.ZigbeeFlag, dataNodeInfo.TemTopFlag, dataNodeInfo.TemBotFlag, dataNodeInfo.EquipSta);
|
||||||
|
sprintf(whereCon, "dataNodeNo = '%s'", strLongAddr.c_str());
|
||||||
|
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
||||||
|
}
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
sprintf(buf, "%02x%02x", pRecvData->Data[81]);
|
sprintf(buf, "%02x%02x", pRecvData->Data[81]);
|
||||||
iTemp = (int)strtol(buf, NULL, 8);
|
iTemp = (int)strtol(buf, NULL, 8);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user