![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
Class that offers an easy way to run a background monitorin thread that periodically inspects and reports information about the camera interface passed as argument. More...
#include <monitor.hpp>
Public Member Functions | |
StatusMonitor (const Interface &cam, irsol::types::duration_t monitorInterval=std::chrono::milliseconds(100)) | |
Constructs a StatusMonitor for the given camera interface. | |
~StatusMonitor () | |
Destructor stops the monitoring thread if running. | |
void | start () |
Starts the monitoring thread. If the monitor is already running, this call has no effect. | |
void | stop () |
Stops the monitoring thread and waits for it to finish. If the monitor is not running, this call has no effect. | |
Protected Member Functions | |
virtual void | runMonitor () const |
The main monitoring loop executed on the background thread. | |
Private Attributes | |
const irsol::camera::Interface & | m_cam |
Reference to the camera interface being monitored. | |
irsol::types::duration_t | m_monitorInterval |
Interval at which the monitor thread executes runMonitor() | |
std::atomic< bool > | m_hasStartedMonitor |
Flag indicating if the monitor thread has been started. | |
std::thread | m_monitorThread |
Thread running the periodic monitoring loop. | |
Class that offers an easy way to run a background monitorin thread that periodically inspects and reports information about the camera interface passed as argument.
Check out 01-loading-images for an example usage.
Definition at line 43 of file monitor.hpp.
irsol::camera::StatusMonitor::StatusMonitor | ( | const Interface & | cam, |
irsol::types::duration_t | monitorInterval = std::chrono::milliseconds(100) |
||
) |
Constructs a StatusMonitor for the given camera interface.
cam | Reference to the camera interface to monitor. |
monitorInterval | Interval at which the monitoring task should run. Defaults to 100ms. |
Definition at line 9 of file monitor.cpp.
irsol::camera::StatusMonitor::~StatusMonitor | ( | ) |
Destructor stops the monitoring thread if running.
Definition at line 15 of file monitor.cpp.
|
protectedvirtual |
The main monitoring loop executed on the background thread.
Override this method in derived classes to implement specific monitoring logic. It is called repeatedly with the frequency specified by monitorInterval.
Definition at line 24 of file monitor.cpp.
void irsol::camera::StatusMonitor::start | ( | ) |
Starts the monitoring thread. If the monitor is already running, this call has no effect.
Definition at line 42 of file monitor.cpp.
void irsol::camera::StatusMonitor::stop | ( | ) |
Stops the monitoring thread and waits for it to finish. If the monitor is not running, this call has no effect.
Definition at line 52 of file monitor.cpp.
|
private |
Reference to the camera interface being monitored.
Definition at line 83 of file monitor.hpp.
|
private |
Flag indicating if the monitor thread has been started.
Definition at line 89 of file monitor.hpp.
|
private |
Interval at which the monitor thread executes runMonitor()
Definition at line 86 of file monitor.hpp.
|
private |
Thread running the periodic monitoring loop.
Definition at line 92 of file monitor.hpp.