5 |
void RunHeaderReader(char *buf); |
void RunHeaderReader(char *buf); |
6 |
extern long int OBTtimesync; |
extern long int OBTtimesync; |
7 |
extern long int Timesync; |
extern long int Timesync; |
8 |
extern char MYSQL[80]; |
extern char MYSQL[120]; |
9 |
extern char database[80]; |
extern char database[120]; |
10 |
|
extern char arina[120]; |
11 |
extern int print_flag; |
extern int print_flag; |
12 |
|
|
13 |
struct Names |
struct Names |
14 |
{ |
{ |
15 |
char a[80]; /*Full name for nnnnn_mmm_xxx_AA.bin*/ |
char a[100]; /*Full name for nnnnn_mmm_xxx_AA.bin*/ |
16 |
char a_short[80]; /*Short name for nnnnn_mmm_xxx_AA.bin*/ |
char a_short[80]; /*Short name for nnnnn_mmm_xxx_AA.bin*/ |
17 |
FILE *fo_a; |
FILE *fo_a; |
18 |
}; |
}; |
19 |
|
|
21 |
char file_init[], int packet_type[]) |
char file_init[], int packet_type[]) |
22 |
|
|
23 |
{ |
{ |
24 |
FILE *fo_log, *fo_ql, *fo_work2, *f_temp; |
FILE *fo_log, *fo_ql, *fo_work2; |
25 |
|
|
26 |
Names data[NumberPack+1]; |
Names data[NumberPack+1]; |
27 |
char fno2[80]; /* Out help file mm_nnnnn_work2.dat*/ |
char fno2[80]; /* Out help file mm_nnnnn_work2.dat*/ |
28 |
char ql[80]; |
char ql[80]; |
29 |
char tmp[80], tmp1[80], numer[10]; |
char tmp[80], tmp1[80], numer[10]; |
|
char arina[80]; |
|
30 |
char connection[80]; |
char connection[80]; |
31 |
char query[500]; |
char query[500]; |
32 |
long int orbit, route, count; |
long int orbit=0, route=0, count=0; |
33 |
// char buffer[10]; |
// char buffer[10]; |
34 |
char *packet=new char[Nmax]; |
char *packet=new char[Nmax]; |
35 |
unsigned int type=0; /*PAMELA packet type*/ |
unsigned int type=0; /*PAMELA packet type*/ |
52 |
for (i=0;i<4;i++) |
for (i=0;i<4;i++) |
53 |
{Hex_first[i]=0; |
{Hex_first[i]=0; |
54 |
Hex_last[i]=0;} |
Hex_last[i]=0;} |
|
|
|
55 |
for (i=0;i<NumberPack+1;i++) |
for (i=0;i<NumberPack+1;i++) |
56 |
{counter[i]=0; |
{counter[i]=0; |
57 |
first[i]=0; |
first[i]=0; |
58 |
last[i]=0;} |
last[i]=0;} |
|
|
|
59 |
Length=(int)(strlen(file_init)); |
Length=(int)(strlen(file_init)); |
60 |
strncat(strcpy(tmp,"\0"),file_init,Length-8); |
strncat(strcpy(tmp,"\0"),file_init,Length-8); |
|
strcat(strcpy(tmp1,path),"tmp.dat"); |
|
|
f_temp=fopen(tmp1,"wb+"); |
|
61 |
|
|
62 |
stringstream oss; |
stringstream oss; |
63 |
|
|
64 |
strcpy(connection,MYSQL); |
strcpy(connection,MYSQL); |
65 |
strcat(connection,database); |
strcat(connection,database); |
66 |
TSQLServer *sqlServer = TSQLServer::Connect(connection, "pamelaprod", "rawprod"); |
TSQLServer *sqlServer = TSQLServer::Connect(connection, "pamelaprod", "rawprod"); |
67 |
|
if (sqlServer==0) {cerr<<"can not connect with MYSQL server\n"; exit(1);} |
68 |
|
|
69 |
for (i=0;i<NumberPack+1;i++) |
for (i=0;i<NumberPack+1;i++) |
70 |
{ |
{ |
71 |
if (i==0) {fprintf(f_temp,"%02i",i);} |
if (i==0) |
72 |
else {fprintf(f_temp,"%02X",packet_type[i-1]);} |
{sprintf(tmp1,"%02i",i); |
73 |
fseek(f_temp,0,0); |
sscanf(tmp1,"%02s",numer); |
74 |
fgets(numer,10,f_temp); |
numer[2]='\0'; |
75 |
fseek(f_temp,0,0); |
} |
76 |
|
else |
77 |
|
{sprintf(tmp1,"%02X",packet_type[i-1]); |
78 |
|
sscanf(tmp1,"%02s",numer); |
79 |
|
numer[2]='\0'; |
80 |
|
} |
81 |
|
|
82 |
/*************Open files /home/pamelaprod/rawreader/level0/nnnnn/xxx_mmm/packets/nnnnn_mmm_xxx_AA.bin*******/ |
/*************Open files /home/pamelaprod/rawreader/level0/nnnnn/xxx_mmm/packets/nnnnn_mmm_xxx_AA.bin*******/ |
83 |
strncat(strcpy(data[i].a,path3),file_init,Length-8); |
strncat(strcpy(data[i].a,path3),file_init,Length-8); |
84 |
strcat(data[i].a,numer); |
strcat(data[i].a,numer); |
96 |
{cerr<<"can not open _%s.dat file",numer; exit(1);} |
{cerr<<"can not open _%s.dat file",numer; exit(1);} |
97 |
|
|
98 |
} |
} |
|
fclose(f_temp); |
|
|
remove(tmp1); |
|
99 |
/**********************OPEN NECESSARY FILES************************/ |
/**********************OPEN NECESSARY FILES************************/ |
100 |
/******************************************************************/ |
/******************************************************************/ |
101 |
ifstream fo_pam; |
ifstream fo_pam; |
103 |
if(fo_pam.good()==0) {cerr<<"can not open pam file"; exit(1);} |
if(fo_pam.good()==0) {cerr<<"can not open pam file"; exit(1);} |
104 |
|
|
105 |
ofstream fo_arina; |
ofstream fo_arina; |
106 |
strcpy(arina,"/home/arina/orientation/"); |
strcat(arina,data[28].a_short); |
107 |
strcat(arina,data[28].a_short); |
if (print_flag>0) cout<<"arina="<<arina<<"\n"; |
108 |
if (print_flag>0) cout<<arina<<"\n"; |
fo_arina.open(arina,ios::binary); //open file for arina |
|
fo_arina.open(arina,ios::binary); |
|
109 |
if(fo_arina.good()==0) {cerr<<"can not open arina file"; exit(1);} |
if(fo_arina.good()==0) {cerr<<"can not open arina file"; exit(1);} |
110 |
|
|
111 |
fo_log=fopen(log, "rb"); //open input file "nnnnn_mmm_xxx_cln2.log" |
fo_log=fopen(log, "rb"); //open input file "nnnnn_mmm_xxx_cln2.log" |
158 |
moscowtime=time-(OBTtimesync-Timesync); |
moscowtime=time-(OBTtimesync-Timesync); |
159 |
|
|
160 |
/*temp is packet number*/ |
/*temp is packet number*/ |
161 |
temp=(long int)(unsigned char)(packet[7])+ |
temp=(long int)(unsigned char)(packet[7])+256*(long int)(unsigned char)(packet[6])+ |
162 |
256*(long int)(unsigned char)(packet[6])+ |
256*256*(long int)(unsigned char)(packet[5]); |
|
256*256*(long int)(unsigned char)(packet[5]); |
|
163 |
if ((print_flag>0)&&(fmod((float)(temp),(float)(10000.))==0.)&&(temp!=0)) cout<<"sorting "<<temp<<"\n"; |
if ((print_flag>0)&&(fmod((float)(temp),(float)(10000.))==0.)&&(temp!=0)) cout<<"sorting "<<temp<<"\n"; |
164 |
|
|
165 |
/*unpacking several packets.... mikhailov |
/*unpacking several packets.... mikhailov |
166 |
unpackingPamelaPacket(packet,type)*/ |
unpackingPamelaPacket(packet,type)*/ |
167 |
if( type == 11) |
if( type == 16) |
168 |
{ |
{cout<<"RunHeader is calling\n"; |
169 |
RunHeaderReader(packet); |
RunHeaderReader(packet); |
170 |
|
cout<<"RunHeader is finishing\n"; |
171 |
if (flag_time==0) time_differ=Timesync-OBTtimesync; |
if (flag_time==0) time_differ=Timesync-OBTtimesync; |
172 |
flag_time=1; |
flag_time=1; |
173 |
} |
} |
264 |
|
|
265 |
for (i=0;i<NumberPack+1;i++) |
for (i=0;i<NumberPack+1;i++) |
266 |
fprintf(fo_work2,"Number of packets in %s file = %i\n",data[i].a_short,counter[i]); |
fprintf(fo_work2,"Number of packets in %s file = %i\n",data[i].a_short,counter[i]); |
267 |
|
if (print_flag>0) cout<<file_init<<"\n"; |
268 |
for(i=0;i<5;i++) {tmp1[i]=file_init[i];} tmp1[5]=' '; |
for(i=0;i<5;i++) {tmp1[i]=file_init[i];} tmp1[5]='\0'; |
269 |
sscanf(tmp1,"%5d",&orbit); |
sscanf(tmp1,"%5u",&orbit); |
270 |
|
for(i=6;i<9;i++) {tmp1[i-6]=file_init[i];} tmp1[3]='\0'; |
271 |
for(i=6;i<9;i++) {tmp1[i-6]=file_init[i];} tmp1[3]=' '; |
sscanf(tmp1,"%3u",&route); |
272 |
sscanf(tmp1,"%3d",&route); |
for(i=10;i<13;i++) {tmp1[i-10]=file_init[i];} tmp1[3]='\0'; |
273 |
|
sscanf(tmp1,"%3u",&count); |
|
for(i=10;i<13;i++) {tmp1[i-10]=file_init[i];} tmp1[3]=' '; |
|
|
sscanf(tmp1,"%3d",&count); |
|
|
|
|
274 |
oss.str(""); |
oss.str(""); |
275 |
oss << "UPDATE FILES1 set time_dif="<<time_differ<<" where cirquit_n="<<orbit<<" and route_n="<<route<< |
oss << "UPDATE FILES1 set time_dif="<<time_differ<<" where cirquit_n="<<orbit<<" and route_n="<<route<< |
276 |
" and counter="<<count; |
" and counter="<<count; |