ifw-ccf  3.0.0-pre2
procThread.hpp
Go to the documentation of this file.
1 
5 #ifndef CCF_CONTROL_PROC_THREAD_HPP_H_
6 #define CCF_CONTROL_PROC_THREAD_HPP_H_
7 
8 #include <ccf/common/base.hpp>
12 
13 namespace ccf::control {
14 
16  class ProcThread: public ccf::mptk::Thread, public ccf::Base {
17  public:
18 
20  static void SetStatusAll(const ccf::ProcStatus status);
21 
23  ProcThread(const std::string& thread_name,
24  ccf::mptk::MessageBus& message_bus,
25  const double period = 0.1);
26 
27  virtual ~ProcThread();
28 
30  void Initialise();
31 
33  virtual void UserLogic();
34 
36  void SetInputQ(std::shared_ptr<ccf::common::FrameQueue>& queue);
37 
40 
42  void SetOutputQ(std::shared_ptr<ccf::common::FrameQueue>& queue);
43 
46 
48  void SetStatus(const ccf::ProcStatus status);
49 
51  ccf::ProcStatus GetStatus() const;
52 
53  // TODO: Remove these. Use the repository in ccf::common::RecipeBase.
54  void AddRecipe(std::shared_ptr<ccf::common::RecipeBase>& recipe_obj);
55  uint8_t NbOfRecipes() const;
56  const ccf::common::RecipeBase& GetRecipe(const uint16_t nb);
57 
60 
61  protected:
62 
63  private:
64  bool _CheckMessageBus(bool& new_data_available,
65  bool& new_setup);
66  void _CopyAndReleaseFrameHandle();
67  void _ExecuteRecipes();
68  void _SubmitAndNotify();
69  void _HandleNewSetup();
70 
71  bool m_allow_frame_skippping;
72  double m_time_for_last_frame_skipping_log;
73 
74  // Names of Publisher Threads associated with this Processing Thread.
75  std::vector<std::string> m_pub_thr_names;
76 
77  ccf::ProcStatus m_proc_thread_status; // Used to avoid updating OLDB/PubSub unnecessarily.
78 
79  std::list<std::shared_ptr<ccf::common::RecipeBase>> m_recipes;
80 
81  // Map to find Recipe objects easily by means of the Instance ID.
82  std::map<std::string, std::shared_ptr<ccf::common::RecipeBase>> m_recipe_map;
83 
84  // Note: The queues are allocated and deleted by the ccf::control::application class.
85  std::shared_ptr<ccf::common::FrameQueue> m_input_q;
86  std::shared_ptr<ccf::common::FrameQueue> m_output_q;
87 
88  ccf::mptk::Message m_cur_msg; // Current thread message being handled.
89  ccf::common::DataFrame m_cur_frame; // Current data frame being handled.
90 
91  ccf::common::FrameStatistics m_frame_stat;
92 
93  bool m_pipeline_enabled;
94  };
95 
96 }
97 
98 #endif // CCF_CONTROL_PROC_THREAD_HPP_H_
Class to be used as parent all CCF classes.
Definition: base.hpp:151
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
Processing Recipe base class. All recipes shall be derived from this class.
Definition: recipeBase.hpp:47
Processing Thread MPTK Thread implementation (see also ccf::mptk::Thread).
Definition: procThread.hpp:16
void SetStatus(const ccf::ProcStatus status)
Set the Processing Status of this Processing Thread.
Definition: procThread.cpp:262
virtual void UserLogic()
Implements the user logic, executed periodically.
Definition: procThread.cpp:72
ccf::ProcStatus GetStatus() const
Return the Processing Status of this Processing Thread.
Definition: procThread.cpp:288
void SetInputQ(std::shared_ptr< ccf::common::FrameQueue > &queue)
Set reference to the Application Input Queue from which the thread gets the frames.
Definition: procThread.cpp:236
uint8_t NbOfRecipes() const
Definition: procThread.cpp:307
ProcThread(const std::string &thread_name, ccf::mptk::MessageBus &message_bus, const double period=0.1)
See ccf::mptk::Thread.
Definition: procThread.cpp:30
virtual ~ProcThread()
Definition: procThread.cpp:41
static void SetStatusAll(const ccf::ProcStatus status)
Set the status of all Processing Threads running.
Definition: procThread.cpp:13
void AddRecipe(std::shared_ptr< ccf::common::RecipeBase > &recipe_obj)
Definition: procThread.cpp:293
void Initialise()
Initialise the thread object.
Definition: procThread.cpp:56
ccf::common::FrameQueue & GetOutputQ()
Get reference to the Output Queue of this Processing Thread.
Definition: procThread.cpp:254
const ccf::common::RecipeBase & GetRecipe(const uint16_t nb)
Definition: procThread.cpp:312
ccf::common::FrameQueue & GetInputQ()
Get reference to the Application Input Queue from which the thread gets the frames.
Definition: procThread.cpp:241
ccf::common::FrameStatistics & GetFrameStat()
Get reference to frame handling statistics.
Definition: procThread.cpp:323
void SetOutputQ(std::shared_ptr< ccf::common::FrameQueue > &queue)
Set reference to the Output Queue of this Processing Thread.
Definition: procThread.cpp:249
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
ProcStatus
Possible states for a Processing Recipe defined.
Definition: base.hpp:289