⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfpcooperatedch.cpp

📁 3G中FP协议的DCH和RACH解码
💻 CPP
📖 第 1 页 / 共 2 页
字号:

	int sum=0;//计算所有TBS长度
	for(i=0;i<Num;i++)
	{
		
//		pFirstTB=temp;
		TBSstruct* tempstruct=new TBSstruct;
		tempstruct->pFirstTB=temp;
		tempstruct->TFIvalue=a[i];
		
		if(ConfigInfArray[i].m_Tfs[a[i]].wNumOfTb!=0)
		{
		
		tempstruct->TBbitLength=ConfigInfArray[i].m_Tfs[a[i]].wTbsSize/ConfigInfArray[i].m_Tfs[a[i]].wNumOfTb;
		if(tempstruct->TBbitLength%8)
		{
			int c;//used to calculate the bit numer of the Padding
			tempstruct->TBByteLenth=tempstruct->TBbitLength/8+1;
			tempstruct->TBSByteLength=ConfigInfArray[i].m_Tfs[a[i]].wNumOfTb*tempstruct->TBByteLenth;
			for(int n=1;n<=ConfigInfArray[i].m_Tfs[a[i]].wNumOfTb;n++)
			{
				c=tempstruct->TBbitLength%8;
				temp+=tempstruct->TBByteLenth-1;//pointing to the last byte of the current TB
				b[i]=*temp&(255>>c);
				temp++;
//				PadStr[n].Format(_T("@Padding|%X|填充"),b[n]);
				str.Format(_T("⑴Padding"));
				PadStr[n]+=str;
				str.Format(_T("@Padding|%X|填充"),b[n]);
				PadStr[n]+=str;
			}
			
		}
		else
		{
			tempstruct->TBByteLenth=tempstruct->TBbitLength/8;
			tempstruct->TBSByteLength=ConfigInfArray[i].m_Tfs[a[i]].wNumOfTb*tempstruct->TBByteLenth;
			temp+=tempstruct->TBSByteLength;
		}
		
		
		CHTBStructArray.AddToRear(tempstruct);
		
		sum+=tempstruct->TBSByteLength;
		}

		else
		{
			str.Format(_T("@第 %d 个传输信道TB块个数为0"),i);
			res+=str;	
		}
		
	}
	PDUByteLength=PDUByteLength-sum;
	if(PDUByteLength>=0)//考虑到存在CRCI字段,这里判断条件放宽为大于等于0。符合的话进行TB块解码,否则报错返回。
    {//4 3月15日,修改增加程序健壮性。

	str.Format(_T("⑴Trailer"));
	TrailStr+=str;
	str.Format(_T("@QE|%X|质量估计"),*temp);
	TrailStr+=str;
	temp++;
	
	//if(Length-Num-sum-3>0)
	//{
		int k=0;//计算所有TB个数
		for(i=0;i<Num;i++)
		{
			
			k+=ConfigInfArray[i].m_Tfs[a[i]].wNumOfTb;
			str.Format(_T("⑵DCH %d CRCI"),i+1);
			TrailStr+=str;
			
			for(int j=1;j<=ConfigInfArray[i].m_Tfs[a[i]].wNumOfTb;j++)
			{
				if(j<=8)
				{
					BYTE m=8-j;
					BYTE l=128>>(j-1);		
					str.Format(_T("@TB %d CRCI|%X|"),j,(*temp&l)>>m);
					TrailStr+=str;
					if((*temp&l)>>m)
						str.Format(_T("错误"));
					else
						str.Format(_T("正确"));
					TrailStr+=str;
				}
				else if(j<=16)
				{
					BYTE m=16-j;
					BYTE l=128>>(i-8-1);		
					str.Format(_T("@TB %d CRCI|%X|"),j,(*(temp+1)&l)>>m);
					TrailStr+=str;
					if((*(temp+1)&l)>>m)
						str.Format(_T("错误"));
					else
						str.Format(_T("正确"));
					TrailStr+=str;
				}
				else if(j<=24)
				{
					BYTE m=24-j;
					BYTE l=128>>(j-16-1);		
					str.Format(_T("@TB %d CRCI|%X|"),j,(*(temp+2)&l)>>m);
					TrailStr+=str;
					if((*(temp+2)&l)>>m)
						str.Format(_T("错误"));
					else
						str.Format(_T("正确"));
					TrailStr+=str;
				}
				else if(j<=32)
				{
					BYTE m=32-j;
					BYTE l=128>>(j-24-1);		
					str.Format(_T("@TB %d CRCI|%X|"),j,(*(temp+3)&l)>>m);
					TrailStr+=str;
					if((*(temp+3)&l)>>m)
						str.Format(_T("错误"));
					else
						str.Format(_T("正确"));
					TrailStr+=str;
				}
				else if(j<=40)
				{
					BYTE m=40-j;
					BYTE l=128>>(j-32-1);		
					str.Format(_T("@TB %d CRCI|%X|"),j,(*(temp+4)&l)>>m);
					TrailStr+=str;
					if((*(temp+4)&l)>>m)
						str.Format(_T("错误"));
					else
						str.Format(_T("正确"));
					TrailStr+=str;
				}
				else if(j<=48)
				{
					BYTE m=48-j;
					BYTE l=128>>(j-40-1);		
					str.Format(_T("@TB %d CRCI|%X|"),j,(*(temp+5)&l)>>m);
					TrailStr+=str;
					if((*(temp+5)&l)>>m)
						str.Format(_T("错误"));
					else
						str.Format(_T("正确"));
					TrailStr+=str;
				}
				else if(j<=56)
				{
					BYTE m=56-j;
					BYTE l=128>>(j-48-1);		
					str.Format(_T("@TB %d CRCI|%X|"),j,(*(temp+6)&l)>>m);
					TrailStr+=str;
					if((*(temp+6)&l)>>m)
						str.Format(_T("错误"));
					else
						str.Format(_T("正确"));
					TrailStr+=str;
				}
				else if(j<=64)
				{
					BYTE m=64-j;
					BYTE l=128>>(j-56-1);		
					str.Format(_T("@TB %d CRCI|%X|"),j,(*(temp+7)&l)>>m);
					TrailStr+=str;
					if((*(temp+7)&l)>>m)
						str.Format(_T("错误"));
					else
						str.Format(_T("正确"));
					TrailStr+=str;
				}
				else
				{
					str.Format(_T("@not exist"));
					TrailStr+=str;
				}
				
			}
		}
		
		
		if(k%8)
		{
			temp=temp+k/8;
			int d;
			d=(*temp)&(255>>(k%8));
			str.Format(_T("@Padding|%X|填充"),d);
			TrailStr+=str;
			temp++;
		}
		else 
			temp+=k/8;
		
		WORD payloadCRCbitlength;
		payloadCRCbitlength=ConfigInfArray[0].wCrcBitSize;
		str.Format(_T("@Payload CRC|%s|净荷CRC"),ConvertToHexStr(temp,payloadCRCbitlength/8,TRUE));
		TrailStr+=str;
		return 0;
   }//4 3月15日,修改增加程序健壮性。
     else
   {
       str.Format(_T("数据与传输格式集不符!"));
	   res+=str;
	   return   1;
   }
	   return 0; 
}//11
else
{   
    str.Format(_T("待解码数据错误!"));
	res+=str;
	return 1;
}
  return 0;
}

