AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
import/Module.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXFMI2_IMPORT_MODULE_H
18#define AGXFMI2_IMPORT_MODULE_H
19
20#include <agx/config/AGX_USE_FMI.h>
21
22#if AGX_USE_FMI()
23
25
26#include <agx/Component.h>
27#include <agx/PluginMacros.h>
28
29#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
30extern "C"
31{
32 #include <JM/jm_callbacks.h>
33 #include <FMI/fmi_import_context.h>
34 #include <FMI2/fmi2_functions.h>
35 #include <FMI2/fmi2_import.h>
36 #include <FMI2/fmi2_types.h>
37}
38#include <agx/PopDisableWarnings.h> // End of disabled warnings.
39
40namespace agxFMI2
41{
42 namespace Export
43 {
44 class Module;
45 }
46
47 namespace Import
48 {
49 class Master;
50
51 AGX_DECLARE_POINTER_TYPES(RigidBodyConnector);
52 AGX_DECLARE_VECTOR_TYPES(RigidBodyConnector);
53
56
57
61 class AGXFMI_EXPORT Module : public agx::Component
62 {
63 public:
64 enum LogLevel {
65 LOG_LEVEL_NOTHING = jm_log_level_nothing,
66 LOG_LEVEL_FATAL = jm_log_level_fatal,
67 LOG_LEVEL_ERROR = jm_log_level_error,
68 LOG_LEVEL_WARNING = jm_log_level_warning,
69 LOG_LEVEL_INFO = jm_log_level_info,
70 LOG_LEVEL_VERBOSE = jm_log_level_verbose,
71 LOG_LEVEL_DEBUG = jm_log_level_debug,
72 LOG_LEVEL_ALL = jm_log_level_all
73 };
74
75 const VariableRefVector& getVariables() const;
76
77 agxFMI2::Import::Variable *getVariable(const agx::Name& name);
78
79 void instantiate(bool visible);
80 void init(fmi2_real_t tStart, fmi2_real_t tEnd, fmi2_boolean_t stopTimeDefined = true);
81 void terminate();
82
83 bool isInstantiated() const;
84
85 Master* getMaster();
86
87 Export::Module *getAgxExportModule();
88
89 agx::String getModelDescription();
90
91
92 fmi2_status_t doStep(agx::Real currentTime, agx::Real timeStep, bool newStep);
93
94 fmi2_status_t getDirectionalDerivative(const fmi2_value_reference_t vKnown_ref[] , size_t nKnown, const fmi2_value_reference_t vUnknown_ref[], size_t nUnknown, const fmi2_real_t dvKnown[], fmi2_real_t dvUnknown[]);
95
96 // fmi2_real_t getOutputDerivative(agx::UInt32 vr, fmi2_integer_t order = 1);
97
98 fmi2_import_t *getFmuImpl() const;
99
100 private:
101 friend class Master;
102 Module(Master *master, const agx::String& zipPath, LogLevel logLevel = LOG_LEVEL_INFO);
103 static void jmLogger_dispatch(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_level, jm_string message);
104 void jmLogger(jm_string module, jm_log_level_enu_t log_level, jm_string message);
105
106
107 protected:
108 virtual ~Module();
109
110 private:
111 Master *m_master;
112 bool m_ownUnpackedData;
113 agx::String m_diskRootPath;
114 agx::String m_fmuLocation;
115 jm_callbacks m_jmCallbacks;
116 fmi_import_context_t *m_context;
117 fmi2_import_t *m_fmu;
118 fmi2_callback_functions_t m_fmi2callbackFunctions;
119 VariableRefVector m_variables;
120 bool m_instantiated;
121 agx::PluginHandle m_plugin;
122 Export::Module *m_agxExportModule;
123 // agx::TiXmlElement *m_modelDescription;
124 };
125
126 }
127}
128
129#endif /* AGX_USE_FMI */
130
131#endif /* AGXFMI2_IMPORT_MODULE_H */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXFMI_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition agx/Vector.h:34
A component is an object containing other objects, enabling hierarchical structuring.
Definition Component.h:39
Representation of a name string.
Definition Name.h:33
This namespace contains functionality for using AGX together with version 2 of the Functional Mockup ...
void * PluginHandle
double Real
Definition Real.h:42
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.