/[PAMELA software]/rawreader/src/Main.cpp
ViewVC logotype

Diff of /rawreader/src/Main.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by cafagna, Fri Sep 1 10:56:22 2006 UTC revision 1.2 by cafagna, Sun Dec 10 12:21:21 2006 UTC
# Line 15  long int RTtoMT,RT,Timesync,OBTtimesync; Line 15  long int RTtoMT,RT,Timesync,OBTtimesync;
15  void read(char [], char [], char [], char [], char [], char [],  void read(char [], char [], char [], char [], char [], char [],
16                    char[], float [], int[], int &);                    char[], float [], int[], int &);
17  void verify(char [], char[], char [], char [], char [], char [], char [],  void verify(char [], char[], char [], char [], char [], char [], char [],
18                          char [], int[], int, float, int, int[]);                          char [], int[], float, int, int[]);
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    
23    
24  int main(int argc, char *argv[])  int main(int argc, char *argv[])
25  { time_t time_set=0, *time_p;  {
26  // char stop;  // char stop;
27   float IndexQ, quality[100];     /*Quality index*/   float IndexQ, quality[100];     /*Quality index*/
28   int real_route[64];   int real_route[64];
# Line 68  int main(int argc, char *argv[]) Line 68  int main(int argc, char *argv[])
68   int stop;   int stop;
69   char *ttt=new char[Nmax];   char *ttt=new char[Nmax];
70        
71   for (i=0;i<100;i++) quality[i]==0;   for (i=0;i<100;i++) quality[i]=0;
72   for (i=0;i<64;i++) real_route[i]==0;   for (i=0;i<64;i++) real_route[i]=0;
73  // int RTtoMT,RT,Timesync,OBTtimesync;  // int RTtoMT,RT,Timesync,OBTtimesync;
74    
75   FILE *ftime_sync;       FILE *ftime_sync;    
76   FILE *fff, *tmp, *tmp1, *tmp2, *tmp3, *tmp4;   FILE *fff, *tmp, *tmp1, *tmp2, *tmp3, *tmp4;
77    
78  // mikhailov 06.12.2004  // mikhailov 06.12.2004
79  ftime_sync=fopen("/home/pamelaprod/rawreader/source/timesync.dat","r+");  ftime_sync=fopen("/home/pamelaprod/rawreader/bin/timesync.dat","r+");
80  while(feof(ftime_sync)==0)  while(feof(ftime_sync)==0)
81  {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);}
82  fclose(ftime_sync);  fclose(ftime_sync);
83  // end mikhailov  // end mikhailov
84    
85   time_set=time(time_p);  // cout<<"global_err="<<GLOBAL_LEN_ER<<"\n";
86     if (strlen(argv[2])!=12) {cout<<"WRONG RAW FILE NAME\n"; exit(0);}
 // cout<<copy(LINUX_flag)<<"\n";  
 // cout<<dir(LINUX_flag)<<"\n";  
  cout<<"global_err="<<GLOBAL_LEN_ER<<"\n";  
87    
88   strcpy(fni,argv[1]);   strcpy(fni,argv[1]);
89   strcat(fni,argv[2]);   strcat(fni,argv[2]);
# Line 96  fclose(ftime_sync); Line 93  fclose(ftime_sync);
93   name_route[1]=name[6];   name_route[1]=name[6];
94   name_route[2]=name[7];   name_route[2]=name[7];
95   name_route[3]='\0';   name_route[3]='\0';
96   cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!\n";  
97   if (LINUX_flag==1) strcpy(MainPath,"/home/pamelaprod/rawreader/level0/");   strcpy(MainPath,"/home/pamelaprod/rawreader/level0/");
  if (LINUX_flag!=1) strcpy(MainPath,"c:\\home\\pamelaprod\\");  
98    
99  /**************Creation directory nnnnn**********************/  /**************Creation directory nnnnn**********************/
100   if (LINUX_flag==1) strncat(strcpy(nnnnn_TMP,MainPath),argv[2],5);   strncat(strcpy(nnnnn_TMP,MainPath),argv[2],5);
  if (LINUX_flag!=1) strcat(strncat(strcat(strcpy(nnnnn_TMP,MainPath),"Temp\\"),argv[2],5),"_TMP");  
101   strcpy(temp,nnnnn_TMP);   strcpy(temp,nnnnn_TMP);
102   if (LINUX_flag==1)strcat(temp,"/tmp.dat");   strcat(temp,"/tmp.dat");
  if (LINUX_flag!=1) strcat(temp,"\\tmp.dat");  
103    
104   if ((tmp=fopen(temp,"w"))==0)     if ((tmp=fopen(temp,"w"))==0)  
105   {   {
106    if (LINUX_flag==1) strcpy(command,"mkdir ");    strcpy(command,"mkdir ");
   if (LINUX_flag!=1) strcpy(command,"md ");  
107    strcat(command,nnnnn_TMP);    strcat(command,nnnnn_TMP);
108    system(command);    system(command);
109   }   }
# Line 123  fclose(ftime_sync); Line 116  fclose(ftime_sync);
116   }   }
117  /****************************************************************/  /****************************************************************/
118    
119   if (LINUX_flag==1) strcat(strncat(strcat( strcpy(INF,nnnnn_TMP),"/"),name,8),"_cln1.inf");   strcat(strncat(strcat( strcpy(INF,nnnnn_TMP),"/"),name,8),"_cln1.inf");
120   if (LINUX_flag!=1) strcat(strncat(strcat( strcpy(INF,nnnnn_TMP),"\\"),name,8),"_cln1.inf");   strcat(strcpy(path,nnnnn_TMP),"/");
121   if (LINUX_flag==1) strcat(strcpy(path,nnnnn_TMP),"/");   strcat(strncat(strcat(strcpy(fno,nnnnn_TMP),"/"),name,8),"_work.dat");
122   if (LINUX_flag!=1) strcat(strcpy(path,nnnnn_TMP),"\\");   strcat(strncat(strcat(strcpy(protocol,nnnnn_TMP),"/"),name,8),"_protocol.txt");
  if (LINUX_flag==1) strcat(strncat(strcat(strcpy(fno,nnnnn_TMP),"/"),name,8),"_work.dat");  
  if (LINUX_flag!=1) strcat(strncat(strcat(strcpy(fno,nnnnn_TMP),"\\"),name,8),"_work.dat");  
  if (LINUX_flag==1) strcat(strncat(strcat(strcpy(protocol,nnnnn_TMP),"/"),name,8),"_protocol.txt");  
  if (LINUX_flag!=1) strcat(strncat(strcat(strcpy(protocol,nnnnn_TMP),"\\"),name,8),"_protocol.txt");  
123    
124   if (VRL_HEADER>0)   if (VRL_HEADER>0)
125   {   {
# Line 143  fclose(ftime_sync); Line 132  fclose(ftime_sync);
132    temp[1]=name[6];    temp[1]=name[6];
133    temp[2]=name[7];    temp[2]=name[7];
134    temp[3]='\0';    temp[3]='\0';
135    if (LINUX_flag==1) strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),temp);    strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),temp);
136    if (LINUX_flag!=1) strcat(strcat(strcpy(temp1,nnnnn_TMP),"\\"),temp);    strcat(strcpy(command,"mkdir "),temp1);
   if (LINUX_flag==1) strcat(strcpy(command,"mkdir "),temp1);  
   if (LINUX_flag!=1) strcat(strcpy(command,"md "),temp1);  
137        
138    system(command);    system(command);
139    if (LINUX_flag==1) strcat(temp1,"/Cln1");    strcat(temp1,"/Cln1");
140    if (LINUX_flag!=1) strcat(temp1,"\\Cln1");    strcat(strcpy(command,"mkdir "),temp1);
   if (LINUX_flag==1) strcat(strcpy(command,"mkdir "),temp1);  
   if (LINUX_flag!=1) strcat(strcpy(command,"md "),temp1);  
141    system(command);    system(command);
142  /**********Copy file to directory nnnnn_TMP\mmm\Cln1*************/  /**********Copy file to directory nnnnn_TMP\mmm\Cln1*************/
143    if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcpy(command,"cp "),fni),    strcat(strcat(strcat(strcat(strcat(strcpy(command,"cp "),fni)," "),temp1),"/"),name);
144                                  " "),temp1),"/"),name);  
   if (LINUX_flag!=1) strcat(strcat(strcat(strcat(strcat(strcpy(command,"copy "),fni),  
                                 " "),temp1),"\\"),name);  
