// main genere automatiquement par xsl // ne pas modifier // derniere mise a jour : VF le 22/10/2002 // inclusions expat #include #include "expat.h" // inclusions c++ #include #include "config.h" #include using namespace std; #include #include "toi.h" #include "toiprocessor.h" #include "toimanager.h" #include "toisegment.h" #include "sophyainit.h" #include #ifndef MAXINT #define MAXINT 2147483647 #endif #include "smoothtoi.h" #include "demopipe.h" #include "fitstoirdr.h" #include "fitstoiwtr.h" // classe de gestion des balises en design patern object call-back class ToiPipe { public: ToiPipe(void); virtual ~ToiPipe(); static void startElement(void *userData, const char *name, const char **atts); static void endElement(void *userData, const char *name); private: // pour concordances instances - nom map toiProc; string id; // gestionnaire de TOI TOIManager* mgr; void startElementC(const char *name, const char **atts); void endElementC(const char *name); }; ToiPipe::ToiPipe() { // Ouverture du gestionnaire de TOI. mgr = TOIManager::getManager(); // initialisation du processeur courant id=""; } ToiPipe::~ToiPipe() { } void ToiPipe::startElement(void *userData, const char *name, const char **atts) { ToiPipe *toiPipe = (ToiPipe*) userData; toiPipe->startElementC(name, atts); } void ToiPipe::endElement(void *userData, const char *name) { ToiPipe* toiPipe = (ToiPipe*) userData; toiPipe->endElementC(name); } void ToiPipe::startElementC(const char *name, const char **atts) { int i; //puts(name); // filtrage des balises if ((string)name == "connect") { // mise en ordre des arguments string nom; TOIProcessor* procin=NULL; TOIProcessor* procout=NULL; string input; string output; int taille = 1024; bool writeflag = false; for (i=0; atts[i]; i+=2) { if ((string)atts[i] == "name") { nom=atts[i+1]; } if ((string)atts[i] == "procin") { map::iterator j=toiProc.find(atts[i+1]); if (j != toiProc.end()) { procin = (*j).second; } else { throw ParmError("Connect error: processor in not found"); } } if ((string)atts[i] == "procout") { map::iterator j=toiProc.find(atts[i+1]); if (j != toiProc.end()) { procout = (*j).second; } else { throw ParmError("Connect error: processor out not found"); } } if ((string)atts[i] == "input") { input = atts[i+1]; } if ((string)atts[i] == "output") { output = atts[i+1]; } } // connection automatique des toiprocesseurs if (procin != NULL && procout != NULL ) { cout << "connect " << output << " " << input << endl; mgr->connect(*procout, output, *procin, input, nom, taille, writeflag); cout << "connect done" << endl; } } else if ((string)name == "constraint") { // si balise de contrainte TOIProcessor* proc=NULL; int min=0; int max=MAXINT; for (i=0; atts[i]; i+=2) { if ((string)atts[i] =="proc") { map::iterator j=toiProc.find(atts[i+1]); if (j != toiProc.end()) { proc = (*j).second; } else { throw ParmError("Constraint error: processor not found"); } } if ((string)atts[i] == "min") { min = atoi(atts[i+1]); } if ((string)atts[i] == "max") { max = atoi(atts[i+1]); } } cout << "setting " << proc << " " << min << " " << max << endl; proc->setRequestedSample(min, max); cout << "constraint done" << endl; } else if ((string)name == "start") { // si balise de demarrage cout << "***** Starting execution *****" << endl; mgr->startAll(); // Gestion de la re-connection des threads cout<<"***** Joining threads *****"<joinAll(); cout<<"***** End threads *****"<DoNotLookAt (flag); } if ((string)name == "SetFlagFailed") { uint_8 flag; // gestion des arguments de la methode for (i=0; atts[i]; i+=2) { //initialisation des arguments par defaut si existants flag = FlgToiInterp; // mise a jour des arguments if ((string)atts[i] == "flag") { flag = atoi(atts[i+1]); } } // appelle de la methode du processeur concerne ((DataSmooth*)toiProc[id])->SetFlagFailed (flag); } if ((string)name == "SetBuff") { uint_4 bupd; // gestion des arguments de la methode for (i=0; atts[i]; i+=2) { //initialisation des arguments par defaut si existants bupd = 100; // mise a jour des arguments if ((string)atts[i] == "bupd") { bupd = atoi(atts[i+1]); } } // appelle de la methode du processeur concerne ((DataSmooth*)toiProc[id])->SetBuffUpd (bupd); } if ((string)name == "MinSmoothLength") { uint_4 lsmin; // gestion des arguments de la methode for (i=0; atts[i]; i+=2) { //initialisation des arguments par defaut si existants lsmin = 0; // mise a jour des arguments if ((string)atts[i] == "lsmin") { lsmin = atoi(atts[i+1]); } } // appelle de la methode du processeur concerne ((DataSmooth*)toiProc[id])->MinSmoothLength (lsmin); } } if (id == "demopipe") { } if (id == "fitsreader") { } if (id == "fitswriter") { } } } void ToiPipe::endElementC(const char *name) { // verification si une balise processeur est fermee pour la gestion des methodes d'initialisation if ((string)name == "smooth") { id=""; } if ((string)name == "demopipe") { id=""; } if ((string)name == "fitsreader") { id=""; } if ((string)name == "fitswriter") { id=""; } // execution du pipeline if ((string)name == "toipipe") { cout << "***** Starting execution *****" << endl; mgr->startAll(); // Gestion de la re-connection des threads cout<<"***** Joining threads *****"<joinAll(); cout<<"***** End threads *****"<