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

Annotation of /rawreader/src/Main.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sun Dec 10 12:21:21 2006 UTC (17 years, 11 months ago) by cafagna
Branch: MAIN
CVS Tags: v1r12
Changes since 1.1: +46 -73 lines
*** empty log message ***

1 cafagna 1.1
2     #ifdef HAVE_CONFIG_H
3     #include <config.h>
4     #endif
5    
6     /***************MAIN********************************************/
7     #include "descript.h"
8     #include "flag.h"
9    
10     //mikhailov 06. 12. 2004. : initialization of global parameteres for time sync. it is used
11     //in in sort.cpp to convert OBT of Pamela to Moscow Time .
12     //this information is apdated in RunHeaderReader
13     long int RTtoMT,RT,Timesync,OBTtimesync; // Resurs time to moscow, Resurs time, ...
14    
15     void read(char [], char [], char [], char [], char [], char [],
16     char[], float [], int[], int &);
17     void verify(char [], char[], char [], char [], char [], char [], char [],
18 cafagna 1.2 char [], int[], float, int, int[]);
19 cafagna 1.1 void confluence(char [], char [], char [], char [], char [], int[]);
20     void sort(char [], char [], char [], char[], char [], int[]);
21    
22    
23    
24     int main(int argc, char *argv[])
25 cafagna 1.2 {
26 cafagna 1.1 // char stop;
27     float IndexQ, quality[100]; /*Quality index*/
28     int real_route[64];
29     int rc=0;
30     int r_counter; /*Route counter*/
31    
32     char MainPath[80]; /* /home/pamelaprod/ */
33     char INF[80]; /*Full out information file name nnnnn_cln1.inf*/
34     char fni[80]; /*Full initial file name nnnnnmmm.pam*/
35     char fno[80]; /*Full out helping file name nnnnn_work.dat*/
36     char path[80]; /*Initial path*/
37     char name[80]; /*Initial file name nnnnn_out.pam*/
38     char protocol[80]; /*Full out file name nnnnn_protocol.txt*/
39     char RAW[80]; /*Directory for RAW data*/
40     char nnnnn_TMP[80]; /*Directory for processed data*/
41     char command[180]; /*DOS command*/
42     char str_del[80]; /*Delete Cln1 directory in case of good quality*/
43     char temp[80]; /*For temporary file*/
44     char temp1[80]; /*For temporary file*/
45     char temp2[80]; /*For temporary file*/
46     char temp3[80]; /*For temporary file*/
47     char temp4[80];
48    
49     char fni2[80]; /*Initial file mmm_nnnnn_cln1.pam*/
50     char inf2[80]; /*File name mmm_nnnnn_cln2.inf*/
51     char pam2[80]; /*File name mmm_nnnnn_cln2.pam*/
52     char name2[80]; /*Initial file name mmm_counter_nnnnn_cln1.pam*/
53     char name_ql[80]; /*File name mmm_nnnnn_ql.log*/
54     char log2[80]; /*File name mmm_nnnnn_cln2.log*/
55     char fno2[80]; /*Out help file mmm_nnnnn_work.dat*/
56     char path2[80]; /*Path for ...Temp/nnnnn_TMP/mmm/Cln2/*/
57     char mmm[80]; /*For route number*/
58     char name_route[4]; /*Route number in the file name*/
59    
60     char path3[80]; /*Path for ...Level0/nnnnn_mmm_L0/*/
61    
62     int Rcount=0; /*Number of Routes*/
63     int packet_type[NumberPack]={0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x16, 0x17, 0x18, 0x19,
64     0x1A, 0x1B, 0x1C, 0x1D, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x30, 0x50, 0x51, 0x52, 0x53,
65     0x54, 0x55, 0x60, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x81, 0x82, 0x83, 0x84,
66     0x85, 0x86, 0x88, 0x89, 0x8A, 0xA1, 0xAB, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4};/*PAMELA packet type code*/
67     int i, j;
68     int stop;
69     char *ttt=new char[Nmax];
70    
71 cafagna 1.2 for (i=0;i<100;i++) quality[i]=0;
72     for (i=0;i<64;i++) real_route[i]=0;
73 cafagna 1.1 // int RTtoMT,RT,Timesync,OBTtimesync;
74    
75     FILE *ftime_sync;
76     FILE *fff, *tmp, *tmp1, *tmp2, *tmp3, *tmp4;
77 cafagna 1.2
78 cafagna 1.1 // mikhailov 06.12.2004
79 cafagna 1.2 ftime_sync=fopen("/home/pamelaprod/rawreader/bin/timesync.dat","r+");
80 cafagna 1.1 while(feof(ftime_sync)==0)
81 cafagna 1.2 {fscanf(ftime_sync,"%u%[ ]%u%[ ]%u%[ ]%u\n",&RTtoMT, temp, &RT, temp, &Timesync, temp, &OBTtimesync);}
82 cafagna 1.1 fclose(ftime_sync);
83     // end mikhailov
84    
85 cafagna 1.2 // cout<<"global_err="<<GLOBAL_LEN_ER<<"\n";
86     if (strlen(argv[2])!=12) {cout<<"WRONG RAW FILE NAME\n"; exit(0);}
87 cafagna 1.1
88     strcpy(fni,argv[1]);
89     strcat(fni,argv[2]);
90    
91     strcpy(name,argv[2]);
92     name_route[0]=name[5];
93     name_route[1]=name[6];
94     name_route[2]=name[7];
95     name_route[3]='\0';
96 cafagna 1.2
97     strcpy(MainPath,"/home/pamelaprod/rawreader/level0/");
98 cafagna 1.1
99     /**************Creation directory nnnnn**********************/
100 cafagna 1.2 strncat(strcpy(nnnnn_TMP,MainPath),argv[2],5);
101 cafagna 1.1 strcpy(temp,nnnnn_TMP);
102 cafagna 1.2 strcat(temp,"/tmp.dat");
103 cafagna 1.1
104     if ((tmp=fopen(temp,"w"))==0)
105     {
106 cafagna 1.2 strcpy(command,"mkdir ");
107 cafagna 1.1 strcat(command,nnnnn_TMP);
108     system(command);
109     }
110     else
111     {
112     printf("directory %s already exists - rewriting \n",strncat(strcpy(temp1," "),argv[2],5));
113     fclose(tmp);
114     remove(temp);
115     // exit(0);
116     }
117     /****************************************************************/
118    
119 cafagna 1.2 strcat(strncat(strcat( strcpy(INF,nnnnn_TMP),"/"),name,8),"_cln1.inf");
120     strcat(strcpy(path,nnnnn_TMP),"/");
121     strcat(strncat(strcat(strcpy(fno,nnnnn_TMP),"/"),name,8),"_work.dat");
122     strcat(strncat(strcat(strcpy(protocol,nnnnn_TMP),"/"),name,8),"_protocol.txt");
123 cafagna 1.1
124     if (VRL_HEADER>0)
125     {
126     /*Creation of directories nnnnn_TMP\mmm_counter and ...\Cln1 in filename.cpp*/
127     read(fni, fno, INF, protocol, path, name, nnnnn_TMP, quality, real_route, Rcount); ////////////////// //////////////
128     }
129     else
130     {
131     temp[0]=name[5];
132     temp[1]=name[6];
133     temp[2]=name[7];
134     temp[3]='\0';
135 cafagna 1.2 strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),temp);
136     strcat(strcpy(command,"mkdir "),temp1);
137 cafagna 1.1
138     system(command);
139 cafagna 1.2 strcat(temp1,"/Cln1");
140     strcat(strcpy(command,"mkdir "),temp1);
141 cafagna 1.1 system(command);
142     /**********Copy file to directory nnnnn_TMP\mmm\Cln1*************/
143 cafagna 1.2 strcat(strcat(strcat(strcat(strcat(strcpy(command,"cp "),fni)," "),temp1),"/"),name);
144    
145 cafagna 1.1 system(command);
146 cafagna 1.2 strcat(strcat(strcpy(temp2,temp1),"/"),name);
147     strcat(strcat(strcat(strcpy(temp3,temp1),"/"),temp),"_");
148 cafagna 1.1 strcat(strncat(temp3,name,5),"_cln1.pam");
149     rename(temp2,temp3);
150     }
151    
152 cafagna 1.2 strcat(strcpy(temp,nnnnn_TMP),"/tmp.dat");
153 cafagna 1.1 tmp=fopen(temp, "w+");
154    
155     for(i=0;i<256;i++)
156     {
157     fprintf(tmp,"%03i",i);
158     fseek(tmp,0,0);
159     fgets(mmm,10,tmp);
160     fseek(tmp,0,0);
161 cafagna 1.2 strcat(strcat(strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),name_route),"_"),mmm),"/tmp.dat");
162    
163 cafagna 1.1 if ((tmp1=fopen(temp1,"w"))!=0)
164     {
165     fclose(tmp1);
166     remove(temp1);
167     strcat(strncat(strcat(strcat(strcat(strcpy(name2,name_route),"_"),mmm),"_"),name,5),"_cln1.pam");
168 cafagna 1.2 strcat(strcat(strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln1/"),name2);
169     name2[0]='\0';
170     strcat(strcat(strcat(strcat(strcat(strncat(name2,name,5),"_"),name_route),"_"),mmm),"_cln1.pam");
171 cafagna 1.1 strcpy(temp4,path);
172 cafagna 1.2 strcat(strcat(strcat(strcat(temp4,name_route),"_"),mmm),"/Cln2/tmp.dat");
173 cafagna 1.1 if ((tmp4=fopen(temp4,"w"))==0)
174     {
175 cafagna 1.2 /**************Creation directory nnnnn\xxx_mmm\Cln2****************/
176     strcat(strcat(strcat(strcat(strcat(strcat(strcpy(command,"mkdir "),nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2");
177 cafagna 1.1 system(command);
178     /*******************************************************************/
179     }
180     else
181     {
182     fclose(tmp4);
183     remove(temp4);
184     }
185 cafagna 1.2 strcat(strcat(strcat(strcat(strcat(strcpy(path2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2/");
186 cafagna 1.1 strcat(strncat(strcpy(inf2,path2),name2,13),"_cln2.inf");
187     strcat(strncat(strcpy(log2,path2),name2,13),"_cln2.log");
188     strcat(strncat(strcpy(pam2,path2),name2,13),"_cln2.pam");
189     strcat(strncat(strcpy(fno2,path2),name2,13),"_work.dat");
190    
191     IndexQ=quality[i-1];
192 cafagna 1.2 r_counter=i;
193     verify(fni2, inf2, log2, pam2, fno2, path2, name, name2, packet_type, IndexQ, r_counter, real_route); /////////////////////////////////
194 cafagna 1.1 //Delete Cln1
195     if (IndexQ>0.999)
196     {strcpy(str_del,"rm -r -f ");
197     strncat(str_del,fni2,strlen(fni2)-22);
198     if (system(str_del)) cout<<"Can not delete Cln1 for counter="<<r_counter<<"\n";
199     }
200 cafagna 1.2 strcat(strcat(strcat(strcat(strcat(strncat(strcpy(path3,MainPath),argv[2],5),"/"),name_route),"_"),mmm),"/packets");
201    
202     strcat(strcpy(temp2,path3),"/tmpM.dat");
203 cafagna 1.1 if ((tmp2=fopen(temp2,"w"))==0)
204     {
205     /**************Creation directory level0\nnnnn\counter_mmm\packets***************/
206 cafagna 1.2 strcat(strcpy(command,"mkdir "),path3);
207 cafagna 1.1 system(command);
208     /*******************************************************************/
209     }
210     else
211     {
212     fclose(tmp2);
213     remove(temp2);
214 cafagna 1.2 printf("directory for file %s already exists - rewriting \n",
215     strcat(strcat(strcat(strcat(strncat(strcpy(temp3," "),argv[2],5),"_"),name_route),"_"),mmm));
216 cafagna 1.1 }
217 cafagna 1.2 strcat(path3,"/");
218 cafagna 1.1 sort(log2, pam2, path2, path3, name2, packet_type); /////////////////////////////////////
219     strcat(strncat(strcat(strcat(strcpy(name_ql,path3),mmm),"_"),argv[2],5),"_ql.log");
220 cafagna 1.2 strcpy(temp3,"/home/pamelaprod/rawreader/bin/coordinate.exe");
221 cafagna 1.1 if ((tmp3=fopen(temp3,"r"))==0)
222     {printf("file %s does not exist\n",temp3);}
223     else
224     {
225     fclose(tmp3);
226     strcat(strcat(strcpy(command,temp3)," "),name_ql);
227     // system(command);
228     }
229     }
230     }
231     fclose(tmp);
232     remove(temp); delete [] ttt;
233    
234     return 0;
235     }

  ViewVC Help
Powered by ViewVC 1.1.23