RTC Toolkit  1.0.0
Public Member Functions | List of all members
rtctk::telSub::OperationalLogic Class Referencefinal

Implements the behaviour for Operational state. More...

#include <operationalLogic.hpp>

Inheritance diagram for rtctk::telSub::OperationalLogic:
rtctk::telSub::OperationalLogicIf

Public Member Functions

 OperationalLogic (OperationalParams params, std::unique_ptr< CorrelatorIf > &&correlator, std::unique_ptr< ShmPublisherIf > &&shm_publisher, 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...
 
std::error_code 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 ()
 

Detailed Description

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.

Monitoring

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).

SHM Queue

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.

Synchronization

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.

Thread Safety
thread-compatibleOperationalLogic interacts both with component framework main thread and the private correlator worker thread. If not documented explicitly all methods are thread compatible.

Constructor & Destructor Documentation

◆ OperationalLogic()

rtctk::telSub::OperationalLogic::OperationalLogic ( OperationalParams  params,
std::unique_ptr< CorrelatorIf > &&  correlator,
std::unique_ptr< ShmPublisherIf > &&  shm_publisher,
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.

Parameters
paramsParameters.
correlatorCorrelator.
shm_publisherShared memory publisher.
resourceMemory resource which, if valid, may be used by correlator and shm_publisher and should be destroyed last.
memoryMemory resource which, if valid, may be used by correlator and shm_publisher and should be destroyed last.

◆ ~OperationalLogic()

rtctk::telSub::OperationalLogic::~OperationalLogic ( )
noexcept

Requests threads to exit and joins with it.

Member Function Documentation

◆ GetErrorCount()

uint64_t rtctk::telSub::OperationalLogic::GetErrorCount ( ) const
overridevirtual

Get current error count.

Returns
Thread Safety
thread-safe

Implements rtctk::telSub::OperationalLogicIf.

◆ GetLastError()

std::error_code rtctk::telSub::OperationalLogic::GetLastError ( ) const
overridevirtual

Return last recorded error.

Thread Safety
thread-safe

Implements rtctk::telSub::OperationalLogicIf.

◆ IdleAsync()

void rtctk::telSub::OperationalLogic::IdleAsync ( )
overridevirtual

Stop publishing.

Thread Safety
thread-safe

Implements rtctk::telSub::OperationalLogicIf.

◆ RunAsync()

void rtctk::telSub::OperationalLogic::RunAsync ( )
overridevirtual

Start publishing.

Postcondition
Error count is reset to 0.
Thread Safety
thread-safe

Implements rtctk::telSub::OperationalLogicIf.


The documentation for this class was generated from the following files: