English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Launcher: TCodeFMU.h Source File
Uranie / Launcher  v4.10.0
/* @license-end */
TCodeFMU.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2024 CEA/DES
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as published
6 // by the Free Software Foundation, either version 3 of the License, or any
7 // later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
51 #ifndef TCODEFMU_H
52 #define TCODEFMU_H
53 
54 // ROOT
55 
56 //URANIE
57 #include "TCode.h"
58 
59 // FMI
60 #ifdef WIN32
61 #define WIN32_LEAN_AND_MEAN
62 #include <Windows4Root.h>
63 #endif
64 #include "fmilib.h"
65 #include <JM/jm_portability.h>
66 
67 #include <string>
68 
69 namespace URANIE {
70 namespace Launcher {
71 
72 class TCodeFMU : public TCode
73 {
74 public:
75 
77  enum ELogLevel_t {
86  };
87 
88  // Constructors/Destructors
89  //
90 
91 
95  TCodeFMU ();
101  TCodeFMU(const TString &name, const TString &title);
107  TCodeFMU(URANIE::DataServer::TDataServer *tds, TString sFMUfile, Option_t *option ="");
108 
114 
118  virtual ~TCodeFMU ();
119 
120  // Static Public attributes
121  //
122 
123  // Public attributes
124  //
125  //---------------------------------------------
134  virtual void init(Option_t *option = "");
135  virtual void initRun(forkcode *fjob, Option_t *option = "");
136 
141  virtual void start(forkcode *fjob, Option_t *option = "");
142 
147  virtual void terminate(Option_t *option = "");
148 
149  void initIFirst(Option_t *option = "");
150 
152 
153 
154  // Public attribute accessor methods
155  //
156  //---------------------------------------------
167  void setFMUFile (TString new_var, Option_t *option = "");
175  TString getFMUFile () {
176  FUNCT_TRACE();
177  return _sFMUFile;
178  }
179 
180  Double_t getStartSimulation() {
181  FUNCT_TRACE();
182  return _dStart;
183  }
184  void setStartSimulation(Double_t dval) {
185  FUNCT_TRACE();
186  _dStart = dval;
187  _bStart = kTRUE;
188  }
189  Double_t getStoptSimulation() {
190  FUNCT_TRACE();
191  return _dStop;
192  }
193  void setStopSimulation(Double_t dval) {
194  FUNCT_TRACE();
195  _dStop = dval;
196  _bStop = kTRUE;
197  }
198  Double_t getStepSimulation() {
199  FUNCT_TRACE();
200  return _dStep;
201  }
202  void setStepSimulation(Double_t dval) {
203  FUNCT_TRACE();
204  _dStep = dval;
205  _bStep = kTRUE;
206  }
207 
209  return _dTolerance;
210  }
211  void setToleranceSimulation(Double_t dval) {
212  FUNCT_TRACE();
213  _dTolerance = dval;
214  _bTolerance = kTRUE;
215  }
216  void setStartStopSimulation(Double_t dstart, Double_t dstop) {
217  FUNCT_TRACE();
218  try {
219  if ( dstart < dstop ) {
220  setStartSimulation(dstart);
221  setStopSimulation(dstop);
222  } else {
223  throw URANIE::Exceptions::UErrorExceptions(
224  __FILE__, __LINE__,
225  Form("TcodeFMU::%s Method\n The start time[%f] is greater than stop [%e] time", __func__, dstart, dstop));
226  }
227  } catch (URANIE::Exceptions::UExceptions& ue) {
228  ue.printMessage();
229  if (ue.getMessageType() > URANIE::Exceptions::UExceptions::kWARNING)
230  exit(-1);
231 
232  }
233  }
234 
235 
237 
238  // Public FMI functions
239  //
240  //---------------------------------------------
244 
245 
251  void do_exit(int code)
252  {
253  printf("Press 'Enter' to exit\n");
254  /* getchar(); */
255  exit(code);
256  }
257 
259 
260  // Public attribute accessor methods
261  //
262 
263  //---------------------------------------------
270  void setLog() {
271  _blog = kTRUE;
272  }
276  void unsetLog() {
277  _blog = kFALSE;
278  }
282  void changeLog() {
283  _blog = _blog ? kFALSE : kTRUE;
284  }
289  Bool_t getLog() {
290  return _blog;
291  }
292 
299  void setLogLevel(ELogLevel_t theLogLevel = log_level_info) {
300  _logLevel = theLogLevel;
301  }
302 
308  return _logLevel;
309  }
310 
315  virtual void printLog(Option_t *option = "");
317 
318 protected:
319 
320  // Static Protected attributes
321  //
322 
323  // Protected attributes
324  //
325 
326 public:
327 
328 
329  // Protected attribute accessor methods
330  //
331 
332  //---------------------------------------------
337 protected:
338  TString _sFMUFile;
341  Double_t _dStart;
342  Double_t _dStop;
343  Double_t _dStep;
344  Double_t _dTolerance;
345  Bool_t _bStart;
346  Bool_t _bStop;
347  Bool_t _bStep;
348  Bool_t _bTolerance;
349  Bool_t _binitIFirst;
350 
351  // FMI structures
352  fmi_version_enu_t _sVersion;
353  fmi_import_context_t* _context_FMI;
354  fmi1_import_t* _fmi1Import;
355  fmi2_import_t* _fmi2Import;
356 
357  // FMI General informations
360  Double_t _dFMUStart;
361  Double_t _dFMUStop;
362  Double_t _dFMUStep;
363  Double_t _dFMUTolerance;
364 
366 
367 public:
368 
369 
370  // Protected attribute accessor methods
371  //
372 
373 protected:
374 
375 
376 private:
377 
378  // Static Private attributes
379  //
380 
381  // Private attributes
382  //
383 
384 public:
385 
386 
387  // Private attribute accessor methods
388  //
389 
390 private:
395  void treatOption(TString soption);
396 
397 public:
398 
399 
400  // Private attribute accessor methods
401  //
402 
403 private:
404 
405  ClassDef(URANIE::Launcher::TCodeFMU, ID_LAUNCHER)
406 
407 
408 };
409 
410 } // End of namespace Launcher
411 } // End of namespace URANIE
412 
413 #endif // TCODEFMU_H
414 // End of File
415 
Definition: TCluster.h:66
void treatOption(TString soption)
treat the soption for the class
TString _sGenerationDateTime
The FMU generation date and time.
Definition: TCodeFMU.h:359
void setLogLevel(ELogLevel_t theLogLevel=log_level_info)
Set the Log Level for the FMI Library.
Definition: TCodeFMU.h:299
TCodeFMU()
Default constructor.
virtual void printLog(Option_t *option="")
Print the log of the object/class.
ELogLevel_t
The list of log level.
Definition: TCodeFMU.h:77
fmi2_import_t * _fmi2Import
The FMU 2.0 Object.
Definition: TCodeFMU.h:355
Debug messages. Only enabled if library is configured with FMILIB_ENABLE_LOG_LEVEL_DEBUG.
Definition: TCodeFMU.h:85
Double_t getStoptSimulation()
Definition: TCodeFMU.h:189
Double_t _dFMUStep
The step time for default experiment as specified in the XML file.
Definition: TCodeFMU.h:362
void setStartSimulation(Double_t dval)
Definition: TCodeFMU.h:184
void setStartStopSimulation(Double_t dstart, Double_t dstop)
Definition: TCodeFMU.h:216
Bool_t _blog
Boolean for edit the log.
Definition: TCode.h:444
virtual void init(Option_t *option="")
Init phase of the code.
Double_t _dFMUTolerance
The tolerance for default experiment as specified in the XML file.
Definition: TCodeFMU.h:363
Double_t getStepSimulation()
Definition: TCodeFMU.h:198
fmi_version_enu_t _sVersion
The FMU version.
Definition: TCodeFMU.h:352
virtual void terminate(Option_t *option="")
Terminate phase of the code.
Bool_t getLog()
Get the status of the log.
Definition: TCodeFMU.h:289
virtual void start(forkcode *fjob, Option_t *option="")
Run the code.
Verbose messages.
Definition: TCodeFMU.h:84
Double_t _dTolerance
The tolerance for the simulation.
Definition: TCodeFMU.h:344
Double_t _dStop
The stop time for the simulation.
Definition: TCodeFMU.h:342
Double_t _dFMUStart
The start time for default experiment as specified in the XML file.
Definition: TCodeFMU.h:360
struct unforkjob forkcode
Definition: TInputFile.h:53
ELogLevel_t _logLevel
The log Level for FMI Library.
Definition: TCodeFMU.h:340
void setToleranceSimulation(Double_t dval)
Definition: TCodeFMU.h:211
Double_t _dFMUStop
The stop time for default experiment as specified in the XML file.
Definition: TCodeFMU.h:361
virtual void initRun(forkcode *fjob, Option_t *option="")
Unrecoverable errors.
Definition: TCodeFMU.h:80
Non-critical issues.
Definition: TCodeFMU.h:82
void setLog()
Force the log.
Definition: TCodeFMU.h:270
void initIFirst(Option_t *option="")
Errors that may be not critical for some FMUs.
Definition: TCodeFMU.h:81
void do_exit(int code)
do_exit
Definition: TCodeFMU.h:251
Bool_t _bTolerance
boolean to known if _dTolerance is defined by user
Definition: TCodeFMU.h:348
Informative messages.
Definition: TCodeFMU.h:83
TString _sGenerationTool
The FMU generation tool.
Definition: TCodeFMU.h:358
Bool_t _bStop
boolean to known if _dstop is defined by user
Definition: TCodeFMU.h:346
Bool_t _bStart
boolean to known if _dstart is defined by user
Definition: TCodeFMU.h:345
A virtual class for the FMI/FMU encapsulation.
Definition: TCodeFMU.h:72
void changeLog()
Swith the status of the log.
Definition: TCodeFMU.h:282
Interface of the class URANIE::Launcher::TCode.
void setStopSimulation(Double_t dval)
Definition: TCodeFMU.h:193
ELogLevel_t getLogLevel()
Get the Log Level in the FMI Library.
Definition: TCodeFMU.h:307
Double_t getToleranceSimulation()
Definition: TCodeFMU.h:208
void setFMUFile(TString new_var, Option_t *option="")
Set the value of _sFMUFile.
Double_t getStartSimulation()
Definition: TCodeFMU.h:180
Bool_t _binitIFirst
boolean to known if passed into the initIFirst step
Definition: TCodeFMU.h:349
TString getFMUFile()
Get the value of the _sFMUFile attribute.
Definition: TCodeFMU.h:175
fmi_import_context_t * _context_FMI
The FMU context.
Definition: TCodeFMU.h:353
Must be first in this enum. May be usefull in application relying solely on jm_get_last_error() ...
Definition: TCodeFMU.h:79
Double_t _dStep
The step time for the simulation.
Definition: TCodeFMU.h:343
void unsetLog()
Force to desable the log.
Definition: TCodeFMU.h:276
TString _sFMUFile
The FMU filename.
Definition: TCodeFMU.h:338
Bool_t _bStep
boolean to known if _dstep is defined by user
Definition: TCodeFMU.h:347
Double_t _dStart
The start time for the simulation.
Definition: TCodeFMU.h:341
Description of the class TCode.
Definition: TCode.h:48
void setStepSimulation(Double_t dval)
Definition: TCodeFMU.h:202
fmi1_import_t * _fmi1Import
The FMU 1.0 Object.
Definition: TCodeFMU.h:354
TString _sFMUWorkingDirectory
the FMU import directory
Definition: TCodeFMU.h:339