ifw-ccf  3.0.0-pre2
acqThread.hpp
Go to the documentation of this file.
1 
5 #ifndef IFW_CCF_CTL_ACQ_THREAD_HPP_
6 #define IFW_CCF_CTL_ACQ_THREAD_HPP_
7 
8 #include <boost/exception/diagnostic_information.hpp>
9 
10 #include <ccf/common/base.hpp>
11 #include <ccf/common/utilities.hpp>
13 
14 namespace ccf::control {
15 
17  const double FRAME_RECV_TIMEOUT = 0.100;
18 
20  class AcqThread: public ccf::mptk::Thread {
21  public:
22 
24  const double NO_FRAME_RECV_SLEEP_TIME = 0.001;
25 
27  AcqThread(const std::string& thread_name,
28  ccf::mptk::MessageBus& message_bus,
29  const double period = 0.1);
30 
31  virtual ~AcqThread();
32 
33  void Initialise();
34 
36  void ResetCounters();
37 
39  void SetInputQ(std::shared_ptr<ccf::common::FrameQueue>& queue);
40 
43 
45  virtual void UserLogic();
46 
49 
50  private:
51  bool m_allow_frame_skippping;
52 
53  // Current data frame used for receiving data. Should not be shared_ptr.
54  ccf::common::DataFrame* m_cur_frame;
55 
56  ccf::common::DataFrame m_spare_frame;
57  uint64_t m_iteration_count;
58  uint64_t m_iterations_since_start_count;
59  uint64_t m_frames_acquired;
60 
61  double m_time_last_no_free_input_frames_log;
62  double m_time_for_last_cam_check;
63 
64  void _GetFreeFrame(uint8_t attempts);
65  void _ReceiveFrame(bool& frame_received,
66  double& fr_reception_time);
67  void _HandleFrameRecvStatus();
68  void _SubmitAndNotify();
69  void _CheckCameraHealth();
70  void _CheckMessageBus(bool& new_setup);
71  void _AssessAndUpdateAcqStatus();
72  void _HandleNewSetup(ccf::Status status,
73  std::string& diagnostics);
74 
75  // Note: The queues are allocated and deleted by the ccf::control::application class.
76  std::shared_ptr<ccf::common::FrameQueue> m_input_q;
77  ccf::mptk::Message m_cur_msg; // Current thread message being handled.
78 
79  ccf::common::FrameStatistics m_frame_stat;
80  };
81 
82 }
83 
84 #endif // IFW_CCF_CTL_ACQ_THREAD_HPP_
Frame class used to store the data and metadata for one frames received from the camera.
Definition: dataFrame.hpp:17
The FrameQueue class implements a queue, to manage a set of CCF DataFrame instances as a ring buffer.
Definition: frameQueue.hpp:14
Class used by the threads to store info for generating performance statistics.
Definition: utilities.hpp:25
CCF Acquisition Thread, handling the reception of image data from the camera.
Definition: acqThread.hpp:20
ccf::common::FrameStatistics & GetFrameStat()
Get reference to frame handling statistics.
Definition: acqThread.cpp:280
void SetInputQ(std::shared_ptr< ccf::common::FrameQueue > &queue)
Set reference to the Application Input Queue.
Definition: acqThread.cpp:39
void Initialise()
Definition: acqThread.cpp:27
void ResetCounters()
Reset counters for the internal household.
Definition: acqThread.cpp:52
AcqThread(const std::string &thread_name, ccf::mptk::MessageBus &message_bus, const double period=0.1)
Acquisition Thread, handling the interfacing and data acquisition from the camera.
Definition: acqThread.cpp:12
virtual ~AcqThread()
Definition: acqThread.cpp:23
ccf::common::FrameQueue & GetInputQ()
Get refrence to the Application Input Queue.
Definition: acqThread.cpp:44
const double NO_FRAME_RECV_SLEEP_TIME
Sleep to apply when no frame is available.
Definition: acqThread.hpp:24
virtual void UserLogic()
Acquisition Thread user logic.
Definition: acqThread.cpp:62
IFW CTD Multiprocessing Toolkit Message Bus.
Definition: messageBus.hpp:91
IFW CTD Multiprocessing Toolkit Message class.
Definition: message.hpp:19
IFW CTD Multiprocessing Toolkit Thread base class.
Definition: thread.hpp:29
Definition: acqThread.cpp:10
const double FRAME_RECV_TIMEOUT
Timeout to apply, waiting for the next frame.
Definition: acqThread.hpp:17
Status
General status variable.
Definition: base.hpp:201