145    system(command);    system(command);
146    if (LINUX_flag==1) strcat(strcat(strcpy(temp2,temp1),"/"),name);    strcat(strcat(strcpy(temp2,temp1),"/"),name);
147    if (LINUX_flag!=1) strcat(strcat(strcpy(temp2,temp1),"\\"),name);    strcat(strcat(strcat(strcpy(temp3,temp1),"/"),temp),"_");
   if (LINUX_flag==1) strcat(strcat(strcat(strcpy(temp3,temp1),"/"),temp),"_");  
   if (LINUX_flag!=1) strcat(strcat(strcat(strcpy(temp3,temp1),"\\"),temp),"_");  
148    strcat(strncat(temp3,name,5),"_cln1.pam");    strcat(strncat(temp3,name,5),"_cln1.pam");
149    rename(temp2,temp3);    rename(temp2,temp3);
150   }   }
151    
152   if (LINUX_flag==1) strcat(strcpy(temp,nnnnn_TMP),"/tmp.dat");   strcat(strcpy(temp,nnnnn_TMP),"/tmp.dat");
  if (LINUX_flag!=1) strcat(strcpy(temp,nnnnn_TMP),"\\tmp.dat");  
153   tmp=fopen(temp, "w+");   tmp=fopen(temp, "w+");
154    
155   for(i=0;i<256;i++)   for(i=0;i<256;i++)
# Line 178  fclose(ftime_sync); Line 158  fclose(ftime_sync);
158    fseek(tmp,0,0);    fseek(tmp,0,0);
159    fgets(mmm,10,tmp);    fgets(mmm,10,tmp);
160    fseek(tmp,0,0);    fseek(tmp,0,0);
161    if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),name_route),"_"),mmm),"/tmp.dat");    strcat(strcat(strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),name_route),"_"),mmm),"/tmp.dat");
162    if (LINUX_flag!=1) strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"\\"),mmm),"\\tmp.dat");      
163    if ((tmp1=fopen(temp1,"w"))!=0)    if ((tmp1=fopen(temp1,"w"))!=0)
164    {    {
165     fclose(tmp1);     fclose(tmp1);
166     remove(temp1);     remove(temp1);
167     strcat(strncat(strcat(strcat(strcat(strcpy(name2,name_route),"_"),mmm),"_"),name,5),"_cln1.pam");     strcat(strncat(strcat(strcat(strcat(strcpy(name2,name_route),"_"),mmm),"_"),name,5),"_cln1.pam");
168     if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln1/"),name2);     strcat(strcat(strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln1/"),name2);
169     if (LINUX_flag!=1) strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"\\"),mmm),"\\Cln1\\"),name2);     name2[0]='\0';
170       strcat(strcat(strcat(strcat(strcat(strncat(name2,name,5),"_"),name_route),"_"),mmm),"_cln1.pam");
171     strcpy(temp4,path);     strcpy(temp4,path);
172     if (LINUX_flag==1) strcat(strcat(strcat(strcat(temp4,name_route),"_"),mmm),"/Cln2/tmp.dat");     strcat(strcat(strcat(strcat(temp4,name_route),"_"),mmm),"/Cln2/tmp.dat");
    if (LINUX_flag!=1) strcat(strcat(temp4,mmm),"\\Cln2\\tmp.dat");  
173     if ((tmp4=fopen(temp4,"w"))==0)     if ((tmp4=fopen(temp4,"w"))==0)
174     {     {
175  /**************Creation directory nnnnn\counter_mmm\Cln2****************/  /**************Creation directory nnnnn\xxx_mmm\Cln2****************/
176      if (LINUX_flag==1) 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");
     if (LINUX_flag!=1) strcat(strcat(strcat(strcat(strcpy(command,"md "),nnnnn_TMP),"\\"),mmm),"\\Cln2");  
177      system(command);      system(command);
178  /*******************************************************************/  /*******************************************************************/
179     }     }
# Line 203  fclose(ftime_sync); Line 182  fclose(ftime_sync);
182      fclose(tmp4);      fclose(tmp4);
183      remove(temp4);      remove(temp4);
184     }     }
185     if (LINUX_flag==1) 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/");
    if (LINUX_flag!=1) strcat(strcat(strcat(strcpy(path2,nnnnn_TMP),"\\"),mmm),"\\Cln2\\");  
