Skip to content

VesselPage

class nmeasim::app::VesselPage · Applications

Settings tab for the engines and the AIS static data of the own vessel.

Inherits QWidget

Declared in src/app/dialogs/vessel_page.hpp (line 38)

SettingsDialog calls load once with its copy of the profile, validate when the operator presses OK, and store into the same copy when every page is valid. The widgets are the only state of the page. The ranges of the numeric AIS widgets stay within those of the fields of ITU-R M.1371-5 messages 1 and 5, so the encoder never has to clamp a number the page stores; load clamps a profile value outside a widget's range to the nearest limit.

Every widget, cell widget and table item is owned through Qt parents by the page, and the public widget pointers are never null and stay valid for the lifetime of the page. The class declares no signals or slots of its own.

See also

Summary

Public types

Name Description
EngineColumn Columns of engines_table.

Public member functions

Name Description
VesselPage() Creates the page with an empty engine table and the AIS widgets at their minimum or first item.
load() Shows the engines and AIS static data of a profile's seed in the widgets.
store() Writes the engines and AIS static data into the seed of a profile.
validate() Checks the AIS data.
add_engine() Appends an engine row and selects it.
remove_current_engine() Removes the current row of the engine table; does nothing when there is none.
engine_count() Returns the number of rows in the engine table.
engine_at() Returns the engine of a row as store writes it.
set_engine() Replaces the values shown in an engine row.

Public data members

Name Description
engines_table One row per engine, core::model::VesselState::engines in order, with the columns of EngineColumn.
add_engine_button The Add engine button, which calls add_engine.
remove_engine_button The Remove button, which calls remove_current_engine.
mmsi_spin Maritime Mobile Service Identity, core::model::AisStatic::mmsi; [0, 999999999], at most nine digits.
imo_spin IMO number, core::model::AisStatic::imo_number; [0, 999999999], shown as None when 0, the value for a vessel without one.
name_edit Vessel name, core::model::AisStatic::name; at most 20 characters, the length of the name field of message 5.
call_sign_edit Call sign, core::model::AisStatic::call_sign; at most 7 characters, the length of the call sign field of message 5.
ship_type_spin Type of ship and cargo code, core::model::AisStatic::ship_type; [0, 255], the range of the 8-bit field of message 5.
to_bow_spin Distance from the GNSS antenna to the bow, core::model::AisStatic::dimension_to_bow_m; [0, 511] whole metres, the range of the 9-bit field of message 5.
to_stern_spin Distance from the GNSS antenna to the stern, core::model::AisStatic::dimension_to_stern_m; [0, 511] whole metres, the range of the 9-bit field of message 5.
to_port_spin Distance from the GNSS antenna to port, core::model::AisStatic::dimension_to_port_m; [0, 63] whole metres, the range of the 6-bit field of message 5.
to_starboard_spin Distance from the GNSS antenna to starboard, core::model::AisStatic::dimension_to_starboard_m; [0, 63] whole metres, the range of the 6-bit field of message 5.
draught_spin Maximum present static draught, core::model::AisStatic::draught_m; [0, 25.5] m with one decimal, the tenths of a metre that message 5 carries.
ais_destination_edit Voyage destination, core::model::AisStatic::destination; at most 20 characters, the length of the destination field of message 5, and empty for none.
navigation_status_spin Navigational status code, core::model::AisStatic::navigation_status; [0, 15], the range of the 4-bit field of the position report.
report_type_combo Position report message type 1, 2 or 3, as index 0 to 2.

Private member functions

Name Description
append_engine_row() Appends a row that shows an engine, without selecting it.

Public types

EngineColumn

enum EngineColumn

Columns of engines_table.

Enumerator Value Description
Label 0 Editable item with the engine label, core::model::Engine::label.
Running Checkable item, core::model::Engine::running.
Rpm QDoubleSpinBox cell widget with the shaft revolutions per minute.
Temperature QDoubleSpinBox cell widget with the coolant temperature in °C.
EngineColumnCount Number of columns, not a column.

Declared in src/app/dialogs/vessel_page.hpp:43

Public member functions

VesselPage()

explicit VesselPage(QWidget* parent = nullptr)

Creates the page with an empty engine table and the AIS widgets at their minimum or first item.

