source: Sophya/trunk/ArchTOIPipe/TestPipes/mainxmlpipe.cc@ 2281

Last change on this file since 2281 was 2238, checked in by aubourg, 23 years ago

generation xsl a jour

File size: 28.4 KB
Line 
1
2// main genere automatiquement par xsl
3// ne pas modifier
4// derniere mise a jour : VF le 29/10/2002 -- derniere version
5
6// inclusions expat
7#include <stdio.h>
8#include "expat.h"
9
10// inclusions c++
11#include <string>
12#include "config.h"
13#include <map>
14using namespace std;
15#include <iostream.h>
16#include "toi.h"
17#include "toiprocessor.h"
18#include "toimanager.h"
19#include "toisegment.h"
20#include "sophyainit.h"
21#include <stdexcept>
22
23#ifndef MAXINT
24#define MAXINT 2147483647
25#endif
26
27#include "fitstoirdr.h"
28#include "fitstoiwtr.h"
29#include "smoothtoi.h"
30#include "toi2map.h"
31#include "map2toi.h"
32#include "flag2map.h"
33#include "rztoi.h"
34#include "rztoi.h"
35#include "noisegen.h"
36#include "noisegen.h"
37#include "noisegen.h"
38#include "meanvarestim.h"
39#include "demopipe.h"
40
41// classe de gestion des balises en design patern object call-back
42class ToiPipe
43{
44public:
45 ToiPipe(void);
46 virtual ~ToiPipe();
47 static void startElement(void *userData, const char *name, const char **atts);
48 static void endElement(void *userData, const char *name);
49private:
50 // pour concordances instances - nom
51 map<string,TOIProcessor*> toiProc;
52 string id;
53 // gestionnaire de TOI
54 TOIManager* mgr;
55 void startElementC(const char *name, const char **atts);
56 void endElementC(const char *name);
57};
58
59
60
61ToiPipe::ToiPipe()
62{
63 // Ouverture du gestionnaire de TOI.
64 mgr = TOIManager::getManager();
65 // initialisation du processeur courant
66 id="";
67
68}
69
70ToiPipe::~ToiPipe()
71{
72
73}
74
75void ToiPipe::startElement(void *userData, const char *name, const char **atts)
76{
77 ToiPipe *toiPipe = (ToiPipe*) userData;
78 toiPipe->startElementC(name, atts);
79}
80
81void ToiPipe::endElement(void *userData, const char *name)
82{
83 ToiPipe* toiPipe = (ToiPipe*) userData;
84 toiPipe->endElementC(name);
85}
86
87
88void ToiPipe::startElementC(const char *name, const char **atts)
89{
90 int i;
91 //puts(name);
92
93 // filtrage des balises
94 if ((string)name == "connect") {
95 // mise en ordre des arguments
96 string nom;
97 TOIProcessor* procin=NULL;
98 TOIProcessor* procout=NULL;
99 string input;
100 string output;
101 int taille = 1024;
102 bool writeflag = false;
103 for (i=0; atts[i]; i+=2) {
104 if ((string)atts[i] == "name") {
105 nom=atts[i+1];
106 }
107 if ((string)atts[i] == "procin") {
108 map<string,TOIProcessor*>::iterator j=toiProc.find(atts[i+1]);
109 if (j != toiProc.end()) {
110 procin = (*j).second;
111 } else {
112 throw ParmError("Connect error: processor in not found");
113 }
114 }
115 if ((string)atts[i] == "procout") {
116 map<string,TOIProcessor*>::iterator j=toiProc.find(atts[i+1]);
117 if (j != toiProc.end()) {
118 procout = (*j).second;
119 } else {
120 throw ParmError("Connect error: processor out not found");
121 }
122 }
123 if ((string)atts[i] == "input") {
124 input = atts[i+1];
125 }
126 if ((string)atts[i] == "output") {
127 output = atts[i+1];
128 }
129 }
130 // connection automatique des toiprocesseurs
131 if (procin != NULL && procout != NULL ) {
132 cout << "connect " << output << " " << input << endl;
133 mgr->connect(*procout, output, *procin, input, nom, taille, writeflag);
134 cout << "connect done" << endl;
135 }
136
137 } else if ((string)name == "constraint") { // si balise de contrainte
138 TOIProcessor* proc=NULL;
139 int min=0;
140 int max=MAXINT;
141 for (i=0; atts[i]; i+=2) {
142 if ((string)atts[i] =="proc") {
143 map<string,TOIProcessor*>::iterator j=toiProc.find(atts[i+1]);
144 if (j != toiProc.end()) {
145 proc = (*j).second;
146 } else {
147 throw ParmError("Constraint error: processor not found");
148 }
149 }
150 if ((string)atts[i] == "min") {
151 min = atoi(atts[i+1]);
152 }
153 if ((string)atts[i] == "max") {
154 max = atoi(atts[i+1]);
155 }
156 }
157 cout << "setting " << proc << " " << min << " " << max << endl;
158 proc->setRequestedSample(min, max);
159 cout << "constraint done" << endl;
160
161 } else if ((string)name == "start") { // si balise de demarrage
162 cout << "***** Starting execution *****" << endl;
163 mgr->startAll();
164 // Gestion de la re-connection des threads
165 cout<<"***** Joining threads *****"<<endl;
166 mgr->joinAll();
167 cout<<"***** End threads *****"<<endl;
168 // destruction du toimanager et des processeurs a implementer dans toimanager pour l'utilisation de plusieurs start
169 //TOIManager::~toimanager();
170 //toiProc.clear();
171
172 } else if (id == "") { // si nouveau processeur
173
174 if ((string)name == "fitsreader") {
175 string fn;
176
177
178 // gestion des arguments du constructeur
179 for (i=0; atts[i]; i+=2) {
180 // var pour instanciation
181 if ((string)atts[i] == "id") {
182 id=atts[i+1];
183 }
184
185 //initialisation des arguments par defaut si existants
186 fn = "test.fits";
187
188
189 // mise a jour des arguments
190
191 if ((string)atts[i] == "fn") {
192 fn = atts[i+1];
193
194 }
195
196 }
197
198 // creation du toiprocesseur
199 toiProc[id] = new FITSTOIReader (fn);
200 }
201
202 if ((string)name == "fitswriter") {
203 string fn;
204
205
206 // gestion des arguments du constructeur
207 for (i=0; atts[i]; i+=2) {
208 // var pour instanciation
209 if ((string)atts[i] == "id") {
210 id=atts[i+1];
211 }
212
213 //initialisation des arguments par defaut si existants
214
215
216 // mise a jour des arguments
217
218 if ((string)atts[i] == "fn") {
219 fn = atts[i+1];
220
221 }
222
223 }
224
225 // creation du toiprocesseur
226 toiProc[id] = new FITSTOIWriter (fn);
227 }
228
229 if ((string)name == "smooth") {
230 uint_4 lsm;
231 uint_4 deg;
232
233
234 // gestion des arguments du constructeur
235 for (i=0; atts[i]; i+=2) {
236 // var pour instanciation
237 if ((string)atts[i] == "id") {
238 id=atts[i+1];
239 }
240
241 //initialisation des arguments par defaut si existants
242
243
244 // mise a jour des arguments
245
246 if ((string)atts[i] == "lsm") {
247 lsm = atoi(atts[i+1]);
248
249 }
250
251 if ((string)atts[i] == "deg") {
252 deg = atoi(atts[i+1]);
253
254 }
255
256 }
257
258 // creation du toiprocesseur
259 toiProc[id] = new DataSmooth (lsm, deg);
260 }
261
262 if ((string)name == "toi2map") {
263 string map;
264 string wmap;
265
266
267 // gestion des arguments du constructeur
268 for (i=0; atts[i]; i+=2) {
269 // var pour instanciation
270 if ((string)atts[i] == "id") {
271 id=atts[i+1];
272 }
273
274 //initialisation des arguments par defaut si existants
275 wmap = "NULL";
276
277
278 // mise a jour des arguments
279
280 if ((string)atts[i] == "map") {
281 map = atts[i+1];
282
283 }
284
285 if ((string)atts[i] == "wmap") {
286 wmap = atts[i+1];
287
288 }
289
290 }
291
292 // creation du toiprocesseur
293 toiProc[id] = new TOI2Map (map, wmap);
294 }
295
296 if ((string)name == "map2toi") {
297 string sph;
298
299
300 // gestion des arguments du constructeur
301 for (i=0; atts[i]; i+=2) {
302 // var pour instanciation
303 if ((string)atts[i] == "id") {
304 id=atts[i+1];
305 }
306
307 //initialisation des arguments par defaut si existants
308
309
310 // mise a jour des arguments
311
312 if ((string)atts[i] == "sph") {
313 sph = atts[i+1];
314
315 }
316
317 }
318
319 // creation du toiprocesseur
320 toiProc[id] = new Map2TOI (sph);
321 }
322
323 if ((string)name == "flag2map") {
324 string map;
325 string wmap;
326
327
328 // gestion des arguments du constructeur
329 for (i=0; atts[i]; i+=2) {
330 // var pour instanciation
331 if ((string)atts[i] == "id") {
332 id=atts[i+1];
333 }
334
335 //initialisation des arguments par defaut si existants
336 wmap = "NULL";
337
338
339 // mise a jour des arguments
340
341 if ((string)atts[i] == "map") {
342 map = atts[i+1];
343
344 }
345
346 if ((string)atts[i] == "wmap") {
347 wmap = atts[i+1];
348
349 }
350
351 }
352
353 // creation du toiprocesseur
354 toiProc[id] = new FLAG2Map (map, wmap);
355 }
356
357 if ((string)name == "rztoiproc") {
358 int w1;
359 int w2;
360 int nmax;
361
362
363 // gestion des arguments du constructeur
364 for (i=0; atts[i]; i+=2) {
365 // var pour instanciation
366 if ((string)atts[i] == "id") {
367 id=atts[i+1];
368 }
369
370 //initialisation des arguments par defaut si existants
371 w1 = 4096;
372 w2 = 128;
373 nmax = 20;
374
375
376 // mise a jour des arguments
377
378 if ((string)atts[i] == "w1") {
379 w1 = atoi(atts[i+1]);
380
381 }
382
383 if ((string)atts[i] == "w2") {
384 w2 = atoi(atts[i+1]);
385
386 }
387
388 if ((string)atts[i] == "nmax") {
389 nmax = atoi(atts[i+1]);
390
391 }
392
393 }
394
395 // creation du toiprocesseur
396 toiProc[id] = new RzTOIProc (w1, w2, nmax);
397 }
398
399 if ((string)name == "rzsimpletoiproc") {
400 int wsz;
401 double fact;
402
403
404 // gestion des arguments du constructeur
405 for (i=0; atts[i]; i+=2) {
406 // var pour instanciation
407 if ((string)atts[i] == "id") {
408 id=atts[i+1];
409 }
410
411 //initialisation des arguments par defaut si existants
412 wsz = 1024;
413 fact = 1.0;
414
415
416 // mise a jour des arguments
417
418 if ((string)atts[i] == "wsz") {
419 wsz = atoi(atts[i+1]);
420
421 }
422
423 if ((string)atts[i] == "fact") {
424 fact = atof(atts[i+1]);
425
426 }
427
428 }
429
430 // creation du toiprocesseur
431 toiProc[id] = new RzSimpleTOIProc (wsz, fact);
432 }
433
434 if ((string)name == "noisegen") {
435
436
437 // gestion des arguments du constructeur
438 for (i=0; atts[i]; i+=2) {
439 // var pour instanciation
440 if ((string)atts[i] == "id") {
441 id=atts[i+1];
442 }
443
444 //initialisation des arguments par defaut si existants
445
446
447 // mise a jour des arguments
448
449 }
450
451 // creation du toiprocesseur
452 toiProc[id] = new NoiseGen ();
453 }
454
455 if ((string)name == "noisegengauss") {
456 float sigma;
457
458
459 // gestion des arguments du constructeur
460 for (i=0; atts[i]; i+=2) {
461 // var pour instanciation
462 if ((string)atts[i] == "id") {
463 id=atts[i+1];
464 }
465
466 //initialisation des arguments par defaut si existants
467
468
469 // mise a jour des arguments
470
471 if ((string)atts[i] == "sigma") {
472 sigma = atof(atts[i+1]);
473
474 }
475
476 }
477
478 // creation du toiprocesseur
479 toiProc[id] = new NoiseGenGauss (sigma);
480 }
481
482 if ((string)name == "noisegen00F") {
483 float fknee;
484 float sigma;
485
486
487 // gestion des arguments du constructeur
488 for (i=0; atts[i]; i+=2) {
489 // var pour instanciation
490 if ((string)atts[i] == "id") {
491 id=atts[i+1];
492 }
493
494 //initialisation des arguments par defaut si existants
495
496
497 // mise a jour des arguments
498
499 if ((string)atts[i] == "fknee") {
500 fknee = atof(atts[i+1]);
501
502 }
503
504 if ((string)atts[i] == "sigma") {
505 sigma = atof(atts[i+1]);
506
507 }
508
509 }
510
511 // creation du toiprocesseur
512 toiProc[id] = new NoiseGenOOF (fknee, sigma);
513 }
514
515 if ((string)name == "meanvarestimator") {
516 int nsamp;
517
518
519 // gestion des arguments du constructeur
520 for (i=0; atts[i]; i+=2) {
521 // var pour instanciation
522 if ((string)atts[i] == "id") {
523 id=atts[i+1];
524 }
525
526 //initialisation des arguments par defaut si existants
527
528
529 // mise a jour des arguments
530
531 if ((string)atts[i] == "nsamp") {
532 nsamp = atoi(atts[i+1]);
533
534 }
535
536 }
537
538 // creation du toiprocesseur
539 toiProc[id] = new MeanVarEstimator (nsamp);
540 }
541
542 if ((string)name == "demopipe") {
543
544
545 // gestion des arguments du constructeur
546 for (i=0; atts[i]; i+=2) {
547 // var pour instanciation
548 if ((string)atts[i] == "id") {
549 id=atts[i+1];
550 }
551
552 //initialisation des arguments par defaut si existants
553
554
555 // mise a jour des arguments
556
557 }
558
559 // creation du toiprocesseur
560 toiProc[id] = new DemoPipe ();
561 }
562
563
564 } else { // sinon c une methode
565 // gestion des methodes
566
567 if (id == "fitsreader") {
568
569 }
570
571 if (id == "fitswriter") {
572
573 }
574
575 if (id == "smooth") {
576
577 if ((string)name == "DoNotLookAt") {
578 uint_8 flag;
579
580
581 // gestion des arguments de la methode
582 for (i=0; atts[i]; i+=2) {
583 //initialisation des arguments par defaut si existants
584 flag = FlgToiAll;
585
586
587 // mise a jour des arguments
588
589 if ((string)atts[i] == "flag") {
590 flag = atoi(atts[i+1]);
591
592 }
593
594 }
595
596 // appelle de la methode du processeur concerne
597 ((DataSmooth*)toiProc[id])->DoNotLookAt (flag);
598 }
599
600 if ((string)name == "SetFlagFailed") {
601 uint_8 flag;
602
603
604 // gestion des arguments de la methode
605 for (i=0; atts[i]; i+=2) {
606 //initialisation des arguments par defaut si existants
607 flag = FlgToiInterp;
608
609
610 // mise a jour des arguments
611
612 if ((string)atts[i] == "flag") {
613 flag = atoi(atts[i+1]);
614
615 }
616
617 }
618
619 // appelle de la methode du processeur concerne
620 ((DataSmooth*)toiProc[id])->SetFlagFailed (flag);
621 }
622
623 if ((string)name == "SetBuff") {
624 uint_4 bupd;
625
626
627 // gestion des arguments de la methode
628 for (i=0; atts[i]; i+=2) {
629 //initialisation des arguments par defaut si existants
630 bupd = 100;
631
632
633 // mise a jour des arguments
634
635 if ((string)atts[i] == "bupd") {
636 bupd = atoi(atts[i+1]);
637
638 }
639
640 }
641
642 // appelle de la methode du processeur concerne
643 ((DataSmooth*)toiProc[id])->SetBuffUpd (bupd);
644 }
645
646 if ((string)name == "MinSmoothLength") {
647 uint_4 lsmin;
648
649
650 // gestion des arguments de la methode
651 for (i=0; atts[i]; i+=2) {
652 //initialisation des arguments par defaut si existants
653 lsmin = 0;
654
655
656 // mise a jour des arguments
657
658 if ((string)atts[i] == "lsmin") {
659 lsmin = atoi(atts[i+1]);
660
661 }
662
663 }
664
665 // appelle de la methode du processeur concerne
666 ((DataSmooth*)toiProc[id])->MinSmoothLength (lsmin);
667 }
668
669 }
670
671 if (id == "toi2map") {
672
673 if ((string)name == "SetEquinox") {
674 double actualyear;
675
676
677 // gestion des arguments de la methode
678 for (i=0; atts[i]; i+=2) {
679 //initialisation des arguments par defaut si existants
680 actualyear = 2000;
681
682
683 // mise a jour des arguments
684
685 if ((string)atts[i] == "actualyear") {
686 actualyear = atof(atts[i+1]);
687
688 }
689
690 }
691
692 // appelle de la methode du processeur concerne
693 ((TOI2Map*)toiProc[id])->SetEquinox (actualyear);
694 }
695
696 if ((string)name == "SetCoorIn") {
697 long mfg;
698
699
700 // gestion des arguments de la methode
701 for (i=0; atts[i]; i+=2) {
702 //initialisation des arguments par defaut si existants
703 mfg = TypCoordGalStd;
704
705
706 // mise a jour des arguments
707
708 if ((string)atts[i] == "mfg") {
709 mfg = atoi(atts[i+1]);
710
711 }
712
713 }
714
715 // appelle de la methode du processeur concerne
716 ((TOI2Map*)toiProc[id])->SetCoorIn (mfg);
717 }
718
719 if ((string)name == "SetCoorInChr") {
720 char* ctype;
721
722
723 // gestion des arguments de la methode
724 for (i=0; atts[i]; i+=2) {
725 //initialisation des arguments par defaut si existants
726
727
728 // mise a jour des arguments
729
730 if ((string)atts[i] == "ctype") {
731 ctype = atts[i+1];
732
733 }
734
735 }
736
737 // appelle de la methode du processeur concerne
738 ((TOI2Map*)toiProc[id])->SetCoorIn (ctype);
739 }
740
741 if ((string)name == "SetCoorMap") {
742 long mfg;
743
744
745 // gestion des arguments de la methode
746 for (i=0; atts[i]; i+=2) {
747 //initialisation des arguments par defaut si existants
748 mfg = TypCoordGal;
749
750
751 // mise a jour des arguments
752
753 if ((string)atts[i] == "mfg") {
754 mfg = atoi(atts[i+1]);
755
756 }
757
758 }
759
760 // appelle de la methode du processeur concerne
761 ((TOI2Map*)toiProc[id])->SetCoorMap (mfg);
762 }
763
764 if ((string)name == "SetCoorMapChr") {
765 char* ctype;
766
767
768 // gestion des arguments de la methode
769 for (i=0; atts[i]; i+=2) {
770 //initialisation des arguments par defaut si existants
771
772
773 // mise a jour des arguments
774
775 if ((string)atts[i] == "ctype") {
776 ctype = atts[i+1];
777
778 }
779
780 }
781
782 // appelle de la methode du processeur concerne
783 ((TOI2Map*)toiProc[id])->SetCoorMap (ctype);
784 }
785
786 if ((string)name == "SetCalibrationFactor") {
787 double fac;
788
789
790 // gestion des arguments de la methode
791 for (i=0; atts[i]; i+=2) {
792 //initialisation des arguments par defaut si existants
793 fac = 1.;
794
795
796 // mise a jour des arguments
797
798 if ((string)atts[i] == "fac") {
799 fac = atof(atts[i+1]);
800
801 }
802
803 }
804
805 // appelle de la methode du processeur concerne
806 ((TOI2Map*)toiProc[id])->SetCalibrationFactor (fac);
807 }
808
809 if ((string)name == "SetTestFlag") {
810 bool tflg;
811 long badflg;
812
813
814 // gestion des arguments de la methode
815 for (i=0; atts[i]; i+=2) {
816 //initialisation des arguments par defaut si existants
817 tflg = "false";
818 badflg = FlgToiAll;
819
820
821 // mise a jour des arguments
822
823 if ((string)atts[i] == "tflg") {
824 tflg = atts[i+1];
825
826 }
827
828 if ((string)atts[i] == "badflg") {
829 badflg = atoi(atts[i+1]);
830
831 }
832
833 }
834
835 // appelle de la methode du processeur concerne
836 ((TOI2Map*)toiProc[id])->SetTestFlag (tflg, badflg);
837 }
838
839 if ((string)name == "SetTestMin") {
840 bool tmin;
841 double vmin;
842
843
844 // gestion des arguments de la methode
845 for (i=0; atts[i]; i+=2) {
846 //initialisation des arguments par defaut si existants
847 tmin = "false";
848 vmin = -1.e30;
849
850
851 // mise a jour des arguments
852
853 if ((string)atts[i] == "tmin") {
854 tmin = atts[i+1];
855
856 }
857
858 if ((string)atts[i] == "vmin") {
859 vmin = atof(atts[i+1]);
860
861 }
862
863 }
864
865 // appelle de la methode du processeur concerne
866 ((TOI2Map*)toiProc[id])->SetTestMin (tmin, vmin);
867 }
868
869 if ((string)name == "SetTestMax") {
870 bool tmax;
871 double vmax;
872
873
874 // gestion des arguments de la methode
875 for (i=0; atts[i]; i+=2) {
876 //initialisation des arguments par defaut si existants
877 tmax = "false";
878 vmax = +1.e30;
879
880
881 // mise a jour des arguments
882
883 if ((string)atts[i] == "tmax") {
884 tmax = atts[i+1];
885
886 }
887
888 if ((string)atts[i] == "vmax") {
889 vmax = atof(atts[i+1]);
890
891 }
892
893 }
894
895 // appelle de la methode du processeur concerne
896 ((TOI2Map*)toiProc[id])->SetTestMax (tmax, vmax);
897 }
898
899 }
900
901 if (id == "map2toi") {
902
903 if ((string)name == "SetBad") {
904 long flg;
905
906
907 // gestion des arguments de la methode
908 for (i=0; atts[i]; i+=2) {
909 //initialisation des arguments par defaut si existants
910 flg = FlgToiOut;
911
912
913 // mise a jour des arguments
914
915 if ((string)atts[i] == "flg") {
916 flg = atoi(atts[i+1]);
917
918 }
919
920 }
921
922 // appelle de la methode du processeur concerne
923 ((Map2TOI*)toiProc[id])->SetBad (flg);
924 }
925
926 if ((string)name == "SetEquinox") {
927 double actualyear;
928
929
930 // gestion des arguments de la methode
931 for (i=0; atts[i]; i+=2) {
932 //initialisation des arguments par defaut si existants
933 actualyear = 2000;
934
935
936 // mise a jour des arguments
937
938 if ((string)atts[i] == "actualyear") {
939 actualyear = atof(atts[i+1]);
940
941 }
942
943 }
944
945 // appelle de la methode du processeur concerne
946 ((Map2TOI*)toiProc[id])->SetEquinox (actualyear);
947 }
948
949 if ((string)name == "SetCoorIn") {
950 long mfg;
951
952
953 // gestion des arguments de la methode
954 for (i=0; atts[i]; i+=2) {
955 //initialisation des arguments par defaut si existants
956 mfg = TypCoordGalStd;
957
958
959 // mise a jour des arguments
960
961 if ((string)atts[i] == "mfg") {
962 mfg = atoi(atts[i+1]);
963
964 }
965
966 }
967
968 // appelle de la methode du processeur concerne
969 ((Map2TOI*)toiProc[id])->SetCoorIn (mfg);
970 }
971
972 if ((string)name == "SetCoorInChr") {
973 char* ctype;
974
975
976 // gestion des arguments de la methode
977 for (i=0; atts[i]; i+=2) {
978 //initialisation des arguments par defaut si existants
979
980
981 // mise a jour des arguments
982
983 if ((string)atts[i] == "ctype") {
984 ctype = atts[i+1];
985
986 }
987
988 }
989
990 // appelle de la methode du processeur concerne
991 ((Map2TOI*)toiProc[id])->SetCoorIn (ctype);
992 }
993
994 if ((string)name == "SetCoorMap") {
995 long mfg;
996
997
998 // gestion des arguments de la methode
999 for (i=0; atts[i]; i+=2) {
1000 //initialisation des arguments par defaut si existants
1001 mfg = TypCoordGal;
1002
1003
1004 // mise a jour des arguments
1005
1006 if ((string)atts[i] == "mfg") {
1007 mfg = atoi(atts[i+1]);
1008
1009 }
1010
1011 }
1012
1013 // appelle de la methode du processeur concerne
1014 ((Map2TOI*)toiProc[id])->SetCoorMap (mfg);
1015 }
1016
1017 if ((string)name == "SetCoorMapChr") {
1018 char* ctype;
1019
1020
1021 // gestion des arguments de la methode
1022 for (i=0; atts[i]; i+=2) {
1023 //initialisation des arguments par defaut si existants
1024
1025
1026 // mise a jour des arguments
1027
1028 if ((string)atts[i] == "ctype") {
1029 ctype = atts[i+1];
1030
1031 }
1032
1033 }
1034
1035 // appelle de la methode du processeur concerne
1036 ((Map2TOI*)toiProc[id])->SetCoorMap (ctype);
1037 }
1038
1039 }
1040
1041 if (id == "flag2map") {
1042
1043 if ((string)name == "SetEquinox") {
1044 double actualyear;
1045
1046
1047 // gestion des arguments de la methode
1048 for (i=0; atts[i]; i+=2) {
1049 //initialisation des arguments par defaut si existants
1050 actualyear = 2000;
1051
1052
1053 // mise a jour des arguments
1054
1055 if ((string)atts[i] == "actualyear") {
1056 actualyear = atof(atts[i+1]);
1057
1058 }
1059
1060 }
1061
1062 // appelle de la methode du processeur concerne
1063 ((FLAG2Map*)toiProc[id])->SetEquinox (actualyear);
1064 }
1065
1066 if ((string)name == "SetCoorIn") {
1067 long mfg;
1068
1069
1070 // gestion des arguments de la methode
1071 for (i=0; atts[i]; i+=2) {
1072 //initialisation des arguments par defaut si existants
1073 mfg = TypCoordGalStd;
1074
1075
1076 // mise a jour des arguments
1077
1078 if ((string)atts[i] == "mfg") {
1079 mfg = atoi(atts[i+1]);
1080
1081 }
1082
1083 }
1084
1085 // appelle de la methode du processeur concerne
1086 ((FLAG2Map*)toiProc[id])->SetCoorIn (mfg);
1087 }
1088
1089 if ((string)name == "SetCoorInChr") {
1090 char* ctype;
1091
1092
1093 // gestion des arguments de la methode
1094 for (i=0; atts[i]; i+=2) {
1095 //initialisation des arguments par defaut si existants
1096
1097
1098 // mise a jour des arguments
1099
1100 if ((string)atts[i] == "ctype") {
1101 ctype = atts[i+1];
1102
1103 }
1104
1105 }
1106
1107 // appelle de la methode du processeur concerne
1108 ((FLAG2Map*)toiProc[id])->SetCoorIn (ctype);
1109 }
1110
1111 if ((string)name == "SetCoorMap") {
1112 long mfg;
1113
1114
1115 // gestion des arguments de la methode
1116 for (i=0; atts[i]; i+=2) {
1117 //initialisation des arguments par defaut si existants
1118 mfg = TypCoordGal;
1119
1120
1121 // mise a jour des arguments
1122
1123 if ((string)atts[i] == "mfg") {
1124 mfg = atoi(atts[i+1]);
1125
1126 }
1127
1128 }
1129
1130 // appelle de la methode du processeur concerne
1131 ((FLAG2Map*)toiProc[id])->SetCoorMap (mfg);
1132 }
1133
1134 if ((string)name == "SetCoorMapChr") {
1135 char* ctype;
1136
1137
1138 // gestion des arguments de la methode
1139 for (i=0; atts[i]; i+=2) {
1140 //initialisation des arguments par defaut si existants
1141
1142
1143 // mise a jour des arguments
1144
1145 if ((string)atts[i] == "ctype") {
1146 ctype = atts[i+1];
1147
1148 }
1149
1150 }
1151
1152 // appelle de la methode du processeur concerne
1153 ((FLAG2Map*)toiProc[id])->SetCoorMap (ctype);
1154 }
1155
1156 if ((string)name == "SetCalibrationFactor") {
1157 double fac;
1158
1159
1160 // gestion des arguments de la methode
1161 for (i=0; atts[i]; i+=2) {
1162 //initialisation des arguments par defaut si existants
1163 fac = 1.;
1164
1165
1166 // mise a jour des arguments
1167
1168 if ((string)atts[i] == "fac") {
1169 fac = atof(atts[i+1]);
1170
1171 }
1172
1173 }
1174
1175 // appelle de la methode du processeur concerne
1176 ((FLAG2Map*)toiProc[id])->SetCalibrationFactor (fac);
1177 }
1178
1179 if ((string)name == "SetTestFlag") {
1180 bool tflg;
1181 long badflg;
1182
1183
1184 // gestion des arguments de la methode
1185 for (i=0; atts[i]; i+=2) {
1186 //initialisation des arguments par defaut si existants
1187 tflg = "false";
1188 badflg = FlgToiAll;
1189
1190
1191 // mise a jour des arguments
1192
1193 if ((string)atts[i] == "tflg") {
1194 tflg = atts[i+1];
1195
1196 }
1197
1198 if ((string)atts[i] == "badflg") {
1199 badflg = atoi(atts[i+1]);
1200
1201 }
1202
1203 }
1204
1205 // appelle de la methode du processeur concerne
1206 ((FLAG2Map*)toiProc[id])->SetTestFlag (tflg, badflg);
1207 }
1208
1209 if ((string)name == "SetTestMin") {
1210 bool tmin;
1211 double vmin;
1212
1213
1214 // gestion des arguments de la methode
1215 for (i=0; atts[i]; i+=2) {
1216 //initialisation des arguments par defaut si existants
1217 tmin = "false";
1218 vmin = -1.e30;
1219
1220
1221 // mise a jour des arguments
1222
1223 if ((string)atts[i] == "tmin") {
1224 tmin = atts[i+1];
1225
1226 }
1227
1228 if ((string)atts[i] == "vmin") {
1229 vmin = atof(atts[i+1]);
1230
1231 }
1232
1233 }
1234
1235 // appelle de la methode du processeur concerne
1236 ((FLAG2Map*)toiProc[id])->SetTestMin (tmin, vmin);
1237 }
1238
1239 if ((string)name == "SetTestMax") {
1240 bool tmax;
1241 double vmax;
1242
1243
1244 // gestion des arguments de la methode
1245 for (i=0; atts[i]; i+=2) {
1246 //initialisation des arguments par defaut si existants
1247 tmax = "false";
1248 vmax = +1.e30;
1249
1250
1251 // mise a jour des arguments
1252
1253 if ((string)atts[i] == "tmax") {
1254 tmax = atts[i+1];
1255
1256 }
1257
1258 if ((string)atts[i] == "vmax") {
1259 vmax = atof(atts[i+1]);
1260
1261 }
1262
1263 }
1264
1265 // appelle de la methode du processeur concerne
1266 ((FLAG2Map*)toiProc[id])->SetTestMax (tmax, vmax);
1267 }
1268
1269 }
1270
1271 if (id == "rztoiproc") {
1272
1273 if ((string)name == "SetOutPPF") {
1274 string ppfname;
1275
1276
1277 // gestion des arguments de la methode
1278 for (i=0; atts[i]; i+=2) {
1279 //initialisation des arguments par defaut si existants
1280
1281
1282 // mise a jour des arguments
1283
1284 if ((string)atts[i] == "ppfname") {
1285 ppfname = atts[i+1];
1286
1287 }
1288
1289 }
1290
1291 // appelle de la methode du processeur concerne
1292 ((RzTOIProc*)toiProc[id])->SetOutPPF (ppfname);
1293 }
1294
1295 }
1296
1297 if (id == "rzsimpletoiproc") {
1298
1299 }
1300
1301 if (id == "noisegen") {
1302
1303 }
1304
1305 if (id == "noisegengauss") {
1306
1307 }
1308
1309 if (id == "noisegen00F") {
1310
1311 }
1312
1313 if (id == "meanvarestimator") {
1314
1315 if ((string)name == "doNotLookAt") {
1316 long flag;
1317
1318
1319 // gestion des arguments de la methode
1320 for (i=0; atts[i]; i+=2) {
1321 //initialisation des arguments par defaut si existants
1322 flag = FlgToiAll;
1323
1324
1325 // mise a jour des arguments
1326
1327 if ((string)atts[i] == "flag") {
1328 flag = atoi(atts[i+1]);
1329
1330 }
1331
1332 }
1333
1334 // appelle de la methode du processeur concerne
1335 ((MeanVarEstimator*)toiProc[id])->doNotLookAt (flag);
1336 }
1337
1338 }
1339
1340 if (id == "demopipe") {
1341
1342 }
1343
1344
1345 }
1346
1347}
1348
1349
1350void ToiPipe::endElementC(const char *name)
1351{
1352 // verification si une balise processeur est fermee pour la gestion des methodes d'initialisation
1353
1354 if ((string)name == "fitsreader") {
1355 id="";
1356 }
1357
1358 if ((string)name == "fitswriter") {
1359 id="";
1360 }
1361
1362 if ((string)name == "smooth") {
1363 id="";
1364 }
1365
1366 if ((string)name == "toi2map") {
1367 id="";
1368 }
1369
1370 if ((string)name == "map2toi") {
1371 id="";
1372 }
1373
1374 if ((string)name == "flag2map") {
1375 id="";
1376 }
1377
1378 if ((string)name == "rztoiproc") {
1379 id="";
1380 }
1381
1382 if ((string)name == "rzsimpletoiproc") {
1383 id="";
1384 }
1385
1386 if ((string)name == "noisegen") {
1387 id="";
1388 }
1389
1390 if ((string)name == "noisegengauss") {
1391 id="";
1392 }
1393
1394 if ((string)name == "noisegen00F") {
1395 id="";
1396 }
1397
1398 if ((string)name == "meanvarestimator") {
1399 id="";
1400 }
1401
1402 if ((string)name == "demopipe") {
1403 id="";
1404 }
1405
1406
1407 // execution du pipeline
1408 if ((string)name == "toipipe") {
1409 cout << "***** Starting execution *****" << endl;
1410 mgr->startAll();
1411 // Gestion de la re-connection des threads
1412 cout<<"***** Joining threads *****"<<endl;
1413 mgr->joinAll();
1414 cout<<"***** End threads *****"<<endl;
1415 }
1416}
1417
1418
1419int main(int argc, char *argv[])
1420{
1421 char buf[BUFSIZ];
1422 XML_Parser parser = XML_ParserCreate(NULL);
1423 int done;
1424 FILE* fich=fopen(argv[1],"r");
1425
1426 ToiPipe* toiPipe = new ToiPipe();
1427
1428 // Initialisation de Sophya
1429 SophyaInit();
1430 cout << "-- Application start --" << endl;
1431 XML_SetUserData(parser, toiPipe);
1432 XML_SetElementHandler(parser, ToiPipe::startElement, ToiPipe::endElement);
1433 if (fich != NULL) {
1434 cout << "-- Reading file --" << endl;
1435 // traitement des balises
1436 do {
1437 try {
1438 size_t len = fread(buf, 1, sizeof(buf), fich);
1439 done = len < sizeof(buf);
1440 if (!XML_Parse(parser, buf, len, done)) {
1441 fprintf(stderr,
1442 "%s at line %d\n",
1443 XML_ErrorString(XML_GetErrorCode(parser)),
1444 XML_GetCurrentLineNumber(parser));
1445 return 1;
1446 }
1447 } catch (PThrowable & exc) { // Sophya exceptions
1448 cout << "\ntstdemopipe: Catched Exception \n" << (string)typeid(exc).name()
1449 << " - Msg= " << exc.Msg() << endl;
1450 } catch (const std::exception & sex) { // Standard exceptions
1451 cout << "\ntstdemopipe: Catched std::exception \n"
1452 << (string)typeid(sex).name() << endl;
1453 } catch (...) { // Other exceptions
1454 cout << "\ntstdemopipe: some other exception was caught ! " << endl;
1455 }
1456 } while (!done);
1457 XML_ParserFree(parser);
1458 fclose(fich);
1459 } else {
1460 fprintf(stderr,"file not found");
1461 return 1;
1462 }
1463 return(0);
1464}
1465
Note: See TracBrowser for help on using the repository browser.