适配DN102 波形传输数量

This commit is contained in:
zhangsheng 2024-10-21 11:41:54 +08:00
parent 39829fd709
commit 36a18ab96c
4 changed files with 52 additions and 12 deletions

View File

@ -55,6 +55,10 @@ typedef struct statfs DISK,*pDISK;
#define BUILD_UINT2(x,y) (((x) << 2u) | (y)) #define BUILD_UINT2(x,y) (((x) << 2u) | (y))
// 生成UINT32 数据 // 生成UINT32 数据
#define BUILD_UINT32(u,v,x,y) (((u & 0x00FFu) << 24u) | (v & 0x00FFu) << 16u) | (((x & 0x00FFu) << 8u) | (y & 0x00FFu)) #define BUILD_UINT32(u,v,x,y) (((u & 0x00FFu) << 24u) | (v & 0x00FFu) << 16u) | (((x & 0x00FFu) << 8u) | (y & 0x00FFu))
// 生成UINT64 数据
#define BUILD_UINT48(u,v,x,y,x1,y1) ( ((u & 0x00FFu) << 40u)| ((u & 0x00FFu) << 32u) |((x & 0x00FFu) << 24u) | (y & 0x00FFu) << 16u) | (((x1 & 0x00FFu) << 8u) | (y1 & 0x00FFu))
// 获取UINT32的高低字节 // 获取UINT32的高低字节
#define UINT32_HIGH_1(x) ((x & 0xFF000000u) >> 24u) #define UINT32_HIGH_1(x) ((x & 0xFF000000u) >> 24u)
#define UINT32_HIGH_2(x) ((x & 0x00FF0000u) >> 16u) #define UINT32_HIGH_2(x) ((x & 0x00FF0000u) >> 16u)

View File

