增加web修改波形发送状态的接口
This commit is contained in:
parent
c1fc6584f2
commit
f8cf01b6c6
@ -2536,6 +2536,19 @@ int compareVersions(const std::string& version1, const std::string& version2) {
|
||||
return 0; // 版本号相同
|
||||
}
|
||||
|
||||
void Binary_Bit(unsigned char* p_data, unsigned char position, int flag)
|
||||
{
|
||||
//二进制某位置零或者一 position为位数(从0 开始)
|
||||
if (flag)
|
||||
{
|
||||
*p_data |= 0x01 << (position);
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_data &= ~(0x01 << (position));
|
||||
}
|
||||
}
|
||||
|
||||
static const char* JSON_FIELD_CMD = "cmd";//协议: 命令字段
|
||||
static const char* JSON_FIELD_NAME = "dataWatchName";//协议: 终端名称
|
||||
static const char* JSON_FIELD_dataNodeGatewayNo = "dataNodeGatewayNo";
|
||||
|
@ -91,10 +91,16 @@ struct compressWaveChannel
|
||||
int compressChannelX;
|
||||
int compressChannelY;
|
||||
int compressChannelZ;
|
||||
int CountX;
|
||||
int CountY;
|
||||
int CountZ;
|
||||
compressWaveChannel(){
|
||||
compressChannelX = 0;
|
||||
compressChannelY = 0;
|
||||
compressChannelZ = 0;
|
||||
CountX = 0;
|
||||
CountY = 0;
|
||||
CountZ = 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -468,8 +474,9 @@ struct Param_41 {
|
||||
std::string mfaultFrequency;
|
||||
int ZigbeePower;
|
||||
int ZigbeeRetry;
|
||||
std::string nodeWaveSend;
|
||||
Param_41():mdataNodeName(""),mdataNodeNo(""),mfeatureInterVal(0),mwaveInterVal(0),msamplingRate(0),mrange(0),mAccSampleTime(0),\
|
||||
mstartBrands(""),mstopBrands(""),menvelopeBandPass(""),mviff(0),mfaultFrequency(""),mMeasurementID{""}{};
|
||||
mstartBrands(""),mstopBrands(""),menvelopeBandPass(""),mviff(0),mfaultFrequency(""),mMeasurementID{""},nodeWaveSend{""}{};
|
||||
};
|
||||
struct Param_42 {
|
||||
string fileName;
|
||||
@ -820,5 +827,6 @@ extern bool NetIsOk();
|
||||
extern int Ping( const char *ips, int timeout);
|
||||
extern int get_netlink_status(const char *if_name);
|
||||
extern int compareVersions(const std::string& version1, const std::string& version2);
|
||||
extern void Binary_Bit(unsigned char* p_data, unsigned char position, int flag);
|
||||
extern Mutex g_tDbMutex;
|
||||
#endif
|
||||
|
@ -1385,6 +1385,7 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m)
|
||||
jsSensorData["update"] = atoi(arrRes[j][41].c_str());
|
||||
jsSensorData["MeasurementID"] = arrRes[j][44];
|
||||
jsSensorData["battery"] = arrRes[j][43];
|
||||
jsSensorData["nodeWaveSend"] = arrRes[j][45];
|
||||
jsArray.append(jsSensorData);
|
||||
}
|
||||
} else {
|
||||
@ -2070,10 +2071,10 @@ std::string JsonData::JsonCmd_Cgi_41(std::vector<Param_41> ¶m,int isServer)
|
||||
param[i].mstopBrands.c_str(),param[i].menvelopeBandPass.c_str(),param[i].mviff,param[i].mfaultFrequency.c_str(),param[i].mMeasurementID.c_str());
|
||||
}else if(dataNodeNameLength == 0 ){
|
||||
sprintf(updateSql, "ZigbeePower = '%d',ZigbeeRetry = '%d',featureInterVal='%d',waveInterVal='%d',range='%d',samplingRate='%d',AccSampleTime = '%d',\
|
||||
startBrands = '%s',stopBrands = '%s',envelopeBandPass = '%s',viff = '%d',faultFrequency = '%s',MeasurementID = '%s',UpdateFlag = 0",
|
||||
startBrands = '%s',stopBrands = '%s',envelopeBandPass = '%s',viff = '%d',faultFrequency = '%s',MeasurementID = '%s',NodeWaveSend = '%s',UpdateFlag = 0",
|
||||
param[i].ZigbeePower,param[i].ZigbeeRetry,param[i].mfeatureInterVal, param[i].mwaveInterVal,param[i].mrange,\
|
||||
param[i].msamplingRate,param[i].mAccSampleTime, param[i].mstartBrands.c_str(),\
|
||||
param[i].mstopBrands.c_str(),param[i].menvelopeBandPass.c_str(),param[i].mviff,param[i].mfaultFrequency.c_str(),param[i].mMeasurementID.c_str());
|
||||
param[i].mstopBrands.c_str(),param[i].menvelopeBandPass.c_str(),param[i].mviff,param[i].mfaultFrequency.c_str(),param[i].mMeasurementID.c_str(),param[i].nodeWaveSend.c_str());
|
||||
}
|
||||
if(!isServer)
|
||||
sprintf(whereCon, "dataNodeNo='%s'", param[i].mdataNodeNo.c_str());
|
||||
|
@ -524,6 +524,7 @@ try{
|
||||
param.ZigbeePower = recvBody[i]["ZigbeePower"].asInt();
|
||||
param.ZigbeeRetry = recvBody[i]["ZigbeeRetry"].asInt();
|
||||
param.mMeasurementID = recvBody[i]["MeasurementID"].asString();
|
||||
param.nodeWaveSend = recvBody[i]["nodeWaveSend"].asString();
|
||||
param41.push_back(param);
|
||||
}
|
||||
std::string data = jd.JsonCmd_Cgi_41(param41);
|
||||
|
10
main.cpp
10
main.cpp
@ -37,9 +37,9 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_VecWaveDataX.resize(300000);
|
||||
g_VecWaveDataY.resize(300000);
|
||||
g_VecWaveDataZ.resize(500000);
|
||||
g_VecWaveDataX.reserve(300000);
|
||||
g_VecWaveDataY.reserve(300000);
|
||||
g_VecWaveDataZ.reserve (500000);
|
||||
// 设置线程属性之栈空间大小
|
||||
boost::thread::attributes attrs;
|
||||
attrs.set_stack_size(1024*1024*2);//2M
|
||||
@ -147,7 +147,7 @@ int main(int argc, char *argv[])
|
||||
printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n");
|
||||
}
|
||||
|
||||
//int fd = OpenWatchDog();
|
||||
int fd = OpenWatchDog();
|
||||
int count = 0;
|
||||
while (GlobalConfig::QuitFlag_G) {
|
||||
#ifdef G2UL_GATEWAY
|
||||
@ -155,7 +155,7 @@ int main(int argc, char *argv[])
|
||||
usleep(20000);
|
||||
gpio_set(GlobalConfig::GPIO_G.hardWatchDog,0);
|
||||
#endif
|
||||
//WriteWatchDog(fd);
|
||||
WriteWatchDog(fd);
|
||||
sleep(20);
|
||||
if(GlobalConfig::threadStatus == 0){
|
||||
count ++;
|
||||
|
@ -545,6 +545,12 @@ int Uart::FindRecvPackage(int bytesRead, char* mUartRecvBuf,char* head)
|
||||
bSendTimeStamp = false;
|
||||
GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS;
|
||||
GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0;
|
||||
m_waveCountX = 0;
|
||||
m_waveCountY = 0;
|
||||
m_waveCountZ = 0;
|
||||
g_VecWaveDataX.clear();
|
||||
g_VecWaveDataY.clear();
|
||||
g_VecWaveDataZ.clear();
|
||||
//std::vector<RecvData>().swap(m_VecWaveData);
|
||||
break;
|
||||
}
|
||||
@ -1349,12 +1355,13 @@ int Uart::UpdateConfig(unsigned char* pDestShortAddr)
|
||||
int x = atoi(vecResult[2].c_str());
|
||||
UpdateData[21] = BUILD_UINT2(x,y);
|
||||
UpdateData[22] = atoi(vecResult[4].c_str()) & 0xFF;
|
||||
print_info("vecResult size = %s==%s==%s==%s\n",vecResult[5].c_str(),vecResult[6].c_str(),vecResult[7].c_str(),vecResult[8].c_str());
|
||||
print_info("vecResult size = %s==%s==%s==%s=%s\n",vecResult[5].c_str(),vecResult[6].c_str(),vecResult[7].c_str(),vecResult[8].c_str(),vecResult[14].c_str());
|
||||
vector<string> vStart,vStop,vEnvelopeBandPass,vfaultFrequency,vNodeWaveSend;
|
||||
boost::split( vStart, vecResult[5], boost::is_any_of( "," ), boost::token_compress_on );
|
||||
boost::split( vStop, vecResult[6], boost::is_any_of( "," ), boost::token_compress_on );
|
||||
boost::split( vEnvelopeBandPass, vecResult[7], boost::is_any_of( "," ), boost::token_compress_on );
|
||||
boost::split( vfaultFrequency, vecResult[8], boost::is_any_of( "," ), boost::token_compress_on );
|
||||
if(vecResult[14] != "")
|
||||
boost::split( vNodeWaveSend, vecResult[14], boost::is_any_of( "," ), boost::token_compress_on );
|
||||
|
||||
UpdateData[23] = UINT16_HIGH(atoi(vStart[0].c_str()));
|
||||
@ -1419,31 +1426,34 @@ int Uart::UpdateConfig(unsigned char* pDestShortAddr)
|
||||
UpdateData[66] = bytes[6];
|
||||
UpdateData[67] = bytes[7];
|
||||
}
|
||||
if (vNodeWaveSend[0] == "0");
|
||||
unsigned char byte = 0;
|
||||
if(vNodeWaveSend.size() > 0){
|
||||
if (vNodeWaveSend[0] == "0")
|
||||
{
|
||||
UpdateData[68] &= ~(1 << 0);
|
||||
Binary_Bit(&byte,0,0);
|
||||
}
|
||||
if (vNodeWaveSend[0] == "1");
|
||||
if (vNodeWaveSend[0] == "1")
|
||||
{
|
||||
UpdateData[68] |= (1 << 0);
|
||||
Binary_Bit(&byte,0,1);
|
||||
}
|
||||
if (vNodeWaveSend[1] == "0");
|
||||
if (vNodeWaveSend[1] == "0")
|
||||
{
|
||||
UpdateData[68] &= ~(1 << 1);
|
||||
Binary_Bit(&byte,1,0);
|
||||
}
|
||||
if (vNodeWaveSend[1] == "1");
|
||||
if (vNodeWaveSend[1] == "1")
|
||||
{
|
||||
UpdateData[68] |= (1 << 1);
|
||||
Binary_Bit(&byte,1,1);
|
||||
}
|
||||
if (vNodeWaveSend[2] == "0");
|
||||
if (vNodeWaveSend[2] == "0")
|
||||
{
|
||||
UpdateData[68] &= ~(1 << 2);
|
||||
Binary_Bit(&byte,2,0);
|
||||
}
|
||||
if (vNodeWaveSend[2] == "1");
|
||||
if (vNodeWaveSend[2] == "1")
|
||||
{
|
||||
UpdateData[68] |= (1 << 2);
|
||||
Binary_Bit(&byte,2,1);
|
||||
}
|
||||
|
||||
}
|
||||
UpdateData[68] = byte;
|
||||
free(bytes);
|
||||
unsigned char tmp1 = 0x00;
|
||||
for(int k = 0; k < 99;k++){
|
||||
@ -2106,11 +2116,15 @@ void Uart::DealDataNodeFeature(const char *pData, int flag)
|
||||
}
|
||||
unsigned char compressChannel = pRecvData->Data[34];
|
||||
compressWaveChannel tempchannel;
|
||||
tempchannel.compressChannelX = GET_BIT(compressChannel ,1);
|
||||
tempchannel.compressChannelX = GET_BIT(compressChannel ,0);
|
||||
tempchannel.compressChannelY = GET_BIT(compressChannel ,2);
|
||||
tempchannel.compressChannelZ = GET_BIT(compressChannel ,4);
|
||||
tempchannel.CountX = BUILD_UINT16(pRecvData->Data[55],pRecvData->Data[54]);
|
||||
tempchannel.CountY = BUILD_UINT16(pRecvData->Data[57],pRecvData->Data[56]);
|
||||
tempchannel.CountZ = BUILD_UINT16(pRecvData->Data[59],pRecvData->Data[58]);
|
||||
g_mapCompress[strShortAddr] = tempchannel;
|
||||
|
||||
print_info("count X = %d,Y = %d,Z = %d\n",tempchannel.CountX,tempchannel.CountY,tempchannel.CountZ);
|
||||
print_info("compress X = %d,Y = %d,Z = %d \n",tempchannel.compressChannelX,tempchannel.compressChannelY,tempchannel.compressChannelZ);
|
||||
}else{
|
||||
memset(whereCon,0x00,sizeof(whereCon));
|
||||
@ -3522,7 +3536,6 @@ void Uart::DealDataNodeWave(const char *pData,int comand)
|
||||
{
|
||||
//print_info("recv wave\n");
|
||||
RecvData * pRecvData = (RecvData *)pData;
|
||||
//m_VecWaveData.push_back(*pRecvData);
|
||||
if (comand == 3)
|
||||
{
|
||||
g_VecWaveDataX[m_waveCountX] = *pRecvData;
|
||||
@ -3596,7 +3609,7 @@ std::vector<float> Uart::DealData(int iChannel,float coe,int sampleRate,int ACCS
|
||||
unsigned char outdata[1024*100]={0x00};
|
||||
unsigned char dealdata[1024*100]={0x00};
|
||||
long unsigned int new_len = 0,deallen = 0;
|
||||
int compress = 0;
|
||||
int compress = 0,count = 0;
|
||||
long iTemp = 0;
|
||||
char buf[8] = {0x00};
|
||||
std::vector<float> vecData;
|
||||
@ -3616,6 +3629,7 @@ std::vector<float> Uart::DealData(int iChannel,float coe,int sampleRate,int ACCS
|
||||
sprintf(buf, "%02x%02x", g_VecWaveDataX[0].ShortAddr[0], g_VecWaveDataX[0].ShortAddr[1]);
|
||||
std::string strShortAddr = std::string(buf);
|
||||
compress = g_mapCompress[strShortAddr].compressChannelX;
|
||||
count = g_mapCompress[strShortAddr].CountX;
|
||||
}
|
||||
if (iChannel == 4)
|
||||
{
|
||||
@ -3629,6 +3643,7 @@ std::vector<float> Uart::DealData(int iChannel,float coe,int sampleRate,int ACCS
|
||||
sprintf(buf, "%02x%02x", g_VecWaveDataY[0].ShortAddr[0], g_VecWaveDataY[0].ShortAddr[1]);
|
||||
std::string strShortAddr = std::string(buf);
|
||||
compress = g_mapCompress[strShortAddr].compressChannelY;
|
||||
count = g_mapCompress[strShortAddr].CountY;
|
||||
}
|
||||
if (iChannel == 5)
|
||||
{
|
||||
@ -3642,14 +3657,15 @@ std::vector<float> Uart::DealData(int iChannel,float coe,int sampleRate,int ACCS
|
||||
sprintf(buf, "%02x%02x", g_VecWaveDataZ[0].ShortAddr[0], g_VecWaveDataZ[0].ShortAddr[1]);
|
||||
std::string strShortAddr = std::string(buf);
|
||||
compress = g_mapCompress[strShortAddr].compressChannelZ;
|
||||
count = g_mapCompress[strShortAddr].CountZ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
print_info("len = %d,data = %02x\n",j,data[0]);
|
||||
if(j * 92 < count)
|
||||
return vecData;
|
||||
print_info("len = %d,data = %02x,iChannel = %d,compress = %d,count = %d\n",j,data[0],iChannel,compress,count);
|
||||
if(compress){
|
||||
print_info("iChannel = %d,compress = %d\n",iChannel,compress);
|
||||
int r = lzo1x_decompress(data,j * 92,outdata,&new_len,NULL);
|
||||
int r = lzo1x_decompress(data,count,outdata,&new_len,NULL);
|
||||
print_info("lzo1x_decompress end\n");
|
||||
if (r == LZO_E_OK ){
|
||||
printf("decompressed %lu bytes back into %lu bytes\n",
|
||||
(unsigned long) j * 92, (unsigned long) new_len);
|
||||
@ -3842,6 +3858,8 @@ float Uart::Calcoe(int ran,int iChannel,string& product,int range)
|
||||
}
|
||||
void Uart::WriteDatFile(int sampleRate,string& strMeasurementID,int iChannel,std::vector<float>& vecData)
|
||||
{
|
||||
if(vecData.size() <= 0)
|
||||
return;
|
||||
std::string strFileName = "";
|
||||
char localtimestamp[32] = { 0 };
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user