Marine systems simulation
Connection/DdsReader

Get data from external DDS applications into an FhSim simulation.

+ Collaboration diagram for Connection/DdsReader:
Author
Joakim Haugen

This SimObject enables communication via DDS. This includes communication between different FhSim instances on the same network, or input from external processes such as physical processes. The DDS abstraction lets the user specify Partitions and Topics that one can publish or subscribe to. Within a Partition one can specify Topics, which are 'buffers' that holds information.

DdsReader is a SimObject that subscribes to the user-specified Partition:Topic. The SimObject reads from the 'buffer' and outputs the obtained information (doubles vector(s)) on the output ports of the SimObject. We employ sample-and-hold on the port outputs, with NaN initial output values.

Example file input:

<Lib LibName = "fhsim_extras"
SimObject = "Connection/DdsReader"
Name = "DdsInput"
Partition = "FhSimExternal"
Topic = "PhysicalEntity"
DdsRoot = "../lib"
DdsConfigFile = "../resources/ospl.xml"
ForceDdsEnv = "0"
InitializationTimeout = "2000"
PortWidth = "3"
Tags = "InputAlpha, Input2, Input3"
ArrayIDs = "0, 2, 4"
PortSizes = "1, 4, 3"
/>

Input Ports

No input ports available

Output Ports

Name Width Description
Out1 .. Out<PortWidth> <PortSizes> NOTE: Only present if <Tags> are not defined. Value received on DDS corresponding partition and topic with <ArrayIDs::i>.
OutTime1 .. OutTime<PortWidth> 1 NOTE: Only present if <Tags> are not defined. The timestamp of the current output Out::i.
[Tags] <PortSizes> Value received on DDS corresponding partition and topic with <ArrayIDs> (replaces Out::i). (optional)
[Tags]Time <PortSizes> The timestamp of the current output (replaces OutTime::i). (optional)

Configuration parameters

Name Width Description
Partition 1 String name of DDS partition to read from.
Topic 1 String name of DDS topic to read from.
DdsRoot 1 The relative path to the DDS Library from the current working directory, which might be the directory of the FhSim executable. Also sets OSPL_HOME
DdsConfigFile 1 Path to OpenSplice DDS config file. Effectively sets OSPL_URI
ForceDdsEnv 1 Force setting OpenSplice DDS environment variables OSPL_HOME and OSPL_URI, even if they are set (default: 0).
PortWidth 1 Number of vectors to read.
ArrayIDs <PortWidth> or 0 (Optional). The array IDs to read from on the prescribed partition and topic. A zero-indexed sequence is assumed if parameter is missing.
PortSizes <PortWidth> The length of each vector to be read.
Tags <PortWidth> or 0 (Optional) Name tags of each output port.
InitializationTimeout 1 or 0 (Optional: Default is 1500). Maximal time to wait for data on the DDS buffer in milliseconds. If you set this parameter to 0, the simulation will proceed with a default buffer that you need to specify with Default{ArrayIDs} or Default{Tags} parameters.
Default{ArrayIDs} or Default{Tags} <PortWidth> or 0 (Optional) Default buffer values for the specified arrays. The dimension must match PortSizes.

Initial conditions

This SimObject contains no initial conditions.

Full example file

<Contents>
<OBJECTS>
<Lib LibName = "fhsim_extras"
SimObject = "Connection/DdsWriter"
Name = "DdsOutput"
Partition = "FhSimExternal"
Topic = "PhysicalEntity"
DdsRoot = "../lib"
DdsConfigFile = "../resources/ospl.xml"
ForceDdsEnv = "0"
PortWidth = "2"
ArrayIDs = "1, 2"
PortSizes = "1, 2"
SamplingPeriods = "0.3"
/>
<Lib LibName = "fhsim_extras"
SimObject = "Connection/DdsReader"
Name = "DdsInput"
Partition = "FhSimExternal"
Topic = "PhysicalEntity"
DdsRoot = "../lib"
DdsConfigFile = "../resources/ospl.xml"
ForceDdsEnv = "1"
InitializationTimeout = "0"
PortWidth = "2"
Tags = "InputAlpha, Input2"
DefaultInputAlpha = "0"
DefaultInput2 = "1, 2"
ArrayIDs = "1, 2"
PortSizes = "1, 2"
/>
</OBJECTS>
<INTERCONNECTIONS>
<Connection
DdsOutput.In1="1"
DdsOutput.In2="2, 3"
/>
</INTERCONNECTIONS>
<INITIALIZATION>
<InitialConditions/>
</INITIALIZATION>
<INTEGRATION>
<Engine
IntegratorMethod="2"
NumCores="1"
TOutput="0, 5, 5"
LogStates ="1"
stepsize ="0.001"
HMax="0.2"
HMin="0.00001"
AbsTol="1e-3" RelTol="1e-3"
UseRSSNormInsteadOfInfNorm="0"
FileOutput="object.DdsInput:ports"
/>
</INTEGRATION>
</Contents>