test.cpp
来自「ABis无线接口全套资料」· C++ 代码 · 共 1,598 行 · 第 1/3 页
CPP
1,598 行
{
//小区信息表中找出邻居信息
if((pCellInfo->bsic == bsic) && (pCellInfo->bcch == bcch))
{
strncpy(neibhour,pCellInfo->cell_cgi, strlen(pCellInfo->cell_cgi));
return pCellInfo->cell_cgi;//找到符合的cgi
}
}
pCellInfo = pCellInfo->next;
}
pNeibCell = pNeibCell->next;
}
}
pNeibhour = pNeibhour->next;
}
return NULL;
/*
//在邻居信息表中找不到匹配记录
pCellInfo = cell_info_list[index_neib];
while(pCellInfo != NULL)
{
if (strncmp(pCellInfo->cell_cgi, cell, strlen(cell)) == 0)
{
local_cell_x = pCellInfo->cell_x;
local_cell_y = pCellInfo->cell_y;
break;
}
pCellInfo = pCellInfo->next;
}
for(int i = 0; i < MAX_CELL_LIST; i++)
{
pCellInfo = cell_info_list[i];
while(pCellInfo != NULL)
{
if((pCellInfo->bsic == bsic) && (pCellInfo->bcch == bcch))
{
distance = (local_cell_x - pCellInfo->cell_x) * (local_cell_x - pCellInfo->cell_x) + (local_cell_y - pCellInfo->cell_y) * (local_cell_y - pCellInfo->cell_y);
if(fwest_distance == 0){
fwest_distance= distance;
fwest_distance_cell = pCellInfo;
}
else
{
if(distance < fwest_distance)
{
fwest_distance = distance;
fwest_distance_cell = pCellInfo;
}
}
}
pCellInfo = pCellInfo->next;
}
}
if(fwest_distance_cell != NULL)
{
strncpy(neibhour,fwest_distance_cell->cell_cgi, strlen(fwest_distance_cell->cell_cgi));
return fwest_distance_cell->cell_cgi;
}
else
return NULL;
*/
}
struct SFormat
{
char datetime[64];
char CGI[64];
char TRX[64];
char timeslot[64];
char IMSI[64];
char ReasultNumber[64];
char IsMeasSuccess[64]; //解码是否成功
char channel_type[64];
char Dtxd[64];
char RXLEV_FULL_UP[64];
char RXLEV_SUB_UP[64];
char RXQUAL_FULL_UP[64];
char RXQUAL_SUB_UP[64];
char POWER_LEVEL[64];
char MS_POWER_LEVEL[64];
char ACTUAL_TIMINIG_ADVANCE[64];
char BA_USED[64];
char _3G_BA_USED[64];
char DTX_USED[64];
char IsMeasValid[64];// 是否有下行指标
char RXLEV_FULL_SERVING_CELL[64];
char RXLEV_SUB_SERVING_CELL[64];
char RXLEV_SUB_SERVING_CELL_non_PC[64];
char RXQUAL_FULL_SERVING_CELL[64];
char RXQUAL_SUB_SERVING_CELL[64];
char UP_PATH_WASTE[64]; // 上下行路径损耗差
char CURRENT_SEND_POWER[64]; // 即时发射功率
char LINKNUM[64];//Xiao Add
char ADDRESS_TEI[64];//Xiao Add
char ADDRESS_SAPI[64];//Xiao Add
char NO_NCELL_M[64];
char BCCH_FREQ_NCELL1[64];//Xiao Add
char RXLEV_NCELL_1[64];
char BCCH_FREQ_NCELL_1[64];
char BSIC_NCELL_1[64];
char NCELL_CGI_1[64];
char BCCH_FREQ_NCELL2[64];//Xiao Add
char RXLEV_NCELL_2[64];
char BCCH_FREQ_NCELL_2[64];
char BSIC_NCELL_2[64];
char NCELL_CGI_2[64];
char BCCH_FREQ_NCELL3[64];//Xiao Add
char RXLEV_NCELL_3[64];
char BCCH_FREQ_NCELL_3[64];
char BSIC_NCELL_3[64];
char NCELL_CGI_3[64];
char BCCH_FREQ_NCELL4[64];//Xiao Add
char RXLEV_NCELL_4[64];
char BCCH_FREQ_NCELL_4[64];
char BSIC_NCELL_4[64];
char NCELL_CGI_4[64];
char BCCH_FREQ_NCELL5[64];//Xiao Add
char RXLEV_NCELL_5[64];
char BCCH_FREQ_NCELL_5[64];
char BSIC_NCELL_5[64];
char NCELL_CGI_5[64];
char BCCH_FREQ_NCELL6[64];//Xiao Add
char RXLEV_NCELL_6[64];
char BCCH_FREQ_NCELL_6[64];
char BSIC_NCELL_6[64];
char NCELL_CGI_6[64];
}OutData;
void Output(CAbisPdu& pdu)
{
CIeBase* pIe = pdu.GetIE(ABIS_LK_IE_MSG_TYPE);
if(pIe == NULL)
return;
UINT32 pduType = pIe->GetIeData();
SMessageType msgType = (*(SMessageType*)&pduType);
if(msgType.TYPE != 40)//MEASUREMENT_RESULT
return;
UINT8 pcm = 0;
char outbuf[1024];
char cgi[28];
struct SAddressField address_field;
short linknumber = -1;
memset(&OutData, '\0', sizeof(OutData));
memset(outbuf, '\0', 1024);
memcpy(OutData.datetime, date, 10);
OutData.datetime[10] = ' ';
memcpy(OutData.datetime+11, time, 8);
OutData.datetime[19] = ',';
OutData.datetime[20] = ' ';
//解码赋初值
sprintf(OutData.IsMeasSuccess, "0, ");
//GET CGI code, add by chris
//----------------------------------------------
UINT32 data_linkid;
pIe = pdu.GetIE(ABIS_LK_IE_LINKNUMBER);
if(pIe != NULL)
{
data_linkid= pIe->GetIeData();
memcpy(&linknumber, (char *)&data_linkid, sizeof(short));
pcm = linknumber/64;
++gStatTab.BTS_MR_TOTAL[pcm];
}
else
{
return;
}
memset(cgi, 0, sizeof(cgi));
pIe = pdu.GetIE(ABIS_LK_IE_ADDRESS);
if(pIe != NULL)
{
UINT32 data2 = pIe->GetIeData();
int cgi_len;
memcpy(&address_field, (char *)&data2, sizeof(SAddressField));
//cgi_len = getCgi(linknumber, address_field.TEI, cgi);
cgi_len = getCgi((char *)&data_linkid, address_field.TEI, cgi);
if(cgi_len == 0)
{
OutData.CGI[0] = ',';
OutData.CGI[1] = ' ';
}
else
{
int cgilen = strlen(cgi+7);
memcpy(OutData.CGI, (cgi+7), cgilen);
OutData.CGI[cgilen] = ',';
OutData.CGI[cgilen+1] = ' ';
}
}
//----------------------------------------------
//print TRX
pIe = pdu.GetIE(ABIS_LK_IE_ADDRESS);
if(pIe != NULL)
{
UINT32 data = pIe->GetIeData();
SAddressField addr = *((SAddressField*)&data);
sprintf(OutData.TRX, "%d, ", (addr.TEI-1));
}
//print timeslot
pIe = pdu.GetIE(ABIS_NT_IE_CHANNEL_NUMBER);
if(pIe != NULL)
{
UINT32 data = pIe->GetIeData();
SChannelNumber channum = *((SChannelNumber*)&data);
UINT8 timeslot = channum.TN;
sprintf(OutData.timeslot, "%d, ", timeslot); //timslot
}
pIe = pdu.GetIE(ABIS_NT_IE_MEASUREMENT_RESULT_NUMBER);
if(pIe != NULL)
{
UINT8 resultnumber = pIe->GetIeData();
sprintf(OutData.ReasultNumber, "%d, ", resultnumber);
}
pIe = pdu.GetIE(ABIS_NT_IE_CHANNEL_NUMBER);
if(pIe != NULL)
{
UINT32 data = pIe->GetIeData();
SChannelNumber channum = *((SChannelNumber*)&data);
UINT8 chantype = channum.C;
sprintf(OutData.channel_type, "%d, ", chantype); //channel_type
}
pIe = pdu.GetIE(ABIS_NT_IE_UPLINK_MEASUREMENTS);
unsigned short datalen = 0;
char* pdata = pIe->GetIeData(datalen);
if(datalen >= 3)
{
SUplinkMeasurements& uplink = *((SUplinkMeasurements*)pdata);
sprintf(OutData.Dtxd, "%d, ", uplink.DTXD);
sprintf(OutData.RXLEV_FULL_UP, "%d, ", uplink.RXLEV_FULL_UP);
sprintf(OutData.RXLEV_SUB_UP, "%d, ", uplink.RXLEV_SUB_UP);
sprintf(OutData.RXQUAL_FULL_UP, "%d, ", uplink.RXQUAL_FULL_UP);
sprintf(OutData.RXQUAL_SUB_UP, "%d, ", uplink.RXQUAL_SUB_UP);
}
pIe = pdu.GetIE(ABIS_NT_IE_BS_POWER);
if(pIe != NULL)
{
UINT32 data = pIe->GetIeData();
SBsPower bspower = *((SBsPower*)&data);
sprintf(OutData.POWER_LEVEL, "%d, ", bspower.POWER_LEVEL); // power_level
}
pIe = pdu.GetIE(ABIS_NT_IE_L1_INFORMATION);
if(pIe != NULL)
{
UINT32 data = pIe->GetIeData();
SL1Information l1info = *((SL1Information*)&data);
sprintf(OutData.MS_POWER_LEVEL, "%d, ", l1info.MS_POWER_LEVEL); // power_level
sprintf(OutData.ACTUAL_TIMINIG_ADVANCE, "%d, ", l1info.ACTUAL_TIMINIG_ADVANCE); // Actual Timing Advance
}
// layer3 info print
pIe = pdu.GetIE(LAYER3INFO_IE_MEASUREMENT_RESULT);
if(pIe != NULL)
{
//if(linknumber/64 >=4)
//printf("%s\n", msubuf);
unsigned char rxllev_full_serving_cell = 0;
unsigned char dtx_used = 0;
unsigned char ba_used = 0;
unsigned char rxlev_sub_serving_cell = 0;
unsigned char meas_valid = 0;
unsigned char no_ncellm;
unsigned char rxqual_sub_serving_cell = 0;
unsigned char rxqual_full_serving_cell = 0;
unsigned char rxlev_ncell1 = 0;
unsigned char bsic_ncell1 = 0;
unsigned char bcch_freq_ncell1 = 0;
unsigned char rxlev_ncell2 = 0;
unsigned char bsic_ncell2 = 0;
unsigned char bcch_freq_ncell2 = 0;
unsigned char rxlev_ncell3 = 0;
unsigned char bsic_ncell3 = 0;
unsigned char bcch_freq_ncell3 = 0;
unsigned char rxlev_ncell4 = 0;
unsigned char bcch_freq_ncell4 = 0;
unsigned char rxlev_ncell5 = 0;
unsigned char bsic_ncell4 = 0;
unsigned char bcch_freq_ncell5 = 0;
unsigned char rxlev_ncell6 = 0;
unsigned char bsic_ncell5 = 0;
unsigned char bcch_freq_ncell6 = 0;
unsigned char bsic_ncell6 = 0;
int bcch_freq = 0;
char neibhbour_cell[28];
int current_cell = 0;
// UINT16 neibi_len = 0;
// 注意BSIC为8进制
struct SMeasurementResult *pMeasure ;
char *pdata = pIe->GetIeData(datalen);
pMeasure = (struct SMeasurementResult*)pdata;
rxllev_full_serving_cell = pMeasure->rxllev_full_serving_cell;
dtx_used = pMeasure->dtx_used;
ba_used = pMeasure->ba_used;
rxlev_sub_serving_cell = pMeasure->rxlev_sub_serving_cell;
meas_valid = pMeasure->meas_valid;
no_ncellm = pMeasure->no_ncellm_l | (pMeasure->no_ncellm_h<<2);
rxqual_sub_serving_cell = pMeasure->rxqual_sub_serving_cell;
rxqual_full_serving_cell = pMeasure->rxqual_full_serving_cell;
rxlev_ncell1 = pMeasure->rxlev_ncell1;
bsic_ncell1 = A2O(pMeasure->bsic_ncell1_l | (pMeasure->bsic_ncell1_h<<3));
bcch_freq_ncell1 = pMeasure->bcch_freq_ncell1;
rxlev_ncell2 = pMeasure->rxlev_ncell2_l |( pMeasure->rxlev_ncell2_h<<1);
bsic_ncell2 = A2O(pMeasure->bsic_ncell2_l | (pMeasure->bsic_ncell2_h<<4));
bcch_freq_ncell2 = pMeasure->bcch_freq_ncell2;
rxlev_ncell3 = pMeasure->rxlev_ncell3_l | (pMeasure->rxlev_ncell3_h<<2);
bsic_ncell3 = A2O(pMeasure->bsic_ncell3_l | (pMeasure->bsic_ncell3_h<<5));
bcch_freq_ncell3 = pMeasure->bcch_freq_ncell3;
rxlev_ncell4 = pMeasure->rxlev_ncell4_l | (pMeasure->rxlev_ncell4_h<<3);
bcch_freq_ncell4 = pMeasure->bcch_freq_ncell4;
rxlev_ncell5 = pMeasure->rxlev_ncell5_l | (pMeasure->rxlev_ncell5_h<<4);
bsic_ncell4 = A2O(pMeasure->bsic_ncell4);
bcch_freq_ncell5 = pMeasure->bcch_freq_ncell5_l | (pMeasure->bcch_freq_ncell5_h<<1);
rxlev_ncell6 = pMeasure->rxlev_ncell6_l | (pMeasure->rxlev_ncell6_h<<5);
bsic_ncell5 = A2O(pMeasure->bsic_ncell5);
bcch_freq_ncell6 = pMeasure->bcch_freq_ncell6_l | (pMeasure->bcch_freq_ncell6_h<<2);
bsic_ncell6 = A2O(pMeasure->bsic_ncell6);
sprintf(OutData.BA_USED, "%d, ", ba_used);
sprintf(OutData._3G_BA_USED, ", ");
sprintf(OutData.DTX_USED, "%d, ", dtx_used);
sprintf(OutData.IsMeasValid, "%d, ", meas_valid);
sprintf(OutData.RXLEV_FULL_SERVING_CELL, "%d, ", rxllev_full_serving_cell);
sprintf(OutData.RXLEV_SUB_SERVING_CELL, "%d, ", rxlev_sub_serving_cell);
pIe = pdu.GetIE(ABIS_NT_IE_BS_POWER);
if(pIe != NULL)
{
UINT32 data = pIe->GetIeData();
SBsPower bspower = *((SBsPower*)&data);
sprintf(OutData.RXLEV_SUB_SERVING_CELL_non_PC, "%d, ", rxlev_sub_serving_cell+2*bspower.POWER_LEVEL); // power_level
}
sprintf(OutData.RXQUAL_FULL_SERVING_CELL, "%d, ", rxqual_full_serving_cell);
sprintf(OutData.RXQUAL_SUB_SERVING_CELL, "%d, ", rxqual_sub_serving_cell);
//sprintf(OutData.LINKNUM, "%x, ", (char *)&data_linkid);//Xiao Add
sprintf(OutData.LINKNUM, "%x, ", data_linkid);//Xiao Add
sprintf(OutData.ADDRESS_TEI, "%d, ", address_field.TEI);//Xiao Add
sprintf(OutData.ADDRESS_SAPI, "%d, ", address_field.SAPI);//Xiao Add
sprintf(OutData.NO_NCELL_M, "%d, ", no_ncellm);
sprintf(OutData.BCCH_FREQ_NCELL1, "%d, ", bcch_freq_ncell1);//Xiao Add
bool isAllCgi = false;
//bcch_freq = FindBcch(false, linknumber, address_field.TEI, bcch_freq_ncell1);
bcch_freq = FindBcch(false, (char *)&data_linkid, address_field.TEI, bcch_freq_ncell1);
if((bcch_freq < 0) && (current_cell <= no_ncellm)){
return;
}
current_cell++;
memset(neibhbour_cell, 0 ,sizeof(neibhbour_cell));
if(NULL != get_neibhbour_cell_cgi((char*)cgi, bsic_ncell1, bcch_freq,neibhbour_cell))
isAllCgi = true;
sprintf(OutData.RXLEV_NCELL_1, "%d, ", rxlev_ncell1);
sprintf(OutData.BCCH_FREQ_NCELL_1, "%d, ", bcch_freq);
sprintf(OutData.BSIC_NCELL_1, "%d, ", bsic_ncell1);
sprintf(OutData.NCELL_CGI_1, "%s, ", neibhbour_cell+7);
sprintf(OutData.BCCH_FREQ_NCELL2, "%d, ", bcch_freq_ncell2);//Xiao Add
//bcch_freq = FindBcch(false, linknumber, address_field.TEI, bcch_freq_ncell2);
bcch_freq = FindBcch(false, (char *)&data_linkid, address_field.TEI, bcch_freq_ncell2);
if((bcch_freq < 0) && (current_cell < no_ncellm)){
return;
}
current_cell++;
memset(neibhbour_cell, 0 ,sizeof(neibhbour_cell));
if(NULL != get_neibhbour_cell_cgi((char*)cgi, bsic_ncell2, bcch_freq,neibhbour_cell))
isAllCgi = true;
sprintf(OutData.RXLEV_NCELL_2,"%d, ", rxlev_ncell2);
sprintf(OutData.BCCH_FREQ_NCELL_2,"%d, ", bcch_freq);
sprintf(OutData.BSIC_NCELL_2,"%d, ", bsic_ncell2);
sprintf(OutData.NCELL_CGI_2, "%s, ", neibhbour_cell+7);
sprintf(OutData.BCCH_FREQ_NCELL3, "%d, ", bcch_freq_ncell3);//Xiao Add
//bcch_freq = FindBcch(false, linknumber, address_field.TEI, bcch_freq_ncell3);
bcch_freq = FindBcch(false, (char *)&data_linkid, address_field.TEI, bcch_freq_ncell3);
if((bcch_freq < 0) && (current_cell < no_ncellm)){
return;
}
current_cell++;
memset(neibhbour_cell, 0 ,sizeof(neibhbour_cell));
if(NULL != get_neibhbour_cell_cgi((char*)cgi, bsic_ncell3, bcch_freq, neibhbour_cell))
isAllCgi = true;
sprintf(OutData.RXLEV_NCELL_3, "%d, ", rxlev_ncell3);
sprintf(OutData.BCCH_FREQ_NCELL_3, "%d, ", bcch_freq);
sprintf(OutData.BSIC_NCELL_3, "%d, ", bsic_ncell3);
sprintf(OutData.NCELL_CGI_3, "%s, ", neibhbour_cell+7);
sprintf(OutData.BCCH_FREQ_NCELL4, "%d, ", bcch_freq_ncell4);//Xiao Add
//bcch_freq = FindBcch(false, linknumber, address_field.TEI, bcch_freq_ncell4);
bcch_freq = FindBcch(false, (char *)&data_linkid, address_field.TEI, bcch_freq_ncell4);
if((bcch_freq < 0) && (current_cell < no_ncellm)){
return;
}
current_cell++;
memset(neibhbour_cell, 0 ,sizeof(neibhbour_cell));
if(NULL != get_neibhbour_cell_cgi((char*)cgi, bsic_ncell4, bcch_freq,neibhbour_cell))
isAllCgi = true;
sprintf(OutData.RXLEV_NCELL_4, "%d, ", rxlev_ncell4);
sprintf(OutData.BCCH_FREQ_NCELL_4, "%d, ", bcch_freq);
sprintf(OutData.BSIC_NCELL_4, "%d, ", bsic_ncell4);
sprintf(OutData.NCELL_CGI_4, "%s, ", neibhbour_cell+7);
sprintf(OutData.BCCH_FREQ_NCELL5, "%d, ", bcch_freq_ncell5);//Xiao Add
//bcch_freq = FindBcch(false, linknumber, address_field.TEI, bcch_freq_ncell5);
bcch_freq = FindBcch(false, (char *)&data_linkid, address_field.TEI, bcch_freq_ncell5);
if((bcch_freq < 0) && (current_cell < no_ncellm)){
return;
}
current_cell++;
memset(neibhbour_cell, 0 ,sizeof(neibhbour_cell));
if(NULL != get_neibhbour_cell_cgi((char*)cgi, bsic_ncell5, bcch_freq, neibhbour_cell))
isAllCgi = true;
sprintf(OutData.RXLEV_NCELL_5,"%d, ",rxlev_ncell5);
sprintf(OutData.BCCH_FREQ_NCELL_5,"%d, ",bcch_freq);
sprintf(OutData.BSIC_NCELL_5, "%d, ", bsic_ncell5);
sprintf(OutData.NCELL_CGI_5, "%s, ", neibhbour_cell+7);
sprintf(OutData.BCCH_FREQ_NCELL6, "%d, ", bcch_freq_ncell6);//Xiao Add
//bcch_freq = FindBcch(false, linknumber, address_field.TEI, bcch_freq_ncell6);
bcch_freq = FindBcch(false, (char *)&data_linkid, address_field.TEI, bcch_freq_ncell6);
if((bcch_freq < 0) && (current_cell < no_ncellm)){
return;
}
current_cell++;
memset(neibhbour_cell, 0 ,sizeof(neibhbour_cell));
if(NULL != get_neibhbour_cell_cgi((char*)cgi, bsic_ncell6, bcch_freq, neibhbour_cell))
isAllCgi = true;
sprintf(OutData.RXLEV_NCELL_6, "%d, ", rxlev_ncell6);
sprintf(OutData.BCCH_FREQ_NCELL_6, "%d, ", bcch_freq);
sprintf(OutData.BSIC_NCELL_6, "%d, ", bsic_ncell6);
sprintf(OutData.NCELL_CGI_6, "%s, ", neibhbour_cell+7);
//解码成功
sprintf(OutData.IsMeasSuccess, "1, ");
++gStatTab.BTS_MR_SUCCESS_DECODE[pcm];
if(isAllCgi)
++gStatTab.BTS_MR_FIND_CGI[pcm];
}
char* pos = outbuf;
char* pIdent = (char*)&OutData;
//for(int i=0; i<52; ++i)
for(int i=0; i<61; ++i)/* Xiao modify for display MR */
{
if(pIdent[0] == '\0')
pos += sprintf(pos, ", ");
else
{
strncpy(pos, pIdent, strlen(pIdent));
pos += strlen(pIdent);
}
pIdent+=64;
}
pIe = pdu.GetIE(ABIS_LK_IE_LINKNUMBER);
if(pIe != NULL)
{
UINT32 data = pIe->GetIeData();
short linknumber = 0;
memcpy(&linknumber, (char *)&data, sizeof(short));
log[linknumber/64].Log(outbuf);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?