RTC Toolkit
2.0.0
|
Implements the behaviour for Operational state. More...
#include <operationalLogic.hpp>
Public Member Functions | |
OperationalLogic (OperationalParams params, std::unique_ptr< CorrelatorIf > &&correlator, std::unique_ptr< ShmPublisherIf > &&shm_publisher, componentFramework::ComponentMetricsIf &metrics, componentFramework::AlertSourceFactoryIf &alerts, std::unique_ptr< std::pmr::monotonic_buffer_resource > &&resource={}, std::unique_ptr< std::byte[]> &&memory={}) | |
Spawns reader thread and starts subscribing to DDS data, but does not publish until StartAsync() is invoked. More... | |
~OperationalLogic () noexcept | |
Requests threads to exit and joins with it. More... | |
void | RunAsync () RTCTK_NOEXCEPT override |
Start publishing. More... | |
void | IdleAsync () RTCTK_NOEXCEPT override |
Stop publishing. More... | |
LastError | GetLastError () const RTCTK_NOEXCEPT override |
Return last recorded error. More... | |
uint64_t | GetErrorCount () const RTCTK_NOEXCEPT override |
Get current error count. More... | |
Public Member Functions inherited from rtctk::telSub::OperationalLogicIf | |
virtual | ~OperationalLogicIf () |
Implements the behaviour for Operational state.
Main purpose is to take ownership of DDS subscriber and SHM publisher to create isolation between objects to limit thread safe requirements such that no synchronization between m_dds_subscriber and m_shm_publisher is needed.
OperationalLogic also acts as the broker/intermediator between DdsSubscriber and ShmPublisher. as such it is in a position to uniquely enable or disable data flow based on request from user with GoingRunning/GoingIdle.
Due to performance requirements the path between DDS subscriber and SHM publisher must keep a low overhead. This means that non-fatal errors are not thrown.
Non-fatal errors are reported using light-weight counters that can be monitored independently from a lower priority thread (TBC).
OperationalLogic is responsible for the delay between closing the SHM queue and deleting the shm_publisher object, as configured with OperationalParams::close_detach_delay
.
If SHM object is still reachable after ShmPublisher has been deleted, it means that some reader have not detached as they should, which OperationalLogic is then responsible for raising an operator alarm/error.
Non-fatal errors that occur when Idle are ignored.
The running thread is doing a relaxed synchronization with the requested state. This will reduce synchronization overhead with the downside that StartAsync()
and StopAsync()
are non-blocking and will return before requested state has changed.
The only blocking operation is the destruction of OperationalLogic which synchronizes and joins with the thread.
rtctk::telSub::OperationalLogic::OperationalLogic | ( | OperationalParams | params, |
std::unique_ptr< CorrelatorIf > && | correlator, | ||
std::unique_ptr< ShmPublisherIf > && | shm_publisher, | ||
componentFramework::ComponentMetricsIf & | metrics, | ||
componentFramework::AlertSourceFactoryIf & | alerts, | ||
std::unique_ptr< std::pmr::monotonic_buffer_resource > && | resource = {} , |
||
std::unique_ptr< std::byte[]> && | memory = {} |
||
) |
Spawns reader thread and starts subscribing to DDS data, but does not publish until StartAsync()
is invoked.
params | Parameters. |
correlator | Correlator. |
shm_publisher | Shared memory publisher. |
metrics | the ComponentMetricsIf service to use. |
resource | Memory resource which, if valid, may be used by correlator and shm_publisher and should be destroyed last. |
memory | Memory resource which, if valid, may be used by correlator and shm_publisher and should be destroyed last. |
|
noexcept |
Requests threads to exit and joins with it.
|
overridevirtual |
Get current error count.
Implements rtctk::telSub::OperationalLogicIf.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Start publishing.
Implements rtctk::telSub::OperationalLogicIf.