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 
72  unsigned int m_CurrentIndex;
73  std::string m_CurrentIndexStr;
74  unsigned int m_CurrentSimulator;
75 
76  unsigned int m_TotalTime;
77  unsigned int m_TotalSimulators;
78 
79  unsigned int m_CurrentPreSim;
80  unsigned int m_CurrentInit;
81  unsigned int m_CurrentFinal;
82  unsigned int m_TotalTotal;
83 
84  bool m_Completed;
85 
86  openfluid::core::Duration_t m_SimDuration;
87 
88  bool m_PausedByUser;
89  bool m_ConfirmedPauseByUser;
90 
91  bool m_AbortedByUser;
92 
93 
94  signals:
95 
97 
98  void progressValueChanged(int Index);
99 
100  void progressMaxChanged(int Index);
101 
102  void pauseConfirmed();
103 
104 
105  public slots:
106 
107  void requestAbort();
108 
109  void requestSuspendResume();
110 
111 
112  public:
113 
115 
117 
118 
119  void setInfos(const unsigned int& TotalSimulators, const unsigned int& TotalTime);
120 
121  bool isPausedByUser();
122 
123 
124  void onInitParams();
125 
126  void onInitializeRun();
127 
128  void onBeforeRunSteps();
129 
130  void onRunStep(const openfluid::base::SimulationStatus* SimStatus);
131 
132  void onFinalizeRun();
133 
134  void onFinalizeRunDone(const openfluid::base::Listener::Status& /*Status*/);
135 
136 
137  void onSimulatorInitParams(const std::string& /*SimulatorID*/);
138 
139  void onSimulatorPrepareData(const std::string& /*SimulatorID*/);
140 
141  void onSimulatorCheckConsistency(const std::string& /*SimulatorID*/);
142 
143  void onSimulatorInitializeRun(const std::string& /*SimulatorID*/);
144 
145  void onSimulatorRunStep(const std::string& /*SimulatorID*/);
146 
147  void onSimulatorFinalizeRun(const std::string& /*SimulatorID*/);
148 
149 };
150 
151 
152 // =====================================================================
153 // =====================================================================
154 
155 
156 class RunSimulationWorker : public QObject
157 {
158 
159  Q_OBJECT;
160 
161  private:
162 
163  const openfluid::fluidx::FluidXDescriptor* mp_FXDesc;
164 
165  RunSimulationListener* mp_Listener;
166 
167 
168  signals:
169 
170  void periodChanged(QString Begin, QString End, int Duration);
171 
172  void warningsChanged(unsigned int Count);
173 
174  void finished();
175 
176  void error(QString Error, openfluid::base::ExceptionContext Context);
177 
178  void userAbort();
179 
180 
181  public slots:
182 
183  void run();
184 
185 
186  public:
187 
189 
191 
192 };
193 
194 
195 } } } //namespaces
196 
197 
199 
200 
201 #endif /* __OPENFLUID_UICOMMON_RUNSIMULATIONWORKER_HPP__ */
Status
Definition: Listener.hpp:55
unsigned long long Duration_t
Definition: DateTime.hpp:68
Definition: FluidXDescriptor.hpp:67
Definition: RunSimulationWorker.hpp:156
Definition: RunSimulationWorker.hpp:62
Definition: SimulationStatus.hpp:55
Stage
Definition: RunSimulationWorker.hpp:68
Definition: ApplicationException.hpp:47
Definition: MachineListener.hpp:55
#define OPENFLUID_API
Definition: dllexport.hpp:87
Definition: ExceptionContext.hpp:53
Q_DECLARE_METATYPE(openfluid::ui::common::RunSimulationListener::Stage)