Ignore:
Timestamp:
Mar 4, 2013, 6:08:02 PM (11 years ago)
Author:
garnier
Message:

Changement de la couleur des sections selectionnes + plein dautres choses

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r357 r359  
    1414
    1515dataManager::dataManager(PspaApplication* pspa) :
    16   currentBeam_(NULL),
    17   pspa_ (pspa)
     16currentBeam_(NULL),
     17pspa_ (pspa)
    1818{}
    1919
    20 dataManager::~dataManager() 
    21 {
    22   unsigned k;
    23   for (k=0; k < jobList_.size();k++) {
    24     if ( jobList_[k] != NULL ) delete jobList_[k];
    25   }
    26   if ( currentBeam_ == NULL ) delete currentBeam_;
     20dataManager::~dataManager()
     21{
     22    unsigned k;
     23    for (k=0; k < jobList_.size();k++) {
     24        if ( jobList_[k] != NULL ) delete jobList_[k];
     25    }
     26    if ( currentBeam_ == NULL ) delete currentBeam_;
    2727}
    2828
    2929void dataManager::consoleMessage(string message) {
    30   GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    31   if (console) console->addConsoleMessage(message);
    32   pspa_->processEvents();
     30    GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     31    if (console) console->addConsoleMessage(message);
     32    pspa_->processEvents();
    3333}
    3434
     
    4343int dataManager::getNumeroFromElementLabel(string label)
    4444{
    45   int index = -1;
    46  
    47   for (int k = 0; k < getBeamLineSize() ; k++)
     45    int index = -1;
     46   
     47    for (int k = 0; k < getBeamLineSize() ; k++)
    4848    {
    49       if (pspa_->getBeamLine()->getAbstractElement(k) != NULL){
    50         if ( pspa_->getBeamLine()->getAbstractElement(k)->getLabel() == label )
    51           {
    52             index = (int)k + 1;
    53             return index;
    54           }
    55       }
    56     }
    57   return index;
     49        if (pspa_->getBeamLine()->getAbstractElement(k) != NULL){
     50            if ( pspa_->getBeamLine()->getAbstractElement(k)->getLabel() == label )
     51            {
     52                index = (int)k + 1;
     53                return index;
     54            }
     55        }
     56    }
     57    return index;
    5858}
    5959
     
    6161abstractElement* dataManager::getElementPointerFromNumero(int k)
    6262{
    63   return pspa_->getBeamLine()->getAbstractElement(k-1);
     63    return pspa_->getBeamLine()->getAbstractElement(k-1);
    6464}
    6565
     
    6767void dataManager::addSectionToExecute(int debut, int fin, nomDeLogiciel prog)
    6868{
    69   jobList_.push_back(new sectionToExecute);
    70   jobList_.back()->firstElement = debut;
    71   jobList_.back()->lastElement = fin;
    72   jobList_.back()->software  = prog;
     69    jobList_.push_back(new sectionToExecute);
     70    jobList_.back()->firstElement = debut;
     71    jobList_.back()->lastElement = fin;
     72    jobList_.back()->software  = prog;
    7373}
    7474
    7575void dataManager::clearSectionToExecute()
    7676{
    77   unsigned k;
    78   for(k = 0; k < jobList_.size(); k++)
     77    unsigned k;
     78    for(k = 0; k < jobList_.size(); k++)
    7979    {
    80       if ( jobList_[k] != NULL ) delete jobList_[k];
    81     }
    82   jobList_.clear();
    83 }
    84 
    85 trivaluedBool dataManager::checkExecute(string& diagnostic)
    86 {
    87   cout << "dataManager::checkExecute()" << endl;
    88   consoleMessage(" VERIFICATION AVANT EXECUTION ");
    89  
    90   trivaluedBool resul = ok;
    91   diagnostic.clear();
    92  
    93   for(unsigned k = 0; k < jobList_.size(); k++) {
    94    
    95     unsigned numeroDeb = jobList_[k]->firstElement;
    96     unsigned numeroFin = jobList_[k]->lastElement;
    97    
    98     if ( numeroFin  < numeroDeb ) {
    99       diagnostic += " last element before first for job " + (jobList_[k]->software).getString() + " \n";
    100       resul = error;
    101       break;
    102     }
    103 
    104     string checkCompatibility;
    105     resul = checkElementsForExec(jobList_[k]->software,numeroDeb,numeroFin,checkCompatibility);
    106     diagnostic += checkCompatibility;
    107   } //k
    108 
    109   return resul;
    110 }
    111 
    112 trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel,unsigned numeroDeb,unsigned numeroFin,string& diagnostic)
    113 {
    114   trivaluedBool resul = ok;
    115   trivaluedBool accepted;
    116 
    117   diagnostic.clear(); 
    118   abstractElement* elPtr;
    119 
    120   for(unsigned j = numeroDeb; j <= numeroFin; j++) {
    121     elPtr = pspa_->getBeamLine()->getAbstractElement(j-1);
    122     accepted = elPtr->is_accepted_by_software(logiciel);
    123 
    124     if(accepted == error) {
    125       diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " is not allowed with " + logiciel.getString() + " \n";
    126       resul = error;
    127     } else if (accepted  == warning) {
    128       diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " will be ignored by " + logiciel.getString() + " \n";
    129       if ( resul != error ) resul = warning;
    130     }
    131   }
    132 
    133   return resul;
    134 }
     80        if ( jobList_[k] != NULL ) delete jobList_[k];
     81    }
     82    jobList_.clear();
     83}
     84
     85
     86
    13587
    13688void dataManager::initializeExecution()
    13789{
    138   string workingDir = pspa_->getWorkingDir();
     90    string workingDir = pspa_->getWorkingDir();
    13991    if (workingDir == "") {
    14092        return;
     
    165117bool dataManager::executeAll()
    166118{
    167   bool success = true;
    168   abstractSoftware* softw = NULL;
    169   string workingDir = pspa_->getWorkingDir();
    170 
    171   for(unsigned k = 0; k < jobList_.size(); k++)
    172     { 
    173       cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl;
    174      
    175       int debut = jobList_[k]->firstElement;
    176       int fin = jobList_[k]->lastElement;
    177       softw = createSoftwareConnexion(jobList_[k]->software);
    178      
    179       if (softw == NULL) {
    180         success = false;
    181         consoleMessage("dataManager::executeAll : unknown software");
    182         break;
    183       }
    184 
    185       success = softw->createInputFile(currentBeam_,debut,fin,workingDir);
    186       if ( success ) {
    187         success = softw->execute(debut,fin,workingDir);
    188         if ( success ) {
    189           success = softw->buildBeamAfterElements(debut,fin,diagnosticBeam_,workingDir);
    190         }
    191       }
    192      
    193       delete softw;
    194       if ( success ) {
    195         currentBeam_ = &diagnosticBeam_.back();
    196         cout << " execute termine avec succes " << endl;
    197       } else {
    198         currentBeam_ = NULL;
    199         cout << " execute termine en ECHEC " << endl;
    200       }
    201       if ( !success ) break;
    202  
    203       //debug
    204       cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl;
    205       cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl;
    206       for (int j = debut; j <= fin; j++) {
    207         abstractElement* elPtr= getElementPointerFromNumero(j);
    208         cout << "[" << j << "] " << elPtr->getNomdElement().getElementName() << endl;
    209       }
    210 
     119    bool success = true;
     120    abstractSoftware* softw = NULL;
     121    string workingDir = pspa_->getWorkingDir();
     122   
     123    for(unsigned k = 0; k < jobList_.size(); k++)
     124    {
     125        cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl;
     126       
     127        int debut = jobList_[k]->firstElement;
     128        int fin = jobList_[k]->lastElement;
     129        softw = createSoftwareConnexion(jobList_[k]->software);
     130       
     131        if (softw == NULL) {
     132            success = false;
     133            consoleMessage("dataManager::executeAll : unknown software");
     134            break;
     135        }
     136       
     137        success = softw->createInputFile(currentBeam_,debut,fin,workingDir);
     138        if ( success ) {
     139            success = softw->execute(debut,fin,workingDir);
     140            if ( success ) {
     141                success = softw->buildBeamAfterElements(debut,fin,diagnosticBeam_,workingDir);
     142            }
     143        }
     144       
     145        delete softw;
     146        if ( success ) {
     147            currentBeam_ = &diagnosticBeam_.back();
     148            cout << " execute termine avec succes " << endl;
     149        } else {
     150            currentBeam_ = NULL;
     151            cout << " execute termine en ECHEC " << endl;
     152        }
     153        if ( !success ) break;
     154       
     155        //debug
     156        cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl;
     157        cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl;
     158        for (int j = debut; j <= fin; j++) {
     159            abstractElement* elPtr= getElementPointerFromNumero(j);
     160            cout << "[" << j << "] " << elPtr->getNomdElement().getElementName() << endl;
     161        }
     162       
    211163    } //k
    212  
    213   return success;
     164   
     165    return success;
    214166}
    215167
     
    222174    cout << " et qu'on puisse restaurer normalement" << endl;
    223175    string name = pspa_->getWorkingDir() + "/" + nameOfFile + ".save";
    224 
     176   
    225177    // make dir if not exist
    226178    boost::filesystem::create_directories(pspa_->getWorkingDir() + folder + "/");
     
    230182        cerr << " error opening output file for persistency " << name << endl;
    231183    }
    232  
    233   outfile << globParam_.FileOutputFlow();
    234   abstractElement* elPtr;
    235   for(unsigned k = 0; k < getBeamLineSize() ; k++)
     184   
     185    outfile << globParam_.FileOutputFlow();
     186    abstractElement* elPtr;
     187    for(unsigned k = 0; k < getBeamLineSize() ; k++)
    236188    {
    237       elPtr = pspa_->getBeamLine()->getAbstractElement(k);
    238       outfile << elPtr->FileOutputFlow();
    239     }
    240   outfile.close();
     189        elPtr = pspa_->getBeamLine()->getAbstractElement(k);
     190        outfile << elPtr->FileOutputFlow();
     191    }
     192    outfile.close();
    241193}
    242194
     
    283235    }
    284236    infile.close();
    285 
     237   
    286238    // debug
    287239    // unsigned k;
    288240    // for(k = 0; k < getBeamLineSize(); k++) {
    289     //     abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(k);       
     241    //     abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(k);
    290242    //     cout << "reupere " << ptr->getLabel() << endl;
    291243    // }
     
    295247particleBeam* dataManager::getDiagnosticBeam(unsigned index)
    296248{
    297   if (index >= diagnosticBeam_.size()) {
    298     return NULL;
    299   } else {
    300     return &diagnosticBeam_.at(index);
    301   }
     249    if (index >= diagnosticBeam_.size()) {
     250        return NULL;
     251    } else {
     252        return &diagnosticBeam_.at(index);
     253    }
    302254}
    303255
     
    331283// }
    332284
     285
    333286// on ne tient pas compte des elements "snapshot" presents dans la beamLine
    334287void dataManager::donneesRmsEnveloppe(string type,vector<double>& xcor,vector<double>& ycor)
     
    358311      i++;
    359312    }
    360   } else {
    361     cerr << " dataManager::donneesRmsEnveloppe type " << type << " not programmed " << endl;
    362     return;
    363313  }
    364314}
    365315
    366316int dataManager::getBeamLineSize() {
    367   return pspa_->getBeamLine()->getBeamLineSize();
    368 }
    369 
    370 abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi) 
    371 {
    372   string inputFileName;
    373   if(logi == nomDeLogiciel::parmela) {
    374     inputFileName = "parmin";
    375     return new softwareParmela(inputFileName, &globParam_, this);
    376   } else if (logi == nomDeLogiciel::transport) {
    377     inputFileName = "transport.input";
    378     return new softwareTransport(inputFileName, &globParam_, this);
    379   } else if (logi == nomDeLogiciel::generator) {
    380     inputFileName = "generator.in";
    381     return new softwareGenerator(inputFileName, &globParam_, this);
    382   } else if (logi == nomDeLogiciel::test) {
    383     return new softwareTest(inputFileName, &globParam_, this);
    384   } else {
    385     return NULL;
    386   }
    387 }
     317    return pspa_->getBeamLine()->getBeamLineSize();
     318}
     319
     320abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi)
     321{
     322    string inputFileName;
     323    if(logi == nomDeLogiciel::parmela) {
     324        inputFileName = "parmin";
     325        return new softwareParmela(inputFileName, &globParam_, this);
     326    } else if (logi == nomDeLogiciel::transport) {
     327        inputFileName = "transport.input";
     328        return new softwareTransport(inputFileName, &globParam_, this);
     329    } else if (logi == nomDeLogiciel::generator) {
     330        inputFileName = "generator.in";
     331        return new softwareGenerator(inputFileName, &globParam_, this);
     332    } else if (logi == nomDeLogiciel::test) {
     333        return new softwareTest(inputFileName, &globParam_, this);
     334    } else {
     335        return NULL;
     336    }
     337}
Note: See TracChangeset for help on using the changeset viewer.