ifw-ccf  2.0.0
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 std::string GenId(const std::string& proc_thread_name);
21 
23  static void SetStatusAll(const ccf::ProcStatus status);
24 
26  ProcThread(const std::string& thread_id,
27  ccf::mptk::MessageBus& message_bus,
28  const double period = 0.1);
29 
30  virtual ~ProcThread();
31 
33  void Initialise();
34 
36  virtual void UserLogic();
37 
39  void SetInputQ(std::shared_ptr<ccf::common::FrameQueue>& queue);
40 
43 
45  void SetOutputQ(std::shared_ptr<ccf::common::FrameQueue>& queue);
46 
49 
51  void SetStatus(const ccf::ProcStatus status);
52 
54  ccf::ProcStatus GetStatus() const;
55 
56  // TODO: Remove these. Use the repository in ccf::common::RecipeBase.
57  void AddRecipe(std::shared_ptr<ccf::common::RecipeBase>& recipe_obj);
58  uint8_t NbOfRecipes() const;
59  const ccf::common::RecipeBase& GetRecipe(const uint16_t nb);
60 
62  std::string GetProcThreadId() const;
63 
65  std::string GetProcThreadName() const;
66 
69 
70  protected:
71 
72  private:
73  bool _CheckMessageBus(bool& new_data_available,
74  bool& new_setup);
75  void _CopyAndReleaseFrameHandle();
76  void _ExecuteRecipes();
77  void _SubmitAndNotify();
78  void _HandleNewSetup();
79 
80  bool m_allow_frame_skippping;
81  double m_time_for_last_frame_skipping_log;
82 
83  std::string m_proc_thread_id;
84  std::string m_proc_thread_name;
85 
86  std::vector<std::string> m_pub_thr_ids;
87 
88  ccf::ProcStatus m_proc_thread_status; // Used to avoid updating OLDB/PubSub unnecessarily.
89 
90  std::list<std::shared_ptr<ccf::common::RecipeBase>> m_recipes;
91 
92  // Map to find Recipe objects easily by means of the Instance ID.
93  std::map<std::string, std::shared_ptr<ccf::common::RecipeBase>> m_recipe_map;
94 
95  // Note: The queues are allocated and deleted by the ccf::control::application class.
96  std::shared_ptr<ccf::common::FrameQueue> m_input_q;
97  std::shared_ptr<ccf::common::FrameQueue> m_output_q;
98 
99  ccf::mptk::Message m_cur_msg; // Current thread message being handled.
100  ccf::common::DataFrame m_cur_frame; // Current data frame being handled.
101 
102  ccf::common::FrameStatistics m_frame_stat;
103 
104  bool m_proc_enabled;
105  };
106 
107 }
108 
109 #endif // CCF_CONTROL_PROC_THREAD_HPP_H_
ccf::Base
Class to be used as parent all CCF classes.
Definition: base.hpp:152
ccf::control::ProcThread::SetStatus
void SetStatus(const ccf::ProcStatus status)
Set the Processing Status of this Processing Thread.
Definition: procThread.cpp:271
ccf::control::ProcThread::NbOfRecipes
uint8_t NbOfRecipes() const
Definition: procThread.cpp:316
frameQueue.hpp
ccf::control::ProcThread::UserLogic
virtual void UserLogic()
Implements the user logic, executed periodically.
Definition: procThread.cpp:84
ccf::control::ProcThread::GetProcThreadId
std::string GetProcThreadId() const
Return the ID of the Proc Thread.
ccf::mptk::Thread
IFW CTD Multiprocessing Toolkit Thread base class.
Definition: thread.hpp:29
ccf::control::ProcThread::GenId
static std::string GenId(const std::string &proc_thread_name)
Generate the Processing Thread ID used for the interthread communication.
Definition: procThread.cpp:13
ccf::control::ProcThread::ProcThread
ProcThread(const std::string &thread_id, ccf::mptk::MessageBus &message_bus, const double period=0.1)
See ccf::mptk::Thread.
Definition: procThread.cpp:35
ccf::control::ProcThread::GetProcThreadName
std::string GetProcThreadName() const
Return the name of the Proc Thread defined in the cfg.
Definition: procThread.cpp:79
ccf::control::ProcThread::GetInputQ
ccf::common::FrameQueue & GetInputQ()
Get reference to the Application Input Queue from which the thread gets the frames.
Definition: procThread.cpp:250
ccf::ProcStatus
ProcStatus
Possible states for a Processing Recipe defined.
Definition: base.hpp:303
ccf::control::ProcThread::SetInputQ
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:245
ccf::mptk::MessageBus
IFW CTD Multiprocessing Toolkit Message Bus.
Definition: messageBus.hpp:30
ccf::control::ProcThread::AddRecipe
void AddRecipe(std::shared_ptr< ccf::common::RecipeBase > &recipe_obj)
Definition: procThread.cpp:302
ccf::control::ProcThread::GetStatus
ccf::ProcStatus GetStatus() const
Return the Processing Status of this Processing Thread.
Definition: procThread.cpp:297
ccf::mptk::Message
IFW CTD Multiprocessing Toolkit Message class.
Definition: message.hpp:19
ccf::control::ProcThread::Initialise
void Initialise()
Initialise the thread object.
Definition: procThread.cpp:66
ccf::control::ProcThread::GetFrameStat
ccf::common::FrameStatistics & GetFrameStat()
Get reference to frame handling statistics.
Definition: procThread.cpp:332
ccf::control::ProcThread::SetOutputQ
void SetOutputQ(std::shared_ptr< ccf::common::FrameQueue > &queue)
Set reference to the Output Queue of this Processing Thread.
Definition: procThread.cpp:258
ccf::common::FrameQueue
The FrameQueue class implements a queue, to manage a set of CCF DataFrame instances as a ring buffer.
Definition: frameQueue.hpp:14
ccf::control::ProcThread
Processing Thread MPTK Thread implementation (see also ccf::mptk::Thread).
Definition: procThread.hpp:16
base.hpp
ccf::control::ProcThread::SetStatusAll
static void SetStatusAll(const ccf::ProcStatus status)
Set the status of all Processing Threads running.
Definition: procThread.cpp:17
ccf::control::ProcThread::GetOutputQ
ccf::common::FrameQueue & GetOutputQ()
Get reference to the Output Queue of this Processing Thread.
Definition: procThread.cpp:263
ccf::common::RecipeBase
Processing Recipe base class. All recipes shall be derived from this class.
Definition: recipeBase.hpp:47
ccf::common::FrameStatistics
Class used by the threads to store info for generating performance statistics.
Definition: utilities.hpp:25
recipeBase.hpp
ccf::control
Definition: acqThread.cpp:10
ccf::common::DataFrame
Frame class used to store the data and metadata for one frames received from the camera.
Definition: dataFrame.hpp:17
utilities.hpp
ccf::control::ProcThread::~ProcThread
virtual ~ProcThread()
Definition: procThread.cpp:51
ccf::control::ProcThread::GetRecipe
const ccf::common::RecipeBase & GetRecipe(const uint16_t nb)
Definition: procThread.cpp:321