| 19 |
void confluence(char [], char [], char [], char [], char [], int[]); |
void confluence(char [], char [], char [], char [], char [], int[]); |
| 20 |
void sort(char [], char [], char [], char[], char [], int[]); |
void sort(char [], char [], char [], char[], char [], int[]); |
| 21 |
|
|
| 22 |
|
char MYSQL[80]; |
| 23 |
|
char database[80]; |
| 24 |
|
float YODA_flag; |
| 25 |
|
float transmit_flag; |
| 26 |
|
int print_flag; |
| 27 |
|
|
| 28 |
int main(int argc, char *argv[]) |
int main(int argc, char *argv[]) |
| 29 |
{ |
{ |
| 30 |
|
|
| 31 |
// char stop; |
// char stop; |
| 32 |
float IndexQ, quality[100]; /*Quality index*/ |
float IndexQ, quality[100]; /*Quality index*/ |
| 33 |
int real_route[64]; |
int real_route[64]; |
| 34 |
int rc=0; |
int rc=0; |
| 35 |
int r_counter; /*Route counter*/ |
int r_counter; /*Route counter*/ |
| 36 |
|
|
| 37 |
char MainPath[80]; /* /home/pamelaprod/ */ |
char MainPath[80]; /* /home/pamelaprod/rawreader/ */ |
| 38 |
|
char timesync[80]; |
| 39 |
|
char arina[80]; |
| 40 |
char INF[80]; /*Full out information file name nnnnn_cln1.inf*/ |
char INF[80]; /*Full out information file name nnnnn_cln1.inf*/ |
| 41 |
char fni[80]; /*Full initial file name nnnnnmmm.pam*/ |
char fni[80]; /*Full initial file name nnnnnmmm.pam*/ |
| 42 |
char fno[80]; /*Full out helping file name nnnnn_work.dat*/ |
char fno[80]; /*Full out helping file name nnnnn_work.dat*/ |
| 43 |
char path[80]; /*Initial path*/ |
char path[80]; /*Initial path*/ |
| 44 |
char name[80]; /*Initial file name nnnnn_out.pam*/ |
char name[80]; /*Initial file name nnnnnmmm.pam*/ |
| 45 |
char protocol[80]; /*Full out file name nnnnn_protocol.txt*/ |
char protocol[80]; /*Full out file name nnnnn_protocol.txt*/ |
|
char RAW[80]; /*Directory for RAW data*/ |
|
| 46 |
char nnnnn_TMP[80]; /*Directory for processed data*/ |
char nnnnn_TMP[80]; /*Directory for processed data*/ |
| 47 |
char command[180]; /*DOS command*/ |
char command[180]; /*DOS command*/ |
| 48 |
char str_del[80]; /*Delete Cln1 directory in case of good quality*/ |
char str_del[80]; /*Delete Cln1 directory in case of good quality*/ |
| 49 |
char temp[80]; /*For temporary file*/ |
char temp[120]; /*For temporary file*/ |
| 50 |
char temp1[80]; /*For temporary file*/ |
char temp1[80]; /*For temporary file*/ |
| 51 |
char temp2[80]; /*For temporary file*/ |
char temp2[80]; /*For temporary file*/ |
| 52 |
char temp3[80]; /*For temporary file*/ |
char temp3[80]; /*For temporary file*/ |
| 64 |
char name_route[4]; /*Route number in the file name*/ |
char name_route[4]; /*Route number in the file name*/ |
| 65 |
|
|
| 66 |
char path3[80]; /*Path for ...Level0/nnnnn_mmm_L0/*/ |
char path3[80]; /*Path for ...Level0/nnnnn_mmm_L0/*/ |
| 67 |
|
char exten[10]; /*Extension for the raw initial file*/ |
| 68 |
|
char temporary[80], Tymesync[80]; |
| 69 |
int Rcount=0; /*Number of Routes*/ |
int Rcount=0; /*Number of Routes*/ |
| 70 |
int packet_type[NumberPack]={0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x16, 0x17, 0x18, 0x19, |
int packet_type[NumberPack]={0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x16, 0x17, 0x18, 0x19, |
| 71 |
0x1A, 0x1B, 0x1C, 0x1D, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x30, 0x50, 0x51, 0x52, 0x53, |
0x1A, 0x1B, 0x1C, 0x1D, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x30, 0x50, 0x51, 0x52, 0x53, |
| 73 |
0x85, 0x86, 0x88, 0x89, 0x8A, 0xA1, 0xAB, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4};/*PAMELA packet type code*/ |
0x85, 0x86, 0x88, 0x89, 0x8A, 0xA1, 0xAB, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4};/*PAMELA packet type code*/ |
| 74 |
int i, j; |
int i, j; |
| 75 |
int stop; |
int stop; |
|
char *ttt=new char[Nmax]; |
|
| 76 |
|
|
| 77 |
for (i=0;i<100;i++) quality[i]=0; |
for (i=0;i<100;i++) quality[i]=0; |
| 78 |
for (i=0;i<64;i++) real_route[i]=0; |
for (i=0;i<64;i++) real_route[i]=0; |
|
// int RTtoMT,RT,Timesync,OBTtimesync; |
|
| 79 |
|
|
| 80 |
FILE *ftime_sync; |
FILE *ftime_sync; |
| 81 |
FILE *fff, *tmp, *tmp1, *tmp2, *tmp3, *tmp4; |
FILE *fff, *tmp, *tmp1, *tmp2, *tmp3, *tmp4; |
| 82 |
|
ifstream fpath; |
| 83 |
|
|
| 84 |
|
//Read parameters from the initial file |
| 85 |
|
fpath.open("/home/pamelaprod/rawreader/bin/parameters.dat", ios::out); |
| 86 |
|
if (!fpath) {cout<<"can not open file with input parameters \n"; exit(0);} |
| 87 |
|
fpath.getline(MainPath, 80, '\n'); |
| 88 |
|
sscanf(MainPath,"%s",MainPath); |
| 89 |
|
fpath.getline(timesync, 80, '\n'); |
| 90 |
|
sscanf(timesync,"%s",timesync); |
| 91 |
|
fpath.getline(arina, 80, '\n'); |
| 92 |
|
sscanf(arina,"%s",arina); |
| 93 |
|
fpath.getline(MYSQL, 80, '\n'); |
| 94 |
|
sscanf(MYSQL,"%s",MYSQL); |
| 95 |
|
fpath.getline(database, 80, '\n'); |
| 96 |
|
sscanf(database,"%s",database); |
| 97 |
|
fpath.getline(temp, 120, '\n'); |
| 98 |
|
sscanf(temp,"%f",&YODA_flag); |
| 99 |
|
fpath.getline(temp, 120, '\n'); |
| 100 |
|
sscanf(temp,"%f",&transmit_flag); |
| 101 |
|
fpath.getline(temp, 120, '\n'); |
| 102 |
|
sscanf(temp,"%i",&print_flag); |
| 103 |
|
|
| 104 |
|
/* cout<<MainPath<<"\n"; |
| 105 |
|
cout<<timesync<<"\n"; |
| 106 |
|
cout<<arina<<"\n"; |
| 107 |
|
cout<<MYSQL<<"\n"; |
| 108 |
|
cout<<database<<"\n"; |
| 109 |
|
cout<<YODA_flag<<"\n"; |
| 110 |
|
cout<<transmit_flag<<"\n"; |
| 111 |
|
cout<<print_flag<<"\n";*/ |
| 112 |
|
|
| 113 |
|
fpath.close(); |
| 114 |
|
|
| 115 |
// mikhailov 06.12.2004 |
// mikhailov 06.12.2004 |
| 116 |
ftime_sync=fopen("/home/pamelaprod/rawreader/bin/timesync.dat","r+"); |
ftime_sync=fopen(timesync,"r+"); |
| 117 |
while(feof(ftime_sync)==0) |
while(feof(ftime_sync)==0) |
| 118 |
{fscanf(ftime_sync,"%u%[ ]%u%[ ]%u%[ ]%u\n",&RTtoMT, temp, &RT, temp, &Timesync, temp, &OBTtimesync);} |
{fscanf(ftime_sync,"%u%[ ]%u%[ ]%u%[ ]%u\n",&RTtoMT, temp, &RT, temp, &Timesync, temp, &OBTtimesync);} |
| 119 |
fclose(ftime_sync); |
fclose(ftime_sync); |
| 120 |
// end mikhailov |
// end mikhailov |
| 121 |
|
|
| 122 |
// cout<<"global_err="<<GLOBAL_LEN_ER<<"\n"; |
if (print_flag>0) cout<<"global_err="<<GLOBAL_LEN_ER<<"\n"; |
|
if (strlen(argv[2])!=12) {cout<<"WRONG RAW FILE NAME\n"; exit(0);} |
|
|
|
|
|
strcpy(fni,argv[1]); |
|
|
strcat(fni,argv[2]); |
|
|
|
|
| 123 |
strcpy(name,argv[2]); |
strcpy(name,argv[2]); |
| 124 |
name_route[0]=name[5]; |
name_route[0]=name[5]; |
| 125 |
name_route[1]=name[6]; |
name_route[1]=name[6]; |
| 126 |
name_route[2]=name[7]; |
name_route[2]=name[7]; |
| 127 |
name_route[3]='\0'; |
name_route[3]='\0'; |
| 128 |
|
|
| 129 |
strcpy(MainPath,"/home/pamelaprod/rawreader/level0/"); |
for(i=0;i<3;i++) |
| 130 |
|
{exten[i]=name[i+9];} |
| 131 |
|
exten[3]='\0'; |
| 132 |
|
|
| 133 |
|
if ((strlen(argv[2])!=12)||(strncmp(exten,"pam",3)!=0)) {cout<<"WRONG RAW FILE NAME\n"; exit(0);} |
| 134 |
|
|
| 135 |
|
strcpy(fni,argv[1]); |
| 136 |
|
strcat(fni,argv[2]); |
| 137 |
|
|
| 138 |
/**************Creation directory nnnnn**********************/ |
/**************Creation directory nnnnn**********************/ |
| 139 |
strncat(strcpy(nnnnn_TMP,MainPath),argv[2],5); |
strncat(strcpy(nnnnn_TMP,MainPath),argv[2],5); |
| 140 |
strcpy(temp,nnnnn_TMP); |
strcpy(temp,nnnnn_TMP); |
| 188 |
rename(temp2,temp3); |
rename(temp2,temp3); |
| 189 |
} |
} |
| 190 |
|
|
| 191 |
strcat(strcpy(temp,nnnnn_TMP),"/tmp.dat"); |
if (CLN2_FLAG==1) |
|
tmp=fopen(temp, "w+"); |
|
|
|
|
|
for(i=0;i<256;i++) |
|
| 192 |
{ |
{ |
| 193 |
fprintf(tmp,"%03i",i); |
for(i=0;i<256;i++) |
|
fseek(tmp,0,0); |
|
|
fgets(mmm,10,tmp); |
|
|
fseek(tmp,0,0); |
|
|
strcat(strcat(strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),name_route),"_"),mmm),"/tmp.dat"); |
|
|
|
|
|
if ((tmp1=fopen(temp1,"w"))!=0) |
|
| 194 |
{ |
{ |
| 195 |
fclose(tmp1); |
sprintf(temp4,"%03i",i); |
| 196 |
remove(temp1); |
sscanf(temp4,"%3s",mmm); mmm[3]='\0'; |
| 197 |
strcat(strncat(strcat(strcat(strcat(strcpy(name2,name_route),"_"),mmm),"_"),name,5),"_cln1.pam"); |
strcat(strcat(strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),name_route),"_"),mmm),"/tmp.dat"); |
| 198 |
strcat(strcat(strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln1/"),name2); |
|
| 199 |
name2[0]='\0'; |
if ((tmp1=fopen(temp1,"w"))!=0) |
|
strcat(strcat(strcat(strcat(strcat(strncat(name2,name,5),"_"),name_route),"_"),mmm),"_cln1.pam"); |
|
|
strcpy(temp4,path); |
|
|
strcat(strcat(strcat(strcat(temp4,name_route),"_"),mmm),"/Cln2/tmp.dat"); |
|
|
if ((tmp4=fopen(temp4,"w"))==0) |
|
| 200 |
{ |
{ |
| 201 |
|
fclose(tmp1); |
| 202 |
|
remove(temp1); |
| 203 |
|
name2[0]='\0'; |
| 204 |
|
strcat(strcat(strcat(strcat(strcat(strncat(name2,name,5),"_"),name_route),"_"),mmm),"_cln1.pam"); |
| 205 |
|
if (CLN1_MEPHI==0) |
| 206 |
|
{strcat(strcat(strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln1/"),name2);} |
| 207 |
|
else |
| 208 |
|
{strcat(strcat(strncat(strcpy(fni2,""),nnnnn_TMP,strlen(nnnnn_TMP)-5),"Cln1/"),name2);} |
| 209 |
|
|
| 210 |
|
strcpy(temp4,path); |
| 211 |
|
strcat(strcat(strcat(strcat(temp4,name_route),"_"),mmm),"/Cln2/tmp.dat"); |
| 212 |
|
if ((tmp4=fopen(temp4,"w"))==0) |
| 213 |
|
{ |
| 214 |
/**************Creation directory nnnnn\xxx_mmm\Cln2****************/ |
/**************Creation directory nnnnn\xxx_mmm\Cln2****************/ |
| 215 |
strcat(strcat(strcat(strcat(strcat(strcat(strcpy(command,"mkdir "),nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2"); |
strcat(strcat(strcat(strcat(strcat(strcat(strcpy(command,"mkdir "),nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2"); |
| 216 |
system(command); |
system(command); |
| 217 |
/*******************************************************************/ |
/*******************************************************************/ |
| 218 |
} |
} |
| 219 |
else |
else |
| 220 |
{ |
{ |
| 221 |
fclose(tmp4); |
fclose(tmp4); |
| 222 |
remove(temp4); |
remove(temp4); |
| 223 |
} |
} |
| 224 |
strcat(strcat(strcat(strcat(strcat(strcpy(path2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2/"); |
strcat(strcat(strcat(strcat(strcat(strcpy(path2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2/"); |
| 225 |
strcat(strncat(strcpy(inf2,path2),name2,13),"_cln2.inf"); |
strcat(strncat(strcpy(inf2,path2),name2,13),"_cln2.inf"); |
| 226 |
strcat(strncat(strcpy(log2,path2),name2,13),"_cln2.log"); |
strcat(strncat(strcpy(log2,path2),name2,13),"_cln2.log"); |
| 227 |
strcat(strncat(strcpy(pam2,path2),name2,13),"_cln2.pam"); |
strcat(strncat(strcpy(pam2,path2),name2,13),"_cln2.pam"); |
| 228 |
strcat(strncat(strcpy(fno2,path2),name2,13),"_work.dat"); |
strcat(strncat(strcpy(fno2,path2),name2,13),"_work.dat"); |
| 229 |
|
|
| 230 |
IndexQ=quality[i-1]; |
IndexQ=quality[i-1]; |
| 231 |
r_counter=i; |
r_counter=i; |
| 232 |
verify(fni2, inf2, log2, pam2, fno2, path2, name, name2, packet_type, IndexQ, r_counter, real_route); ///////////////////////////////// |
verify(fni2, inf2, log2, pam2, fno2, path2, name, name2, packet_type, IndexQ, r_counter, real_route); ///////////////////////////////// |
| 233 |
//Delete Cln1 |
strcat(strcat(strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln1/"),name2); |
| 234 |
if (IndexQ>0.999) |
//Delete Cln1 |
| 235 |
{strcpy(str_del,"rm -r -f "); |
if (IndexQ>0.999) |
| 236 |
strncat(str_del,fni2,strlen(fni2)-22); |
{strcpy(str_del,"rm -r -f "); |
| 237 |
if (system(str_del)) cout<<"Can not delete Cln1 for counter="<<r_counter<<"\n"; |
strncat(str_del,fni2,strlen(fni2)-22); |
| 238 |
} |
if (system(str_del)) cout<<"Can not delete Cln1 for counter="<<r_counter<<"\n"; |
| 239 |
strcat(strcat(strcat(strcat(strcat(strncat(strcpy(path3,MainPath),argv[2],5),"/"),name_route),"_"),mmm),"/packets"); |
} |
| 240 |
|
strcat(strcat(strcat(strcat(strcat(strncat(strcpy(path3,MainPath),argv[2],5),"/"),name_route),"_"),mmm),"/packets"); |
| 241 |
strcat(strcpy(temp2,path3),"/tmpM.dat"); |
|
| 242 |
if ((tmp2=fopen(temp2,"w"))==0) |
strcat(strcpy(temp2,path3),"/tmpM.dat"); |
| 243 |
{ |
if ((tmp2=fopen(temp2,"w"))==0) |
| 244 |
|
{ |
| 245 |
/**************Creation directory level0\nnnnn\counter_mmm\packets***************/ |
/**************Creation directory level0\nnnnn\counter_mmm\packets***************/ |
| 246 |
strcat(strcpy(command,"mkdir "),path3); |
strcat(strcpy(command,"mkdir "),path3); |
| 247 |
system(command); |
system(command); |
| 248 |
/*******************************************************************/ |
/*******************************************************************/ |
| 249 |
} |
} |
| 250 |
else |
else |
| 251 |
{ |
{ |
| 252 |
fclose(tmp2); |
fclose(tmp2); |
| 253 |
remove(temp2); |
remove(temp2); |
| 254 |
printf("directory for file %s already exists - rewriting \n", |
printf("directory for file %s already exists - rewriting \n", |
| 255 |
strcat(strcat(strcat(strcat(strncat(strcpy(temp3," "),argv[2],5),"_"),name_route),"_"),mmm)); |
strcat(strcat(strcat(strcat(strncat(strcpy(temp3," "),argv[2],5),"_"),name_route),"_"),mmm)); |
| 256 |
} |
} |
| 257 |
strcat(path3,"/"); |
strcat(path3,"/"); |
| 258 |
sort(log2, pam2, path2, path3, name2, packet_type); ///////////////////////////////////// |
sort(log2, pam2, path2, path3, name2, packet_type); ///////////////////////////////////// |
| 259 |
strcat(strncat(strcat(strcat(strcpy(name_ql,path3),mmm),"_"),argv[2],5),"_ql.log"); |
strcat(strncat(strcat(strcat(strcpy(name_ql,path3),mmm),"_"),argv[2],5),"_ql.log"); |
| 260 |
strcpy(temp3,"/home/pamelaprod/rawreader/bin/coordinate.exe"); |
strcpy(temp3,"/home/pamelaprod/rawreader/bin/coordinate.exe"); |
| 261 |
if ((tmp3=fopen(temp3,"r"))==0) |
if ((tmp3=fopen(temp3,"r"))==0) |
| 262 |
{printf("file %s does not exist\n",temp3);} |
{printf("file %s does not exist\n",temp3);} |
| 263 |
else |
else |
| 264 |
{ |
{ |
| 265 |
fclose(tmp3); |
fclose(tmp3); |
| 266 |
strcat(strcat(strcpy(command,temp3)," "),name_ql); |
strcat(strcat(strcpy(command,temp3)," "),name_ql); |
| 267 |
// system(command); |
// system(command); |
| 268 |
} |
} |
| 269 |
|
} |
| 270 |
} |
} |
| 271 |
} |
} |
|
fclose(tmp); |
|
|
remove(temp); delete [] ttt; |
|
| 272 |
|
|
| 273 |
return 0; |
return 0; |
| 274 |
} |
} |