VPTissue Reference Manual
SimSessionCoupled.h
Go to the documentation of this file.
1 #ifndef SIM_SESSION_COUPLED_H_INCLUDED
2 #define SIM_SESSION_COUPLED_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "session/SimSession.h"
23 #include "session/ISession.h"
24 #include "util/misc/Subject.h"
25 
26 #include <chrono>
27 #include <memory>
28 #include <string>
29 #include <vector>
30 
31 class QThread;
32 namespace SimShell{ namespace Ws { class IWorkspace; }}
33 namespace SimPT_Sim { class CoupledSim; }
34 
35 namespace SimPT_Shell {
36 namespace Session {
37 
43 {
44  Q_OBJECT
45 public:
56  const std::shared_ptr<MergedPreferences>& prefs,
57  const ptree& project_info,
58  const std::shared_ptr<SimShell::Ws::IWorkspace>& workspaceModel);
59 
61  virtual ~SimSessionCoupled();
62 
64  virtual std::shared_ptr<RootViewerType> CreateRootViewer(
66 
68  virtual ExportersType GetExporters();
69 
71  virtual const ptree& GetParameters() const;
72 
74  std::string GetStatusMessage() const;
75 
77  virtual Timings GetTimings() const;
78 
80  virtual void ForceExport();
81 
82  virtual void RefreshPreferences() {}
83 
85  virtual void SetParameters(const ptree&);
86 
88  virtual void StartSimulation(int steps = -1);
89 
91  virtual void StopSimulation();
92 
93 public slots:
95  virtual void TimeStep();
96 private slots:
97  virtual void ExecuteViewUnit(QString);
98 
99 signals:
100  void ExecuteWorkUnit();
101 
102 private:
109  std::vector<std::pair<std::string, std::string>>
110  ReadSubprojectList(const boost::property_tree::ptree& pt);
111 
120  std::shared_ptr<SimShell::Ws::IProject> OpenSubproject(
121  const std::string& projectName,
122  const std::string& file,
123  const std::shared_ptr<SimShell::Ws::IWorkspace>& workspaceModel);
124 
125 private:
127  std::shared_ptr<SimShell::Ws::MergedPreferences> m_preferences;
128 
130  std::map<std::string, std::shared_ptr<SimShell::Ws::IProject>> m_projects;
131 
133  std::shared_ptr<SimPT_Sim::CoupledSim> m_sim;
134 
136  int m_steps_limit;
137 
138 
140  Timings m_timings;
141 
142  bool m_running;
143 
144 
145  std::mutex m_parameters_mutex;
146  std::mutex m_viewers_mutex;
147 
148  QThread* m_sim_thread;
149 
150  struct {
151  bool updated;
152  ptree pt;
153  } m_parameter_buffer;
154 
155 };
156 
157 } // namespace
158 } // namespace
159 
160 #endif // end_of_include_guard
virtual void SetParameters(const ptree &)
SimSessionCoupled(const std::shared_ptr< MergedPreferences > &prefs, const ptree &project_info, const std::shared_ptr< SimShell::Ws::IWorkspace > &workspaceModel)
Constructor.
ptree pt
Ptree containing parameters.
Namespace for SimPT shell package.
Definition: Client.cpp:50
virtual ~SimSessionCoupled()
Destructor virtual, just in case.
virtual std::shared_ptr< RootViewerType > CreateRootViewer(SimShell::Gui::Controller::AppController *parent=nullptr)
Namespace for the core simulator.
bool updated
Whether parameters were updated and need saving to disk.
Interface/Implementation of Subject.
Interface for ISession.
Interfaces for simulator session.
std::string GetStatusMessage() const
Return the status message.
Collection of instances associated with an opened/running coupled project.
virtual Timings GetTimings() const
Get timing information from simulation and viewers.
virtual void StartSimulation(int steps=-1)
virtual const ptree & GetParameters() const
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32
Generic session interface.
Definition: ISession.h:53