优化松动判断逻辑
This commit is contained in:
parent
fa77947c88
commit
9d3c22b10a
@ -805,7 +805,8 @@ void ImportConfig(std::string filename)
|
|||||||
WriteStr2Config(SERVERCONFIG, "Server", "Password", jsSystemSetting["Password"].asString());
|
WriteStr2Config(SERVERCONFIG, "Server", "Password", jsSystemSetting["Password"].asString());
|
||||||
WriteStr2Config(SERVERCONFIG, "Server", "APN", jsSystemSetting["APN"].asString());
|
WriteStr2Config(SERVERCONFIG, "Server", "APN", jsSystemSetting["APN"].asString());
|
||||||
char APN[100]={0x00};
|
char APN[100]={0x00};
|
||||||
sprintf(APN,"sed -i '15c \t\t\t\t/opt/quectel-CM/quectel-CM -s %s > /dev/null &' /etc/init.d/S95check5G",jsSystemSetting["APN"].asString());
|
string apn = jsSystemSetting["APN"].asString();
|
||||||
|
sprintf(APN,"sed -i '15c \t\t\t\t/opt/quectel-CM/quectel-CM -s %s > /dev/null &' /etc/init.d/S95check5G",apn.c_str());
|
||||||
system(APN);
|
system(APN);
|
||||||
|
|
||||||
WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", jsonValZigbee["channel"].asString());
|
WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", jsonValZigbee["channel"].asString());
|
||||||
|
@ -858,6 +858,7 @@ int SqliteDB::CalculateDip()
|
|||||||
GetTimeNet(localtimestamp, 1);
|
GetTimeNet(localtimestamp, 1);
|
||||||
readStringValue("config", "loose",looseValue,(char*)GlobalConfig::Config_G.c_str());
|
readStringValue("config", "loose",looseValue,(char*)GlobalConfig::Config_G.c_str());
|
||||||
vecRes = GetDataMultiLine(T_SENSOR_INFO(TNAME), " * ", NULL);
|
vecRes = GetDataMultiLine(T_SENSOR_INFO(TNAME), " * ", NULL);
|
||||||
|
print_info("vecRes = %d\n",vecRes.size());
|
||||||
for(int i = 0 ; i < vecRes.size(); i++){
|
for(int i = 0 ; i < vecRes.size(); i++){
|
||||||
vector<string> vParam;
|
vector<string> vParam;
|
||||||
print_info("vecRes =%s\n",vecRes[i][42].c_str());
|
print_info("vecRes =%s\n",vecRes[i][42].c_str());
|
||||||
@ -872,14 +873,14 @@ int SqliteDB::CalculateDip()
|
|||||||
char szTablename[32]={0x00};
|
char szTablename[32]={0x00};
|
||||||
memset(whereCon,0x00,sizeof(whereCon));
|
memset(whereCon,0x00,sizeof(whereCon));
|
||||||
if(vParam[1] == "2"){//人工干预
|
if(vParam[1] == "2"){//人工干预
|
||||||
sprintf(whereCon," timeStamp > %ld ",atol(vParam[2].c_str()));
|
sprintf(whereCon," timeStamp > '%ld' ",atol(vParam[2].c_str()));
|
||||||
}else if(vParam[1] == "0"){//正常状态
|
}else if(vParam[1] == "0"){//正常状态
|
||||||
sprintf(whereCon," timeStamp > %ld ",atol(localtimestamp) - 86400);//一天数据
|
sprintf(whereCon," timeStamp > '%ld' ",atol(localtimestamp) - 86400);//一天数据
|
||||||
}else if(vParam[1] == "1")//松动状态
|
}else if(vParam[1] == "1")//松动状态
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
print_info("vParam[0]= %s,vParam[1]=%s\n",vParam[0].c_str(),vParam[1].c_str());
|
||||||
|
|
||||||
sprintf(szTablename,"t_dataStatic_%s",vecRes[i][0].c_str());
|
sprintf(szTablename,"t_dataStatic_%s",vecRes[i][0].c_str());
|
||||||
vec_Value vecResDip = GetDataMultiLineOfOneColumnDouble(szTablename," Dip ", whereCon);
|
vec_Value vecResDip = GetDataMultiLineOfOneColumnDouble(szTablename," Dip ", whereCon);
|
||||||
@ -897,13 +898,20 @@ int SqliteDB::CalculateDip()
|
|||||||
}else if(vParam[1] == "1"){
|
}else if(vParam[1] == "1"){
|
||||||
|
|
||||||
}else if(vParam[1] == "2"){
|
}else if(vParam[1] == "2"){
|
||||||
|
print_info("localtimestamp = %ld,vParam[2]=%d,%ld\n",atol(localtimestamp),atol(vParam[2].c_str()),atol(localtimestamp) - atol(vParam[2].c_str()));
|
||||||
|
if(atol(localtimestamp) - atol(vParam[2].c_str()) > 86400){
|
||||||
|
sprintf(updateSql,"LooseValue = '%f,0' ",vParam[0].c_str());
|
||||||
|
}else{
|
||||||
|
sprintf(updateSql,"LooseValue = '%f,2,",vParam[0].c_str());
|
||||||
|
string strUpdateSql = string(updateSql) + vParam[2] + "' " ;
|
||||||
|
memset(updateSql,0x00,sizeof(updateSql));
|
||||||
|
memcpy(updateSql,strUpdateSql.c_str(),sizeof(updateSql));
|
||||||
|
}
|
||||||
if(sample_variance > atol(looseValue))
|
if(sample_variance > atol(looseValue))
|
||||||
{
|
{
|
||||||
sprintf(updateSql,"LooseValue = '%f,1' ",sample_variance);
|
sprintf(updateSql,"LooseValue = '%f,1' ",sample_variance);
|
||||||
}
|
}
|
||||||
if(atol(localtimestamp) - atol(vParam[2].c_str()) > 86400){
|
|
||||||
sprintf(updateSql,"LooseValue = '%f,0' ",vParam[0].c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ extern "C"{
|
|||||||
#define T_DATASTATIC_INFO(x) T_DATASTATIC_INFO[T_DATASTATIC_INFO_##x]
|
#define T_DATASTATIC_INFO(x) T_DATASTATIC_INFO[T_DATASTATIC_INFO_##x]
|
||||||
#define T_GATEWAY_INFO(x) T_GATEWAY_INFO[T_GATEWAY_INFO_##x]
|
#define T_GATEWAY_INFO(x) T_GATEWAY_INFO[T_GATEWAY_INFO_##x]
|
||||||
#define T_DATANODE_TIME(x) T_DATANODE_TIME[T_DATANODE_TIME_##x]
|
#define T_DATANODE_TIME(x) T_DATANODE_TIME[T_DATANODE_TIME_##x]
|
||||||
|
#define T_BATTERY_INFO(x) T_BATTERY_INFO[T_BATTERY_INFO##x]
|
||||||
|
|
||||||
typedef std::map<std::string, std::string> map_t;
|
typedef std::map<std::string, std::string> map_t;
|
||||||
typedef std::vector<std::string> vec_t;
|
typedef std::vector<std::string> vec_t;
|
||||||
@ -182,4 +183,25 @@ typedef enum {
|
|||||||
T_GATEWAY_INFO_MAC2,
|
T_GATEWAY_INFO_MAC2,
|
||||||
}T_GATEWAY_INFO_Index;
|
}T_GATEWAY_INFO_Index;
|
||||||
const static char* T_GATEWAY_INFO[] = { "t_gateway_info","gatewayMAC","sensorVersion","gatewayLocation","zigbeePanID","zigbeeChannel","communicationType","signal","localIP","systemVersion","programVersion","webVersion","serverIP","serverPort","status","gateWayUpdate","MAC2"};
|
const static char* T_GATEWAY_INFO[] = { "t_gateway_info","gatewayMAC","sensorVersion","gatewayLocation","zigbeePanID","zigbeeChannel","communicationType","signal","localIP","systemVersion","programVersion","webVersion","serverIP","serverPort","status","gateWayUpdate","MAC2"};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
T_BATTERY_INFO_TNAME = 0,
|
||||||
|
T_BATTERY_INFO_GATEWAYMAC,
|
||||||
|
T_GATEWAY_INFO_SENSORVER,
|
||||||
|
T_GATEWAY_INFO_GATEWAYLOCATION,
|
||||||
|
T_GATEWAY_INFO_ZIGBEEPANID,
|
||||||
|
T_GATEWAY_INFO_ZIGBEECHANNEL,
|
||||||
|
T_GATEWAY_INFO_COMMUNICATIONTYPE,
|
||||||
|
T_GATEWAY_INFO_SIGNAL,
|
||||||
|
T_GATEWAY_INFO_LOCALIP,
|
||||||
|
T_GATEWAY_INFO_SYSTEMVERSION,
|
||||||
|
T_GATEWAY_INFO_PROGRAMVERSION,
|
||||||
|
T_GATEWAY_INFO_WEBVERSION,
|
||||||
|
T_GATEWAY_INFO_SERVERIP,
|
||||||
|
T_GATEWAY_INFO_SERVERPORT,
|
||||||
|
T_GATEWAY_INFO_STATUS,
|
||||||
|
T_GATEWAY_INFO_GATEWAYUPDATE,
|
||||||
|
T_GATEWAY_INFO_MAC2,
|
||||||
|
}T_GATEWAY_INFO_Index;
|
||||||
|
const static char* T_GATEWAY_INFO[] = {};
|
||||||
#endif
|
#endif
|
||||||
|
@ -1369,7 +1369,7 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m)
|
|||||||
sprintf(selectCon, "zigbeeSignalNode <> '' ORDER BY timeStamp desc LIMIT 0,1");
|
sprintf(selectCon, "zigbeeSignalNode <> '' ORDER BY timeStamp desc LIMIT 0,1");
|
||||||
string strZigbeeSignalNode = sql_ctl->GetData(szTableName, "zigbeeSignalNode", selectCon);
|
string strZigbeeSignalNode = sql_ctl->GetData(szTableName, "zigbeeSignalNode", selectCon);
|
||||||
if(strZigbeeSignal == "")
|
if(strZigbeeSignal == "")
|
||||||
jsSensorData["RSSI"] = arrRes[j][40];
|
jsSensorData["RSSI"] = "0," + arrRes[j][40];
|
||||||
else
|
else
|
||||||
jsSensorData["RSSI"] = strZigbeeSignal + "," + strZigbeeSignalNode;
|
jsSensorData["RSSI"] = strZigbeeSignal + "," + strZigbeeSignalNode;
|
||||||
jsSensorData["update"] = atoi(arrRes[j][41].c_str());
|
jsSensorData["update"] = atoi(arrRes[j][41].c_str());
|
||||||
@ -1563,8 +1563,10 @@ std::string JsonData::JsonCmd_Cgi_27(Param_27 ¶m)
|
|||||||
vector<string> vParam;
|
vector<string> vParam;
|
||||||
boost::split( vParam, strLooseValue, boost::is_any_of( "," ), boost::token_compress_on );
|
boost::split( vParam, strLooseValue, boost::is_any_of( "," ), boost::token_compress_on );
|
||||||
GetTimeNet(localtimestamp, 1);
|
GetTimeNet(localtimestamp, 1);
|
||||||
sprintf(updateSql,"LooseValue = '%f,2,%s' ",vParam[0].c_str(),localtimestamp);
|
sprintf(updateSql,"LooseValue = '%f,2,",vParam[0].c_str());
|
||||||
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME),updateSql,whereCon);
|
string strUpdateSql = string(updateSql) + string(localtimestamp) + "' " ;
|
||||||
|
print_info("updateSql = %s\n",strUpdateSql.c_str());
|
||||||
|
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME),strUpdateSql.c_str(),whereCon);
|
||||||
} else {
|
} else {
|
||||||
jsonVal["success"] = false;
|
jsonVal["success"] = false;
|
||||||
jsonVal["message"] = "没有传感器号";
|
jsonVal["message"] = "没有传感器号";
|
||||||
|
@ -12,7 +12,7 @@ int GlobalConfig::LinkCount = 0;
|
|||||||
int GlobalConfig::net0Status = 1;
|
int GlobalConfig::net0Status = 1;
|
||||||
|
|
||||||
|
|
||||||
std::string GlobalConfig::Version = "3.0";
|
std::string GlobalConfig::Version = "3.1";
|
||||||
std::string GlobalConfig::MacAddr_G = "";
|
std::string GlobalConfig::MacAddr_G = "";
|
||||||
std::string GlobalConfig::MacAddr_G2 = "";
|
std::string GlobalConfig::MacAddr_G2 = "";
|
||||||
std::string GlobalConfig::IpAddr_G = "";
|
std::string GlobalConfig::IpAddr_G = "";
|
||||||
|
@ -216,7 +216,7 @@ void CheckThread()
|
|||||||
// UpdateZigbee = 0;
|
// UpdateZigbee = 0;
|
||||||
// pUart->UpdateZigbeeInfoCtrl();
|
// pUart->UpdateZigbeeInfoCtrl();
|
||||||
// }
|
// }
|
||||||
if(60 == loose_check){
|
if(3600 == loose_check){
|
||||||
loose_check = 0;
|
loose_check = 0;
|
||||||
sql_ctl->CalculateDip();
|
sql_ctl->CalculateDip();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user