WORD CFpCooperateDch::DCHControlFrameDecode(BYTE *pMsg, WORD Length, CString &res)
{
	
	BYTE* temp=pMsg;
	CString str;
	Length=Length/8;
	
	BYTE Type=*(temp+1);
	WORD a;
	DWORD a1=0;
	int toa;
	long toa1=0;
	DWORD t1;
	DWORD t2;
	DWORD t3;
	BYTE t_h;
	BYTE t_m;
	BYTE t_l;
	float t;
	BYTE toa_h;
	BYTE toa_l;
	switch(Type){
	case 0x01:
		str.Format(_T("#FP DCH: OUTER LOOP POWER CONTROL"));
		res+=str;
		
		str.Format(_T("⑴Header"));
		res+=str;
		
		str.Format(_T("@FT(Frame Type)|%X|控制帧"),*temp&0x01);
		res+=str;
		
		str.Format(_T("@Frame CRC|%X|帧头CRC"),(*temp&0xfe)>>1);
		res+=str;
		temp++;

		str.Format(_T("@Control Frame Type|%X|"),*temp);
		res+=str;
		str.Format(_T("OUTER LOOP POWER CONTROL"));
		res+=str;
		temp++;
		str.Format(_T("⑴Payload"));
		res+=str;
		str.Format(_T("@UL_SIR_TARGET|%X|上行内环功率控制的SIR目标值:%d dB"),*temp,0.1*(*temp)-8.2);
		res+=str;
		temp++;
		if(Length-3)
		{
			str.Format(_T("⑴Trailer"));
			res+=str;

			str.Format(_T("@Spare Extension|%s|备用扩展"),ConvertToHexStr(temp,Length-3,TRUE));
			res+=str;
//			return 0;
		}
//		else
			return 0;
		break;
	case 0x02:
		str.Format(_T("#FP DCH: TIMING ADJUSTMENT"));
		res+=str;
		
		str.Format(_T("⑴Header"));
		res+=str;
		
		str.Format(_T("@FT(Frame Type)|%X|控制帧"),*temp&0x01);
		res+=str;
		
		str.Format(_T("@Frame CRC|%X|帧头CRC"),(*temp&0xfe)>>1);
		res+=str;
		temp++;
		
		str.Format(_T("@Control Frame Type|%X|"),*temp);
		res+=str;

		str.Format(_T("TIMING ADJUSTMENT"));
		res+=str;
		temp++;
		str.Format(_T("⑴Payload"));
		res+=str;
		str.Format(_T("@CFN(Connection Frame Number)|%X|连接帧号"),*temp);
		res+=str;
		temp++;
		
		toa_h=*temp;
		toa_l=*(temp+1);
		a=(toa_h<<8)+toa_l;
		toa=(int)a;
		str.Format(_T("@ToA|%s|到达时间:%f ms"),ConvertToHexStr(temp,2,TRUE),0.125*toa);
		res+=str;
		temp+=2;
		if(Length-5)
		{
			str.Format(_T("⑴Trailer"));
			res+=str;

			str.Format(_T("@Spare Extension|%s|备用扩展"),ConvertToHexStr(temp,Length-5,TRUE));
			res+=str;
//			return 0;
		}
//		else 
			return 0;
		break;
	case 0x03:
		str.Format(_T("#FP DCH: DL SYNCHRONISATION"));
		res+=str;
		
		str.Format(_T("⑴Header"));
		res+=str;
		
		str.Format(_T("@FT(Frame Type)|%X|控制帧"),*temp&0x01);
		res+=str;
		
		str.Format(_T("@Frame CRC|%X|帧头CRC"),(*temp&0xfe)>>1);
		res+=str;
		temp++;
		
		str.Format(_T("@Control Frame Type|%X|"),*temp);
		res+=str;

		str.Format(_T("DL SYNCHRONISATION"));
		res+=str;
		temp++;
		str.Format(_T("⑴Payload"));
		res+=str;

		str.Format(_T("@CFN(Connection Frame Number)|%X|连接帧号"),*temp);
		res+=str;
		temp++;
		if(Length-3)
		{
			str.Format(_T("⑴Trailer"));
			res+=str;

			str.Format(_T("@Spare Extension|%s|备用扩展"),ConvertToHexStr(temp,Length-3,TRUE));
			res+=str;
//			return 0;
		}
//		else
			return 0;
		break;
	case 0x04:
		str.Format(_T("#FP DCH: UL SYNCHRONISATION"));
		res+=str;
		
		str.Format(_T("⑴Header"));
		res+=str;
		
		str.Format(_T("@FT(Frame Type)|%X|控制帧"),*temp&0x01);
		res+=str;
		
		str.Format(_T("@Frame CRC|%X|帧头CRC"),(*temp&0xfe)>>1);
		res+=str;
		temp++;
		
		str.Format(_T("@Control Frame Type|%X|"),*temp);
		res+=str;

		str.Format(_T("UL SYNCHRONISATION"));
		res+=str;
		temp++;
		str.Format(_T("⑴Payload"));
		res+=str;

		str.Format(_T("@CFN(Connection Frame Number)|%X|连接帧号"),*temp);
		res+=str;
		temp++;
		
		toa_h=*temp;
		toa_l=*(temp+1);
		a=(toa_h<<8)+toa_l;
		toa=(int)a;
		str.Format(_T("@ToA|%s|到达时间:%f ms"),ConvertToHexStr(temp,2,TRUE),0.125*toa);
		res+=str;
		
		temp+=2;
		if(Length-5)
		{
			str.Format(_T("⑴Trailer"));
			res+=str;

			str.Format(_T("@Spare Extension|%s|备用扩展"),ConvertToHexStr(temp,Length-5,TRUE));
			res+=str;
//			return 0;
		}
//		else 
			return 0;
		break;
	case 0x06:
		str.Format(_T("#FP DCH: DL NODE SYNCHRONISATION"));
		res+=str;
		
		str.Format(_T("⑴Header"));
		res+=str;
		
		str.Format(_T("@FT(Frame Type)|%X|控制帧"),*temp&0x01);
		res+=str;
		
		str.Format(_T("@Frame CRC|%X|帧头CRC"),(*temp&0xfe)>>1);
		res+=str;
		temp++;
		
		str.Format(_T("@Control Frame Type|%X|"),*temp);
		res+=str;

		str.Format(_T("DL NODE SYNCHRONISATION"));
		res+=str;
		temp++;
		str.Format(_T("⑴Payload"));
		res+=str;
		
		t_h=*temp;
		t_m=*(temp+1);
		t_l=*(temp+2);
		t1=(t_h<<16)+(t_m<<8)+t_l;
		t=t1*0.125;
		str.Format(_T("@T1|%s|RNC特定帧号:%f ms"),ConvertToHexStr(temp,3,TRUE),t);
		res+=str;
		temp+=3;
		if(Length-5)
		{
			str.Format(_T("⑴Trailer"));
			res+=str;

			str.Format(_T("@Spare Extension|%s|备用扩展"),ConvertToHexStr(temp,Length-5,TRUE));
			res+=str;
//			return 0;
		}
//		else
			return 0;
		break;
	case 0x07:
		str.Format(_T("#FP DCH: UL NODE SYNCHRONISATION"));
		res+=str;
		
		str.Format(_T("⑴Header"));
		res+=str;
		
		str.Format(_T("@FT(Frame Type)|%X|控制帧"),*temp&0x01);
		res+=str;
		
		str.Format(_T("@Frame CRC|%X|帧头CRC"),(*temp&0xfe)>>1);
		res+=str;
		temp++;
		
		str.Format(_T("@Control Frame Type|%X|"),*temp);
		res+=str;

		str.Format(_T("UL NODE SYNCHRONISATION"));
		res+=str;
		temp++;
		
		str.Format(_T("⑴Payload"));
		res+=str;

		t_h=*temp;
		t_m=*(temp+1);
		t_l=*(temp+2);
		t1=(t_h<<16)+(t_m<<8)+t_l;
		t=t1*0.125;
		str.Format(_T("@T1|%s|RNC特定帧号(指示RNC将帧通过SAP发送到传输层的时间):%f ms"),ConvertToHexStr(temp,3,TRUE),t);
		res+=str;
		temp+=3;

		t_h=*temp;
		t_m=*(temp+1);
		t_l=*(temp+2);
		t2=(t_h<<16)+(t_m<<8)+t_l;
		t=t2*0.125;
		str.Format(_T("@T2|%s|Node B 特定帧号(BFN)(指示当Node B从传输层通过SAP收到相应的下行节点同步帧的时间):%f ms"),ConvertToHexStr(temp,3,TRUE),t);
		res+=str;
		temp+=3;
		
		t_h=*temp;
		t_m=*(temp+1);
		t_l=*(temp+2);
		t3=(t_h<<16)+(t_m<<8)+t_l;
		t=t3*0.125;
		str.Format(_T("@T3|%s|Node B 特定帧号(BFN)(指示当Node B 通过SAP向传输层发送帧的时间):%f ms"),ConvertToHexStr(temp,3,TRUE),t);
		res+=str;
		temp+=3;
		if(Length-11)
		{
			str.Format(_T("⑴Trailer"));
			res+=str;
			
			str.Format(_T("@Spare Extension|%s|备用扩展"),ConvertToHexStr(temp,Length-11,TRUE));
			res+=str;
//			return 0;
		}
//		else
			return 0;
		break;	
	default:
		str.Format(_T("@error"));
		res+=str;
		return 1;
		break;	
	}
	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -