17 #ifndef AGXFMI2_EXPORT_MODULE_H
18 #define AGXFMI2_EXPORT_MODULE_H
20 #include <agx/config/AGX_USE_FMI.h>
33 #include <agx/config/AGX_USE_OSG.h>
43 #include <external/fmi/2.0/fmi2Functions.h>
46 #pragma warning( pop )
51 class ExampleApplication;
77 Module(
const agx::Name& name,
const char* GUID,
bool createOsgWindow =
false);
87 void initRemoteConnection();
92 Variable* getVariable(
const agx::Name& name);
94 const char *getGUID()
const;
97 void setDescription(
const agx::String& description);
109 void setOsgRoot(osg::Group *group);
110 osg::Group *getOsgRoot();
112 void exportModelDescriptionFile(
const agx::String& filePath);
114 bool getCreateOsgWindow()
const;
117 void setCreateOsgWindow(
bool flag);
118 void setThrottleRealTime(
bool flag);
119 void setUseDebugRendering(
bool flag);
121 void setAutoStepCallback(
bool flag);
123 void setEnableJournalRecord(
bool flag);
124 void setEnableTaskProfiling(
bool flag);
125 void setEnableThreadTimeline(
bool flag);
127 void setJournalConfiguration(
const agx::String& config);
128 void setJournalRecordFrequency(
agx::Real frequency);
129 void setInternalStepMultiplier(
agx::Int multiplier);
130 void setApplicationArguments(
const agx::String& args);
131 void createRenderObjects();
136 void setEnableAutoRendering(
bool enable);
141 void finalizeSetup();
142 fmi2Status fmiSetupExperiment(fmi2Boolean toleranceDefined, fmi2Real relativeTolerance, fmi2Real tStart, fmi2Boolean stopTimeDefined, fmi2Real tStop);
143 fmi2Status fmiEnterInitializationMode();
144 fmi2Status fmiExitInitializationMode();
145 fmi2Status fmiTerminate();
146 fmi2Status fmiReset();
147 fmi2Status fmiSetDebugLogging(fmi2Boolean loggingOn,
size_t nCategories,
const fmi2String categories[]);
148 fmi2Status fmiGetReal(
const fmi2ValueReference vr[],
size_t nvr, fmi2Real value[]);
149 fmi2Status fmiGetInteger(
const fmi2ValueReference vr[],
size_t nvr, fmi2Integer value[]);
150 fmi2Status fmiGetBoolean(
const fmi2ValueReference vr[],
size_t nvr, fmi2Boolean value[]);
151 fmi2Status fmiGetString(
const fmi2ValueReference vr[],
size_t nvr, fmi2String value[]);
152 fmi2Status fmiSetReal(
const fmi2ValueReference vr[],
size_t nvr,
const fmi2Real value[]);
153 fmi2Status fmiSetInteger(
const fmi2ValueReference vr[],
size_t nvr,
const fmi2Integer value[]);
154 fmi2Status fmiSetBoolean(
const fmi2ValueReference vr[],
size_t nvr,
const fmi2Boolean value[]);
155 fmi2Status fmiSetString(
const fmi2ValueReference vr[],
size_t nvr,
const fmi2String value[]);
156 fmi2Status fmiSetRealInputDerivatives(
const fmi2ValueReference vr[],
size_t nvr,
const fmi2Integer order[],
const fmi2Real value[]);
157 fmi2Status fmiGetRealOutputDerivatives(
const fmi2ValueReference vr[],
size_t nvr,
const fmi2Integer order[], fmi2Real value[]);
158 fmi2Status fmiCancelStep();
159 fmi2Status fmiDoStep(fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean commitStep);
160 fmi2Status fmiGetStatus(
const fmi2StatusKind s, fmi2Status* value);
161 fmi2Status fmiGetRealStatus(
const fmi2StatusKind s, fmi2Real* value);
162 fmi2Status fmiGetIntegerStatus(
const fmi2StatusKind s, fmi2Integer* value);
163 fmi2Status fmiGetBooleanStatus(
const fmi2StatusKind s, fmi2Boolean* value);
164 fmi2Status fmiGetStringStatus(
const fmi2StatusKind s, fmi2String* value);
165 fmi2Status fmiGetDirectionalDerivative(
const fmi2ValueReference vUnknown_ref[],
size_t nUnknown,
const fmi2ValueReference vKnown_ref[] ,
size_t nKnown,
const fmi2Real dvKnown[], fmi2Real dvUnknown[]);
167 fmi2Status fmiGetFMUstate(fmi2FMUstate* state);
168 fmi2Status fmiSetFMUstate(fmi2FMUstate state);
169 fmi2Status fmiFreeFMUstate(fmi2FMUstate* state);
175 template <
typename T>
178 agx::TiXmlElement *exportModel();
179 agx::TiXmlElement *exportCoSimulation();
180 agx::TiXmlElement *exportUnitDefinitions();
181 agx::TiXmlElement *exportTypeDefinitions();
182 agx::TiXmlElement *exportModelVariables();
183 agx::TiXmlElement *exportModelStructure();
185 void createExportGeneralVariables();
186 void applyAccumulators();
188 template <
typename T,
typename VariableT>
189 fmi2Status fmiSetT(
const fmi2ValueReference vr[],
size_t nvr,
const T value[]);
191 template <
typename T,
typename VariableT>
192 fmi2Status fmiGetT(
const fmi2ValueReference vr[],
size_t nvr, T value[]);
198 friend class SteppingThread;
200 void signalStepperDone(
bool completedStep);
202 agx::UInt getInternalStepMultiplier()
const;
205 class RigidBodyMobilityOutputVariable;
207 RigidBodyMobilityTable m_mobilityTable;
213 bool m_createOsgWindow;
214 bool m_throttleRealTime;
215 bool m_useDebugRendering;
216 bool m_enableJournalRecord;
217 bool m_enableTaskProfiling;
218 bool m_enableThreadTimeline;
219 bool m_initializedApplication;
224 bool m_sharedApplication;
228 bool m_enableAutoRendering;
231 osg::ref_ptr<osg::Group> m_renderRoot;
247 VariableRefVector m_variables;
252 bool m_hasStopDefined;
254 SteppingThreadRef m_steppingThread;
256 bool m_strongCouplingStepping;
259 bool m_enableDirectSolverDataSharing;
260 agx::MobilitySolverRef m_mobilityReferenceSolver;
261 agx::MobilitySolverRef m_savedState;
268 SteppingThread(Module *module);
276 void setupStrongCoupling();
279 virtual ~SteppingThread();
282 virtual void run()
override;
300 AGX_FORCE_INLINE bool Module::getCreateOsgWindow()
const {
return m_createOsgWindow; }
#define AGX_DECLARE_POINTER_TYPES(type)
A small argument parser class.
Class that encapsulates rendering and simulation using OpenSceneGraph.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Basic wrapper class aroud std::thread.
Block synchronization primitive.
Templated callback with one argument.
Inheritance with partial specialization due to bug with ref_ptr containers.
Inheritance with partial specialization due to bug with ref_ptr containers.
Representation of a name string.
agx::Object is a refcounted object with a name.
The rigid body class, combining a geometric model and a frame of reference.
A representation of a generic task.
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
Smart pointer for handling referenced counted objects.
This namespace contains functionality for using AGX together with version 2 of the Functional Mockup ...
The agxIO namespace contains classes for reading, writing and finding files.
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.