test.cpp
来自「ABis无线接口全套资料」· C++ 代码 · 共 1,598 行 · 第 1/3 页
CPP
1,598 行
extern "C"
{
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
};
#ifndef _ABISPTL_HPP
#include "abisptl.hpp"
#endif
#ifndef _ABISFMT_HPP
#include "abisfmt.hpp"
#endif
#ifndef _LOGFILE_HPP
#include "logfile.hpp"
#endif
#ifndef _EXCEPTION_HPP
#include "exception.hpp"
#endif
#include "layer3infoPtl.hpp"
//#include <map>
//#include <string>
//#include <iostream>
//using namespace std;
struct SByte
{
char high;
char low;
char spare;
};
void Usage( );
char Asci2Byte(char asci);
char msubuf[1024];
char msu[1024];
int msulen;
//output
char date[10];
char time[8];
void Output(CAbisPdu& pdu);
LogFile* log;
struct SPCMCGI
{
int link_begin;// 开始链路号
int link_end;//结束链路号
int tei;//区分不同小区
unsigned char cgi[28];//小区号
};
struct SPCMCGI cell_name[]={
{0, 63, 1, "460-01-9710-10428"},
{0, 63, 2, "460-01-9710-10428"},
{0, 63, 3, "460-01-9710-20428"},
{0, 63, 4, "460-01-9710-20428"},
{0, 63, 5, "460-01-9710-30428"},
{0, 63, 6, "460-01-9710-30428"},
{64, 127, 1, "460-01-9710-18768"},
{64, 127, 2, "460-01-9710-18768"},
{64, 127, 3, "460-01-9710-28768"},
{64, 127, 4, "460-01-9710-28768"},
{64, 127, 5, "460-01-9710-38768"},
{64, 127, 6, "460-01-9710-38768"},
{128, 191, 1, "460-01-9710-17038"},
{128, 191, 2, "460-01-9710-17038"},
{128, 191, 5, "460-01-9710-27038"},
{128, 191, 9, "460-01-9710-37038"},
{192, 255, 1, "460-01-9710-10318"},
{192, 255, 2, "460-01-9710-10318"},
{192, 255, 5, "460-01-9710-20318"},
{192, 255, 6, "460-01-9710-20318"},
{192, 255, 9, "460-01-9710-30318"},
{192, 255, 10, "460-01-9710-30318"},
{192, 255, 11, "460-01-9710-30318"},
{256, 319, 1, "460-01-9710-10499"},
{256, 319, 2, "460-01-9710-10499"},
{256, 319, 5, "460-01-9710-20499"},
{256, 319, 6, "460-01-9710-20499"},
{256, 319, 9, "460-01-9710-30499"},
{320, 383, 1, "460-01-9710-10429"},
{320, 383, 2, "460-01-9710-10429"},
{320, 383, 5, "460-01-9710-20429"},
{320, 383, 6, "460-01-9710-20429"},
{320, 383, 9, "460-01-9710-30429"},
{320, 383, 10, "460-01-9710-30429"},
{320, 383, 11, "460-01-9710-30429"},
{384, 447, 1, "460-01-9710-10459"},
{384, 447, 2, "460-01-9710-10459"},
{384, 447, 5, "460-01-9710-20459"},
{384, 447, 6, "460-01-9710-20459"},
{384, 447, 9, "460-01-9710-30459"},
{384, 447, 10, "460-01-9710-30459"},
{448, 511, 1, "460-01-9710-10469"},
{448, 511, 2, "460-01-9710-10469"},
{448, 511, 5, "460-01-9710-20469"},
{448, 511, 6, "460-01-9710-20469"},
{448, 511, 9, "460-01-9710-30469"},
{448, 511, 10, "460-01-9710-30469"},
};
struct SCellNeig
{
unsigned char local_cell[28];//本地小区号
unsigned char neighbour[28];;//邻小区号
unsigned char neig_bsic;//邻小区bsic号
float cell_x;//邻区cell_x;
float cell_y;//邻区cell_y;
};
extern struct STeiCgi link_array[MAX_LINK_NUMBER][MAX_LINK_TEI];
struct SNeibhour
{
char neibhour[28];
struct SNeibhour *next;
};
struct SNeibhourInfo
{
char cell[28];
struct SNeibhour *neibhour;//邻区小区列表
struct SNeibhourInfo *next;
};
struct SCellInfo
{
char cell_name[40];
char cell_cgi[28];
int bcch;
int bsic;
float cell_x;
float cell_y;
struct SCellInfo *next;
};
#define MAX_NIBHOUR_LIST 1024
#define MAX_CELL_LIST 1024
struct SNeibhourInfo *nibhour_info_list[MAX_NIBHOUR_LIST];
struct SCellInfo *cell_info_list[MAX_CELL_LIST];
struct SBA
{
public:
SBA()
{
memset(this, 0, sizeof(SBA));
}
UINT8 length;
UINT32 isInit;
UINT16 BA[32];
};
struct SDBA
{
int type;
struct SBA BA0;
struct SBA BA1;
};
//extern struct link_header;
//extern struct link_info;
//extern class CCellInfo;
//map<link_info,CCellInfo> cellinfo_map;
//map<link_info,CCellInfo>::iterator iter;
//#include <map>
//#include <string>
//#include <iostream>
//using namespace std;
UINT8 BtsTrx2Cell(UINT8 pcm, UINT8 trx) // trx = tei-1;
{
switch(pcm)
{
default:
return 0xff;
break;
case 0: //新阳大厦G
if((trx == 0)||(trx == 1))
return 1;
else if((trx == 2)||(trx == 3))
return 2;
else if((trx == 4)||(trx == 5))
return 3;
break;
case 1: //江堤处G
if((trx == 0)||(trx == 1))
return 1;
else if((trx == 2)||(trx == 3))
return 2;
else if((trx == 4)||(trx == 5))
return 3;
break;
case 2: //车辆招待处G
if((trx == 0)||(trx == 1))
return 1;
else if(trx == 4)
return 2;
else if(trx == 8)
return 3;
break;
case 3: //车辆招待处G
if((trx == 0)||(trx == 1))
return 1;
else if((trx == 4)||(trx == 5))
return 2;
else if((trx == 8)||(trx == 9)||(trx == 10))
return 3;
break;
case 4: //武警一支队
if((trx == 0)||(trx == 1))
return 1;
else if((trx == 4)||(trx == 5))
return 2;
else if(trx == 8)
return 3;
break;
case 5: //新阳大厦D
if((trx == 0)||(trx == 1))
return 1;
else if((trx == 4)||(trx == 5))
return 2;
else if((trx == 8)||(trx == 9)||(trx == 10))
return 3;
break;
case 6: //春江旅馆
if((trx == 0)||(trx == 1))
return 1;
else if((trx == 4)||(trx == 5))
return 2;
else if((trx == 8)||(trx == 9))
return 3;
break;
case 7: //北方时报
if((trx == 0)||(trx == 1))
return 1;
else if((trx == 4)||(trx == 5))
return 2;
else if((trx == 8)||(trx == 9))
return 3;
break;
}
return 0xff;
}
struct SDBA gba[8][8]; //pcm ,cell
//struct SDBA gba[100];
//统计记录
struct SStatTab
{
unsigned long BTS_MR_SUCCESS_DECODE[8];
unsigned long BTS_MR_FIND_CGI[8];
unsigned long BTS_MR_TOTAL[8];
}gStatTab;
//哈希函数
int hash_index(unsigned char *s, unsigned int len)
{
uint c;
uint h, g;
for (c = h = g = 0; c < len; c++, s++)
{
h = (h << 4) + (*s);
if ((g = h & 0xf0000000))
{
h ^= (g >> 24);
h ^= g;
}
}
return (h % 1024);
}
/*读邻小区信息文件,填入邻小区信息*/
void read_neibhbour_info(void)
{
FILE * fp;
fp = fopen("neibhour_cell.txt", "r");
if (NULL == fp)
{
fprintf(stderr, "open neibhour_cell.txt fail.\n");
return ;
}
char buf[1024];
char* pos = buf;
char endOfFile = 0;
int index = -1;
int readnum = 0;/* Xioa add for Debug */
for(int i = 0; i < MAX_NIBHOUR_LIST; i++)
{
nibhour_info_list[i] = NULL;
}
/* Xiao modify for debug */
while (! feof(fp)&& (! endOfFile) && (readnum < 42759))
{
readnum++;
/* Xiao modify end */
int line_number = 0;
char cell[28];
char neibhour[28];
char *begin, *end;
memset(buf, 0, sizeof(buf));
memset(cell, 0, sizeof(cell));
memset(neibhour, 0, sizeof(neibhour));
pos = buf;
if (NULL == fgets(buf, 1024, fp))
{
fprintf(stderr, "Reading file error.\n");
return ;
}
line_number = strlen(buf);
begin = buf;
end = buf;
while(*end != '\t')
end++;
strncpy(cell, begin, end - begin);
//skip space
while(*end == '\t')
end++;
begin = end;
while(*end != '\n')
end++;
//strncpy(neibhour, begin, end - begin);
strncpy(neibhour, begin, end - begin - 1);/* Xiao Modify for correct format */
index = hash_index((unsigned char*)cell, strlen(cell));
if(nibhour_info_list[index] == NULL)
{
// struct SNeibhourInfo *newNeib = NULL;
if((nibhour_info_list[index] = new SNeibhourInfo) == NULL)
{
printf("read_neibhbour_info:malloc nibhour_info_list fail\n");
return ;
}
memset(nibhour_info_list[index], 0, sizeof(SNeibhourInfo));
memcpy(nibhour_info_list[index]->cell, cell, sizeof(cell));
if((nibhour_info_list[index]->neibhour = new SNeibhour) == NULL)
{
printf("read_neibhbour_info:malloc neibhour fail\n");
return ;
}
memset(nibhour_info_list[index]->neibhour, 0, sizeof(nibhour_info_list[index]->neibhour));
memcpy(nibhour_info_list[index]->neibhour->neibhour, neibhour,sizeof(neibhour));
}
else
{
struct SNeibhourInfo *pList = nibhour_info_list[index];
struct SNeibhourInfo *newList = NULL;
struct SNeibhour *pNeibhour = NULL, *newNeibhour = NULL;
int find = 0;
while(pList != NULL)
{
if(strncmp(pList->cell, cell, strlen((const char *)cell)) == 0)
{
//原来存在邻区信息
pNeibhour = pList->neibhour;
while(pNeibhour->next != NULL)
{
pNeibhour = pNeibhour->next;
}
//Reach the last node
if((newNeibhour = new SNeibhour) == NULL)
{
printf("read_neibhbour_info:malloc neibhour fail\n");
return ;
}
memset(newNeibhour, 0, sizeof(SNeibhour));
memcpy(newNeibhour->neibhour, neibhour, sizeof(neibhour));
pNeibhour->next = newNeibhour;
find = 1;
break;
}
pList = pList->next;
}
//Add new list node at the end
if(find == 0)
{
pList = nibhour_info_list[index];
while(pList->next != NULL)
{
pList = pList->next;
}
if((newList = new SNeibhourInfo) == NULL)
{
printf("read_neibhbour_info:malloc newList fail\n");
return ;
}
memset(newList, 0, sizeof(SNeibhourInfo));
memcpy(newList->cell, cell, sizeof(cell));
if((newNeibhour = new SNeibhour) == NULL)
{
printf("read_neibhbour_info:malloc neibhour fail\n");
return ;
}
memset(newNeibhour, 0, sizeof(SNeibhour));
memcpy(newNeibhour->neibhour, neibhour,sizeof(neibhour));
newList->neibhour = newNeibhour;
pList->next = newList;
}
}
}
}
void read_cell_info_list(void)
{
FILE * fp;
fp = fopen("cell_info.txt", "r");
if (NULL == fp)
{
fprintf(stderr, "open cell_info.txt fail.\n");
return ;
}
char buf[1024];
char* pos = buf;
char endOfFile = 0;
int index = -1;
int readnum = 0;/* Xiao add for debug */
for(int i = 0; i < MAX_CELL_LIST; i++)
{
cell_info_list[i] = NULL;
}
/* Xiao modify for debug */
while (! feof(fp)&& (! endOfFile) && (readnum < 1758))
{
readnum++;
/* Xiao modify end */
char cell_name[40];
char cell_cgi[28];
char bcch[10];
char bsic[10];
char cell_x[20];
char cell_y[20];
char *begin, *end;
memset(buf, 0, sizeof(buf));
memset(cell_name, 0, sizeof(cell_name));
memset(cell_cgi, 0, sizeof(cell_cgi));
memset(bcch, 0, sizeof(bcch));
memset(bsic, 0, sizeof(bsic));
memset(cell_x, 0, sizeof(cell_x));
memset(cell_y, 0, sizeof(cell_y));
pos = buf;
if (NULL == fgets(buf, 1024, fp))
{
fprintf(stderr, "Reading file cell_info.txt error.\n");
return ;
}
//cell_name
begin = buf;
end = buf;
while(*end != '\t')
end++;
strncpy(cell_name, begin, end - begin);
//skip space
while(*end == '\t')
end++;
//cell_cgi
begin = end;
while(*end != '\t')
end++;
strncpy(cell_cgi, begin, end - begin);
//skip space
while(*end == '\t')
end++;
//bcch
begin = end;
while(*end != '\t')
end++;
strncpy(bcch, begin, end - begin);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?