The widgets show no profile until load is called. Connects the Add engine and Remove buttons.

Parameters

Name Type Description
parent QWidget* The owner of the page, normally the SettingsDialog; when null, the caller owns the page.

Declared in src/app/dialogs/vessel_page.hpp:59 · defined in src/app/dialogs/vessel_page.cpp:65

load()

void load(const io::Profile& profile)

Shows the engines and AIS static data of a profile's seed in the widgets.

The engine table is rebuilt from core::model::VesselState::engines, in order, and every AIS widget is set from the field named at its member. A position report type other than 1, 2 or 3 is shown as type 1, the type the encoder sends for it.

Parameters

Name Type Description
profile const io::Profile& The profile to show; only read during the call.

Declared in src/app/dialogs/vessel_page.hpp:68 · defined in src/app/dialogs/vessel_page.cpp:203

store()

void store(io::Profile& profile) const

Writes the engines and AIS static data into the seed of a profile.

Replaces the seed engines with the rows of the engine table as engine_at returns them, and writes every field of the seed's core::model::AisStatic. The vessel name, call sign and voyage destination are trimmed and upper-cased. The rest of profile is left as it is.

Parameters

Name Type Description
profile io::Profile& The profile to update, normally the dialog's copy.

Note

store does not validate the MMSI. SettingsDialog calls it only after validate returned an empty string.

Declared in src/app/dialogs/vessel_page.hpp:79 · defined in src/app/dialogs/vessel_page.cpp:228

validate()

QString validate() const

Checks the AIS data.

Only the MMSI is checked: it must be positive. The upper limit of nine digits is enforced by mmsi_spin itself.

Returns QString: A message for the operator naming the MMSI when it is 0; an empty string when the data is valid.

Declared in src/app/dialogs/vessel_page.hpp:87 · defined in src/app/dialogs/vessel_page.cpp:196

add_engine()

void add_engine()

Appends an engine row and selects it.

The new engine is labelled Engine n, where n is the new row count, and runs at 1500 rpm with a coolant temperature of 80 °C. Connected to the Add engine button.

Declared in src/app/dialogs/vessel_page.hpp:93 · defined in src/app/dialogs/vessel_page.cpp:152

remove_current_engine()

void remove_current_engine()

Removes the current row of the engine table; does nothing when there is none.

Connected to the Remove button.

Declared in src/app/dialogs/vessel_page.hpp:97 · defined in src/app/dialogs/vessel_page.cpp:162

engine_count()

int engine_count() const

Returns the number of rows in the engine table.

Returns int: The number of engines, running or not.

Declared in src/app/dialogs/vessel_page.hpp:101 · defined in src/app/dialogs/vessel_page.cpp:169

engine_at()

core::model::Engine engine_at(int row) const

Returns the engine of a row as store writes it.

The label is trimmed; an empty label becomes Engine n, where n is row plus one.

Parameters

Name Type Description
row int The row index in the engine table.

Returns core::model::Engine: The engine with its label, running flag, revolutions and coolant temperature.

Preconditions

Declared in src/app/dialogs/vessel_page.hpp:109 · defined in src/app/dialogs/vessel_page.cpp:173

set_engine()

void set_engine(int row, const core::model::Engine& engine)

Replaces the values shown in an engine row.

The label is shown as given; the revolutions and temperature are clamped to the ranges of their spin boxes.

Parameters

Name Type Description
row int The row index in the engine table.
engine const core::model::Engine& The values to show; only read during the call.

Preconditions

Declared in src/app/dialogs/vessel_page.hpp:118 · defined in src/app/dialogs/vessel_page.cpp:187

Public data members

engines_table

QTableWidget* engines_table

One row per engine, core::model::VesselState::engines in order, with the columns of EngineColumn.

The first row is engine 1 in RPM and ENGINE#0 in XDR, and the Signal K id of an engine is derived from its label. The revolutions cell accepts [0, 99999.9] and shows whole revolutions per minute; the temperature cell accepts [-50, 500] °C with one decimal.

Declared in src/app/dialogs/vessel_page.hpp:127

add_engine_button

QPushButton* add_engine_button

The Add engine button, which calls add_engine.

Declared in src/app/dialogs/vessel_page.hpp:129

