|
FhSim
3.1.0
Marine systems simulation
|
The <OBJECTS> section declares the SimObjects that participate in the simulation. Each SimObject is loaded from a shared library at runtime.
Each SimObject is specified by a <Lib /> tag with the following attributes:
| Attribute | Required | Description |
|---|---|---|
LibName | Yes | Name of the shared library containing the SimObject implementation (without platform-specific prefix/suffix). |
SimObject | Yes | The type name of the SimObject within the library. |
Name | Yes | A unique instance name for this SimObject. Used to reference it in other sections. |
| *(any other)* | No | SimObject-specific parameters. Names and types must match the implementation. |
<Lib> is the only element type the object loader understands. Any other element inside <OBJECTS> is read and then rejected with "The simulation object
of class ... was not found."Mass, then Mass="20.0" is valid. Parameters with a default value in the implementation can be omitted. A parameter given twice on the same element keeps the last value and logs a warning.LibName and Name included — goes through $Variable substitution. Arithmetic is evaluated when the SimObject reads the parameter as a number, so Mass="2*1000" is valid for a numeric Mass. A parameter the SimObject reads as text reaches it exactly as written, punctuation and all, so an attribute can carry a JSON document, a regular expression or a bracketed list. See VARIABLES section and Arithmetic in attribute values for the exact rules."1.5m", "ten") stops the run.| Type | Valid | Not valid |
|---|---|---|
| Number | 1.5, 1e-5, 2*1000; spaces around a field are ignored | 1.5m, ten, nan, a number too large for a double |
| Whole number | 3, 2*5 | 2.7, 1e3 (no fraction or exponent), 3abc, a value outside the int range |
| Bool | true, false, 1, 0, yes, no, on, off (any case) | ture, 2, an empty value |
| List | 1,2,3 | 1,2, (a trailing comma is an error), a field that is not a value, a wrong number of fields |
The error names the SimObject, the parameter and the text, for example Tug1: Parameter Mass has the value "1.5m", and "1.5m" is not a number. Arithmetic still works, and string and matrix (;) parameters are not affected. See Runtime errors and diagnostics for the catalogue.
LibName is not searched for on a system library path. It is turned into a relative file path and looked up against the working directory, which is the directory FhSim has selected at startup — see Path resolution.
LibName contains a / or \, everything before the last one is used as the directory. Otherwise the directory is the literal subdirectory SimObjectLibraries..dll (Windows) or .so (Linux). The build configuration appends, in order: Vis for a visualisation build, _static for a static build, _d for a debug build, and then the platform extension. On Linux the prefix lib is added.fhsim_ inserted before it. If neither exists the run stops with an error naming both paths tried.Because of step 3, LibName="base" and LibName="fhsim_base" both find the same library: a release Linux build without visualisation tries SimObjectLibraries/libbase.so and then SimObjectLibraries/libfhsim_base.so. The examples in this manual use the full fhsim_base spelling.
LibName="fhsim_base" resolves to fhsim_baseVis_d.dll from a debug visualisation build, fhsim_baseVis.dll from a release visualisation build and fhsim_base.dll from a release build without visualisation. Mixing variants in one installation does not work.