SentenceScheduler¶
class nmeasim::core::simulation::SentenceScheduler · Library API
The per-sentence enable flags, talkers and periods, plus the operator's custom sentences, with the time each one is next due.
#include <nmeasim/core/simulation/sentence_scheduler.hpp>
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp (line 80)
There is one entry for every descriptor of the registry, starting at the registry defaults; ids not in the registry are ignored by every setter. The schedule runs on the simulated time passed to due: everything enabled is due at the first call, and each sentence is then due again as next_due_after decides. Changing a setting does not move the time a sentence is next due.
The scheduler keeps a pointer to its registry, which must outlive it; the default, nmea0183::SentenceRegistry::standard(), lives for the whole program. Copies share the registry.
Nested types¶
| Type | Description |
|---|---|
SentenceScheduler::Entry |
Schedule of one registry sentence. |
SentenceScheduler::CustomEntry |
Schedule of one accepted custom sentence. |
Summary¶
Public member functions
| Name | Description |
|---|---|
SentenceScheduler() |
Builds a schedule with every registry sentence at its default enable flag, talker and period, and no custom sentences. |
registry() |
Returns the registry the schedule was built from. |
setting() |
Returns the setting of a sentence. |
configure() |
Replaces the setting of a sentence. |
set_enabled() |
Enables or disables one sentence. |
set_group_enabled() |
Enables or disables every registry sentence of a group. |
set_period_for_all() |
Sets every registry sentence to the same period; custom sentences keep their own. |
effective_talker() |
Returns the talker a sentence is sent with after overrides. |
encoder_options() |
Returns the formatting options passed to every encoder. |
set_encoder_options() |
Replaces the formatting options passed to every encoder. |
set_custom_sentences() |
Replaces the operator's custom sentences. |
custom_sentences() |
Returns the custom sentences accepted by the last set_custom_sentences. |
due() |
Encodes every enabled sentence that is due at now and schedules its next emission. |
encode_all() |
Encodes every enabled sentence regardless of schedule, for example for a preview. |
reset() |
Forgets the emission history, so that every enabled sentence, custom ones included, is due at the next call to due. |
Private data members
| Name | Description |
|---|---|
registry_ |
The catalogue scheduled; not owned, never null. |
entries_ |
One entry per registry id, keyed by id; the transparent comparator allows lookup by std::string_view. |
options_ |
Formatting options passed to every encoder. |
custom_ |
The accepted custom sentences, as returned by custom_sentences. |
custom_entries_ |
The schedule of each accepted custom sentence, in the same order as custom_. |
Public member functions¶
SentenceScheduler()¶
explicit SentenceScheduler(
const nmea0183::SentenceRegistry& registry = nmea0183::SentenceRegistry::standard())
Builds a schedule with every registry sentence at its default enable flag, talker and period, and no custom sentences.
Parameters
| Name | Type | Description |
|---|---|---|
registry |
const nmea0183::SentenceRegistry& |
The sentence catalogue to schedule; it must outlive the scheduler. |
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:86 · defined in src/core/src/simulation/sentence_scheduler.cpp:21
registry()¶
const nmea0183::SentenceRegistry& registry() const noexcept
Returns the registry the schedule was built from.
Returns const nmea0183::SentenceRegistry&: The registry given to the constructor.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:92
setting()¶
SentenceSetting setting(std::string_view id) const
Returns the setting of a sentence.
Parameters
| Name | Type | Description |
|---|---|---|
id |
std::string_view |
Registry id, such as RMC or MWV-T. |
Returns SentenceSetting: The current setting, or a disabled setting with an empty talker and a zero period when id is not in the registry.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:99 · defined in src/core/src/simulation/sentence_scheduler.cpp:31
configure()¶
void configure(std::string_view id, SentenceSetting setting)
Replaces the setting of a sentence.
Parameters
| Name | Type | Description |
|---|---|---|
id |
std::string_view |
Registry id; an unknown id is ignored. |
setting |
SentenceSetting |
The new setting. A zero or negative period is replaced by the registry default. |
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:105 · defined in src/core/src/simulation/sentence_scheduler.cpp:39
set_enabled()¶
void set_enabled(std::string_view id, bool enabled)
Enables or disables one sentence.
Parameters
| Name | Type | Description |
|---|---|---|
id |
std::string_view |
Registry id; an unknown id is ignored. |
enabled |
bool |
Whether the sentence is emitted. |
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:110 · defined in src/core/src/simulation/sentence_scheduler.cpp:50
set_group_enabled()¶
void set_group_enabled(nmea0183::SentenceGroup group, bool enabled)
Enables or disables every registry sentence of a group.
Parameters
| Name | Type | Description |
|---|---|---|
group |
nmea0183::SentenceGroup |
The functional group, such as the wind sentences. |
enabled |
bool |
Whether the sentences of the group are emitted. |
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:115 · defined in src/core/src/simulation/sentence_scheduler.cpp:57
set_period_for_all()¶
void set_period_for_all(std::chrono::milliseconds period)
Sets every registry sentence to the same period; custom sentences keep their own.
Parameters
| Name | Type | Description |
|---|---|---|
period |
std::chrono::milliseconds |
The new interval; zero or a negative value is ignored and changes nothing. |
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:120 · defined in src/core/src/simulation/sentence_scheduler.cpp:65
effective_talker()¶
std::string_view effective_talker(const nmea0183::SentenceDescriptor& descriptor) const
Returns the talker a sentence is sent with after overrides.
Parameters
| Name | Type | Description |
|---|---|---|
descriptor |
const nmea0183::SentenceDescriptor& |
The registry descriptor of the sentence. |
Returns std::string_view: The talker of the sentence's setting when it is not empty and is_valid_talker accepts it, otherwise the registry default. The view refers either to a string held by this scheduler, valid until that sentence's setting changes or the scheduler is destroyed, or to the registry's static text.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:129 · defined in src/core/src/simulation/sentence_scheduler.cpp:80
encoder_options()¶
nmea0183::EncoderOptions encoder_options() const noexcept
Returns the formatting options passed to every encoder.
Returns nmea0183::EncoderOptions: A copy of the options.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:135
set_encoder_options()¶
void set_encoder_options(nmea0183::EncoderOptions options) noexcept
Replaces the formatting options passed to every encoder.
Parameters
| Name | Type | Description |
|---|---|---|
options |
nmea0183::EncoderOptions |
The new options, for example the number of position decimals. |
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:139
set_custom_sentences()¶
void set_custom_sentences(const std::vector<CustomSentence>& sentences)
Replaces the operator's custom sentences.
Each sentence is taken over with these changes: an empty id becomes CUSTOM-n, where n is its 1-based position in sentences (effective_custom_id); a zero or negative period becomes one second. A sentence whose body frame_custom_sentence refuses, or whose id (after filling in) is a registry id or the id of a sentence accepted before it, is dropped. Disabled sentences are kept. The accepted sentences are due at the next call to due; they are emitted after the registry ones, in list order.
Parameters
| Name | Type | Description |
|---|---|---|
sentences |
const std::vector<CustomSentence>& |
The custom sentences, in the order they are to be emitted; an empty list removes them all. |
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:153 · defined in src/core/src/simulation/sentence_scheduler.cpp:106
custom_sentences()¶
const std::vector<CustomSentence>& custom_sentences() const noexcept
Returns the custom sentences accepted by the last set_custom_sentences.
Returns const std::vector<CustomSentence>&: The accepted sentences with ids and periods filled in, in list order. The reference is valid until the next set_custom_sentences or the scheduler's destruction.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:159
due()¶
std::vector<EmittedSentence> due(std::chrono::milliseconds now, const model::VesselState& state)
Encodes every enabled sentence that is due at now and schedules its next emission.
A sentence is due when now is at or after its next due time; that time is then advanced with next_due_after. Each registry sentence is encoded from state with its effective talker and the encoder options, lowering the position precision when a sentence would otherwise exceed the length limit.
Parameters
| Name | Type | Description |
|---|---|---|
now |
std::chrono::milliseconds |
Simulated time since the start or the last reset. Successive calls are expected with times that never decrease. |
state |
const model::VesselState& |
The vessel state to encode. |
Returns std::vector<EmittedSentence>: The due sentences without line terminators: registry sentences in registry order (a sentence that needs several lines, such as GSV, contributes all of them), then custom sentences in list order. Empty when nothing is due.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:176 · defined in src/core/src/simulation/sentence_scheduler.cpp:127
encode_all()¶
std::vector<EmittedSentence> encode_all(const model::VesselState& state) const
Encodes every enabled sentence regardless of schedule, for example for a preview.
The schedule is not changed.
Parameters
| Name | Type | Description |
|---|---|---|
state |
const model::VesselState& |
The vessel state to encode. |
Returns std::vector<EmittedSentence>: The same sentences, in the same order, as due returns when everything is due.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:186 · defined in src/core/src/simulation/sentence_scheduler.cpp:150
reset()¶
void reset()
Forgets the emission history, so that every enabled sentence, custom ones included, is due at the next call to due.
Settings and custom sentences are kept.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:192 · defined in src/core/src/simulation/sentence_scheduler.cpp:168
Private data members¶
registry_¶
const nmea0183::SentenceRegistry* registry_
The catalogue scheduled; not owned, never null.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:214
entries_¶
std::map<std::string, Entry, std::less<>> entries_
One entry per registry id, keyed by id; the transparent comparator allows lookup by std::string_view.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:217
options_¶
nmea0183::EncoderOptions options_{}
Formatting options passed to every encoder.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:219
custom_¶
std::vector<CustomSentence> custom_
The accepted custom sentences, as returned by custom_sentences.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:221
custom_entries_¶
std::vector<CustomEntry> custom_entries_
The schedule of each accepted custom sentence, in the same order as custom_.
Declared in src/core/include/nmeasim/core/simulation/sentence_scheduler.hpp:223