.Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
SimulationWorker.h
1 // SimulationWorker.h - Simulation worker declaration.
2 // Written by Jesse Z. Zhong
3 #ifndef __Simulation_Worker_H__
4 #define __Simulation_Worker_H__
5 #pragma region Includes
6 #include <QThread>
7 #include <QReadWriteLock>
8 #include <Simulation/Simulation.h>
9 #include <InfoStruct/InfoStruct.h>
10 using namespace std;
11 using namespace MDSimulation;
12 #pragma endregion
13 namespace SchedulerGUI {
20 
21  };
22 
23 
24 
28  class SimulationWorker : public QObject {
29  Q_OBJECT
30  protected slots:
42  void DoWork();
43 
50  void StopWork();
51 
63  void StartSim(const InfoStruct& parameters,
64  const QString& outDir);
65 
76  void ChangeRunState(bool state);
77 
87  void ChangeLiveState(bool state);
88 
96  void HaltSimulation();
97 
106  void RunSim();
107 
112  void InitLogMsg();
113 
123  void WriteLogMsg(const QString& msg);
124  signals:
129  void Initialized();
130 
135  void LogMsgReady(const QString& logMessage);
136 
141  void SavePointCreated(unsigned long long savePointNumber);
142  void SavePointCreated();
143 
149  void ChangedRunState(const bool state);
150  void ChangedRunState();
151 
158  void ChangedLiveState(const bool state);
159  void ChangedLiveState();
160 
165  void ResultReady(const SimulationResult& result);
166 
170  void Finished();
171 
175  void Error(const QString& message);
176 
177  public:
181  SimulationWorker(QObject* parent = 0);
182 
189  bool GetRunState();
190 
199  bool GetLiveState();
200 
201  // Sets if the a log message will be written
202  // whenever a new instance of the simulation starts.
203  void SetWillWriteLog(bool value);
204 
205  // Returns if the a log message will be written
206  // whenever a new instance of the simulation starts.
207  bool GetWillWriteLog();
208 
209  protected:
213 
216  QString OutputDir_;
217 
220 
223  bool StartNew_;
224 
228 
232  bool RunState_;
233 
235  bool HaltSim_;
236 
240 
243  QReadWriteLock Mutex_;
244 
249  friend class SimulationController;
250  };
251 }
252 #endif // !__Simulation_Thread_H__
bool RunState_
The run state of the simulation. &#39;true&#39; means the simulation is running. &#39;false&#39; means the simulation...
Definition: SimulationWorker.h:232
Worker object for running an instance of the simulation.
Definition: SimulationWorker.h:28
bool WillWriteLog_
Indicates if parameters and simulation constants will be written to a string so they can be displayed...
Definition: SimulationWorker.h:239
QReadWriteLock Mutex_
Mutex used for safeguarding state reads and writes between threads.
Definition: SimulationWorker.h:243
bool StartNew_
Flag that prompts the worker to start a new instance of the simulation.
Definition: SimulationWorker.h:223
QString OutputDir_
Local copy of the directory path used to store the simulation output.
Definition: SimulationWorker.h:216
Handles the running of the simulation with all the necessary requirements and conditions.
Definition: SimulationController.h:17
bool IsWorking_
Indicates whether the event loop is active or not.
Definition: SimulationWorker.h:219
InfoStruct Parameters_
Local copy of the parameters used to instantiate the simulation.
Definition: SimulationWorker.h:212
Stores the results of the simulation after the simulation has been terminated.
Definition: SimulationWorker.h:19
bool LiveState_
Indicates if parameters are loaded and an instance of the simulation has been created, whether it is running or not.
Definition: SimulationWorker.h:227
bool HaltSim_
Halts the simulation when set to true.
Definition: SimulationWorker.h:235
Defines the structure used to hold the configurable constants of the simulation.
Definition: InfoStruct.h:36