1 | #include <stdio.h> |
---|
2 | #include <fstream> |
---|
3 | |
---|
4 | #include "dataManager.h" |
---|
5 | #include "mathematicalConstants.h" |
---|
6 | #include "PhysicalConstants.h" |
---|
7 | #include "softwareUnknown.h" |
---|
8 | |
---|
9 | #include "GWt_pspaApplication.h" |
---|
10 | #include "GWt_console.h" |
---|
11 | #include "GWt_ligneFaisceau.h" // FIXME to be removed ! |
---|
12 | |
---|
13 | #include <boost/filesystem.hpp> |
---|
14 | |
---|
15 | #include "UAP/UAPUtilities.hpp" |
---|
16 | #include "AML/AMLReader.hpp" |
---|
17 | #include "AMLtools.h" |
---|
18 | |
---|
19 | #define BAVARD 1 |
---|
20 | |
---|
21 | dataManager::dataManager(PspaApplication* pspa) : |
---|
22 | pspa_ (pspa), |
---|
23 | currentMachine_(NULL) |
---|
24 | {} |
---|
25 | |
---|
26 | dataManager::~dataManager() |
---|
27 | { |
---|
28 | unsigned k; |
---|
29 | for (k=0; k < sectors_.size();k++) { |
---|
30 | if ( sectors_[k] != NULL ) delete sectors_[k]; |
---|
31 | } |
---|
32 | if ( currentMachine_ ) delete currentMachine_; |
---|
33 | } |
---|
34 | |
---|
35 | void dataManager::consoleMessage(string message) |
---|
36 | { |
---|
37 | cout << " passage console message : " << endl; |
---|
38 | cout << message << endl; |
---|
39 | GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); |
---|
40 | if (console) console->addConsoleMessage(message + "\n"); |
---|
41 | pspa_->processEvents(); |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | void dataManager::initializeExecution() |
---|
46 | { |
---|
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(); |
---|
60 | indexElementToIndexDiag_.clear(); |
---|
61 | // for (unsigned int a=0; a< jobList_.size(); a++) { |
---|
62 | // jobList_[a]->clearSectionToExecute(); |
---|
63 | // } |
---|
64 | } |
---|
65 | |
---|
66 | void dataManager::removeFile(string nameOfFile) |
---|
67 | { |
---|
68 | ifstream fileExists; |
---|
69 | fileExists.open(nameOfFile.c_str(), ios::in); |
---|
70 | if (fileExists) { |
---|
71 | fileExists.close(); |
---|
72 | remove(nameOfFile.c_str()); |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | bool dataManager::executeAll() |
---|
77 | { |
---|
78 | #if BAVARD > 0 |
---|
79 | cout << "***********************************" << endl; |
---|
80 | cout << " dataManager::executeAll() " << endl << endl; |
---|
81 | #endif |
---|
82 | |
---|
83 | bool success = true; |
---|
84 | string workingDir = pspa_->getWorkingDir(); |
---|
85 | |
---|
86 | // Main loop ! |
---|
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; |
---|
103 | |
---|
104 | // for the moment, we put everything in one line without loops |
---|
105 | // for(unsigned int l = 0; l < sector->getSectionsToExecute().size(); l++) |
---|
106 | for (unsigned int l = 0; l < compblock.size(); l++) |
---|
107 | { |
---|
108 | abstractSoftware* softw = compblock.at(l)->getSoftware(); |
---|
109 | cout << " execution du SOFWARE " << softw->getName() << endl; |
---|
110 | if (softw == NULL) { |
---|
111 | success = false; |
---|
112 | consoleMessage("dataManager::executeAll : unknown software"); |
---|
113 | break; |
---|
114 | } |
---|
115 | |
---|
116 | // success = softw->createInputFile(sector->getParticleBeam(),workingDir); |
---|
117 | cout << " dataManager::executeAll() APPEL softw->createInputFile " << endl; |
---|
118 | success = softw->createInputFile(computedBeam,workingDir); |
---|
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)) { |
---|
127 | // sector->setParticleBeam(&diagnosticBeam_.at(indexElementToIndexDiag_.back())); |
---|
128 | computedBeam = &diagnosticBeam_.at(indexElementToIndexDiag_.back()); |
---|
129 | cout << " dataManager::executeAll termine avec succes " << endl; |
---|
130 | } else { |
---|
131 | // sector->setParticleBeam(NULL); |
---|
132 | computedBeam = NULL; |
---|
133 | cout << " dataManager::executeAll termine en ECHEC " << endl; |
---|
134 | } |
---|
135 | if ( !success ) break; |
---|
136 | |
---|
137 | #if BAVARD > 0 |
---|
138 | cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl; |
---|
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; |
---|
144 | } |
---|
145 | #endif |
---|
146 | } //l |
---|
147 | // } //k |
---|
148 | |
---|
149 | // if ( currentBeam_deprecated_ ) { |
---|
150 | // string aml_file = workingDir + "/" + "faisceau_final" + ".aml"; |
---|
151 | // currentBeam_deprecated_->writeToAMLFile(aml_file); |
---|
152 | // // TESTS |
---|
153 | // currentBeam_deprecated_->readFromAMLFile(aml_file); |
---|
154 | // } |
---|
155 | |
---|
156 | return success; |
---|
157 | } |
---|
158 | |
---|
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; |
---|
166 | |
---|
167 | // string name = pspa_->getWorkingDir() + "/" + nameOfFile + ".save"; |
---|
168 | // // make dir if not exist |
---|
169 | // boost::filesystem::create_directories(pspa_->getWorkingDir() + folder + "/"); |
---|
170 | |
---|
171 | // outfile.open(name.c_str(), ios::out); |
---|
172 | // if (!outfile) { |
---|
173 | // cerr<<" ERROR opening output file for persistency "<<name<<endl; |
---|
174 | // } |
---|
175 | |
---|
176 | // outfile << globParam_.FileOutputFlow(); |
---|
177 | |
---|
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 |
---|
183 | |
---|
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 | // } |
---|
197 | |
---|
198 | |
---|
199 | |
---|
200 | |
---|
201 | |
---|
202 | |
---|
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"); |
---|
209 | |
---|
210 | // root node in the hierarchy |
---|
211 | UAPNode* lab = rep->addChild("laboratory"); |
---|
212 | lab->addAttribute("name","PSPA lab"); |
---|
213 | |
---|
214 | // general global parameters--docroot . --http-address 0.0.0.0 --http-port 8077 |
---|
215 | globParam_.InputRep(lab); |
---|
216 | |
---|
217 | // accelerator or section of accelerator |
---|
218 | //UAPNode* acc = lab->addChild("machine"); |
---|
219 | //acc->addAttribute("name",fileName); |
---|
220 | |
---|
221 | //sectorParam_.InputRep(lab); |
---|
222 | |
---|
223 | // sequence of sectors with elements |
---|
224 | |
---|
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); |
---|
233 | } |
---|
234 | } |
---|
235 | |
---|
236 | if ( currentMachine_ ) currentMachine_->FileAMLOutput(lab); |
---|
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 | |
---|
243 | |
---|
244 | bool dataManager::restoreAMLElements(string inputFileName) |
---|
245 | { |
---|
246 | cout << "***********************************" << endl; |
---|
247 | cout << " dataManager::restoreAMLElements() fichier :" << inputFileName << endl << endl; |
---|
248 | |
---|
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; |
---|
254 | return false; |
---|
255 | } |
---|
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")); |
---|
261 | // cout << " dataManager::restoreAMLElements nombre de <laboratory> : " << laboratories.size() << endl; |
---|
262 | |
---|
263 | uap_labname = *laboratories.begin(); |
---|
264 | |
---|
265 | if ( !uap_labname ) { |
---|
266 | cout << " dataManager::restoreAMLElements : fichier non conforme, on ne trouve pas <laboratory...> " << endl; |
---|
267 | // } else { |
---|
268 | // cout << " dataManager::restoreAMLElements : GO !" << endl; |
---|
269 | } |
---|
270 | |
---|
271 | |
---|
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 |
---|
273 | |
---|
274 | // Clear the BeamLine |
---|
275 | sectors_.clear(); |
---|
276 | |
---|
277 | // FIXME : For test purpose !!! |
---|
278 | // sector* mySect = addNewSector(); |
---|
279 | // if ( currentMachine_ ) delete currentMachine_; |
---|
280 | // currentMachine_ = new expandedMachine(); |
---|
281 | |
---|
282 | UAPNode* parametresGlobaux = uap_labname->getChildByName(string("global")); |
---|
283 | if ( !parametresGlobaux ) { |
---|
284 | cout << " dataManager::restoreAMLElements GLOBAUX NON TROUVES " << endl; |
---|
285 | // } else { |
---|
286 | // cout << " dataManager::restoreAMLElements GENIAL ! " << endl; |
---|
287 | } |
---|
288 | globParam_.raz(); |
---|
289 | globParam_.FileAMLInput(parametresGlobaux); |
---|
290 | |
---|
291 | |
---|
292 | |
---|
293 | nomdElements::typedElement elementType; |
---|
294 | string elementLabel; |
---|
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 | } |
---|
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; |
---|
310 | } |
---|
311 | abstractElement* nouveau = NULL; |
---|
312 | for (NodeVecIter iterelem = listElem.begin(); iterelem != listElem.end(); iterelem++) { |
---|
313 | |
---|
314 | string nomNoeud = (*iterelem)->getName(); |
---|
315 | if ( nomNoeud != string("element") ) { |
---|
316 | cout << " le secteur contient un non-element : " << nomNoeud << endl; |
---|
317 | continue; |
---|
318 | } |
---|
319 | |
---|
320 | att = NULL; |
---|
321 | att = (*iterelem)->getAttribute("name"); |
---|
322 | |
---|
323 | |
---|
324 | string nomGenerique; |
---|
325 | AMLtools::readAMLParameterAttribut(*iterelem, "description", "type", nomGenerique); |
---|
326 | elementType = nomdElements::getTypeFromLabel(nomGenerique); |
---|
327 | nouveau = sectors_.back()->addElementAfter(elementType,nouveau); |
---|
328 | if ( nouveau == NULL ) { |
---|
329 | cerr << " dataManager::restoreAMLElements() : restore element " << att->getValue() << " failed " << endl; |
---|
330 | return false; |
---|
331 | } else { |
---|
332 | nouveau->FileAMLInput(*iterelem); |
---|
333 | } |
---|
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)); |
---|
357 | } |
---|
358 | |
---|
359 | |
---|
360 | |
---|
361 | return true; |
---|
362 | } |
---|
363 | |
---|
364 | |
---|
365 | particleBeam* dataManager::getDiagnosticBeam(unsigned index) |
---|
366 | { |
---|
367 | if (index >= indexElementToIndexDiag_.size() ) { |
---|
368 | return NULL; |
---|
369 | } else { |
---|
370 | int indDiag = indexElementToIndexDiag_.at(index); |
---|
371 | return &diagnosticBeam_.at(indDiag); |
---|
372 | } |
---|
373 | } |
---|
374 | |
---|
375 | particleBeam* dataManager::getDiagnosticBeam_deprecated(string elementLabel) |
---|
376 | { |
---|
377 | if ( !currentMachine_ ) return NULL; |
---|
378 | |
---|
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; |
---|
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); |
---|
389 | } |
---|
390 | number ++; |
---|
391 | } |
---|
392 | } |
---|
393 | |
---|
394 | |
---|
395 | return NULL; |
---|
396 | } |
---|
397 | |
---|
398 | |
---|
399 | void dataManager::donneesRmsEnveloppe(string type,vector<double>& xcor,vector<double>& ycor, string& titre, string& legendx, string& legendy) |
---|
400 | { |
---|
401 | double longueur = 0.0; |
---|
402 | double valeur = 0.0; |
---|
403 | xcor.clear(); |
---|
404 | ycor.clear(); |
---|
405 | titre.clear(); |
---|
406 | titre = " rms enveloppe "; |
---|
407 | legendx.clear(); |
---|
408 | legendx = " z (m)"; |
---|
409 | if ( type == "x" ) { |
---|
410 | unsigned i = 0; |
---|
411 | cout << " dataManager::donneesRmsEnveloppe " << endl; |
---|
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 | } |
---|
426 | |
---|
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++; |
---|
433 | } |
---|
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 | |
---|
462 | legendy.clear(); |
---|
463 | legendy = " x (cm) "; |
---|
464 | } |
---|
465 | } |
---|
466 | |
---|
467 | |
---|
468 | |
---|
469 | sector* dataManager::addNewSector() { |
---|
470 | std::stringstream str; |
---|
471 | str << getSectors().size()+1; |
---|
472 | std::string result; |
---|
473 | str >> result; |
---|
474 | |
---|
475 | sector* sect = new sector(this, std::string("sector ") + result); |
---|
476 | sectors_.push_back(sect); |
---|
477 | return sect; |
---|
478 | } |
---|
479 | |
---|
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 | } |
---|