Line | |
---|
1 | #include "abstractSoftware.h" |
---|
2 | #include "dataManager.h" |
---|
3 | |
---|
4 | abstractSoftware::abstractSoftware() |
---|
5 | { |
---|
6 | globParamPtr_ = NULL; |
---|
7 | dataManager_ = NULL; |
---|
8 | nameOfSoftware_ = nomDeLogiciel("unknownSoftware"); |
---|
9 | } |
---|
10 | |
---|
11 | abstractSoftware::abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt) { |
---|
12 | inputFileName_ = inputFileName; |
---|
13 | globParamPtr_ = globals; |
---|
14 | dataManager_ = dt; |
---|
15 | numeroDeb_ = 0; |
---|
16 | numeroFin_ = 0; |
---|
17 | nameOfSoftware_ = nomDeLogiciel("unknownSoftware"); |
---|
18 | } |
---|
19 | |
---|
20 | bool abstractSoftware::initComputationLimits(unsigned int numeroDeb,unsigned int numeroFin) { |
---|
21 | numeroDeb_ = numeroDeb; |
---|
22 | numeroFin_ = numeroFin; |
---|
23 | return ComputationLimitsOk(); |
---|
24 | } |
---|
25 | |
---|
26 | bool abstractSoftware::ComputationLimitsOk() const { |
---|
27 | if ( numeroDeb_ < 1 || numeroFin_ < 1 || numeroDeb_ > dataManager_->getBeamLineSize() || numeroFin_ > dataManager_->getBeamLineSize() ) { |
---|
28 | dataManager_->consoleMessage(" abstractSoftware::initComputationLimit : numero of element out of limits in software " + getName() ); |
---|
29 | return false; |
---|
30 | } else { |
---|
31 | return true; |
---|
32 | } |
---|
33 | } |
---|
34 | |
---|
35 | bool abstractSoftware::launchJob(string commandLine, string& resul) |
---|
36 | { |
---|
37 | bool ExecuteStatus = true; |
---|
38 | |
---|
39 | FILE* pp = popen(commandLine.c_str(), "r"); |
---|
40 | ostringstream sortie; |
---|
41 | if (pp == NULL) { |
---|
42 | sortie << " launching failed : " << commandLine << endl; |
---|
43 | ExecuteStatus = false; |
---|
44 | } else { |
---|
45 | cout << " executing command : " << commandLine << endl; |
---|
46 | // on copie la sortie dans le fichier assigne |
---|
47 | char buf[132]; |
---|
48 | while (fgets(buf, sizeof buf, pp)) |
---|
49 | { |
---|
50 | sortie << buf; |
---|
51 | } |
---|
52 | pclose(pp); |
---|
53 | } |
---|
54 | resul = sortie.str(); |
---|
55 | return ExecuteStatus; |
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.