| 1 |
#include "descript.h"
|
| 2 |
#include "flag.h"
|
| 3 |
|
| 4 |
void filename(char [], char [], char [], char[], int, char[]);
|
| 5 |
void FindRoute(int[], int*);
|
| 6 |
short int CRC(int []);
|
| 7 |
int restrict(int [], long long int[], int);
|
| 8 |
|
| 9 |
extern char database[80];
|
| 10 |
extern char MYSQL[80];
|
| 11 |
extern int print_flag;
|
| 12 |
|
| 13 |
void read(char fni[], char fno[], char INF[],
|
| 14 |
char protocol[], char path[], char name[], char nnnnn_TMP[], float quality[], int real_route[], int &Rcount)
|
| 15 |
{
|
| 16 |
FILE *fo, *fout, *foRout, *foMiss, *fo_log_kadr, *fo_route, *fo_tmp;
|
| 17 |
ifstream fin;
|
| 18 |
ofstream fo_cln1, fokadr_cln1, fo_info;
|
| 19 |
|
| 20 |
char buf[1024];
|
| 21 |
// char stop1;
|
| 22 |
char ch1,ch2,ch3,ch, ch4[80], ch5[5];
|
| 23 |
char file_route[80]; /*protocol binary filesm nnnnn_mmm_xxx_cln1Er.log*/
|
| 24 |
char miss_file[80]; /*protocol files nnnnn_mmm_xxx_mis_cln1.dat*/
|
| 25 |
char cln1_file[80]; /*route binary data files nnnnn_mmm_xxx_cln1.pam*/
|
| 26 |
char cln1_kadr[80]; /*route binary data files nnnnn_mmm_xxx_cln1.bin*/
|
| 27 |
char log_kadr[80]; /*log binary data files nnnnn_mmm_xxx_cln1.log*/
|
| 28 |
char log_route[80]; /*log binary file for number of routes*/
|
| 29 |
char Short_Buf[8], Name_Buf[4];
|
| 30 |
char temp[10], temp1[80], connection[80], command[80], name11[80];
|
| 31 |
short int CalcCheckSum;
|
| 32 |
|
| 33 |
int LenthBuf=1015, flag_help=0;
|
| 34 |
int i, j, k, file_length=0, Hex[3];
|
| 35 |
int N_er=0; /*Number of cadre with name error*/
|
| 36 |
int CRC0_er=0; /*Number of cadre with CRC0 error*/
|
| 37 |
int P_er=0; /*Number of cadre with packet error number*/
|
| 38 |
int end=0; /*End of last pamela packet*/
|
| 39 |
// Buffers for Cadre analysis
|
| 40 |
int buffer1[1024], buffer2[1024], buffer3[1024];
|
| 41 |
int rr=0;
|
| 42 |
int cirquit_no=0, route=0;
|
| 43 |
|
| 44 |
int header1, header2, header3, CRC_0[3], CRC_1[3];
|
| 45 |
long long int icount_int;
|
| 46 |
long long int icount_frac, tmpP, numP[3];
|
| 47 |
long int N1=0; /* Number of identified cadres*/
|
| 48 |
long long int icount=0; /* Number of bytes in identified cadres*/
|
| 49 |
long long int icount_total=0; /* Total number of bytes*/
|
| 50 |
long long int packet_first[100];/* First cadre number for each route*/
|
| 51 |
long long int packet_last[100]; /* Second cadre number for each route*/
|
| 52 |
long int count_missed[100]; /* Number of missed cadres in each route*/
|
| 53 |
long int count_sec_missed[100];
|
| 54 |
unsigned long long int count_ident[100]; /* Number of good bytes in each route*/
|
| 55 |
unsigned long long int count_tot[100]; /* Total number of bytes in each route*/
|
| 56 |
int NumRout[1000]; /* Number of route*/
|
| 57 |
long long int Num_kadrs[1000]; /* Number of identified cadres in each route*/
|
| 58 |
long int Num_good_kadrs[1000]; /* Number of normal cadres in each route*/
|
| 59 |
long long int Num_bad_kadrs[1000]; /* Bad cadres number in each route*/
|
| 60 |
|
| 61 |
int counter=0; /* Last byte position in truncated cadre*/
|
| 62 |
int adr1=0; /* Initial byte of cadre in cln1.bin*/
|
| 63 |
int adr2=0; /* Last byte of cadre in cln2.bin*/
|
| 64 |
int tmp=0;
|
| 65 |
int numPack[4]; /* Number of cadre in given route*/
|
| 66 |
int good_pack=0;
|
| 67 |
long long int good_number=0;
|
| 68 |
int good_route=0;
|
| 69 |
int adress[4];
|
| 70 |
int R_er[100]; /* Route errors number in given route*/
|
| 71 |
int R_er_interf1[100]; /* Interface Route error at the begining of the route*/
|
| 72 |
int R_er_interf2[100]; /* Interface Route error at end of route*/
|
| 73 |
int Mis_group[1000]; /* Number of missed cadres group
|
| 74 |
for each route*/
|
| 75 |
float first_missed[100];
|
| 76 |
int Pack_Er[1000]; /* Number of packets with packet number
|
| 77 |
error for each route*/
|
| 78 |
int CRC_bad_kadr[3]; /* Current CRC bad cadre number*/
|
| 79 |
int flag_pack[3]; /* Flag for error in packet number*/
|
| 80 |
int flag_rout[3]; /* Flag for error in route number*/
|
| 81 |
int flag_name[3]; /* Flag for name error*/
|
| 82 |
int flag_CRC0[3]; /* Flag for CRC0 error*/
|
| 83 |
int flag_CRC[3]; /* Flag for CRC error*/
|
| 84 |
int flag_CRC_cor[3]; /* Flag for CRC error correction*/
|
| 85 |
int flag_tr[3]; /* Truncate flag*/
|
| 86 |
short int flags; /* Number for all errors*/
|
| 87 |
|
| 88 |
for (j=0; j<4; j++) {adress[j]=0; numPack[j]=0;}
|
| 89 |
for (j=0; j<1024; j++)
|
| 90 |
{buffer1[j]=0; buffer2[j]=0; buffer3[j]=0;}
|
| 91 |
for (i=0; i<100; i++)
|
| 92 |
{Num_kadrs[i]=0;
|
| 93 |
NumRout[i]=0;
|
| 94 |
packet_first[i]=0;
|
| 95 |
packet_last[i]=0;
|
| 96 |
count_missed[i]=0;
|
| 97 |
count_sec_missed[i]=0;
|
| 98 |
first_missed[i]=0;
|
| 99 |
count_ident[i]=0;
|
| 100 |
count_tot[i]=0;
|
| 101 |
R_er[i]=0;
|
| 102 |
R_er_interf1[i]=0;
|
| 103 |
Num_bad_kadrs[i]=0;
|
| 104 |
Num_good_kadrs[i]=0;
|
| 105 |
quality[i]=0; Mis_group[i]=0; Pack_Er[i]=0;
|
| 106 |
R_er_interf2[i]=0;}
|
| 107 |
for (i=0; i<3; i++)
|
| 108 |
{numP[i]=0; CRC_bad_kadr[i]=0; Hex[i]=0;
|
| 109 |
flag_pack[i]=0; flag_rout[i]=0;
|
| 110 |
flag_name[i]=0; flag_CRC0[i]=0; flag_tr[i]=0;
|
| 111 |
flag_CRC[i]=0; flag_CRC_cor[i]=0;}
|
| 112 |
|
| 113 |
stringstream oss;
|
| 114 |
|
| 115 |
strcpy(connection,MYSQL);
|
| 116 |
strcat(connection,database);
|
| 117 |
TSQLServer *sqlServer = TSQLServer::Connect(connection, "pamelaprod", "rawprod");
|
| 118 |
// open input file "nnnnnmmm.pam"
|
| 119 |
fin.open(fni, ifstream::binary);
|
| 120 |
if(fin.good()==0) {cerr<<"can not open input file"; exit(0);}
|
| 121 |
//open output file "nnnnnmmm_work.dat"
|
| 122 |
fout=fopen(fno, "wb");
|
| 123 |
if(fout==0) {cerr<<"can not open work file"; exit(0);}
|
| 124 |
|
| 125 |
strcpy(ch5,"info");
|
| 126 |
strcpy(ch4,fno);
|
| 127 |
for(i=0;i<4;i++){ch4[strlen(ch4)-8+i]=ch5[i];}
|
| 128 |
// open input file "nnnnnmmm_info.dat"
|
| 129 |
fo_info.open(ch4, ifstream::binary);
|
| 130 |
if(fo_info.good()==0) {cerr<<"can not open info file"; exit(0);}
|
| 131 |
|
| 132 |
//open output file "nnnnnmmm_protocol.txt"
|
| 133 |
fo=fopen(protocol, "wb");
|
| 134 |
if(fo==0) {cerr<<"can not open protocol file"; exit(0);}
|
| 135 |
//open output file "nnnnnmmm_route.log"
|
| 136 |
strncpy(log_route,INF,strlen(INF)-9);
|
| 137 |
log_route[strlen(INF)-9]='\0';
|
| 138 |
strcat(log_route,"_route.log");
|
| 139 |
fo_route=fopen(log_route, "wb");
|
| 140 |
if(fo_route==0) {cerr<<"can not open file for routes number"; exit(0);}
|
| 141 |
/////////////////////////////////////////////////////////////////
|
| 142 |
// cin>>stop1;
|
| 143 |
k=0;
|
| 144 |
while(fin.eof()==0)
|
| 145 |
{
|
| 146 |
counter=0; //pounter for position of cadre truncation
|
| 147 |
N_er=0;
|
| 148 |
P_er=0;
|
| 149 |
CRC0_er=0;
|
| 150 |
if (N1==0) Rcount=1;
|
| 151 |
/**********************data reading********************************/
|
| 152 |
fin.read(Name_Buf,3);
|
| 153 |
if (fin.eof()) break;
|
| 154 |
fin.read(Short_Buf,5);
|
| 155 |
if (fin.eof()) break;
|
| 156 |
ch1=Name_Buf[0];
|
| 157 |
ch2=Name_Buf[1];
|
| 158 |
ch3=Name_Buf[2];
|
| 159 |
tmpP=(long int)(unsigned char)(Short_Buf[1])+
|
| 160 |
256*(long int)(unsigned char)(Short_Buf[2])+
|
| 161 |
256*256*(long int)(unsigned char)(Short_Buf[3]);
|
| 162 |
icount+=8; icount_total+=8;
|
| 163 |
count_ident[Rcount-1]+=8; count_tot[Rcount-1]+=8;
|
| 164 |
|
| 165 |
while((ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&&
|
| 166 |
(N1==0||buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])))
|
| 167 |
||
|
| 168 |
(ch2!=(char)(CODE2)&&ch3!=(char)(CODE3)&&(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||(numP[2]+1)!=tmpP))
|
| 169 |
||
|
| 170 |
(ch3!=(char)(CODE3)&&ch1!=(char)(CODE1)&&((numP[2]+1)!=tmpP||buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])))
|
| 171 |
||
|
| 172 |
(ch1!=(char)(CODE1)&&
|
| 173 |
(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP))
|
| 174 |
||
|
| 175 |
(ch2!=(char)(CODE2)&&
|
| 176 |
(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP))
|
| 177 |
||
|
| 178 |
(ch3!=(char)(CODE3)&&
|
| 179 |
(buffer3[1023]!=(int)(unsigned char)(Short_Buf[4])||buffer3[3]!=(int)(unsigned char)(Short_Buf[0])||(numP[2]+1)!=tmpP))
|
| 180 |
||
|
| 181 |
(ch1!=(char)(CODE1)&&ch2!=(char)(CODE2)&&ch3!=(char)(CODE3)))
|
| 182 |
{fin.get(ch);
|
| 183 |
if (fin.eof()) {break;}
|
| 184 |
ch1=ch2; ch2=ch3; ch3=Short_Buf[0];
|
| 185 |
for (i=0;i<4;i++) Short_Buf[i]=Short_Buf[i+1]; Short_Buf[4]=ch;
|
| 186 |
icount_total+=1; count_tot[Rcount-1]+=1;
|
| 187 |
tmpP=(long int)(unsigned char)(Short_Buf[1])+
|
| 188 |
256*(long int)(unsigned char)(Short_Buf[2])+
|
| 189 |
256*256*(long int)(unsigned char)(Short_Buf[3]);
|
| 190 |
}
|
| 191 |
if ((fin.eof())&&(N1==0))
|
| 192 |
{
|
| 193 |
fclose(fout);
|
| 194 |
fo_info.close();
|
| 195 |
remove(fno);
|
| 196 |
fclose(fo);
|
| 197 |
remove(protocol);
|
| 198 |
remove(INF);
|
| 199 |
exit(0);
|
| 200 |
}
|
| 201 |
|
| 202 |
/*****************************************************************/
|
| 203 |
/*********************data reading********************************/
|
| 204 |
fin.read(buf,LenthBuf);
|
| 205 |
if (fin.eof()) break;
|
| 206 |
icount+=1015; icount_total+=1015;
|
| 207 |
count_ident[Rcount-1]+=1015; count_tot[Rcount-1]+=1015;
|
| 208 |
/****************************************************************/
|
| 209 |
/********************data reading********************************/
|
| 210 |
fin.get(ch);
|
| 211 |
icount+=1; icount_total+=1;
|
| 212 |
count_ident[Rcount-1]+=1; count_tot[Rcount-1]+=1;
|
| 213 |
if (fin.eof()) break;
|
| 214 |
/***************************************************************/
|
| 215 |
N1+=1; Num_kadrs[Rcount-1]+=1;
|
| 216 |
|
| 217 |
/**********************DATA ANALYSIS****************************/
|
| 218 |
/***************************************************************/
|
| 219 |
header1=(unsigned char)(ch1);
|
| 220 |
header2=(unsigned char)(ch2);
|
| 221 |
header3=(unsigned char)(ch3);
|
| 222 |
switch (N1)
|
| 223 |
{
|
| 224 |
case 1:{
|
| 225 |
buffer3[0]=(int)(unsigned char)(ch1);
|
| 226 |
buffer3[1]=(int)(unsigned char)(ch2);
|
| 227 |
buffer3[2]=(int)(unsigned char)(ch3);
|
| 228 |
buffer3[3]=(int)(unsigned char)(Short_Buf[0]);
|
| 229 |
buffer3[4]=(int)(unsigned char)(Short_Buf[1]);
|
| 230 |
buffer3[5]=(int)(unsigned char)(Short_Buf[2]);
|
| 231 |
buffer3[6]=(int)(unsigned char)(Short_Buf[3]);
|
| 232 |
buffer3[7]=(int)(unsigned char)(Short_Buf[4]);
|
| 233 |
for (i=0; i<1015; i++)
|
| 234 |
{buffer3[i+8]=(int)(unsigned char)(buf[i]);}
|
| 235 |
buffer3[1023]=(int)(unsigned char)(ch);
|
| 236 |
for (i=0; i<1024; i++)
|
| 237 |
{buffer1[i]=buffer3[i];buffer2[i]=buffer3[i];}
|
| 238 |
|
| 239 |
NumRout[Rcount-1]=1;
|
| 240 |
numP[2]=(long int)(unsigned char)(Short_Buf[1])+
|
| 241 |
256*(long int)(unsigned char)(Short_Buf[2])+
|
| 242 |
256*256*(long int)(unsigned char)(Short_Buf[3]);
|
| 243 |
CRC_bad_kadr[2]=0;
|
| 244 |
flag_pack[2]=0; flag_rout[2]=0;
|
| 245 |
flag_name[2]=0; flag_CRC0[2]=0; flag_tr[2]=0;
|
| 246 |
flag_CRC[2]=0; flag_CRC_cor[2]=0;
|
| 247 |
for (i=0; i<2; i++)
|
| 248 |
{numP[i]=numP[2];CRC_bad_kadr[i]=CRC_bad_kadr[2];
|
| 249 |
flag_pack[i]=flag_pack[2]; flag_rout[i]=flag_rout[2];
|
| 250 |
flag_name[i]=flag_name[2]; flag_CRC0[i]=flag_CRC0[2];
|
| 251 |
flag_CRC[i]=flag_CRC[2]; flag_tr[i]=flag_tr[2];
|
| 252 |
flag_CRC_cor[i]=flag_CRC_cor[2];}
|
| 253 |
CRC_0[2]=(int)(unsigned char)(Short_Buf[4]);
|
| 254 |
for (i=0; i<2; i++)
|
| 255 |
{CRC_0[i]=CRC_0[2];}
|
| 256 |
CRC_1[2]=(int)(unsigned char)(ch);
|
| 257 |
for (i=0; i<2; i++)
|
| 258 |
{CRC_1[i]=CRC_1[2];}
|
| 259 |
packet_first[Rcount-1]=numP[2];
|
| 260 |
break;
|
| 261 |
}
|
| 262 |
default:{
|
| 263 |
for (i=0; i<1024; i++)
|
| 264 |
{buffer1[i]=buffer2[i];buffer2[i]=buffer3[i];}
|
| 265 |
buffer3[0]=(int)(unsigned char)(ch1);
|
| 266 |
buffer3[1]=(int)(unsigned char)(ch2);
|
| 267 |
buffer3[2]=(int)(unsigned char)(ch3);
|
| 268 |
buffer3[3]=(int)(unsigned char)(Short_Buf[0]);
|
| 269 |
buffer3[4]=(int)(unsigned char)(Short_Buf[1]);
|
| 270 |
buffer3[5]=(int)(unsigned char)(Short_Buf[2]);
|
| 271 |
buffer3[6]=(int)(unsigned char)(Short_Buf[3]);
|
| 272 |
buffer3[7]=(int)(unsigned char)(Short_Buf[4]);
|
| 273 |
for (i=0; i<1015; i++)
|
| 274 |
{buffer3[i+8]=(int)(unsigned char)(buf[i]);}
|
| 275 |
buffer3[1023]=(int)(unsigned char)(ch);
|
| 276 |
|
| 277 |
for (i=0; i<2; i++)
|
| 278 |
{numP[i]=numP[i+1]; CRC_bad_kadr[i]=CRC_bad_kadr[i+1];
|
| 279 |
flag_pack[i]=flag_pack[i+1];
|
| 280 |
flag_rout[i]=flag_rout[i+1];
|
| 281 |
flag_name[i]=flag_name[i+1];
|
| 282 |
flag_CRC0[i]=flag_CRC0[i+1];
|
| 283 |
flag_tr[i]=flag_tr[i+1];
|
| 284 |
flag_CRC[i]=flag_CRC[i+1];
|
| 285 |
flag_CRC_cor[i]=flag_CRC_cor[i+1];}
|
| 286 |
numP[2]=(long int)(unsigned char)(Short_Buf[1])+
|
| 287 |
256*(long int)(unsigned char)(Short_Buf[2])+
|
| 288 |
256*256*(long int)(unsigned char)(Short_Buf[3]);
|
| 289 |
CRC_bad_kadr[2]=0;
|
| 290 |
flag_pack[2]=0; flag_rout[2]=0;
|
| 291 |
flag_name[2]=0; flag_CRC0[2]=0;
|
| 292 |
flag_CRC[2]=0; flag_CRC_cor[2]=0; flag_tr[2]=0;
|
| 293 |
for (i=0; i<2; i++) CRC_0[i]=CRC_0[i+1];
|
| 294 |
CRC_0[2]=(int)(unsigned char)(Short_Buf[4]);
|
| 295 |
for (i=0; i<2; i++) {CRC_1[i]=CRC_1[i+1];}
|
| 296 |
CRC_1[2]=(int)(unsigned char)(ch);
|
| 297 |
}
|
| 298 |
}
|
| 299 |
if (print_flag>0 && fmod(N1,10000)==0.) cout<<N1<<"\n";
|
| 300 |
|
| 301 |
/******************CRC ERROR ANALYSIS***************************/
|
| 302 |
CalcCheckSum=CRC(buffer3);
|
| 303 |
if (CalcCheckSum!=(short int)(buffer3[1023]))
|
| 304 |
{
|
| 305 |
//write in file nnnnnmmm_info.dat
|
| 306 |
fo_info<<"real CRC = "<<hex<<buffer3[1023]<<" (calculated CRC ="<<CalcCheckSum<<") in cadre "<<dec<<numP[2]<<"\n";
|
| 307 |
//write in file nnnnnmmm_work.dat
|
| 308 |
fprintf(fout,"%i %x (%x)", numP[2], CalcCheckSum, buffer3[1023]);
|
| 309 |
|
| 310 |
flag_CRC[2]=1;
|
| 311 |
Num_bad_kadrs[Rcount-1]+=1;
|
| 312 |
CRC_bad_kadr[2]=numP[2];
|
| 313 |
counter=restrict(buffer3,numP,buffer2[3]);
|
| 314 |
if (counter!=0)
|
| 315 |
{fo_info<<" truncate byte="<<counter<<" in cadre "<<numP[2]<<"\n";
|
| 316 |
if (print_flag>0)
|
| 317 |
{cout<<" truncate counter="<<counter<<" route="<<buffer2[3]<<" "<<buffer3[3]<<" kadr="<<numP[2]<<" "<<numP[1]<<" "<<numP[0]<<"\n";}
|
| 318 |
fin.seekg(-(1024-counter),ios::cur);
|
| 319 |
icount-=1024;
|
| 320 |
count_ident[Rcount-1]-=1024;
|
| 321 |
count_tot[Rcount-1]-=1024-counter;
|
| 322 |
icount_total-=1024-counter;
|
| 323 |
N1-=1;
|
| 324 |
CRC_bad_kadr[2]=0;
|
| 325 |
flag_tr[2]=1;
|
| 326 |
Num_kadrs[Rcount-1]-=1;
|
| 327 |
Num_bad_kadrs[Rcount-1]-=1;}
|
| 328 |
}
|
| 329 |
|
| 330 |
/******************HEADER ANALYSIS*******************************/
|
| 331 |
if ((header1!=(int)(CODE1))||(header2!=(int)(CODE2))||(header3!=(int)(CODE3)))
|
| 332 |
{flag_name[2]=1; N_er=N1;}
|
| 333 |
/****************************************************************/
|
| 334 |
|
| 335 |
/******************CRC0 ANALYSIS*********************************/
|
| 336 |
if ((buffer2[7]!=buffer1[1023])&&
|
| 337 |
((numP[1]==numP[0]+1)||(numP[1]==numP[2]-1))&&(flag_tr[1]!=1)&&(flag_tr[0]!=1)&&(N1>2))
|
| 338 |
{flag_CRC0[1]=1; CRC0_er=N1-1;}
|
| 339 |
/****************************************************************/
|
| 340 |
|
| 341 |
/******************KADR NUMBER ANALYSIS**************************/
|
| 342 |
if ((numP[1]!=(numP[0]+1))&&(numP[1]!=(numP[2]-1))&&(N1!=1)&&(CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0))
|
| 343 |
{P_er=N1-1; flag_pack[1]=1;
|
| 344 |
//Correct error packet number//
|
| 345 |
tmpP=numP[0]+1;
|
| 346 |
for (i=0;i<3;i++) Hex[i]=0;
|
| 347 |
for (i=0;i<3;i++)
|
| 348 |
{if (tmpP/(long int)(pow(256.,2-i))>=1)
|
| 349 |
{Hex[2-i]=(int)(tmpP/(long int)(pow(256.,2-i)));
|
| 350 |
tmpP=tmpP-(long int)pow(256.,2-i)*(int)(tmpP/(long int)(pow(256.,2-i)));}}
|
| 351 |
for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]);
|
| 352 |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
|
| 353 |
|
| 354 |
tmpP=numP[2]-1;
|
| 355 |
for (i=0;i<3;i++) Hex[i]=0;
|
| 356 |
for (i=0;i<3;i++)
|
| 357 |
{if (tmpP/(long int)(pow(256.,2-i))>=1)
|
| 358 |
{Hex[2-i]=(int)(tmpP/(long int)(pow(256.,2-i)));
|
| 359 |
tmpP=tmpP-(long int)pow(256.,2-i)*(int)(tmpP/(long int)(pow(256.,2-i)));}}
|
| 360 |
for (i=4;i<7;i++) (buffer2[i]=Hex[i-4]);
|
| 361 |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
|
| 362 |
}
|
| 363 |
/////////////////////////////////////////////////////////////////////
|
| 364 |
if ((numP[2]!=(numP[1]+1))&&(N1!=1)&&(buffer3[3]==buffer2[3])&&(CRC_bad_kadr[2]==numP[2])&&(numP[2]!=0)) flag_pack[2]=1;
|
| 365 |
if (flag_pack[2]!=1) packet_last[Rcount-1]=numP[2];
|
| 366 |
////////Missing cadre analysis////////////////////////////////////
|
| 367 |
/**route number: 10 (10 19 10) 10 ******************************/
|
| 368 |
/**cadre number: 21 (22 17 18) 19 ******************************/
|
| 369 |
/**missed cadres: 21 20 19 18 17 ******************************/
|
| 370 |
if ((numP[1]<numP[0])&&(numP[1]==numP[2]-1)&&(buffer1[3]==buffer3[3])&&(flag_tr[1]==0)&&
|
| 371 |
(flag_pack[0]==0)&&(flag_pack[1]==0)&&(flag_pack[2]==0))
|
| 372 |
{Mis_group[Rcount-1]+=1;
|
| 373 |
count_sec_missed[Rcount-1]+=numP[0]-1-numP[1];
|
| 374 |
fprintf(foMiss,"secondary transmitted cadres may be %lli - %lli number of cadres=%lli\n",numP[1],numP[0],numP[0]-1-numP[1]);
|
| 375 |
}
|
| 376 |
|
| 377 |
/**route number: 10 (10 19 10) 10 ******************************/
|
| 378 |
/**cadre number: 11 (12 15 20) 21 ******************************/
|
| 379 |
/**missed cadres: 16 17 18 19 ******************************/
|
| 380 |
if ((numP[1]>numP[0]+1)&&(numP[1]<numP[2]-1)&&(buffer1[3]==buffer3[3])&&(flag_tr[1]==0)&&
|
| 381 |
(flag_pack[0]==0)&&(flag_pack[1]==0)&&(flag_pack[2]==0))
|
| 382 |
{Mis_group[Rcount-1]+=1;
|
| 383 |
fprintf(foMiss,"1) %9lli%9lli\n",numP[1]+1,numP[2]-1);
|
| 384 |
count_missed[Rcount-1]+=numP[2]-numP[1]-1;}
|
| 385 |
/**route number: (10 10 10) 10 10 ******************************/
|
| 386 |
/**cadre number: (11 12 15) 20 21 ******************************/
|
| 387 |
/**missed kadrs: 13 14 ******************************/
|
| 388 |
else if ((numP[1]>=numP[0]+1)&&(numP[1]<numP[2]-1)&&
|
| 389 |
(buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&&
|
| 390 |
(flag_tr[1]==0)&&(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0))
|
| 391 |
{Mis_group[Rcount-1]+=1;
|
| 392 |
fprintf(foMiss,"2) %9lli%9lli\n",numP[0]+2,numP[2]-1);
|
| 393 |
count_missed[Rcount-1]+=numP[2]-numP[0]-1-1;}
|
| 394 |
/**route number: (10 10 10) 10 10 ******************************/
|
| 395 |
/**cadre number: (11 29 15) 14 15 ******************************/
|
| 396 |
/**number of missed cadres:2 ******************************/
|
| 397 |
else if (((numP[1]<numP[0]+1)||(numP[1]>numP[2]-1))&&(numP[2]-numP[0]>2)&&
|
| 398 |
(buffer1[3]==buffer3[3])&&(buffer1[3]==buffer2[3])&&(flag_tr[1]==0)&&
|
| 399 |
(flag_pack[2]==0)&&(flag_pack[1]==1)&&(flag_pack[0]==0))
|
| 400 |
{Mis_group[Rcount-1]+=1;
|
| 401 |
fprintf(foMiss,"3) %9lli%9lli -1\n",numP[0]+1,numP[2]-1);
|
| 402 |
count_missed[Rcount-1]+=numP[2]-numP[0]-1-1;}
|
| 403 |
/**route number:(10 10 )10 10 10 10 ******************************/
|
| 404 |
/**cadre number:( 1 11 )12 13 14 15 ******************************/
|
| 405 |
/**number of missed cadres: 10 ******************************/
|
| 406 |
else if ((N1>1)&&(abs(numP[2]-good_pack-2)>abs(Num_kadrs[Rcount-1]-good_number))&&
|
| 407 |
(buffer2[3]==good_route)&&(flag_tr[2]==0)&&(flag_pack[2]==0))
|
| 408 |
{Mis_group[Rcount-1]+=1;
|
| 409 |
count_missed[Rcount-1]+=abs(numP[2]-good_pack)-1;
|
| 410 |
fprintf(foMiss,"4) %9i%9lli number of missed cadres=%i\n", good_pack, numP[2], abs(numP[2]-good_pack)-1);
|
| 411 |
}
|
| 412 |
//truncate cadres
|
| 413 |
/**route number: 10 (10 10 10) 10 ******************************/
|
| 414 |
/**cadre number: 11 (12 13 14) 15 ******************************/
|
| 415 |
/**missed truncate cadre:13 ******************************/
|
| 416 |
else if ((numP[0]<numP[2]-1)&&(buffer1[3]==buffer3[3])&&
|
| 417 |
(flag_tr[0]==0)&&(flag_tr[1]==1)&&(flag_tr[2]==0)&&
|
| 418 |
(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0))
|
| 419 |
{Mis_group[Rcount-1]+=1;
|
| 420 |
fprintf(foMiss,"5) %9lli%9lli\n",numP[0]+1,numP[2]-1);
|
| 421 |
count_missed[Rcount-1]+=numP[2]-numP[0]-1;}
|
| 422 |
/***************************************************************/
|
| 423 |
|
| 424 |
if (flag_CRC[2]!=1) {good_pack=numP[2]; good_route=buffer3[3]; good_number=Num_kadrs[Rcount-1];}
|
| 425 |
|
| 426 |
/******************ROUTE NUMBER ANALYSIS**************************/
|
| 427 |
if ((buffer2[3]!=buffer1[3])&&(buffer2[3]!=buffer3[3])&&(buffer1[3]!=buffer3[3])&&
|
| 428 |
(flag_pack[2]==0)&&(flag_pack[1]==0)&&(flag_pack[0]==0))
|
| 429 |
{
|
| 430 |
|
| 431 |
}
|
| 432 |
/**************First route***************************************/
|
| 433 |
/**route number: (0 4) 4*****************************************/
|
| 434 |
/**cadre number: (0 1) 2*****************************************/
|
| 435 |
if (N1==2)
|
| 436 |
{packet_first[Rcount-1]=numP[1];
|
| 437 |
packet_last[Rcount-1]=numP[2];
|
| 438 |
NumRout[Rcount-1]=1;
|
| 439 |
// CREATE FILE NAMES
|
| 440 |
filename(file_route, miss_file, cln1_file, path, NumRout[Rcount-1], name);
|
| 441 |
strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3);
|
| 442 |
cln1_kadr[strlen(cln1_file)-3]='\0';
|
| 443 |
strcat(cln1_kadr,"bin");
|
| 444 |
strncpy(log_kadr,file_route,strlen(file_route)-6);
|
| 445 |
log_kadr[strlen(file_route)-6]='\0';
|
| 446 |
strcat(log_kadr,"_bin.log");
|
| 447 |
//Open files for new route
|
| 448 |
foRout=fopen(file_route, "wb"); //nnnnn_mmm_xxx_cln1Er.log
|
| 449 |
foMiss=fopen(miss_file, "wb"); //nnnnn_mmm_xxx_mis_cln1.dat
|
| 450 |
if (CLN1_MEPHI>0)
|
| 451 |
{strcpy(ch4,"");
|
| 452 |
strncat(ch4,path,strlen(path)-6);
|
| 453 |
strcat(strcpy(temp1,ch4),"Cln1/tmp.dat");
|
| 454 |
if ((fo_tmp=fopen(temp1,"w"))==NULL)
|
| 455 |
{strcat(strcat(strcpy(command,"mkdir "),ch4),"Cln1");
|
| 456 |
//Creata special directory for cln1 files
|
| 457 |
system(command);
|
| 458 |
}
|
| 459 |
else
|
| 460 |
{
|
| 461 |
fclose(fo_tmp);
|
| 462 |
remove(temp1);
|
| 463 |
}
|
| 464 |
for(i=0;i<22;i++)
|
| 465 |
{name11[i]=cln1_file[i+strlen(cln1_file)-22];}
|
| 466 |
name11[22]='\0';
|
| 467 |
strcat(strcat(ch4,"Cln1/"),name11);
|
| 468 |
strcpy(cln1_file,ch4);
|
| 469 |
}
|
| 470 |
fo_cln1.open(cln1_file, ios::binary); //nnnnn_mmm_xxx_cln1.pam
|
| 471 |
|
| 472 |
if (!fo_cln1) cout<<"can not open "<<cln1_file<<"\n";
|
| 473 |
fokadr_cln1.open(cln1_kadr,ios::binary); //nnnnn_mmm_xxx_cln1.bin
|
| 474 |
if (!fokadr_cln1) cout<<"can not open "<<cln1_kadr<<"\n";
|
| 475 |
fo_log_kadr=fopen(log_kadr,"wb"); //nnnnn_mmm_xxx_cln1_bin.log
|
| 476 |
}
|
| 477 |
/***************New route****************************************/
|
| 478 |
/**route number: 7 ( 7 0 8) 8*********************************/
|
| 479 |
/**cadre number: 199 (200 0 1) 2*********************************/
|
| 480 |
/**route number: 7 ( 7 8 8) 8*********************************/
|
| 481 |
/**cadre number: 199 (200 0 1) 2*********************************/
|
| 482 |
if ( ((buffer1[3]!=buffer3[3])&&(buffer2[3]==0)&&(N1>3)&&(numP[1]!=numP[0]+1)&&(numP[1]<10))||
|
| 483 |
((buffer1[3]!=buffer2[3])&&(buffer2[3]==buffer3[3])&&(buffer1[3]!=0)&&(numP[1]!=numP[0]+1)&&(numP[1]<10))||
|
| 484 |
((numP[2]==numP[1]+1)&&(numP[1]==0)&&(Num_kadrs[Rcount-1]>1000000)) )
|
| 485 |
{Rcount+=1;
|
| 486 |
packet_last[Rcount-2]=numP[0];
|
| 487 |
packet_first[Rcount-1]=numP[1];
|
| 488 |
NumRout[Rcount-1]=Rcount;
|
| 489 |
if (print_flag>0)
|
| 490 |
{cout<<"New route="<<Rcount<<" "<<buffer1[3]<<" "<<buffer2[3]<<" "<<buffer3[3]<<"\n";
|
| 491 |
cout<<numP[0]<<" "<<numP[1]<<" "<<numP[2]<<"\n";}
|
| 492 |
if (flag_tr[1]==0)
|
| 493 |
{Num_kadrs[Rcount-2]-=2;
|
| 494 |
Num_kadrs[Rcount-1]+=2;
|
| 495 |
count_ident[Rcount-1]+=2048; count_ident[Rcount-2]-=2048;
|
| 496 |
count_tot[Rcount-1]+=2048; count_tot[Rcount-2]-=2048;}
|
| 497 |
else
|
| 498 |
{Num_kadrs[Rcount-2]-=1;
|
| 499 |
Num_kadrs[Rcount-1]+=1;
|
| 500 |
count_ident[Rcount-1]+=1024; count_ident[Rcount-2]-=1024;
|
| 501 |
count_tot[Rcount-1]+=1024; count_tot[Rcount-2]-=1024;}
|
| 502 |
// CREATE FILE NAMES
|
| 503 |
filename(file_route, miss_file, cln1_file, path, NumRout[Rcount-1], name);
|
| 504 |
strncpy(cln1_kadr,cln1_file,strlen(cln1_file)-3);
|
| 505 |
cln1_kadr[strlen(cln1_file)-3]='\0';
|
| 506 |
strcat(cln1_kadr,"bin");
|
| 507 |
strncpy(log_kadr,file_route,strlen(file_route)-6);
|
| 508 |
log_kadr[strlen(file_route)-6]='\0';
|
| 509 |
strcat(log_kadr,"_bin.log");
|
| 510 |
fclose(foRout); //Close files
|
| 511 |
fo_cln1.close(); //for old
|
| 512 |
fclose(foMiss); //route
|
| 513 |
fokadr_cln1.close();
|
| 514 |
fclose(fo_log_kadr);
|
| 515 |
//Open files for new route
|
| 516 |
foRout=fopen(file_route, "wb"); //nnnnn_mmm_xxx_cln1Er.log
|
| 517 |
foMiss=fopen(miss_file, "wb"); //nnnnn_mmm_xxx_mis_cln1.dat
|
| 518 |
fo_cln1.open(cln1_file, ios::binary); //nnnnn_mmm_xxx_cln1.pam
|
| 519 |
fokadr_cln1.open(cln1_kadr,ios::binary); //nnnnn_mmm_xxx_cln1.bin
|
| 520 |
fo_log_kadr=fopen(log_kadr,"wb"); //nnnnn_mmm_xxx_cln1_bin.log
|
| 521 |
if ((CRC_bad_kadr[2]==numP[2])&&(numP[2]!=0)) {Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1;}
|
| 522 |
if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0))
|
| 523 |
{Num_bad_kadrs[Rcount-1]+=1; Num_bad_kadrs[Rcount-2]-=1;
|
| 524 |
flags=(short int)(pow((float)(2*flag_name[1]),4)+
|
| 525 |
pow((float)(2*flag_rout[1]),1)+
|
| 526 |
pow((float)(2*flag_pack[1]),2)+
|
| 527 |
pow((float)(2*flag_CRC0[1]),3)+
|
| 528 |
pow((float)(2*flag_CRC[1]),5)+
|
| 529 |
pow((float)(2*flag_CRC_cor[1]),6));
|
| 530 |
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags));
|
| 531 |
fo_info<<"New route: cadre="<<CRC_bad_kadr[1]<<" error flag="<<flags<<"\n";
|
| 532 |
CRC_bad_kadr[1]-=1;}
|
| 533 |
}
|
| 534 |
|
| 535 |
if (((numP[1]==0)&&(N1>1))||(N1==2))
|
| 536 |
{rr=0;
|
| 537 |
FindRoute(buffer2, &rr);
|
| 538 |
if (rr>0)
|
| 539 |
{
|
| 540 |
real_route[Rcount]=rr;
|
| 541 |
}
|
| 542 |
else
|
| 543 |
{
|
| 544 |
real_route[Rcount]=0;
|
| 545 |
}
|
| 546 |
}
|
| 547 |
/***************************************************************/
|
| 548 |
if (CRC_bad_kadr[1]==numP[1])
|
| 549 |
{
|
| 550 |
//Correct CRC0 error/////////////////////////////////////////////////
|
| 551 |
if (flag_CRC0[1]!=0)
|
| 552 |
{
|
| 553 |
buffer2[7]=buffer1[1023];
|
| 554 |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
|
| 555 |
}
|
| 556 |
//Correct name error/////////////////////////////////////////////////
|
| 557 |
if (flag_name[1]!=0)
|
| 558 |
{buffer2[0]=(int)(CODE1);
|
| 559 |
buffer2[1]=(int)(CODE2);
|
| 560 |
buffer2[2]=(int)(CODE3);
|
| 561 |
if (buffer2[1023]==(int)(CRC(buffer2))) flag_CRC_cor[1]=1;
|
| 562 |
}
|
| 563 |
}
|
| 564 |
////////////////////////////////////////////////////////////////////
|
| 565 |
/*******************************************************************/
|
| 566 |
if ((CRC_bad_kadr[1]==numP[1])&&(numP[1]!=0)&&(N1>1))
|
| 567 |
{
|
| 568 |
flags=(short int)(pow((float)(2*flag_name[1]),4)+
|
| 569 |
pow((float)(2*flag_rout[1]),1)+
|
| 570 |
pow((float)(2*flag_pack[1]),2)+
|
| 571 |
pow((float)(2*flag_CRC0[1]),3)+
|
| 572 |
pow((float)(2*flag_CRC[1]),5)+
|
| 573 |
pow((float)(2*flag_CRC_cor[1]),6));
|
| 574 |
fprintf(foRout,"%1c%1c%1c%1c",(char)(buffer2[4]),
|
| 575 |
(char)(buffer2[5]),(char)(buffer2[6]),(char)(flags));
|
| 576 |
fo_info<<"CRC error in cadre "<<CRC_bad_kadr[1]<<" error flag="<<flags<<"\n";}
|
| 577 |
|
| 578 |
/***************************************************************/
|
| 579 |
//*Packet analysis**********************************************
|
| 580 |
if (N_er!=0) fo_info<<"Name error "<<N_er<<" in cadre "<<numP[2]<<"\n";
|
| 581 |
if (P_er!=0) fo_info<<"Number packet error "<<numP[1]<<" in cadre "<<P_er<<"\n";
|
| 582 |
if (CRC0_er!=0) fo_info<<"CRC0 error "<<numP[1]<<" in cadre "<<CRC0_er<<"\n";
|
| 583 |
|
| 584 |
/***************PAMELA data extracting for each route***********/
|
| 585 |
// if (N1!=1&&(flag_CRC[1]==0||(flag_rout[1]==0&&flag_pack[1]==0)||
|
| 586 |
// (flag_CRC[1]!=0&&flag_CRC_cor[1]==1)))
|
| 587 |
if ((N1!=1)&&(flag_tr[1]==0))
|
| 588 |
{end=0;
|
| 589 |
if (buffer2[3]!=buffer1[3]||buffer2[3]!=buffer3[3])
|
| 590 |
{for (i=8;i<1020;i++)
|
| 591 |
{
|
| 592 |
// if (fmodf(float((Num_kadrs[Rcount-1]-1)*1015+i-8),float(64))==0.&&buffer2[i]==0&&buffer2[i+1]==0&&
|
| 593 |
// buffer2[i+2]==0&&buffer2[i+3]==0) end=1;
|
| 594 |
if (end!=1) fo_cln1<<(unsigned char)buffer2[i];
|
| 595 |
}
|
| 596 |
if (end!=1) for(i=1020;i<1023;i++) {fo_cln1<<(unsigned char)buffer2[i];}
|
| 597 |
}
|
| 598 |
else {for(i=8;i<1023;i++) fo_cln1<<(unsigned char)buffer2[i];}
|
| 599 |
for (i=0;i<1024;i++) {fokadr_cln1<<(unsigned char)buffer2[i];}
|
| 600 |
//Write in file nnnnn_mmm_xxx_cln1_bin.log
|
| 601 |
tmp=numP[1];
|
| 602 |
for (k=0;k<4;k++) numPack[k]=0;
|
| 603 |
for (k=0;k<3;k++)
|
| 604 |
{if (tmp/(long int)(pow(256.,2-k))>=1)
|
| 605 |
{numPack[2-k]=(int)(tmp/(long int)(pow(256.,2-k)));
|
| 606 |
tmp=tmp-(long int)pow(256.,2-k)*(int)(tmp/(long int)(pow(256.,2-k)));}}
|
| 607 |
for (i=0;i<3;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr);
|
| 608 |
adr1=icount-1024*2;
|
| 609 |
for (k=0;k<4;k++) adress[k]=0;
|
| 610 |
for (k=0;k<4;k++)
|
| 611 |
{if (adr1/(long int)(pow(256.,3-k))>=1)
|
| 612 |
{adress[3-k]=(int)(adr1/(long int)(pow(256.,3-k)));
|
| 613 |
adr1=adr1-(long int)pow(256.,3-k)*
|
| 614 |
(int)(adr1/(long int)(pow(256.,3-k)));}}
|
| 615 |
for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr);
|
| 616 |
adr2=icount-1024;
|
| 617 |
for (k=0;k<4;k++) adress[k]=0;
|
| 618 |
for (k=0;k<4;k++)
|
| 619 |
{if (adr2/(long int)(pow(256.,3-k))>=1)
|
| 620 |
{adress[3-k]=(int)(adr2/(long int)(pow(256.,3-k)));
|
| 621 |
adr2=adr2-(long int)pow(256.,3-k)*
|
| 622 |
(int)(adr2/(long int)(pow(256.,3-k)));}}
|
| 623 |
for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr);
|
| 624 |
fputc(flags,fo_log_kadr);
|
| 625 |
}
|
| 626 |
}
|
| 627 |
/***************************************************************/
|
| 628 |
/***************************************************************/
|
| 629 |
if (flag_CRC[2]==0||(flag_rout[2]==0&&flag_pack[2]==0)||
|
| 630 |
(flag_CRC[2]!=0&&flag_CRC_cor[2]==1))
|
| 631 |
{end=0;
|
| 632 |
for (i=0;i<1024;i++) fokadr_cln1<<(unsigned char)buffer3[i];
|
| 633 |
//Write in file nnnnn_mmm_xxx_cln1_bin.log
|
| 634 |
tmp=numP[2];
|
| 635 |
for (k=0;k<4;k++) numPack[k]=0;
|
| 636 |
for (k=0;k<3;k++)
|
| 637 |
{if (tmp/(long int)(pow(256.,2-k))>=1)
|
| 638 |
{numPack[2-k]=(int)(tmp/(long int)(pow(256.,2-k)));
|
| 639 |
tmp=tmp-(long int)pow(256.,2-k)*
|
| 640 |
(int)(tmp/(long int)(pow(256.,2-k)));}}
|
| 641 |
for (i=0;i<3;i++) fputc((int)(unsigned char)(numPack[i]),fo_log_kadr);
|
| 642 |
adr1=icount-1024;
|
| 643 |
for (k=0;k<4;k++) adress[k]=0;
|
| 644 |
for (k=0;k<4;k++)
|
| 645 |
{if (adr1/(long int)(pow(256.,3-k))>=1)
|
| 646 |
{adress[3-k]=(int)(adr1/(long int)(pow(256.,3-k)));
|
| 647 |
adr1=adr1-(long int)pow(256.,3-k)*
|
| 648 |
(int)(adr1/(long int)(pow(256.,3-k)));}}
|
| 649 |
for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr);
|
| 650 |
adr2=icount;
|
| 651 |
for (k=0;k<4;k++) adress[k]=0;
|
| 652 |
for (k=0;k<4;k++)
|
| 653 |
{if (adr2/(long int)(pow(256.,3-k))>=1)
|
| 654 |
{adress[3-k]=(int)(adr2/(long int)(pow(256.,3-k)));
|
| 655 |
adr2=adr2-(long int)pow(256.,3-k)*
|
| 656 |
(int)(adr2/(long int)(pow(256.,3-k)));}}
|
| 657 |
for (i=0;i<4;i++) fputc((int)(unsigned char)(adress[i]),fo_log_kadr);
|
| 658 |
fputc(flags,fo_log_kadr);
|
| 659 |
|
| 660 |
for (i=8;i<1019;i++)
|
| 661 |
{
|
| 662 |
// if (fmodf(float((Num_kadrs[Rcount-1]-1)*1015+i-8),
|
| 663 |
// float(64))==0.&&buffer3[i]==0&&buffer3[i+1]==0&&
|
| 664 |
// buffer3[i+2]==0&&buffer3[i+3]==0&&buffer3[i+4]==0) end=1;
|
| 665 |
if (end!=1) fo_cln1<<(unsigned char)buffer3[i];
|
| 666 |
}
|
| 667 |
if (end!=1) {for(i=1019;i<1023;i++) {fo_cln1<<(unsigned char)buffer3[i];}}
|
| 668 |
}
|
| 669 |
|
| 670 |
icount_int = (int)(icount/1024);
|
| 671 |
icount_frac= icount%1024;
|
| 672 |
|
| 673 |
//***protocol file***********************************************
|
| 674 |
file_length=(int)(strlen(name));
|
| 675 |
fprintf(fo,"file name=/home/ntsomz/downlinks/%s\n",name);
|
| 676 |
fprintf(fo,"file size= %i,%i kByte \n", icount_int, icount_frac);
|
| 677 |
fprintf(fo,"number identified cadres= %i\n", N1);
|
| 678 |
fprintf(fo,"number of routes= %i\n", Rcount);
|
| 679 |
|
| 680 |
for(i=0;i<5;i++) {temp[i]=name[i]; temp[5]='\0';}
|
| 681 |
sscanf(temp,"%5d", &cirquit_no);
|
| 682 |
for(i=0;i<3;i++) {temp[i]=name[i+5]; temp[3]='\0';}
|
| 683 |
sscanf(temp,"%3i", &route);
|
| 684 |
|
| 685 |
for (i=0;i<Rcount;i++)
|
| 686 |
{
|
| 687 |
for(j=0;j<22;j++) temp[j]=cln1_file[j+strlen(cln1_file)-22];
|
| 688 |
temp[22]='\0';
|
| 689 |
oss.str("");
|
| 690 |
oss << "INSERT INTO RAW_FILES (cirquit_n, route_n, counter, NumCadr, CRCerr, cln1_name, cln1_size)"
|
| 691 |
<< " VALUES ("<< cirquit_no << ","<< route << ","<< i+1 <<","<< Num_kadrs[i]<< "," << Num_bad_kadrs[i] << ",'"
|
| 692 |
<< temp << "'," << count_ident[i]-Num_kadrs[i]*9 << ")";
|
| 693 |
if (print_flag>0) cout<<oss.str().c_str()<<" table RAW_FILES\n";
|
| 694 |
TSQLResult *res=sqlServer->Query(oss.str().c_str());
|
| 695 |
|
| 696 |
Num_good_kadrs[i]=Num_kadrs[i]-Num_bad_kadrs[i];
|
| 697 |
if (packet_first[i]>1)
|
| 698 |
{first_missed[i]=(float)(1.)-float(packet_first[i]-1.)/(float)(packet_last[i]);}
|
| 699 |
else if (packet_first[i]==0)
|
| 700 |
{first_missed[i]=1.;}
|
| 701 |
|
| 702 |
|
| 703 |
quality[i]=(float)(1.)-(float)(Num_bad_kadrs[i])/(float)(Num_kadrs[i]);
|
| 704 |
fprintf(fo,"\nRoute number=%i: number of normal cadres= %i: number of errors=%i; \n",NumRout[i],Num_good_kadrs[i],Num_bad_kadrs[i]);
|
| 705 |
fprintf(fo,"size of identified cadres =%lli bytes;",count_ident[i]);
|
| 706 |
fprintf(fo," total size of route=%lli bytes;\n",count_tot[i]);
|
| 707 |
fprintf(fo,"first cadre number= %lli:", packet_first[i]);
|
| 708 |
fprintf(fo," last cadre number= %lli:", packet_last[i]);
|
| 709 |
fprintf(fo," Number of missed cadres= %lli:\n", count_missed[i]);
|
| 710 |
fprintf(fo,"number of identified cadres=%lli: quality index=%f: completness=%f \n", Num_kadrs[i], quality[i],
|
| 711 |
first_missed[i]);
|
| 712 |
}
|
| 713 |
|
| 714 |
//***route's number log file**************************************
|
| 715 |
for (i=0;i<Rcount;i++) {fprintf(fo_route,"%1c",(char)(NumRout[i]));}
|
| 716 |
|
| 717 |
|
| 718 |
//***************************************************************
|
| 719 |
fin.close();
|
| 720 |
fclose(fout);
|
| 721 |
fo_info.close();
|
| 722 |
fclose(fo);
|
| 723 |
fclose(foRout);
|
| 724 |
fclose(foMiss);
|
| 725 |
fo_cln1.close();
|
| 726 |
fclose(fo_log_kadr);
|
| 727 |
fokadr_cln1.close();
|
| 728 |
fclose(fo_route);
|
| 729 |
}
|
| 730 |
|