1 | /*
|
---|
2 | Check if suivi is OK
|
---|
3 | > chkfsv -e 1,99999,10 -m 1,99999,10 -p 2 -d 1001,11 s4l074l15R.suivi01
|
---|
4 | > echo $status
|
---|
5 | */
|
---|
6 | #include "sopnamsp.h"
|
---|
7 | #include "machdefs.h"
|
---|
8 | #include <stdlib.h>
|
---|
9 | #include <stdio.h>
|
---|
10 | #include <ctype.h>
|
---|
11 | #include <math.h>
|
---|
12 | #include <iostream>
|
---|
13 | #include <typeinfo>
|
---|
14 | #include <unistd.h>
|
---|
15 |
|
---|
16 | #include "fsvcache.h"
|
---|
17 | #include "fsvst.h"
|
---|
18 |
|
---|
19 | void usage(void)
|
---|
20 | {
|
---|
21 | printf("Usage: chkfsv NomSuivi\n");
|
---|
22 | printf(" -e n1,n2,inc : Traitement des etoiles n1 a n2 avec increment inc\n");
|
---|
23 | printf(" -m m1,m2,inc : Traitement des mesures m1 a m2 avec increment inc\n");
|
---|
24 | printf(" -p lp : print level\n");
|
---|
25 | printf(" -d et,mes : debug by full printing for star et and mesure mes\n");
|
---|
26 | printf("Warning: number go [1,n]\n");
|
---|
27 | }
|
---|
28 |
|
---|
29 | int main(int narg, char *arg[] )
|
---|
30 | {
|
---|
31 | //---- Decodage des arguments
|
---|
32 | int lp=1, etdbg=-1, mesdbg=-1;
|
---|
33 | int numes1=1, numes2=9999999, incmes=1;
|
---|
34 | int numet1=1, numet2=9999999, incet=1;
|
---|
35 | if(narg<2) {usage(); return 1;}
|
---|
36 | char c;
|
---|
37 | while((c = getopt(narg, arg, "he:m:p:d:")) != -1) {
|
---|
38 | switch (c) {
|
---|
39 | case 'e' :
|
---|
40 | sscanf(optarg,"%d,%d,%d",&numet1,&numet2,&incet);
|
---|
41 | case 'm' :
|
---|
42 | sscanf(optarg,"%d,%d,%d",&numes1,&numes2,&incmes);
|
---|
43 | case 'p' :
|
---|
44 | sscanf(optarg,"%d",&lp);
|
---|
45 | if(lp<0) lp=0;
|
---|
46 | case 'd' :
|
---|
47 | sscanf(optarg,"%d,%d",&etdbg,&mesdbg);
|
---|
48 | break;
|
---|
49 | case 'h' :
|
---|
50 | default:
|
---|
51 | usage();
|
---|
52 | return 1;
|
---|
53 | }
|
---|
54 | }
|
---|
55 | if(optind>=narg) {usage(); return 2;}
|
---|
56 | char svf[2048];
|
---|
57 | strcpy(svf,arg[optind]);
|
---|
58 |
|
---|
59 | int rc = 0;
|
---|
60 |
|
---|
61 | //---- Ouverture du fichier de suivi
|
---|
62 | SUIVIFIP *sfip = NULL;
|
---|
63 | if( (sfip=SuiviOpen(svf,SUOF_RO_MEM2)) == NULL ) {
|
---|
64 | cout<<"Error opening: "<<svf<<endl;
|
---|
65 | return(10);
|
---|
66 | }
|
---|
67 | if(lp>0) cout<<svf<<endl;
|
---|
68 | int nbstar = SuiviGetNbStars(sfip);
|
---|
69 | int nbmes = SuiviGetNbMesures(sfip);
|
---|
70 | if(lp>0) cout<<"nbstar = "<<nbstar<<" nbmes = "<<nbmes<<endl;
|
---|
71 |
|
---|
72 | if(incet<=0) incet = 1;
|
---|
73 | if(numes1<1) numes1 = 1;
|
---|
74 | if(numes2<1) numes2 = 1;
|
---|
75 | if(numes2>nbmes) numes2 = nbmes;
|
---|
76 | if(numes2<numes1) numes1 = numes2;
|
---|
77 | if(incmes<=0) incmes = 1;
|
---|
78 | if (numet1<1) numet1 = 1;
|
---|
79 | if (numet2<1) numet2 = 1;
|
---|
80 | if (numet2>nbstar) numet2 = nbstar;
|
---|
81 | if (numet2<numet1) numet1 = numet2;
|
---|
82 |
|
---|
83 | //---- Lecture GlobInfo
|
---|
84 | GLOBINFO glinf;
|
---|
85 | if(lp>0) cout<<"Reading GlobInfo"<<endl;
|
---|
86 | rc = SuiviReadGlobInfo(sfip, (char *)(&glinf));
|
---|
87 | if(rc!=0) {
|
---|
88 | cout<<"Error reading GlobInfo rc="<<rc<<endl;
|
---|
89 | return 11;
|
---|
90 | }
|
---|
91 | if(lp>1) {cout<<"\n>>> GLOBINFO"<<endl; PrtGlobInfo(&glinf,99);}
|
---|
92 |
|
---|
93 | //---- Lecture TimeInfo
|
---|
94 | TIMEINFO tminf;
|
---|
95 | TIMEINFOU tminfu;
|
---|
96 | if(lp>0) cout<<"Reading TimeInfo from "<<numes1<<" to "<<numes2<<" with inc "<<incmes<<endl;
|
---|
97 | if(nbmes>0) for(int i=numes1;i<=numes2;i++) {
|
---|
98 | rc = SuiviReadTimeInfo(sfip,i,i,(char *)(&tminf));
|
---|
99 | if(rc!=0) {
|
---|
100 | cout<<"Error reading TimeInfo mes="<<i<<" rc="<<rc<<endl;
|
---|
101 | return 12;
|
---|
102 | }
|
---|
103 | if(mesdbg==i) {
|
---|
104 | cout<<"\n>>> TIMEINFO"<<endl; PrtTimeInfo(&tminf,i,99);
|
---|
105 | DecodeTim(&tminf,&tminfu);
|
---|
106 | cout<<"\n>>> TIMEINFOU"<<endl; PrtTimeInfoU(&tminfu,i,99);
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | //---- Lecture StarInfo
|
---|
111 | STARINFO star;
|
---|
112 | if(lp>0) cout<<"Reading StarInfo from "<<numet1<<" to "<<numet2<<" with inc "<<incet<<endl;
|
---|
113 | if(nbstar>0) for(int i=numet1;i<=numet2;i+=incet) {
|
---|
114 | rc = SuiviReadStarInfo(sfip,i,(char *)(&star));
|
---|
115 | if(rc!=0) {
|
---|
116 | cout<<"Error reading StarInfo star="<<i<<" rc="<<rc<<endl;
|
---|
117 | return 13;
|
---|
118 | }
|
---|
119 | if(etdbg==i) {cout<<"\n>>> STARINFO"<<endl; PrtStarInfo(&star,i,99);}
|
---|
120 | }
|
---|
121 |
|
---|
122 | //---- Lecture Mesures
|
---|
123 | MESURE mes;
|
---|
124 | MESUREU mesu;
|
---|
125 | if(lp>0) cout<<"Reading Mesures"<<endl;
|
---|
126 | if(nbstar>0) for(int i=numet1;i<=numet2;i+=incet) {
|
---|
127 | if(nbmes>0) for(int j=numes1;j<=numes2;j+=incmes) {
|
---|
128 | rc = SuiviReadMesures(sfip,i,j,j,(char *)(&mes));
|
---|
129 | if(rc!=0) {
|
---|
130 | cout<<"Error reading Mesures star="<<i<<" mes="<<j<<" rc="<<rc<<endl;
|
---|
131 | return 14;
|
---|
132 | }
|
---|
133 | if(etdbg==i && mesdbg==j) {
|
---|
134 | cout<<"\n>>> MESURE"<<endl; PrtMesure(&mes,j,99);
|
---|
135 | DecodeMes(&mes,&mesu);
|
---|
136 | cout<<"\n>>> MESUREU"<<endl; PrtMesureU(&mesu,j,99);
|
---|
137 | Calibre_F_E(&mesu,&tminfu);
|
---|
138 | cout<<"\n>>> MESUREU apres Calib"<<endl; PrtMesureU(&mesu,j,99);
|
---|
139 | }
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | //---- Fermeture du fichier de Suivi
|
---|
144 | rc = SuiviClose(sfip);
|
---|
145 | if(rc!=0) {
|
---|
146 | cout<<"Error Closing Suivi file rc="<<rc<<endl;
|
---|
147 | return 15;
|
---|
148 | }
|
---|
149 |
|
---|
150 | return(rc);
|
---|
151 | }
|
---|