Skip to main content

AVxcelerate Simulation Framework 2025 R1

fmu_logic

Last update: 16.07.2025
1 
4 #pragma once
5 
6 #include "core/lifecycle/fmu_activity/i_fmu_logic.h"
7 #include <memory>
8 #include <set>
9 
10 namespace fmi4cpp
11 {
12 namespace fmi2
13 {
14 class fmu;
15 class cs_fmu;
16 class cs_slave;
17 } // namespace fmi2
18 enum class status;
19 } // namespace fmi4cpp
20 
25 namespace simulation_framework
26 {
27 namespace core
28 {
29 
30 namespace lifecycle
31 {
32 
33 class FmuLogicImpl;
34 
35 namespace fmi = fmi4cpp::fmi2;
36 
39 class FmuLogic : public IFmuLogic
40 {
41  public:
44  FmuLogic(const std::string& fmu_path);
45 
47  virtual ~FmuLogic() override;
48  FmuLogic(FmuLogic&&) noexcept;
49  FmuLogic& operator=(FmuLogic&&) noexcept;
51 
53  void SetupExperiment(double start = 0, double stop = 0, double tolerance = 0) override;
54 
56  void EnterInitialization() override;
57 
59  void ExitInitialization() override;
60 
62  void Setup(double start = 0, double stop = 0, double tolerance = 0) override;
63 
65  void PrepareInputsOutputs() override;
66 
68  FmuInOutMap InitInOutMap(std::set<std::string> variable_names) override;
69 
71  bool Step(double step_size, const FmuInOutMap& input) override;
72 
74  bool Step(double step_size) override;
75 
77  void SetInputs(const FmuInOutMap& inputs) override;
78 
83  template <typename T>
84  void SetValue(const std::string& variable_name, const T& value);
85 
90  template <typename T>
91  T GetOutput(const std::string& variable_name) const;
92 
94  FmuInOutMap GetOutputs() const override;
95 
99  void GetOutputs(FmuInOutMap& requested_outputs) const override;
100 
103  double GetSimulationTime() const;
104 
107  fmi4cpp::status GetLastStatus() const;
108 
111  const fmi::fmu* GetFmuPtr() const;
112 
115  const fmi::cs_fmu* GetCsFmuPtr() const;
116 
119  const fmi::cs_slave* GetFmuInstancePtr() const;
120 
121  private:
123  std::unique_ptr<FmuLogicImpl> impl_;
124 };
125 
126 } // namespace lifecycle
127 } // namespace core
128 } // namespace simulation_framework

Connect with Ansys