Marine systems simulation
|
SimObject libraries are loadable modules (dll
or so
files) that contain one or more classes inheriting from the SimObject interface. These modules get loaded by FhSim at runtime and their SimObjects made available for the simulation.
Herein, a sketch of the procedure for creating a new SimObject library with a set of SimObjects. In practice, it is recommended to use the SimObject template tool. This tool makes it easier to create a new SimObject library that follow good coding practices, see SimObject template tool. Alternatively, one could consider to base new library on an existing library.
Each implemented SimObject must be referenced using ADD_SIMOBJECT_REF
or ADD_SIMOBJECT_REF3
macros in a CMake MODULE
target. The MODULE
target must link to the target FhSim::fhsim
, which contains the SimObject
base implementation. Suppose fhsim_example.cpp
contains a class my::deep::space::VanDerPol
and Pendulum
, both implementing the SimObject interface. To create a SimObject library with these models, we add to fhsim_example.cpp
:
An excerpt of the CMakeLists.txt
is:
The resulting dll
/so
is now a SimObject library with two SimObjects: Oscillator/VanDerPol
and Oscillator/Pendulum
.
The simobject template
tool is a command line interface that help create a minimal SimObject library, with ready-made scripts for CMake, conan and documentation. If you are lucky, you are almost completely relieved the burden of writing build system scripts.
The tool is available from sintef-ocean
conan remote:
Run simobject --help
to get available commands. A user scenario is typically
simobject new config_dir
config_dir/simobject.cfg
in a text editor. A simobject.cfg file will be on the format:simobject create config_dir --output generated_dir
cd generated_dir && git init
conan install . && conan build .
DEVELOPING.md
and README.md
in the generated directory.