#ifdef HAVE_CONFIG_H #include #endif /***************MAIN********************************************/ #include "descript.h" #include "flag.h" //mikhailov 06. 12. 2004. : initialization of global parameteres for time sync. it is used //in in sort.cpp to convert OBT of Pamela to Moscow Time . //this information is apdated in RunHeaderReader long int RTtoMT,RT,Timesync,OBTtimesync; // Resurs time to moscow, Resurs time, ... void read(char [], char [], char [], char [], char [], char [], char[], float [], int[], int &); void verify(char [], char[], char [], char [], char [], char [], char [], char [], int[], int, float, int, int[]); void confluence(char [], char [], char [], char [], char [], int[]); void sort(char [], char [], char [], char[], char [], int[]); int main(int argc, char *argv[]) { time_t time_set=0, *time_p; // char stop; float IndexQ, quality[100]; /*Quality index*/ int real_route[64]; int rc=0; int r_counter; /*Route counter*/ char MainPath[80]; /* /home/pamelaprod/ */ char INF[80]; /*Full out information file name nnnnn_cln1.inf*/ char fni[80]; /*Full initial file name nnnnnmmm.pam*/ char fno[80]; /*Full out helping file name nnnnn_work.dat*/ char path[80]; /*Initial path*/ char name[80]; /*Initial file name nnnnn_out.pam*/ char protocol[80]; /*Full out file name nnnnn_protocol.txt*/ char RAW[80]; /*Directory for RAW data*/ char nnnnn_TMP[80]; /*Directory for processed data*/ char command[180]; /*DOS command*/ char str_del[80]; /*Delete Cln1 directory in case of good quality*/ char temp[80]; /*For temporary file*/ char temp1[80]; /*For temporary file*/ char temp2[80]; /*For temporary file*/ char temp3[80]; /*For temporary file*/ char temp4[80]; char fni2[80]; /*Initial file mmm_nnnnn_cln1.pam*/ char inf2[80]; /*File name mmm_nnnnn_cln2.inf*/ char pam2[80]; /*File name mmm_nnnnn_cln2.pam*/ char name2[80]; /*Initial file name mmm_counter_nnnnn_cln1.pam*/ char name_ql[80]; /*File name mmm_nnnnn_ql.log*/ char log2[80]; /*File name mmm_nnnnn_cln2.log*/ char fno2[80]; /*Out help file mmm_nnnnn_work.dat*/ char path2[80]; /*Path for ...Temp/nnnnn_TMP/mmm/Cln2/*/ char mmm[80]; /*For route number*/ char name_route[4]; /*Route number in the file name*/ char path3[80]; /*Path for ...Level0/nnnnn_mmm_L0/*/ int Rcount=0; /*Number of Routes*/ int packet_type[NumberPack]={0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x30, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x60, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x88, 0x89, 0x8A, 0xA1, 0xAB, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4};/*PAMELA packet type code*/ int i, j; int stop; char *ttt=new char[Nmax]; for (i=0;i<100;i++) quality[i]==0; for (i=0;i<64;i++) real_route[i]==0; // int RTtoMT,RT,Timesync,OBTtimesync; FILE *ftime_sync; FILE *fff, *tmp, *tmp1, *tmp2, *tmp3, *tmp4; // mikhailov 06.12.2004 ftime_sync=fopen("/home/pamelaprod/rawreader/source/timesync.dat","r+"); while(feof(ftime_sync)==0) {fscanf(ftime_sync,"%u%[ ]%u%[ ]%u%[ ]%u\n",&RTtoMT,temp,&RT,temp, &Timesync,temp,&OBTtimesync);} fclose(ftime_sync); // end mikhailov time_set=time(time_p); // cout<0) { /*Creation of directories nnnnn_TMP\mmm_counter and ...\Cln1 in filename.cpp*/ read(fni, fno, INF, protocol, path, name, nnnnn_TMP, quality, real_route, Rcount); ////////////////// ////////////// } else { temp[0]=name[5]; temp[1]=name[6]; temp[2]=name[7]; temp[3]='\0'; if (LINUX_flag==1) strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),temp); if (LINUX_flag!=1) strcat(strcat(strcpy(temp1,nnnnn_TMP),"\\"),temp); if (LINUX_flag==1) strcat(strcpy(command,"mkdir "),temp1); if (LINUX_flag!=1) strcat(strcpy(command,"md "),temp1); system(command); if (LINUX_flag==1) strcat(temp1,"/Cln1"); if (LINUX_flag!=1) strcat(temp1,"\\Cln1"); if (LINUX_flag==1) strcat(strcpy(command,"mkdir "),temp1); if (LINUX_flag!=1) strcat(strcpy(command,"md "),temp1); system(command); /**********Copy file to directory nnnnn_TMP\mmm\Cln1*************/ if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcpy(command,"cp "),fni), " "),temp1),"/"),name); if (LINUX_flag!=1) strcat(strcat(strcat(strcat(strcat(strcpy(command,"copy "),fni), " "),temp1),"\\"),name); system(command); if (LINUX_flag==1) strcat(strcat(strcpy(temp2,temp1),"/"),name); if (LINUX_flag!=1) strcat(strcat(strcpy(temp2,temp1),"\\"),name); if (LINUX_flag==1) strcat(strcat(strcat(strcpy(temp3,temp1),"/"),temp),"_"); if (LINUX_flag!=1) strcat(strcat(strcat(strcpy(temp3,temp1),"\\"),temp),"_"); strcat(strncat(temp3,name,5),"_cln1.pam"); rename(temp2,temp3); } if (LINUX_flag==1) strcat(strcpy(temp,nnnnn_TMP),"/tmp.dat"); if (LINUX_flag!=1) strcat(strcpy(temp,nnnnn_TMP),"\\tmp.dat"); tmp=fopen(temp, "w+"); for(i=0;i<256;i++) { fprintf(tmp,"%03i",i); fseek(tmp,0,0); fgets(mmm,10,tmp); fseek(tmp,0,0); if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),name_route),"_"),mmm),"/tmp.dat"); if (LINUX_flag!=1) strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"\\"),mmm),"\\tmp.dat"); if ((tmp1=fopen(temp1,"w"))!=0) { fclose(tmp1); remove(temp1); strcat(strncat(strcat(strcat(strcat(strcpy(name2,name_route),"_"),mmm),"_"),name,5),"_cln1.pam"); if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln1/"),name2); if (LINUX_flag!=1) strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"\\"),mmm),"\\Cln1\\"),name2); strcpy(temp4,path); if (LINUX_flag==1) strcat(strcat(strcat(strcat(temp4,name_route),"_"),mmm),"/Cln2/tmp.dat"); if (LINUX_flag!=1) strcat(strcat(temp4,mmm),"\\Cln2\\tmp.dat"); if ((tmp4=fopen(temp4,"w"))==0) { /**************Creation directory nnnnn\counter_mmm\Cln2****************/ if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcat(strcpy(command,"mkdir "),nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2"); if (LINUX_flag!=1) strcat(strcat(strcat(strcat(strcpy(command,"md "),nnnnn_TMP),"\\"),mmm),"\\Cln2"); system(command); /*******************************************************************/ } else { fclose(tmp4); remove(temp4); } if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcpy(path2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2/"); if (LINUX_flag!=1) strcat(strcat(strcat(strcpy(path2,nnnnn_TMP),"\\"),mmm),"\\Cln2\\"); strcat(strncat(strcpy(inf2,path2),name2,13),"_cln2.inf"); strcat(strncat(strcpy(log2,path2),name2,13),"_cln2.log"); strcat(strncat(strcpy(pam2,path2),name2,13),"_cln2.pam"); strcat(strncat(strcpy(fno2,path2),name2,13),"_work.dat"); IndexQ=quality[i-1]; r_counter=i; verify(fni2, inf2, log2, pam2, fno2, path2, name, name2, packet_type, GLOBAL_LEN_ER, IndexQ, r_counter, real_route); ///////////////////////////////// //Delete Cln1 if (IndexQ>0.999) {strcpy(str_del,"rm -r -f "); strncat(str_del,fni2,strlen(fni2)-22); if (system(str_del)) cout<<"Can not delete Cln1 for counter="<