Skip to content

nmeasim::io

namespace nmeasim::io · Library API

Profiles, transports and the simulation runner: a static library on Qt Core, Network, Serial Port and WebSockets (CMake target nmeasim::io).

A Profile is the persistent description of a simulation and its outputs; SimulationRunner drives a core::simulation::Simulation on a Qt timer and writes what it produces to Transport implementations. Both the desktop application and the command-line tool are built on it.

Types

Type Description
FileTransport Writes lines to a file, flushing after every write so that the file can be tailed while the simulator runs.
LogTransport Records sentences to a log file: a # header when the file is empty, then one line per sentence prefixed with the wall-clock UTC time.
NetworkInterfaceInfo One IPv4 address of a network interface, with the broadcast address of its subnet.
OutputChannel One enabled output of a running profile: its transport, its filter and its counters.
OutputConfig One configured output channel, an entry of the outputs array of a profile.
Profile A complete simulator setup, stored as a JSON profile file.
ReplaySettings Settings of the log replay mode, the simulation.replay object of a profile.
SerialConfig Settings of a serial port output, applied when the port is opened.
SerialPortDescriptor Describes one serial port found on the host machine.
SerialTransport Writes lines to a serial port.
SimulationRunner Runs the simulation of a profile on a timer and writes its output to the profile's transports and to an optional recording.
StdoutTransport Writes lines to standard output, flushing after each one so that a pipe sees it immediately.
TcpClientTransport Connects to a TCP server, sends it every line, and reconnects automatically after a failed attempt or a dropped connection.
TcpServerTransport Listens for TCP clients and sends every line to all of them.
TrackSettings Settings of the track-following mode, the simulation.track object of a profile.
Transport Abstract output channel: TCP server or client, UDP, WebSocket server, serial port, file, log or standard output.
UdpConfig Settings of a UDP output, applied when the transport is opened.
UdpTransport Sends every line as one UDP datagram to the destination of a UdpConfig.
WebSocketServerTransport Accepts WebSocket clients and sends every line to all of them as a text frame.

Summary

Enumerations

Name Description
SimulationMode What drives the vessel, the simulation.mode key of a profile.

Functions

Name Description
ipv4_interfaces() Lists every IPv4 address of every interface that is up and running, loopback included.
find_ipv4_interface() Finds the first IPv4 address of the interface with a given name.
to_string() Returns the profile name of an output type.
output_type_from_string() Parses the profile name of an output type.
to_string() Returns the profile name of an output encoding.
encoding_from_string() Parses the profile name of an output encoding.
to_string() Returns the profile name of a simulation mode.
simulation_mode_from_string() Parses the profile name of a simulation mode.
available_serial_ports() Enumerates the serial ports currently present on this machine.
to_string() Returns the lower-case name of a transport state, as the desktop application and the reference pages show it.
to_string() Returns the lower-case name of a UDP addressing mode, as used in profiles.

Enumerations

SimulationMode

enum class SimulationMode

What drives the vessel, the simulation.mode key of a profile.

Each enumerator is written as the string given in its description; to_string and simulation_mode_from_string convert. In every mode the delta seed supplies the values the driving source does not.

Enumerator Value Description
Delta delta, the default: seed values that drift, with overrides and steering.
Track track: follows a GPX or KML track file, Profile::track.
Replay replay: sends a recorded log again, Profile::replay.

Declared in src/io/include/nmeasim/io/profile/profile.hpp:206

Functions

ipv4_interfaces()

QList<NetworkInterfaceInfo> ipv4_interfaces()

Lists every IPv4 address of every interface that is up and running, loopback included.

Interfaces that are down, or up but not running, are skipped, as are IPv6 addresses. The list is read afresh on every call.

Returns QList<NetworkInterfaceInfo>: One entry per IPv4 address, in the order the operating system reports the interfaces and their addresses; an interface with several addresses contributes several entries. Empty when there is none.

Declared in src/io/include/nmeasim/io/network_interfaces.hpp:44 · defined in src/io/src/network_interfaces.cpp:11

find_ipv4_interface()

NetworkInterfaceInfo find_ipv4_interface(const QString& name)

Finds the first IPv4 address of the interface with a given name.

Parameters

Name Type Description
name const QString& System name or descriptive name of the interface, compared exactly (case-sensitive) with NetworkInterfaceInfo::name and NetworkInterfaceInfo::human_name.