@ -24,8 +24,8 @@ enum enumZigBeeTransmitStatus {
//#define Q4G_MODULE //#define Q4G_MODULE
//#define WIFI_MODULE //#define WIFI_MODULE
//#define NR5G_MEIGE //#define NR5G_MEIGE
#define G2UL_GATEWAY //#define G2UL_GATEWAY
//#define IMX6UL_GATEWAY #define IMX6UL_GATEWAY
class GlobalConfig class GlobalConfig
{ {

View File

@ -568,6 +568,7 @@ void JsonData::DataNodeStatusCheck()
int lNowTime = atoi(nowTimetamp.c_str()); int lNowTime = atoi(nowTimetamp.c_str());
int onlineCheck = readIntValue( "config", "online",(char*)GlobalConfig::Config_G.c_str()); int onlineCheck = readIntValue( "config", "online",(char*)GlobalConfig::Config_G.c_str());
int loseTime = readIntValue( "config", "loseTime",(char*)GlobalConfig::Config_G.c_str()); int loseTime = readIntValue( "config", "loseTime",(char*)GlobalConfig::Config_G.c_str());
int nodeOnline = readIntValue( "config", "nodeOnline",(char*)GlobalConfig::Config_G.c_str());
int count = 0; int count = 0;
if (nSize > 0) { if (nSize > 0) {
for (int i = 0; i < nSize; i++) { for (int i = 0; i < nSize; i++) {
@ -606,7 +607,7 @@ void JsonData::DataNodeStatusCheck()
} }
} }
} }
if (count == nSize) if (count == nSize && nodeOnline)
{ {
LOG_ERROR("ALL Node offline,count = %d\n",count); LOG_ERROR("ALL Node offline,count = %d\n",count);
exit(0); exit(0);

View File

@ -210,9 +210,9 @@ Uart::Uart():mUart(mIoSev),mStrand(mIoSev)
m_waveCountX = 0; m_waveCountX = 0;
m_waveCountY = 0; m_waveCountY = 0;
m_waveCountZ = 0; m_waveCountZ = 0;
VecWaveDataX.reserve(300000); VecWaveDataX.reserve(1000);
VecWaveDataY.reserve(300000); VecWaveDataY.reserve(1000);
VecWaveDataZ.reserve (500000); VecWaveDataZ.reserve (1500);
} }
Uart::~Uart() Uart::~Uart()
{ {
@ -2059,7 +2059,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag)
//根据数据包中的传感器的短地址获取数据库中长地址MAC在下面判断该传感器是否存在如果不存在则把数据包丢弃 //根据数据包中的传感器的短地址获取数据库中长地址MAC在下面判断该传感器是否存在如果不存在则把数据包丢弃
sprintf(getLongAddr_sql, "zigbeeShortAddr='%s'", strShortAddr.c_str()); sprintf(getLongAddr_sql, "zigbeeShortAddr='%s'", strShortAddr.c_str());
//std::string strLongAddr = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(ZIGBEELONGADDR), getLongAddr_sql); //std::string strLongAddr = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(ZIGBEELONGADDR), getLongAddr_sql);
vec_t vecResult = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME)," softVersion,dataNodeNo,MeasurementID ",getLongAddr_sql); vec_t vecResult = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME)," softVersion,dataNodeNo,MeasurementID,ProductNo ",getLongAddr_sql);
if (vecResult.size() < 1) { if (vecResult.size() < 1) {
LOG_ERROR("device info not found %02x%02x\n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]); LOG_ERROR("device info not found %02x%02x\n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]);
@ -2070,6 +2070,7 @@ void 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];
if (1 == flag) { if (1 == flag) {
tcflush(fd,TCIOFLUSH); tcflush(fd,TCIOFLUSH);
@ -2122,9 +2123,42 @@ void Uart::DealDataNodeFeature(const char *pData, int flag)
tempchannel.compressChannelX = GET_BIT(compressChannel ,0); tempchannel.compressChannelX = GET_BIT(compressChannel ,0);
tempchannel.compressChannelY = GET_BIT(compressChannel ,2); tempchannel.compressChannelY = GET_BIT(compressChannel ,2);
tempchannel.compressChannelZ = GET_BIT(compressChannel ,4); tempchannel.compressChannelZ = GET_BIT(compressChannel ,4);
if (strProductNo == "01")
{
tempchannel.CountX = BUILD_UINT16(pRecvData->Data[55],pRecvData->Data[54]); tempchannel.CountX = BUILD_UINT16(pRecvData->Data[55],pRecvData->Data[54]);
tempchannel.CountY = BUILD_UINT16(pRecvData->Data[57],pRecvData->Data[56]); tempchannel.CountY = BUILD_UINT16(pRecvData->Data[57],pRecvData->Data[56]);
tempchannel.CountZ = BUILD_UINT16(pRecvData->Data[59],pRecvData->Data[58]); tempchannel.CountZ = BUILD_UINT16(pRecvData->Data[59],pRecvData->Data[58]);
}else if (strProductNo == "02")
{
int CountX = 0;
int CountY = 0;
int CountZ = 0;
unsigned char buffer[6]={0x00};
memcpy(buffer,&pRecvData->Data[55],1);
memcpy(buffer + 1,&pRecvData->Data[54],1);
memcpy(buffer + 2,&pRecvData->Data[57],1);
memcpy(buffer + 3,&pRecvData->Data[56],1);
memcpy(buffer + 4,&pRecvData->Data[59],1);
memcpy(buffer + 5,&pRecvData->Data[58],1);
uint64_t packed_data = 0;
for (int i = 0; i < 6; i++) {
packed_data |= (uint64_t)buffer[i] << (8 * (5 - i)); // 从高位开始组合
}
// 输出结果
printf("Resulting 48-bit integer: 0x%012llX\n", packed_data);
// 提取 15 位的第一个数据
tempchannel.CountX = (packed_data >> 33) & 0x7FFF; // 提取最高的 15 位
// 提取 15 位的第二个数据
tempchannel.CountY = (packed_data >> 18) & 0x7FFF; // 提取中间的 15 位
// 提取 18 位的第三个数据
tempchannel.CountZ = packed_data & 0x3FFFF; // 提取最低的 18 位
}
g_mapCompress[strShortAddr] = tempchannel; g_mapCompress[strShortAddr] = tempchannel;
print_info("count X = %d,Y = %d,Z = %d\n",tempchannel.CountX,tempchannel.CountY,tempchannel.CountZ); print_info("count X = %d,Y = %d,Z = %d\n",tempchannel.CountX,tempchannel.CountY,tempchannel.CountZ);
@ -3691,9 +3725,10 @@ std::vector<float> Uart::DealData(int iChannel,float coe,int sampleRate,int ACCS
compress = g_mapCompress[strShortAddr].compressChannelZ; compress = g_mapCompress[strShortAddr].compressChannelZ;
count = g_mapCompress[strShortAddr].CountZ; count = g_mapCompress[strShortAddr].CountZ;
} }
print_info("len = %d,data = %02x,iChannel = %d,compress = %d,count = %d\n",j,data[0],iChannel,compress,count);
if(j * 92 < count) if(j * 92 < count)
return vecData; return vecData;
print_info("len = %d,data = %02x,iChannel = %d,compress = %d,count = %d\n",j,data[0],iChannel,compress,count);
if(compress){ if(compress){
print_info("iChannel = %d,compress = %d\n",iChannel,compress); print_info("iChannel = %d,compress = %d\n",iChannel,compress);
int r = lzo1x_decompress(data,count,outdata,&new_len,NULL); int r = lzo1x_decompress(data,count,outdata,&new_len,NULL);
@ -3812,7 +3847,7 @@ void Uart::DealWave()
} }
if (m_waveCountY > 0 || VecWaveDataY.size() > 0) if (m_waveCountY > 0 || VecWaveDataY.size() > 0)
{ {
print_info("m_waveCountX = %d,VecWaveData = %d\n",m_waveCountY,VecWaveDataY.size()); print_info("m_waveCountY = %d,VecWaveData = %d\n",m_waveCountY,VecWaveDataY.size());
coe = Calcoe(n,4,strProduct,range); coe = Calcoe(n,4,strProduct,range);
vecData = DealData(4,coe,sampleRate,ACCSampleTime,strProduct); vecData = DealData(4,coe,sampleRate,ACCSampleTime,strProduct);
WriteDatFile(sampleRate, strMeasurementID, 4,vecData); WriteDatFile(sampleRate, strMeasurementID, 4,vecData);