Go to the documentation of this file.
5 #ifndef CCF_CONTROL_APPLICATION_HPP_
6 #define CCF_CONTROL_APPLICATION_HPP_
10 #include <rad/mal/replier.hpp>
11 #include <rad/dbAdapterRedis.hpp>
69 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
70 auto req = rad::GetPayloadNothrow<T>(event);
72 CCFERROR(
Logger(), event.GetId() <<
" has no associated request!");
76 req->SetException(elt::mal::MalException(
"Request rejected in state " + state));
101 int Execute(
int argc,
char* argv[]);
138 const std::string& status);
147 template <
class COM_ADPT_TYPE,
class SIM_COM_ADPT_TYPE>
149 const SIM_COM_ADPT_TYPE& sim_com_adapter_factory_obj) {
150 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
158 m_com_adapter = std::make_unique<COM_ADPT_TYPE>();
161 m_sim_com_adapter = std::make_unique<SIM_COM_ADPT_TYPE>();
179 const std::vector<std::string>&
GetPubThreadIds(
const std::string& proc_thread_id)
const;
208 std::shared_ptr<recif::RecStatus>& active_rec);
215 std::shared_ptr<recif::RecStatus>& active_rec)
const;
234 std::unique_ptr<rad::cii::Replier> m_mal_replier;
235 std::shared_ptr<elt::mal::Mal> m_mal;
236 std::unique_ptr<DataContext> m_data_ctx;
239 bool m_dismantle_invoked;
241 std::map<std::string, std::string> m_request_status_map;
243 std::unique_ptr<ccf::common::ComAdptBase> m_com_adapter;
244 std::unique_ptr<ccf::common::ComAdptBase> m_sim_com_adapter;
246 std::map<std::string, std::shared_ptr<ccf::common::FrameQueue>> m_frame_queues;
248 std::vector<std::string> m_proc_thread_names;
249 std::vector<std::string> m_proc_thread_ids;
250 std::map<std::string, std::vector<std::string>> m_pub_thread_ids;
253 std::list<PubThread*> m_pub_threads;
257 int64_t m_acq_setup_nb_of_frames;
258 int64_t m_acq_status_frame_count;
261 std::shared_ptr<recif::RecStatus> m_active_recording;
262 int64_t m_exp_nb_of_frames;
263 int32_t m_max_sz_rec_history;
264 int32_t m_rec_history_exp;
266 std::map<std::string, std::shared_ptr<recif::RecStatus>> m_rec_history;
267 std::vector<std::string> m_rec_id_history;
269 std::map<std::string, std::string> m_file_stored_to_pub_id;
272 std::map<std::string, std::shared_ptr<RecWaitRequest>> m_rec_wait_requests;
281 #endif // CCFCONTROL_APPLICATION_HPP_
Implements the core CCF Control Application.
Definition: application.hpp:83
const std::string PUB_THR_TAG
Definition: application.hpp:41
const std::string ACQ_THR_TAG
Definition: application.hpp:39
void SetActiveRecStatusObj(std::shared_ptr< recif::RecStatus > &active_rec)
Set the Active Recording Status Object.
Definition: application.cpp:790
void SetRecordingStatus(const ccf::PubStatus status)
Set the status of the an active Recording Session (Active Recording Object).
Definition: application.cpp:771
void AssertPtr(const void *ptr, const std::string &object, const std::string &location)
Check that pointer is not nullptr and raise rad::exception in case it is.
Definition: base.cpp:53
const std::string ACTIVE_REC_MUTEX
Definition: application.hpp:61
void Dismantle()
Definition: application.cpp:232
const std::string THREAD_SIG_PUBLISH
Definition: application.hpp:51
const std::vector< std::string > & GetPubThreadIds(const std::string &proc_thread_id) const
Get the IDs of the Publisher Threads running.
Definition: application.cpp:539
const std::string INPUT_Q_TAG
Definition: application.hpp:42
Class to be used as parent for CCF application type of classes.
Definition: appBase.hpp:25
Responsible for the life-cycle management of actions and activities.
Definition: actionMgr.hpp:19
ccf::common::ComAdptBase & GetComAdapter()
Definition: application.cpp:491
const std::list< PubThread * > & GetPubThreads() const
Get the IDs of the Publisher Threads running.
Definition: application.cpp:550
void CcfRequestRejectHandler(const rad::AnyEvent &event, const std::string &state)
Template function RAD request rejection check/handler.
Definition: application.hpp:68
void GetRecStatus(const std::string &rec_id, std::shared_ptr< recif::RecStatus > &active_rec) const
Check if a Recording with the given ID is found and returns its status.
Definition: application.cpp:727
elt::mal::Mal & GetMal()
Return reference to the MAL (Singleton) instance.
Definition: application.cpp:60
std::string GetState()
Return the current state (status) of the SCXML state machine.
Definition: application.cpp:555
const std::string REC_HISTORY_MUTEX
Definition: application.hpp:62
Class used by a Publisher to handle its own publisher status.
Definition: pubBase.hpp:32
#define CCFLOC
Macro generating a location identifier: "<file>:<line>:<function>:<thread>".
Definition: base.hpp:457
void CreateThreads()
Definition: application.cpp:356
Application(const Application &)=delete
void CheckRecWaitRequests(const bool recording_completed=false)
Check if there are pending requests from RecWait Requests and send response if needed.
Definition: application.cpp:835
PubStatus
Defines the various possible states of a Data Publisher.
Definition: base.hpp:285
int Execute(int argc, char *argv[])
Return reference to the configuration object.
Definition: application.cpp:66
#define CCFERROR(logger, msg)
ERROR log macro. Includes the location ("CCFLOC") in the log message.
Definition: base.hpp:546
void HandleSetup()
Handle the setup of the application.
Definition: application.cpp:512
void IncrementFrameCounter()
Increment frame counter, counting the number of complete frames received.
Definition: application.cpp:714
const std::vector< std::string > & GetProcThreadIds() const
Get the IDs of the Processing Threads running.
Definition: application.cpp:533
void MoveActiveRecStatusToHistory(const ccf::PubStatus status, std::shared_ptr< recif::RecStatus > &active_rec)
Move the Active Rec Status object to the Rec Status History.
Definition: application.cpp:799
void UpdateActiveRecStatusObj(const ccf::common::PublisherStatus &sum_rec_pub_status)
Update the Active Recording Status Object in memory and in the OLDB.
Definition: application.cpp:599
void StartAcquistion()
Instruct the system to start an acquisition (finite or infnite).
Definition: application.cpp:653
const std::string OUTPUT_Q_TAG
Definition: application.hpp:43
const std::string THREAD_SIG_SETUP
Definition: application.hpp:49
Application & App()
Definition: application.hpp:275
void ConnectDevice()
Connect to the associated device.
Definition: application.cpp:306
void RegisterComAdapters(const COM_ADPT_TYPE &com_adapter_factory_obj, const SIM_COM_ADPT_TYPE &sim_com_adapter_factory_obj)
Method to allocate and register the Communication Adapters.
Definition: application.hpp:148
virtual ~Application()
Definition: application.cpp:55
std::string GetRequestStatus(const std::string &request) const
Get the status of the given request.
Definition: application.cpp:900
void UpdateRecStatusInDb()
Update the status of the current Recording Session in the DB.
Definition: application.cpp:626
void GetMostRecentRecStatus(std::shared_ptr< recif::RecStatus > &active_rec) const
Get the information about the most recent Recording (active or in the history).
Definition: application.cpp:766
bool GetAcquisitionActive()
Returns true if image acquisition is active.
Definition: application.cpp:528
void SetRequestStatus(const std::string &request, const std::string &status)
Set status of the given request.
Definition: application.cpp:894
const std::string THREAD_SIG_TERM
Definition: application.hpp:48
void CheckStopAcquistion()
Check if the conditions are met to stop an ongoing acqusition session.
Definition: application.cpp:682
void LoadInitSetup()
Load the Initialisation Setup specified in the configuration and install it.
Definition: application.cpp:504
void GetActiveRecStatus(std::shared_ptr< recif::RecStatus > &active_rec) const
Get the currently active Recording status.
Definition: application.cpp:719
ExpoMode
Exposure modes.
Definition: base.hpp:313
const std::string THREAD_SIG_NEW_DATA
Definition: application.hpp:50
void DisconnectDevice()
Disconnect from the associated device.
Definition: application.cpp:324
std::string ListAdapters()
List the available adapters registered in this executable.
Definition: application.cpp:340
const std::string THREAD_SIG_START
Definition: application.hpp:52
static Application & Instance()
Return reference to unique instance of the application class.
Definition: application.cpp:34
const std::string PROC_THR_TAG
Definition: application.hpp:40
const std::string MON_THR_TAG
Definition: application.hpp:38
void StopAcquistion()
Definition: application.cpp:699
Definition: acqThread.cpp:10
void AddRecWaitRequest(std::shared_ptr< RecWaitRequest > &req_wait_req)
Add a ReqWaitRequest in the internal registry.
Definition: application.cpp:827
Application & operator=(const Application &)=delete
Disable copy constructor.
static Application * s_app_instance
Singleton instance.
Definition: application.hpp:87
void CleanUpRecWaitRequests()
Check if there are RecWait Requests that can be removed from the queue.
Definition: application.cpp:873
void UpdateRecordingStatus()
Disable assignment operator.
Definition: application.cpp:560
log4cplus::Logger & Logger()
Definition: base.cpp:9
const std::string MUTEX_REC_WAIT_REQUESTS
Definition: application.hpp:63
Class to be used as parent for CCF Communication Adapters.
Definition: comAdptBase.hpp:31