[431] | 1 | #include <stdio.h> |
---|
| 2 | #include <fstream> |
---|
| 3 | |
---|
[27] | 4 | #include "dataManager.h" |
---|
[243] | 5 | #include "mathematicalConstants.h" |
---|
| 6 | #include "PhysicalConstants.h" |
---|
[493] | 7 | #include "softwareUnknown.h" |
---|
[431] | 8 | |
---|
| 9 | #include "GWt_pspaApplication.h" |
---|
| 10 | #include "GWt_console.h" |
---|
[455] | 11 | #include "GWt_ligneFaisceau.h" // FIXME to be removed ! |
---|
[431] | 12 | |
---|
[347] | 13 | #include <boost/filesystem.hpp> |
---|
[27] | 14 | |
---|
[424] | 15 | #include "UAP/UAPUtilities.hpp" |
---|
| 16 | #include "AML/AMLReader.hpp" |
---|
[488] | 17 | #include "AMLtools.h" |
---|
[424] | 18 | |
---|
[493] | 19 | #define BAVARD 1 |
---|
[431] | 20 | |
---|
[342] | 21 | dataManager::dataManager(PspaApplication* pspa) : |
---|
[493] | 22 | pspa_ (pspa), |
---|
| 23 | currentMachine_(NULL) |
---|
[342] | 24 | {} |
---|
[305] | 25 | |
---|
[359] | 26 | dataManager::~dataManager() |
---|
[50] | 27 | { |
---|
[431] | 28 | unsigned k; |
---|
[493] | 29 | for (k=0; k < sectors_.size();k++) { |
---|
| 30 | if ( sectors_[k] != NULL ) delete sectors_[k]; |
---|
[431] | 31 | } |
---|
[493] | 32 | if ( currentMachine_ ) delete currentMachine_; |
---|
[50] | 33 | } |
---|
[38] | 34 | |
---|
[431] | 35 | void dataManager::consoleMessage(string message) |
---|
| 36 | { |
---|
[493] | 37 | cout << " passage console message : " << endl; |
---|
| 38 | cout << message << endl; |
---|
[431] | 39 | GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); |
---|
| 40 | if (console) console->addConsoleMessage(message + "\n"); |
---|
| 41 | pspa_->processEvents(); |
---|
[313] | 42 | } |
---|
[493] | 43 | |
---|
[299] | 44 | |
---|
[302] | 45 | void dataManager::initializeExecution() |
---|
[102] | 46 | { |
---|
[371] | 47 | string workingDir = pspa_->getWorkingDir(); |
---|
| 48 | if (workingDir == "") { |
---|
| 49 | return; |
---|
| 50 | } |
---|
| 51 | removeFile(workingDir + "parmdesz"); |
---|
| 52 | removeFile(workingDir + "parmin"); |
---|
| 53 | removeFile(workingDir + "parin.input0"); |
---|
| 54 | removeFile(workingDir + "transport.input"); |
---|
| 55 | removeFile(workingDir + "transport.output"); |
---|
| 56 | removeFile(workingDir + "generator.in"); |
---|
| 57 | removeFile(workingDir + "faisceau.ini"); |
---|
| 58 | removeFile(workingDir + "generator.output"); |
---|
| 59 | diagnosticBeam_.clear(); |
---|
[386] | 60 | indexElementToIndexDiag_.clear(); |
---|
[493] | 61 | // for (unsigned int a=0; a< jobList_.size(); a++) { |
---|
| 62 | // jobList_[a]->clearSectionToExecute(); |
---|
| 63 | // } |
---|
[105] | 64 | } |
---|
| 65 | |
---|
[305] | 66 | void dataManager::removeFile(string nameOfFile) |
---|
[105] | 67 | { |
---|
[431] | 68 | ifstream fileExists; |
---|
| 69 | fileExists.open(nameOfFile.c_str(), ios::in); |
---|
| 70 | if (fileExists) { |
---|
| 71 | fileExists.close(); |
---|
| 72 | remove(nameOfFile.c_str()); |
---|
| 73 | } |
---|
[112] | 74 | } |
---|
| 75 | |
---|
[313] | 76 | bool dataManager::executeAll() |
---|
[112] | 77 | { |
---|
[436] | 78 | #if BAVARD > 0 |
---|
[431] | 79 | cout << "***********************************" << endl; |
---|
| 80 | cout << " dataManager::executeAll() " << endl << endl; |
---|
[436] | 81 | #endif |
---|
[431] | 82 | |
---|
[371] | 83 | bool success = true; |
---|
| 84 | string workingDir = pspa_->getWorkingDir(); |
---|
[431] | 85 | |
---|
[455] | 86 | // Main loop ! |
---|
[493] | 87 | cout << " dataManager::executeAll #sectors_= " << sectors_.size() << endl; |
---|
| 88 | // expandedMachine machine; |
---|
| 89 | // machine.fromJoblist(jobList_); |
---|
| 90 | |
---|
| 91 | // vecteur de blocs de calcul |
---|
| 92 | vector<computingBlock*> compblock = getCurrentMachine()->getComputingBlocks(); |
---|
| 93 | cout << " dataManager::executeAll() : nb blocs de calcul : " << compblock.size() << endl; |
---|
| 94 | |
---|
| 95 | particleBeam* computedBeam = sectors_[0]->getParticleBeam(); |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | // for(unsigned k = 0; k < jobList_.size(); k++) |
---|
| 99 | // { |
---|
| 100 | // sector* sector = jobList_[k]; |
---|
| 101 | // cout << " dataManager::executeAll sector name= " << sector->getName() << endl; |
---|
| 102 | // cout << " dataManager::executeAll #sectionsToExecute= " << sector->getSectionsToExecute().size() << endl; |
---|
[455] | 103 | |
---|
[482] | 104 | // for the moment, we put everything in one line without loops |
---|
[493] | 105 | // for(unsigned int l = 0; l < sector->getSectionsToExecute().size(); l++) |
---|
| 106 | for (unsigned int l = 0; l < compblock.size(); l++) |
---|
[482] | 107 | { |
---|
[493] | 108 | abstractSoftware* softw = compblock.at(l)->getSoftware(); |
---|
[485] | 109 | cout << " execution du SOFWARE " << softw->getName() << endl; |
---|
| 110 | if (softw == NULL) { |
---|
| 111 | success = false; |
---|
| 112 | consoleMessage("dataManager::executeAll : unknown software"); |
---|
| 113 | break; |
---|
| 114 | } |
---|
[482] | 115 | |
---|
[493] | 116 | // success = softw->createInputFile(sector->getParticleBeam(),workingDir); |
---|
| 117 | cout << " dataManager::executeAll() APPEL softw->createInputFile " << endl; |
---|
| 118 | success = softw->createInputFile(computedBeam,workingDir); |
---|
[485] | 119 | if ( success ) { |
---|
| 120 | success = softw->execute(workingDir); |
---|
| 121 | if ( success ) { |
---|
| 122 | success = softw->buildBeamAfterElements(workingDir); |
---|
| 123 | } |
---|
| 124 | } |
---|
| 125 | cout << " dataManager::executeAll success = " << success << " y-a-ty du faisceau : " << diagnosticBeam_.size() << endl; |
---|
| 126 | if ( success && (diagnosticBeam_.size() > 0)) { |
---|
[493] | 127 | // sector->setParticleBeam(&diagnosticBeam_.at(indexElementToIndexDiag_.back())); |
---|
| 128 | computedBeam = &diagnosticBeam_.at(indexElementToIndexDiag_.back()); |
---|
[485] | 129 | cout << " dataManager::executeAll termine avec succes " << endl; |
---|
| 130 | } else { |
---|
[493] | 131 | // sector->setParticleBeam(NULL); |
---|
| 132 | computedBeam = NULL; |
---|
[485] | 133 | cout << " dataManager::executeAll termine en ECHEC " << endl; |
---|
| 134 | } |
---|
| 135 | if ( !success ) break; |
---|
[431] | 136 | |
---|
[455] | 137 | #if BAVARD > 0 |
---|
[482] | 138 | cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl; |
---|
[493] | 139 | // cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl; |
---|
| 140 | // std::vector< abstractElement* > elements = section->getElements(); |
---|
| 141 | // std::vector< abstractElement* > elements = compblock.at(l)->getElements(); |
---|
| 142 | for (unsigned j = 0; j < compblock.at(l)->getNumberOfElements(); j++) { |
---|
| 143 | cout << "[" << j << "] " << compblock.at(l)->getElement(j)->getNomdElement().getExpandedName() << endl; |
---|
[482] | 144 | } |
---|
[436] | 145 | #endif |
---|
[482] | 146 | } //l |
---|
[493] | 147 | // } //k |
---|
[482] | 148 | |
---|
[472] | 149 | // if ( currentBeam_deprecated_ ) { |
---|
[442] | 150 | // string aml_file = workingDir + "/" + "faisceau_final" + ".aml"; |
---|
[472] | 151 | // currentBeam_deprecated_->writeToAMLFile(aml_file); |
---|
[442] | 152 | // // TESTS |
---|
[472] | 153 | // currentBeam_deprecated_->readFromAMLFile(aml_file); |
---|
[442] | 154 | // } |
---|
[482] | 155 | |
---|
[371] | 156 | return success; |
---|
[102] | 157 | } |
---|
[50] | 158 | |
---|
[488] | 159 | // void dataManager::saveConfiguration(string folder, string nameOfFile) |
---|
| 160 | // { |
---|
| 161 | // ofstream outfile; |
---|
| 162 | // //string name = pspa_->getWorkingDir()+ folder + "/" + nameOfFile + ".save"; |
---|
| 163 | // cout << " dataManager::saveConfiguration : suppression du folder dans le nom de " << endl; |
---|
| 164 | // cout << " sauvegarde, en attendant que ce soit autre chose que le sessionId" << endl; |
---|
| 165 | // cout << " et qu'on puisse restaurer normalement" << endl; |
---|
[431] | 166 | |
---|
[488] | 167 | // string name = pspa_->getWorkingDir() + "/" + nameOfFile + ".save"; |
---|
| 168 | // // make dir if not exist |
---|
| 169 | // boost::filesystem::create_directories(pspa_->getWorkingDir() + folder + "/"); |
---|
[431] | 170 | |
---|
[488] | 171 | // outfile.open(name.c_str(), ios::out); |
---|
| 172 | // if (!outfile) { |
---|
| 173 | // cerr<<" ERROR opening output file for persistency "<<name<<endl; |
---|
| 174 | // } |
---|
[431] | 175 | |
---|
[488] | 176 | // outfile << globParam_.FileOutputFlow(); |
---|
[436] | 177 | |
---|
[488] | 178 | // // FIXME Francois: Comment sauver la configuration des section ? |
---|
| 179 | // for (unsigned int a=0; a< jobList_.size(); a++) { |
---|
| 180 | // outfile << jobList_[a]->getSectorParameters().FileOutputFlow(); |
---|
| 181 | // } |
---|
| 182 | // // END |
---|
[455] | 183 | |
---|
[488] | 184 | // abstractElement* elPtr; |
---|
| 185 | // for (unsigned k = 0; k < jobList_.size(); k++) { |
---|
| 186 | // sector* sector = jobList_[k]; |
---|
| 187 | // for (unsigned l = 0; l < sector->getSectionsToExecute().size(); l++) { |
---|
| 188 | // sectionToExecute* section = sector->getSectionsToExecute()[l]; |
---|
| 189 | // for (unsigned m = 0; m < section->getElements().size(); m++) { |
---|
| 190 | // elPtr = section->getElements()[m]; |
---|
| 191 | // outfile << elPtr->FileOutputFlow(); |
---|
| 192 | // } |
---|
| 193 | // } |
---|
| 194 | // } |
---|
| 195 | // outfile.close(); |
---|
| 196 | // } |
---|
[112] | 197 | |
---|
[493] | 198 | |
---|
| 199 | |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | |
---|
[424] | 203 | // ecriture sur fichier AML |
---|
| 204 | void dataManager::writeToAMLFile(string fileName) |
---|
| 205 | { |
---|
| 206 | UAPNode* uap_root = NULL; |
---|
| 207 | uap_root = new UAPNode("UAP_root"); |
---|
| 208 | UAPNode* rep = uap_root->addChild("AML_representation"); |
---|
[431] | 209 | |
---|
[424] | 210 | // root node in the hierarchy |
---|
| 211 | UAPNode* lab = rep->addChild("laboratory"); |
---|
| 212 | lab->addAttribute("name","PSPA lab"); |
---|
[431] | 213 | |
---|
[436] | 214 | // general global parameters--docroot . --http-address 0.0.0.0 --http-port 8077 |
---|
[424] | 215 | globParam_.InputRep(lab); |
---|
[431] | 216 | |
---|
[424] | 217 | // accelerator or section of accelerator |
---|
| 218 | //UAPNode* acc = lab->addChild("machine"); |
---|
| 219 | //acc->addAttribute("name",fileName); |
---|
| 220 | |
---|
[436] | 221 | //sectorParam_.InputRep(lab); |
---|
[431] | 222 | |
---|
[493] | 223 | // sequence of sectors with elements |
---|
[424] | 224 | |
---|
[493] | 225 | for ( unsigned k=0; k < sectors_.size(); k++) { |
---|
| 226 | sector* secteur = sectors_.at(k); |
---|
| 227 | UAPNode* sect = lab->addChild("sector"); |
---|
| 228 | sect->addAttribute("name",secteur->getName()); |
---|
| 229 | abstractElement* elPtr; |
---|
| 230 | for ( unsigned j=0; j < secteur->getElements().size(); j++) { |
---|
| 231 | elPtr = secteur->getElements().at(j); |
---|
| 232 | elPtr->InputRep(sect); |
---|
[455] | 233 | } |
---|
[424] | 234 | } |
---|
[493] | 235 | |
---|
| 236 | if ( currentMachine_ ) currentMachine_->FileAMLOutput(lab); |
---|
[424] | 237 | cout << "!Create the AML file ---------------------------" << endl; |
---|
| 238 | AMLReader reader; |
---|
| 239 | string aml_file = pspa_->getWorkingDir() + "/" + fileName + ".aml"; |
---|
| 240 | reader.AMLRepToAMLFile (uap_root, aml_file); |
---|
| 241 | } |
---|
| 242 | |
---|
[488] | 243 | |
---|
| 244 | bool dataManager::restoreAMLElements(string inputFileName) |
---|
[112] | 245 | { |
---|
[431] | 246 | cout << "***********************************" << endl; |
---|
[488] | 247 | cout << " dataManager::restoreAMLElements() fichier :" << inputFileName << endl << endl; |
---|
[431] | 248 | |
---|
[488] | 249 | AMLReader reader; |
---|
| 250 | UAPNode* uap_root = NULL; |
---|
| 251 | uap_root = reader.AMLFileToAMLRep (inputFileName); |
---|
| 252 | if ( !uap_root ) { |
---|
| 253 | cout << " dataManager::restoreAMLElements ERREUR AML lecture fichier " << inputFileName << endl; |
---|
[431] | 254 | return false; |
---|
| 255 | } |
---|
[488] | 256 | |
---|
| 257 | else cout << " successful opening : " << inputFileName << " UAP_ROOT= " << uap_root->getName() << endl; |
---|
| 258 | UAPNode* uap_labname = NULL; |
---|
| 259 | |
---|
| 260 | NodeVec laboratories = uap_root->getSubNodesByName(string("laboratory")); |
---|
[493] | 261 | // cout << " dataManager::restoreAMLElements nombre de <laboratory> : " << laboratories.size() << endl; |
---|
[488] | 262 | |
---|
| 263 | uap_labname = *laboratories.begin(); |
---|
| 264 | |
---|
| 265 | if ( !uap_labname ) { |
---|
| 266 | cout << " dataManager::restoreAMLElements : fichier non conforme, on ne trouve pas <laboratory...> " << endl; |
---|
[493] | 267 | // } else { |
---|
| 268 | // cout << " dataManager::restoreAMLElements : GO !" << endl; |
---|
[488] | 269 | } |
---|
| 270 | |
---|
| 271 | |
---|
[436] | 272 | //NOTE:: je ne sais pas si les "secteurs" seront conservés, aussi pour ne pas trop changer les fichiers je lis les données aprÚs "globals" dans la boucle |
---|
[431] | 273 | |
---|
[474] | 274 | // Clear the BeamLine |
---|
[493] | 275 | sectors_.clear(); |
---|
[474] | 276 | |
---|
| 277 | // FIXME : For test purpose !!! |
---|
[493] | 278 | // sector* mySect = addNewSector(); |
---|
| 279 | // if ( currentMachine_ ) delete currentMachine_; |
---|
| 280 | // currentMachine_ = new expandedMachine(); |
---|
[488] | 281 | |
---|
| 282 | UAPNode* parametresGlobaux = uap_labname->getChildByName(string("global")); |
---|
| 283 | if ( !parametresGlobaux ) { |
---|
| 284 | cout << " dataManager::restoreAMLElements GLOBAUX NON TROUVES " << endl; |
---|
[493] | 285 | // } else { |
---|
| 286 | // cout << " dataManager::restoreAMLElements GENIAL ! " << endl; |
---|
[488] | 287 | } |
---|
| 288 | globParam_.raz(); |
---|
| 289 | globParam_.FileAMLInput(parametresGlobaux); |
---|
| 290 | |
---|
| 291 | |
---|
[493] | 292 | |
---|
[431] | 293 | nomdElements::typedElement elementType; |
---|
| 294 | string elementLabel; |
---|
[488] | 295 | |
---|
| 296 | |
---|
| 297 | NodeVec sectorNode = uap_root->getSubNodesByName(string("sector")); |
---|
| 298 | |
---|
| 299 | if ( !sectorNode.size() ) { |
---|
| 300 | cout << " dataManager::restoreAMLElements ERREUR lecture fichier : pas de sectors ? " << endl; |
---|
| 301 | return false; |
---|
| 302 | } |
---|
[493] | 303 | for (NodeVecIter iterSect = sectorNode.begin(); iterSect != sectorNode.end(); iterSect++) { |
---|
| 304 | UAPAttribute* att = (*iterSect)->getAttribute("name"); |
---|
| 305 | if ( !att ) continue; |
---|
| 306 | sectors_.push_back( new sector(this, att->getValue()) ); |
---|
| 307 | NodeVec& listElem = (*iterSect)->getChildren(); |
---|
| 308 | if ( !listElem.size() ) { |
---|
| 309 | cout << " dataManager::restoreAMLElements WARNING lecture fichier secteur " << att->getValue() << " : pas d'elements ? " << endl; |
---|
[488] | 310 | } |
---|
[493] | 311 | abstractElement* nouveau = NULL; |
---|
| 312 | for (NodeVecIter iterelem = listElem.begin(); iterelem != listElem.end(); iterelem++) { |
---|
[488] | 313 | |
---|
[493] | 314 | string nomNoeud = (*iterelem)->getName(); |
---|
| 315 | if ( nomNoeud != string("element") ) { |
---|
| 316 | cout << " le secteur contient un non-element : " << nomNoeud << endl; |
---|
| 317 | continue; |
---|
| 318 | } |
---|
[488] | 319 | |
---|
[493] | 320 | att = NULL; |
---|
| 321 | att = (*iterelem)->getAttribute("name"); |
---|
[488] | 322 | |
---|
| 323 | |
---|
[493] | 324 | string nomGenerique; |
---|
| 325 | AMLtools::readAMLParameterAttribut(*iterelem, "description", "type", nomGenerique); |
---|
| 326 | elementType = nomdElements::getTypeFromLabel(nomGenerique); |
---|
| 327 | nouveau = sectors_.back()->addElementAfter(elementType,nouveau); |
---|
[431] | 328 | if ( nouveau == NULL ) { |
---|
[488] | 329 | cerr << " dataManager::restoreAMLElements() : restore element " << att->getValue() << " failed " << endl; |
---|
[431] | 330 | return false; |
---|
| 331 | } else { |
---|
[493] | 332 | nouveau->FileAMLInput(*iterelem); |
---|
[431] | 333 | } |
---|
[493] | 334 | } // iterelem |
---|
| 335 | } // itersect |
---|
| 336 | |
---|
| 337 | |
---|
| 338 | // cout << " dataManager::restoreAMLElements BILAN DES SECTEURS " << endl; |
---|
| 339 | // for ( unsigned m=0; m < sectors_.size(); m++ ) { |
---|
| 340 | // cout << " secteur " << m+1 << " nom : " << sectors_.at(m)->getName() << endl; |
---|
| 341 | // for ( unsigned j=0; j<sectors_.at(m)->getElements().size(); j++) { |
---|
| 342 | // cout << " el. : " << sectors_.at(m)->getElements().at(j)->getLabel() << endl; |
---|
| 343 | // } |
---|
| 344 | // } |
---|
| 345 | |
---|
| 346 | NodeVec machine = uap_root->getSubNodesByName(string("machine")); |
---|
| 347 | if ( !machine.size() ) { |
---|
| 348 | cout << " dataManager::restoreAMLElements ne trouve pas de machine " << endl; |
---|
| 349 | } else { |
---|
| 350 | if ( machine.size() > 1 ) { |
---|
| 351 | cout << " dataManager::restoreAMLElements PLUSIEURS MACHINES : cas non prevu " << endl; |
---|
| 352 | } |
---|
| 353 | // cout << " dataManager::restoreAMLElements il y a une machine a lire dans " << endl; |
---|
| 354 | // cout << currentMachine_ << endl; |
---|
| 355 | if ( !currentMachine_ ) currentMachine_ = new expandedMachine(this); |
---|
| 356 | currentMachine_->FileAMLInput(machine.at(0)); |
---|
[431] | 357 | } |
---|
[493] | 358 | |
---|
[431] | 359 | |
---|
[493] | 360 | |
---|
[431] | 361 | return true; |
---|
[305] | 362 | } |
---|
[50] | 363 | |
---|
[488] | 364 | |
---|
[305] | 365 | particleBeam* dataManager::getDiagnosticBeam(unsigned index) |
---|
[179] | 366 | { |
---|
[386] | 367 | if (index >= indexElementToIndexDiag_.size() ) { |
---|
| 368 | return NULL; |
---|
| 369 | } else { |
---|
| 370 | int indDiag = indexElementToIndexDiag_.at(index); |
---|
| 371 | return &diagnosticBeam_.at(indDiag); |
---|
| 372 | } |
---|
[179] | 373 | } |
---|
[149] | 374 | |
---|
[455] | 375 | particleBeam* dataManager::getDiagnosticBeam_deprecated(string elementLabel) |
---|
[386] | 376 | { |
---|
[493] | 377 | if ( !currentMachine_ ) return NULL; |
---|
| 378 | |
---|
[455] | 379 | // FIXME : Devra etre changé par une récupération par "abstractElement" et non pas par label |
---|
| 380 | unsigned int number = 0; |
---|
| 381 | abstractElement* elPtr; |
---|
[493] | 382 | |
---|
| 383 | for (unsigned k = 0; k < currentMachine_->getComputingBlocks().size(); k++) { |
---|
| 384 | computingBlock* block = currentMachine_->getComputingBlocks().at(k); |
---|
| 385 | for (unsigned m = 0; m < block->getNumberOfElements(); m++) { |
---|
| 386 | elPtr = block->getElement(m); |
---|
| 387 | if (elPtr->getLabel() == elementLabel) { |
---|
| 388 | return getDiagnosticBeam(number); |
---|
[455] | 389 | } |
---|
[493] | 390 | number ++; |
---|
[455] | 391 | } |
---|
| 392 | } |
---|
[493] | 393 | |
---|
| 394 | |
---|
[455] | 395 | return NULL; |
---|
[386] | 396 | } |
---|
[236] | 397 | |
---|
[359] | 398 | |
---|
[381] | 399 | void dataManager::donneesRmsEnveloppe(string type,vector<double>& xcor,vector<double>& ycor, string& titre, string& legendx, string& legendy) |
---|
[342] | 400 | { |
---|
| 401 | double longueur = 0.0; |
---|
| 402 | double valeur = 0.0; |
---|
| 403 | xcor.clear(); |
---|
| 404 | ycor.clear(); |
---|
[381] | 405 | titre.clear(); |
---|
| 406 | titre = " rms enveloppe "; |
---|
| 407 | legendx.clear(); |
---|
| 408 | legendx = " z (m)"; |
---|
[342] | 409 | if ( type == "x" ) { |
---|
| 410 | unsigned i = 0; |
---|
[455] | 411 | cout << " dataManager::donneesRmsEnveloppe " << endl; |
---|
[493] | 412 | |
---|
| 413 | if ( !currentMachine_ ) { |
---|
| 414 | cout << " dataManager::donneesRmsEnveloppe PAS DE MACHINE " << endl; |
---|
| 415 | return; |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | for (unsigned k = 0; k < currentMachine_->getComputingBlocks().size(); k++) { |
---|
| 419 | computingBlock* block = currentMachine_->getComputingBlocks().at(k); |
---|
| 420 | for (unsigned m = 0; m < block->getNumberOfElements(); m++) { |
---|
| 421 | abstractElement* elPtr = block->getElement(m); |
---|
| 422 | particleBeam* beamToDraw = getDiagnosticBeam(i); |
---|
| 423 | if ( !beamToDraw->momentRepresentationOk() ) { |
---|
| 424 | beamToDraw->buildMomentRepresentation(); |
---|
| 425 | } |
---|
[455] | 426 | |
---|
[493] | 427 | longueur += elPtr->getLenghtOfElement(); |
---|
| 428 | valeur = beamToDraw->getXmaxRms(); |
---|
| 429 | cout << " dataManager::donneesRmsEnveloppe index = " << k << " longueur = " << longueur << " enveloppe : " << valeur << endl; |
---|
| 430 | xcor.push_back(0.01*longueur); // on passe en metres |
---|
| 431 | ycor.push_back(valeur); |
---|
| 432 | i++; |
---|
[342] | 433 | } |
---|
[493] | 434 | } |
---|
| 435 | |
---|
| 436 | |
---|
| 437 | |
---|
| 438 | |
---|
| 439 | // for (unsigned k = 0; k < jobList_.size(); k++) { |
---|
| 440 | // sector* sector = jobList_[k]; |
---|
| 441 | // for (unsigned l = 0; l < sector->getSectionsToExecute().size(); l++) { |
---|
| 442 | // sectionToExecute* section = sector->getSectionsToExecute()[l]; |
---|
| 443 | // for (unsigned m = 0; m < section->getElements().size(); m++) { |
---|
| 444 | // abstractElement* elPtr = section->getElements()[m]; |
---|
| 445 | // // if(elPtr->getNomdElement().getElementType() == snapshot) continue; |
---|
| 446 | // // if(elPtr->getNomdElement().getElementType() == fit) continue; |
---|
| 447 | // particleBeam* beamToDraw = getDiagnosticBeam(i); |
---|
| 448 | // if ( !beamToDraw->momentRepresentationOk() ) { |
---|
| 449 | // beamToDraw->buildMomentRepresentation(); |
---|
| 450 | // } |
---|
| 451 | |
---|
| 452 | // longueur += elPtr->getLenghtOfElement(); |
---|
| 453 | // valeur = beamToDraw->getXmaxRms(); |
---|
| 454 | // cout << " dataManager::donneesRmsEnveloppe index = " << k << " longueur = " << longueur << " enveloppe : " << valeur << endl; |
---|
| 455 | // xcor.push_back(0.01*longueur); // on passe en metres |
---|
| 456 | // ycor.push_back(valeur); |
---|
| 457 | // i++; |
---|
| 458 | // } |
---|
| 459 | // } |
---|
| 460 | // } |
---|
| 461 | |
---|
[381] | 462 | legendy.clear(); |
---|
| 463 | legendy = " x (cm) "; |
---|
[342] | 464 | } |
---|
[316] | 465 | } |
---|
[342] | 466 | |
---|
| 467 | |
---|
[401] | 468 | |
---|
[449] | 469 | sector* dataManager::addNewSector() { |
---|
| 470 | std::stringstream str; |
---|
| 471 | str << getSectors().size()+1; |
---|
| 472 | std::string result; |
---|
| 473 | str >> result; |
---|
| 474 | |
---|
[455] | 475 | sector* sect = new sector(this, std::string("sector ") + result); |
---|
[493] | 476 | sectors_.push_back(sect); |
---|
[449] | 477 | return sect; |
---|
| 478 | } |
---|
| 479 | |
---|
[493] | 480 | abstractElement* dataManager::getElementInSectorsByLabel(string etiq) { |
---|
| 481 | for ( unsigned k=0; k < sectors_.size(); k++) { |
---|
| 482 | for ( unsigned j=0; j < sectors_.at(k)->getElements().size(); j++) { |
---|
| 483 | if ( etiq == sectors_.at(k)->getElements().at(j)->getLabel() ) return sectors_.at(k)->getElements().at(j); |
---|
| 484 | } |
---|
| 485 | } |
---|
| 486 | return NULL; |
---|
| 487 | } |
---|
| 488 | |
---|
| 489 | |
---|
| 490 | void dataManager::messageEcran(string niveau, string msg) const { |
---|
| 491 | GWt_dialog::iconType icon; |
---|
| 492 | if ( niveau == "ERROR" ) { |
---|
| 493 | icon = GWt_dialog::Error; |
---|
| 494 | } else if ( niveau == "WARNING" ) { |
---|
| 495 | icon = GWt_dialog::Warning; |
---|
| 496 | } else if ( niveau == "INFO" ) { |
---|
| 497 | icon = GWt_dialog::Info; |
---|
| 498 | } else { |
---|
| 499 | icon = GWt_dialog::NoIcon; |
---|
| 500 | } |
---|
| 501 | GWt_dialog checkConfigNameDialog(niveau, msg, icon,true,true); |
---|
| 502 | checkConfigNameDialog.exec(); |
---|
| 503 | } |
---|