186     strcat(strncat(strcpy(inf2,path2),name2,13),"_cln2.inf");     strcat(strncat(strcpy(inf2,path2),name2,13),"_cln2.inf");
187     strcat(strncat(strcpy(log2,path2),name2,13),"_cln2.log");     strcat(strncat(strcpy(log2,path2),name2,13),"_cln2.log");
188     strcat(strncat(strcpy(pam2,path2),name2,13),"_cln2.pam");     strcat(strncat(strcpy(pam2,path2),name2,13),"_cln2.pam");
189     strcat(strncat(strcpy(fno2,path2),name2,13),"_work.dat");     strcat(strncat(strcpy(fno2,path2),name2,13),"_work.dat");
190    
191     IndexQ=quality[i-1];     IndexQ=quality[i-1];
192     r_counter=i;       r_counter=i;
193     verify(fni2, inf2, log2, pam2, fno2, path2, name, name2, packet_type, GLOBAL_LEN_ER, IndexQ, r_counter, real_route); /////////////////////////////////     verify(fni2, inf2, log2, pam2, fno2, path2, name, name2, packet_type, IndexQ, r_counter, real_route); /////////////////////////////////
194     //Delete Cln1     //Delete Cln1
195     if (IndexQ>0.999)     if (IndexQ>0.999)
196     {strcpy(str_del,"rm -r -f ");     {strcpy(str_del,"rm -r -f ");
197      strncat(str_del,fni2,strlen(fni2)-22);      strncat(str_del,fni2,strlen(fni2)-22);
198      if (system(str_del)) cout<<"Can not delete Cln1 for counter="<<r_counter<<"\n";      if (system(str_del)) cout<<"Can not delete Cln1 for counter="<<r_counter<<"\n";
199     }     }
200     if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strncat(strcpy(path3,MainPath),argv[2],5),"/"),name_route),"_"),mmm),"/packets");     strcat(strcat(strcat(strcat(strcat(strncat(strcpy(path3,MainPath),argv[2],5),"/"),name_route),"_"),mmm),"/packets");
201     if (LINUX_flag!=1) strcat(strcat(strcat(strncat(strcpy(strcpy(path3,MainPath),  
202                                   "Level0\\"),argv[2],5),"_"),mmm),"_L0");     strcat(strcpy(temp2,path3),"/tmpM.dat");
    if (LINUX_flag==1) strcat(strcpy(temp2,path3),"/tmpM.dat");  
    if (LINUX_flag!=1) strcat(strcpy(temp2,path3),"\\tmpM.dat");  
203     if ((tmp2=fopen(temp2,"w"))==0)       if ((tmp2=fopen(temp2,"w"))==0)  
204     {             {        
205  /**************Creation directory level0\nnnnn\counter_mmm\packets***************/  /**************Creation directory level0\nnnnn\counter_mmm\packets***************/
206      if (LINUX_flag==1) strcat(strcpy(command,"mkdir "),path3);      strcat(strcpy(command,"mkdir "),path3);
     if (LINUX_flag!=1) strcat(strcpy(command,"md "),path3);  
207      system(command);      system(command);
208  /*******************************************************************/        /*******************************************************************/      
209     }     }
# Line 236  fclose(ftime_sync); Line 211  fclose(ftime_sync);
211     {     {
212      fclose(tmp2);      fclose(tmp2);
213      remove(temp2);      remove(temp2);
214      printf("directory %s already exists - rewriting \n",      printf("directory for file %s already exists - rewriting \n",
215      strcat(strcat(strcat(strcat(strcat(strncat(strcpy(temp3," "),argv[2],5),"_"),name_route),"_"),mmm),"_L0"));      strcat(strcat(strcat(strcat(strncat(strcpy(temp3," "),argv[2],5),"_"),name_route),"_"),mmm));
216     }     }
217     if (LINUX_flag==1) strcat(path3,"/");     strcat(path3,"/");
    if (LINUX_flag!=1) strcat(path3,"\\");  
218     sort(log2, pam2, path2, path3, name2, packet_type); /////////////////////////////////////     sort(log2, pam2, path2, path3, name2, packet_type); /////////////////////////////////////
219     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");
220     if (LINUX_flag==1) strcpy(temp3,"/home/pamelaprod/rawreader/bin/coordinate.exe");     strcpy(temp3,"/home/pamelaprod/rawreader/bin/coordinate.exe");
    if (LINUX_flag!=1) strcat(strcpy(temp3,MainPath),"Norad\\coordinate.exe");  
221     if ((tmp3=fopen(temp3,"r"))==0)     if ((tmp3=fopen(temp3,"r"))==0)
222     {printf("file %s does not exist\n",temp3);}     {printf("file %s does not exist\n",temp3);}
223     else     else

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.23