machine/Engine.hpp

Go to the documentation of this file.
00001 /*
00002   This file is part of OpenFLUID software
00003   Copyright (c) 2007-2010 INRA-Montpellier SupAgro
00004 
00005 
00006  == GNU General Public License Usage ==
00007 
00008   OpenFLUID is free software: you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation, either version 3 of the License, or
00011   (at your option) any later version.
00012 
00013   OpenFLUID is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017 
00018   You should have received a copy of the GNU General Public License
00019   along with OpenFLUID.  If not, see <http://www.gnu.org/licenses/>.
00020 
00021   In addition, as a special exception, INRA gives You the additional right
00022   to dynamically link the code of OpenFLUID with code not covered
00023   under the GNU General Public License ("Non-GPL Code") and to distribute
00024   linked combinations including the two, subject to the limitations in this
00025   paragraph. Non-GPL Code permitted under this exception must only link to
00026   the code of OpenFLUID dynamically through the OpenFLUID libraries
00027   interfaces, and only for building OpenFLUID plugins. The files of
00028   Non-GPL Code may be link to the OpenFLUID libraries without causing the
00029   resulting work to be covered by the GNU General Public License. You must
00030   obey the GNU General Public License in all respects for all of the
00031   OpenFLUID code and other code used in conjunction with OpenFLUID
00032   except the Non-GPL Code covered by this exception. If you modify
00033   this OpenFLUID, you may extend this exception to your version of the file,
00034   but you are not obligated to do so. If you do not wish to provide this
00035   exception without modification, you must delete this exception statement
00036   from your version and license this OpenFLUID solely under the GPL without
00037   exception.
00038 
00039 
00040  == Other Usage ==
00041 
00042   Other Usage means a use of OpenFLUID that is inconsistent with the GPL
00043   license, and requires a written agreement between You and INRA.
00044   Licensees for Other Usage of OpenFLUID may use this file in accordance
00045   with the terms contained in the written agreement between You and INRA.
00046 */
00047 
00048 
00056 #ifndef __ENGINE_HPP__
00057 #define __ENGINE_HPP__
00058 
00059 
00060 #include <openfluid/dllexport.hpp>
00061 #include <openfluid/core.hpp>
00062 #include <openfluid/base.hpp>
00063 #include <openfluid/io.hpp>
00064 #include <openfluid/machine/PluginManager.hpp>
00065 #include <openfluid/base/RuntimeEnv.hpp>
00066 #include <openfluid/machine/ModelInstance.hpp>
00067 #include <openfluid/machine/MachineListener.hpp>
00068 #include <openfluid/machine/SimulationBlob.hpp>
00069 
00070 namespace openfluid { namespace machine {
00071 
00072 
00073 // =====================================================================
00074 // =====================================================================
00075 
00076 
00080 class DLLEXPORT Engine
00081 {
00082   public:
00083 
00084     struct PretestInfos_t
00085     {
00086       bool Model;
00087       std::string ModelMsg;
00088 
00089       bool Inputdata;
00090       std::string InputdataMsg;
00091 
00092       bool ExtraFiles;
00093       std::string ExtraFilesMsg;
00094 
00095       PretestInfos_t() : Model(true), ModelMsg(""),
00096           Inputdata(true), InputdataMsg(""),
00097           ExtraFiles(true), ExtraFilesMsg("")
00098         { };
00099     };
00100 
00101   private:
00102 
00103      SimulationBlob& m_SimulationBlob;
00104 
00105      openfluid::base::RuntimeEnvironment* mp_RunEnv;
00106 
00107      openfluid::base::SimulationStatus* mp_SimStatus;
00108 
00109 
00110 
00111      MachineListener* mp_MachineListener;
00112 
00113      openfluid::io::IOListener* mp_IOListener;
00114 
00115      ModelInstance& m_ModelInstance;
00116 
00117      openfluid::io::OutputsWriter* mp_OutputsWriter;
00118 
00119      openfluid::io::MessagesWriter* mp_MessagesWriter;
00120 
00121 
00122 
00123      void checkSimulationVarsProduction(int ExpectedVarsCount);
00124 
00125      void checkModelConsistency();
00126 
00127      void checkInputDataConsistency();
00128 
00129      void checkExtraFilesConsistency();
00130 
00131      void checkExistingVariable(openfluid::core::VariableName_t VarName,
00132                                 openfluid::core::UnitClass_t ClassName,
00133                                 std::string FunctionName);
00134 
00135      void createVariable(openfluid::core::VariableName_t VarName,
00136                          openfluid::core::UnitClass_t ClassName,
00137                          bool UpdateMode,
00138                          std::string FunctionName);
00139 
00140      void checkExistingInputData(openfluid::core::InputDataName_t DataName,
00141                                  openfluid::core::UnitClass_t ClassName,
00142                                  std::string FunctionName);
00143 
00144      void prepareOutputDir();
00145 
00146      void initOutputs();
00147 
00148      void prepareOutputs();
00149 
00150      void saveOutputs(const openfluid::core::DateTime& CurrentDT);
00151 
00152      void saveSimulationInfos();
00153 
00154      void saveSimulationProfile();
00155 
00156 
00157   public:
00161     Engine(SimulationBlob& SimBlob, ModelInstance& MInstance,
00162            openfluid::machine::MachineListener* MachineListener,
00163            openfluid::io::IOListener* IOListener);
00164 
00168     ~Engine();
00169 
00170 
00171     void pretestConsistency(PretestInfos_t& PretestInfos);
00172 
00173 
00174     void initParams();
00175 
00176     void prepareData();
00177 
00178     void checkConsistency();
00179 
00180     void run();
00181 
00182     void saveReports();
00183 
00184     void closeOutputs();
00185 
00186     openfluid::base::SimulationInfo* getSimulationInfo() { return (openfluid::base::SimulationInfo*)mp_SimStatus; };
00187 
00188     SimulationBlob*  getSimulationBlob() { return &m_SimulationBlob; };
00189 
00190     MachineListener* getMachineListener() { return mp_MachineListener; };
00191 
00192     openfluid::io::IOListener* getIOListener() { return mp_IOListener; };
00193 
00194     ModelInstance* getModelInstance() { return &m_ModelInstance; };
00195 
00196 
00197 };
00198 
00199 
00200 } } //namespaces
00201 
00202 
00203 #endif
00204 
00205 
00206 
00207 
00208 
00209 
00210 

Generated using Doxygen 1.7.3
Creative Commons License Creative Commons By-NC-ND license