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

Contents of /rawreader/source/Main.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Thu Aug 31 14:06:13 2006 UTC (18 years, 3 months ago) by pam-fi
Branch: rawreader, MAIN
CVS Tags: R0v00, HEAD
Changes since 1.1: +0 -0 lines
First rawreader release

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 char [], int[], int, float, int, int[]);
19 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 { time_t time_set=0, *time_p;
26 // 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 for (i=0;i<100;i++) quality[i]==0;
72 for (i=0;i<64;i++) real_route[i]==0;
73 // int RTtoMT,RT,Timesync,OBTtimesync;
74
75 FILE *ftime_sync;
76 FILE *fff, *tmp, *tmp1, *tmp2, *tmp3, *tmp4;
77
78 // mikhailov 06.12.2004
79 ftime_sync=fopen("/home/pamelaprod/rawreader/source/timesync.dat","r+");
80 while(feof(ftime_sync)==0)
81 {fscanf(ftime_sync,"%u%[ ]%u%[ ]%u%[ ]%u\n",&RTtoMT,temp,&RT,temp, &Timesync,temp,&OBTtimesync);}
82 fclose(ftime_sync);
83 // end mikhailov
84
85 time_set=time(time_p);
86
87 // cout<<copy(LINUX_flag)<<"\n";
88 // cout<<dir(LINUX_flag)<<"\n";
89 cout<<"global_err="<<GLOBAL_LEN_ER<<"\n";
90
91 strcpy(fni,argv[1]);
92 strcat(fni,argv[2]);
93
94 strcpy(name,argv[2]);
95 name_route[0]=name[5];
96 name_route[1]=name[6];
97 name_route[2]=name[7];
98 name_route[3]='\0';
99 cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!\n";
100 if (LINUX_flag==1) strcpy(MainPath,"/home/pamelaprod/rawreader/level0/");
101 if (LINUX_flag!=1) strcpy(MainPath,"c:\\home\\pamelaprod\\");
102 /**************Creation the path to the raw file**********************/
103 if (LINUX_flag==1) strcat(strcpy(RAW,"/home/ntsomz/pit/"),argv[2]);
104 if (LINUX_flag!=1) strcat(strncat(strcat(strcpy(RAW,MainPath),"Raw\\"),argv[2],5),"_RAW");
105
106 /**************Creation directory nnnnn**********************/
107 if (LINUX_flag==1) strncat(strcpy(nnnnn_TMP,MainPath),argv[2],5);
108 if (LINUX_flag!=1) strcat(strncat(strcat(strcpy(nnnnn_TMP,MainPath),"Temp\\"),argv[2],5),"_TMP");
109 strcpy(temp,nnnnn_TMP);
110 if (LINUX_flag==1)strcat(temp,"/tmp.dat");
111 if (LINUX_flag!=1) strcat(temp,"\\tmp.dat");
112
113 if ((tmp=fopen(temp,"w"))==0)
114 {
115 if (LINUX_flag==1) strcpy(command,"mkdir ");
116 if (LINUX_flag!=1) strcpy(command,"md ");
117 strcat(command,nnnnn_TMP);
118 system(command);
119 }
120 else
121 {
122 printf("directory %s already exists - rewriting \n",strncat(strcpy(temp1," "),argv[2],5));
123 fclose(tmp);
124 remove(temp);
125 // exit(0);
126 }
127 /****************************************************************/
128
129 if (LINUX_flag==1) strcat(strncat(strcat( strcpy(INF,nnnnn_TMP),"/"),name,8),"_cln1.inf");
130 if (LINUX_flag!=1) strcat(strncat(strcat( strcpy(INF,nnnnn_TMP),"\\"),name,8),"_cln1.inf");
131 if (LINUX_flag==1) strcat(strcpy(path,nnnnn_TMP),"/");
132 if (LINUX_flag!=1) strcat(strcpy(path,nnnnn_TMP),"\\");
133 if (LINUX_flag==1) strcat(strncat(strcat(strcpy(fno,nnnnn_TMP),"/"),name,8),"_work.dat");
134 if (LINUX_flag!=1) strcat(strncat(strcat(strcpy(fno,nnnnn_TMP),"\\"),name,8),"_work.dat");
135 if (LINUX_flag==1) strcat(strncat(strcat(strcpy(protocol,nnnnn_TMP),"/"),name,8),"_protocol.txt");
136 if (LINUX_flag!=1) strcat(strncat(strcat(strcpy(protocol,nnnnn_TMP),"\\"),name,8),"_protocol.txt");
137
138 if (VRL_HEADER>0)
139 {
140 /*Creation of directories nnnnn_TMP\mmm_counter and ...\Cln1 in filename.cpp*/
141 read(fni, fno, INF, protocol, path, name, nnnnn_TMP, quality, real_route, Rcount); ////////////////// //////////////
142 }
143 else
144 {
145 temp[0]=name[5];
146 temp[1]=name[6];
147 temp[2]=name[7];
148 temp[3]='\0';
149 if (LINUX_flag==1) strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),temp);
150 if (LINUX_flag!=1) strcat(strcat(strcpy(temp1,nnnnn_TMP),"\\"),temp);
151 if (LINUX_flag==1) strcat(strcpy(command,"mkdir "),temp1);
152 if (LINUX_flag!=1) strcat(strcpy(command,"md "),temp1);
153
154 system(command);
155 if (LINUX_flag==1) strcat(temp1,"/Cln1");
156 if (LINUX_flag!=1) strcat(temp1,"\\Cln1");
157 if (LINUX_flag==1) strcat(strcpy(command,"mkdir "),temp1);
158 if (LINUX_flag!=1) strcat(strcpy(command,"md "),temp1);
159 system(command);
160 /**********Copy file to directory nnnnn_TMP\mmm\Cln1*************/
161 if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcpy(command,"cp "),fni),
162 " "),temp1),"/"),name);
163 if (LINUX_flag!=1) strcat(strcat(strcat(strcat(strcat(strcpy(command,"copy "),fni),
164 " "),temp1),"\\"),name);
165 system(command);
166 if (LINUX_flag==1) strcat(strcat(strcpy(temp2,temp1),"/"),name);
167 if (LINUX_flag!=1) strcat(strcat(strcpy(temp2,temp1),"\\"),name);
168 if (LINUX_flag==1) strcat(strcat(strcat(strcpy(temp3,temp1),"/"),temp),"_");
169 if (LINUX_flag!=1) strcat(strcat(strcat(strcpy(temp3,temp1),"\\"),temp),"_");
170 strcat(strncat(temp3,name,5),"_cln1.pam");
171 rename(temp2,temp3);
172 }
173
174 if (LINUX_flag==1) strcat(strcpy(temp,nnnnn_TMP),"/tmp.dat");
175 if (LINUX_flag!=1) strcat(strcpy(temp,nnnnn_TMP),"\\tmp.dat");
176 tmp=fopen(temp, "w+");
177
178 for(i=0;i<256;i++)
179 {
180 fprintf(tmp,"%03i",i);
181 fseek(tmp,0,0);
182 fgets(mmm,10,tmp);
183 fseek(tmp,0,0);
184 if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"/"),name_route),"_"),mmm),"/tmp.dat");
185 if (LINUX_flag!=1) strcat(strcat(strcat(strcpy(temp1,nnnnn_TMP),"\\"),mmm),"\\tmp.dat");
186 if ((tmp1=fopen(temp1,"w"))!=0)
187 {
188 fclose(tmp1);
189 remove(temp1);
190 strcat(strncat(strcat(strcat(strcat(strcpy(name2,name_route),"_"),mmm),"_"),name,5),"_cln1.pam");
191 if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln1/"),name2);
192 if (LINUX_flag!=1) strcat(strcat(strcat(strcat(strcpy(fni2,nnnnn_TMP),"\\"),mmm),"\\Cln1\\"),name2);
193 strcpy(temp4,path);
194 if (LINUX_flag==1) strcat(strcat(strcat(strcat(temp4,name_route),"_"),mmm),"/Cln2/tmp.dat");
195 if (LINUX_flag!=1) strcat(strcat(temp4,mmm),"\\Cln2\\tmp.dat");
196 if ((tmp4=fopen(temp4,"w"))==0)
197 {
198 /**************Creation directory nnnnn\counter_mmm\Cln2****************/
199 if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcat(strcpy(command,"mkdir "),nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2");
200 if (LINUX_flag!=1) strcat(strcat(strcat(strcat(strcpy(command,"md "),nnnnn_TMP),"\\"),mmm),"\\Cln2");
201 system(command);
202 /*******************************************************************/
203 }
204 else
205 {
206 fclose(tmp4);
207 remove(temp4);
208 }
209 if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strcpy(path2,nnnnn_TMP),"/"),name_route),"_"),mmm),"/Cln2/");
210 if (LINUX_flag!=1) strcat(strcat(strcat(strcpy(path2,nnnnn_TMP),"\\"),mmm),"\\Cln2\\");
211 strcat(strncat(strcpy(inf2,path2),name2,13),"_cln2.inf");
212 strcat(strncat(strcpy(log2,path2),name2,13),"_cln2.log");
213 strcat(strncat(strcpy(pam2,path2),name2,13),"_cln2.pam");
214 strcat(strncat(strcpy(fno2,path2),name2,13),"_work.dat");
215
216 IndexQ=quality[i-1];
217 r_counter=i;
218 verify(fni2, inf2, log2, pam2, fno2, path2, name, name2, packet_type, GLOBAL_LEN_ER, IndexQ, r_counter, real_route); /////////////////////////////////
219 //Delete Cln1
220 if (IndexQ>0.999)
221 {strcpy(str_del,"rm -r -f ");
222 strncat(str_del,fni2,strlen(fni2)-22);
223 if (system(str_del)) cout<<"Can not delete Cln1 for counter="<<r_counter<<"\n";
224 }
225 if (LINUX_flag==1) strcat(strcat(strcat(strcat(strcat(strncat(strcpy(path3,MainPath),argv[2],5),"/"),name_route),"_"),mmm),"/packets");
226 if (LINUX_flag!=1) strcat(strcat(strcat(strncat(strcpy(strcpy(path3,MainPath),
227 "Level0\\"),argv[2],5),"_"),mmm),"_L0");
228 if (LINUX_flag==1) strcat(strcpy(temp2,path3),"/tmpM.dat");
229 if (LINUX_flag!=1) strcat(strcpy(temp2,path3),"\\tmpM.dat");
230 if ((tmp2=fopen(temp2,"w"))==0)
231 {
232 /**************Creation directory level0\nnnnn\counter_mmm\packets***************/
233 if (LINUX_flag==1) strcat(strcpy(command,"mkdir "),path3);
234 if (LINUX_flag!=1) strcat(strcpy(command,"md "),path3);
235 system(command);
236 /*******************************************************************/
237 }
238 else
239 {
240 fclose(tmp2);
241 remove(temp2);
242 printf("directory %s already exists - rewriting \n",
243 strcat(strcat(strcat(strcat(strcat(strncat(strcpy(temp3," "),argv[2],5),"_"),name_route),"_"),mmm),"_L0"));
244 }
245 if (LINUX_flag==1) strcat(path3,"/");
246 if (LINUX_flag!=1) strcat(path3,"\\");
247 sort(log2, pam2, path2, path3, name2, packet_type); /////////////////////////////////////
248 strcat(strncat(strcat(strcat(strcpy(name_ql,path3),mmm),"_"),argv[2],5),"_ql.log");
249 if (LINUX_flag==1) strcpy(temp3,"/home/pamelaprod/rawreader/bin/coordinate.exe");
250 if (LINUX_flag!=1) strcat(strcpy(temp3,MainPath),"Norad\\coordinate.exe");
251 if ((tmp3=fopen(temp3,"r"))==0)
252 {printf("file %s does not exist\n",temp3);}
253 else
254 {
255 fclose(tmp3);
256 strcat(strcat(strcpy(command,temp3)," "),name_ql);
257 // system(command);
258 }
259 }
260 }
261 fclose(tmp);
262 remove(temp); delete [] ttt;
263
264 return 0;
265 }

  ViewVC Help
Powered by ViewVC 1.1.23