All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RunSimulationWorker.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file RunSimulationWorker.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@supagro.inra.fr>
37  */
38 
39 
40 #ifndef __OPENFLUID_UICOMMON_RUNSIMULATIONWORKER_HPP__
41 #define __OPENFLUID_UICOMMON_RUNSIMULATIONWORKER_HPP__
42 
43 
44 #include <QApplication>
45 #include <QMetaType>
46 
49 #include <openfluid/dllexport.hpp>
50 
51 
52 namespace openfluid {
53 
54 namespace fluidx {
55  class FluidXDescriptor;
56 }
57 
58 
59 namespace ui { namespace common {
60 
61 
63 {
64  Q_OBJECT;
65 
66  public:
67 
68  enum Stage { RUNW_BEFORE, RUNW_PRESIM, RUNW_INIT, RUNW_RUN, RUNW_FINAL, RUNW_AFTER };
69 
70  private:
71  unsigned int m_CurrentIndex;
72  std::string m_CurrentIndexStr;
73  unsigned int m_CurrentSimulator;
74 
75  unsigned int m_TotalTime;
76  unsigned int m_TotalSimulators;
77 
78  unsigned int m_CurrentPreSim;
79  unsigned int m_CurrentInit;
80  unsigned int m_CurrentFinal;
81  unsigned int m_TotalTotal;
82 
83  bool m_Completed;
84 
85  openfluid::core::Duration_t m_SimDuration;
86 
87  bool m_PausedByUser;
88  bool m_ConfirmedPauseByUser;
89 
90  bool m_AbortedByUser;
91 
92 
93  signals:
94 
96 
97  void progressValueChanged(int Index);
98 
99  void progressMaxChanged(int Index);
100 
101  void pauseConfirmed();
102 
103 
104  public slots:
105 
106  void requestAbort();
107 
108  void requestSuspendResume();
109 
110 
111  public:
112 
114 
116 
117 
118  void setInfos(const unsigned int& TotalSimulators, const unsigned int& TotalTime);
119 
120  bool isPausedByUser();
121 
122 
123  void onInitParams();
124 
125  void onInitializeRun();
126 
127  void onBeforeRunSteps();
128 
129  void onRunStep(const openfluid::base::SimulationStatus* SimStatus);
130 
131  void onFinalizeRun();
132 
133  void onFinalizeRunDone(const openfluid::base::Listener::Status& /*Status*/);
134 
135 
136  void onSimulatorInitParams(const std::string& /*SimulatorID*/);
137 
138  void onSimulatorPrepareData(const std::string& /*SimulatorID*/);
139 
140  void onSimulatorCheckConsistency(const std::string& /*SimulatorID*/);
141 
142  void onSimulatorInitializeRun(const std::string& /*SimulatorID*/);
143 
144  void onSimulatorRunStep(const std::string& /*SimulatorID*/);
145 
146  void onSimulatorFinalizeRun(const std::string& /*SimulatorID*/);
147 
148 };
149 
150 
151 // =====================================================================
152 // =====================================================================
153 
154 
155 class RunSimulationWorker : public QObject
156 {
157 
158  Q_OBJECT;
159 
160  private:
161 
163 
164  RunSimulationListener* mp_Listener;
165 
166 
167  signals:
168 
169  void periodChanged(QString Begin, QString End, int Duration);
170 
171  void warningsChanged(unsigned int Count);
172 
173  void finished();
174 
175  void error(QString Error, openfluid::base::ExceptionContext Context);
176 
177  void userAbort();
178 
179 
180  public slots:
181 
182  void run();
183 
184 
185  public:
186 
188 
190 
191 
192 };
193 
194 } } } //namespaces
195 
196 
198 
199 
200 #endif /* __OPENFLUID_UICOMMON_RUNSIMULATIONWORKER_HPP__ */
void error(QString Error, openfluid::base::ExceptionContext Context)
Q_DECLARE_METATYPE(openfluid::ui::common::RunSimulationListener::Stage)
Definition: SimulationStatus.hpp:55
#define OPENFLUID_API
Definition: dllexport.hpp:87
Stage
Definition: RunSimulationWorker.hpp:68
Status
Definition: Listener.hpp:59
Definition: FluidXDescriptor.hpp:61
unsigned long long Duration_t
Definition: DateTime.hpp:68
void warningsChanged(unsigned int Count)
Definition: MachineListener.hpp:55
void periodChanged(QString Begin, QString End, int Duration)
Definition: RunSimulationWorker.hpp:155
RunSimulationWorker(openfluid::fluidx::FluidXDescriptor *FXDesc, RunSimulationListener *Listener)
Definition: RunSimulationWorker.hpp:62
Definition: ExceptionContext.hpp:53