Returns NetworkInterfaceInfo: The first entry of ipv4_interfaces whose name matches, or a default-constructed value with a null address when no interface that is up and running has that name and an IPv4 address.

Declared in src/io/include/nmeasim/io/network_interfaces.hpp:53 · defined in src/io/src/network_interfaces.cpp:32

to_string()

QString to_string(OutputConfig::Type type)

Returns the profile name of an output type.

Parameters

Name Type Description
type OutputConfig::Type The output type.

Returns QString: The name written as the type key, such as tcp-server or websocket-server; unknown for a value outside the enumeration.

Declared in src/io/include/nmeasim/io/profile/profile.hpp:182 · defined in src/io/src/profile/profile.cpp:858

output_type_from_string()

std::optional<OutputConfig::Type> output_type_from_string(const QString& value)

Parses the profile name of an output type.

Parameters

Name Type Description
value const QString& The name, matched exactly and case-sensitively, such as udp or tcp-client.

Returns std::optional<OutputConfig::Type>: The output type, or std::nullopt when value names none.

Declared in src/io/include/nmeasim/io/profile/profile.hpp:187 · defined in src/io/src/profile/profile.cpp:880

to_string()

QString to_string(OutputConfig::Encoding encoding)

Returns the profile name of an output encoding.

Parameters

Name Type Description
encoding OutputConfig::Encoding The encoding.

Returns QString: nmea0183, signalk or viewsync; nmea0183 for a value outside the enumeration.

Declared in src/io/include/nmeasim/io/profile/profile.hpp:193 · defined in src/io/src/profile/profile.cpp:892

encoding_from_string()

std::optional<OutputConfig::Encoding> encoding_from_string(const QString& value)

Parses the profile name of an output encoding.

Parameters

Name Type Description
value const QString& The name, matched exactly and case-sensitively.

Returns std::optional<OutputConfig::Encoding>: The encoding, or std::nullopt when value is not nmea0183, signalk or viewsync.

Declared in src/io/include/nmeasim/io/profile/profile.hpp:199 · defined in src/io/src/profile/profile.cpp:904

to_string()

QString to_string(SimulationMode mode)

Returns the profile name of a simulation mode.

Parameters

Name Type Description
mode SimulationMode The simulation mode.

Returns QString: delta, track or replay; delta for a value outside the enumeration.

Declared in src/io/include/nmeasim/io/profile/profile.hpp:219 · defined in src/io/src/profile/profile.cpp:914

simulation_mode_from_string()

std::optional<SimulationMode> simulation_mode_from_string(const QString& value)

Parses the profile name of a simulation mode.

Parameters

Name Type Description
value const QString& The name, matched exactly and case-sensitively.

Returns std::optional<SimulationMode>: The mode, or std::nullopt when value is not delta, track or replay.

Declared in src/io/include/nmeasim/io/profile/profile.hpp:224 · defined in src/io/src/profile/profile.cpp:926

available_serial_ports()

std::vector<SerialPortDescriptor> available_serial_ports()

Enumerates the serial ports currently present on this machine.

No filtering is applied: every port the operating system reports is returned so that unusual devices (for example /dev/ttySC* on single-board computers) are never hidden. The list is read afresh on every call.

Returns std::vector<SerialPortDescriptor>: One descriptor per port, in the order Qt reports them; empty when there is none. The strings are UTF-8.

Declared in src/io/include/nmeasim/io/serial_ports.hpp:36 · defined in src/io/src/serial_ports.cpp:11

to_string()

QString to_string(Transport::State state)

Returns the lower-case name of a transport state, as the desktop application and the reference pages show it.

Parameters

Name Type Description
state Transport::State The state to name.

Returns QString: closed, opening, open or failed; unknown for a value outside the enumeration.

Declared in src/io/include/nmeasim/io/transport.hpp:176 · defined in src/io/src/transport.cpp:32

to_string()

QString to_string(UdpConfig::Mode mode)

Returns the lower-case name of a UDP addressing mode, as used in profiles.

Parameters

Name Type Description
mode UdpConfig::Mode The mode to name.

Returns QString: unicast, broadcast or multicast; unknown for a value outside the enumeration.

Declared in src/io/include/nmeasim/io/transports/udp_transport.hpp:135 · defined in src/io/src/transports/udp_transport.cpp:14