remove_engine_button

QPushButton* remove_engine_button

The Remove button, which calls remove_current_engine.

Declared in src/app/dialogs/vessel_page.hpp:131

mmsi_spin

QSpinBox* mmsi_spin

Maritime Mobile Service Identity, core::model::AisStatic::mmsi; [0, 999999999], at most nine digits.

0 is accepted by the widget but refused by validate.

Declared in src/app/dialogs/vessel_page.hpp:135

imo_spin

QSpinBox* imo_spin

IMO number, core::model::AisStatic::imo_number; [0, 999999999], shown as None when 0, the value for a vessel without one.

Declared in src/app/dialogs/vessel_page.hpp:138

name_edit

QLineEdit* name_edit

Vessel name, core::model::AisStatic::name; at most 20 characters, the length of the name field of message 5.

Trimmed and upper-cased by store.

Declared in src/app/dialogs/vessel_page.hpp:141

call_sign_edit

QLineEdit* call_sign_edit

Call sign, core::model::AisStatic::call_sign; at most 7 characters, the length of the call sign field of message 5.

Trimmed and upper-cased by store.

Declared in src/app/dialogs/vessel_page.hpp:144

ship_type_spin

QSpinBox* ship_type_spin

Type of ship and cargo code, core::model::AisStatic::ship_type; [0, 255], the range of the 8-bit field of message 5.

Declared in src/app/dialogs/vessel_page.hpp:147

to_bow_spin

QDoubleSpinBox* to_bow_spin

Distance from the GNSS antenna to the bow, core::model::AisStatic::dimension_to_bow_m; [0, 511] whole metres, the range of the 9-bit field of message 5.

Declared in src/app/dialogs/vessel_page.hpp:150

to_stern_spin

QDoubleSpinBox* to_stern_spin

Distance from the GNSS antenna to the stern, core::model::AisStatic::dimension_to_stern_m; [0, 511] whole metres, the range of the 9-bit field of message 5.

Declared in src/app/dialogs/vessel_page.hpp:154

to_port_spin

QDoubleSpinBox* to_port_spin

Distance from the GNSS antenna to port, core::model::AisStatic::dimension_to_port_m; [0, 63] whole metres, the range of the 6-bit field of message 5.

Declared in src/app/dialogs/vessel_page.hpp:157

to_starboard_spin

QDoubleSpinBox* to_starboard_spin

Distance from the GNSS antenna to starboard, core::model::AisStatic::dimension_to_starboard_m; [0, 63] whole metres, the range of the 6-bit field of message 5.

Declared in src/app/dialogs/vessel_page.hpp:161

draught_spin

QDoubleSpinBox* draught_spin

Maximum present static draught, core::model::AisStatic::draught_m; [0, 25.5] m with one decimal, the tenths of a metre that message 5 carries.

Declared in src/app/dialogs/vessel_page.hpp:164

ais_destination_edit

QLineEdit* ais_destination_edit

Voyage destination, core::model::AisStatic::destination; at most 20 characters, the length of the destination field of message 5, and empty for none.

Trimmed and upper-cased by store.

Declared in src/app/dialogs/vessel_page.hpp:168

QSpinBox* navigation_status_spin

Navigational status code, core::model::AisStatic::navigation_status; [0, 15], the range of the 4-bit field of the position report.

0 is under way using engine, 1 at anchor, 5 moored and 8 under way sailing.

Declared in src/app/dialogs/vessel_page.hpp:172

report_type_combo

QComboBox* report_type_combo

Position report message type 1, 2 or 3, as index 0 to 2.

Edits core::model::AisStatic::position_report_type: type 1 is scheduled, 2 assigned and 3 sent in response to an interrogation.

Declared in src/app/dialogs/vessel_page.hpp:177

Private member functions

append_engine_row()

void append_engine_row(const core::model::Engine& engine)

Appends a row that shows an engine, without selecting it.

Creates the label and running items and the revolutions and temperature spin boxes, all owned by engines_table. Used by load and add_engine.

Parameters

Name Type Description
engine const core::model::Engine& The values to show; only read during the call.

Declared in src/app/dialogs/vessel_page.hpp:186 · defined in src/app/dialogs/vessel_page.cpp:135