5#ifndef CCF_CONTROL_APPLICATION_HPP_
6#define CCF_CONTROL_APPLICATION_HPP_
10#include <rad/mal/replier.hpp>
11#include <rad/dbAdapterRedis.hpp>
68 template <
typename CMD_TYPE,
typename EX_TYPE>
70 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
71 auto req = rad::GetPayloadNothrow<CMD_TYPE>(event);
73 LOG4CPLUS_ERROR(
Logger(), event.GetId() <<
" has no associated request!");
76 req->SetException(EX_TYPE(
"Request rejected in state " + state, 0));
108 int Execute(
int argc,
char* argv[]);
145 const std::string& status);
154 template <
class COM_ADPT_TYPE,
class SIM_COM_ADPT_TYPE>
156 const SIM_COM_ADPT_TYPE& sim_com_adapter_factory_obj) {
157 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
164 m_com_adapter = std::make_unique<COM_ADPT_TYPE>();
166 m_sim_com_adapter = std::make_unique<SIM_COM_ADPT_TYPE>();
171 template <
class MON_ADPT_TYPE>
173 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
174 m_mon_adapter = std::make_unique<MON_ADPT_TYPE>();
179 template <
class EXEC_ADPT_TYPE>
181 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
182 m_exec_adapter = std::make_unique<EXEC_ADPT_TYPE>();
206 const std::vector<std::string>&
GetPubThreadNames(
const std::string& proc_thread_name)
const;
244 std::shared_ptr<recif::RecStatus>& active_rec);
251 std::shared_ptr<recif::RecStatus>& active_rec)
const;
281 std::unique_ptr<rad::cii::Replier> m_mal_replier;
282 std::shared_ptr<elt::mal::Mal> m_mal;
283 std::unique_ptr<DataContext> m_data_ctx;
286 bool m_dismantle_invoked;
288 std::map<std::string, std::string> m_request_status_map;
292 std::unique_ptr<ccf::common::ComAdptBase> m_com_adapter;
293 std::unique_ptr<ccf::common::ComAdptBase> m_sim_com_adapter;
295 std::unique_ptr<ccf::common::MonAdptBase> m_mon_adapter;
297 std::unique_ptr<ccf::common::ExecAdptBase> m_exec_adapter;
299 std::map<std::string, std::shared_ptr<ccf::common::FrameQueue>> m_frame_queues;
301 std::vector<std::string> m_proc_thread_names;
302 std::map<std::string, std::vector<std::string>> m_proc_to_pub_thread_names;
304 std::map<std::string, bool> m_pub_thread_names;
307 std::list<ProcThread*> m_proc_threads;
310 std::list<PubThread*> m_pub_threads;
314 int64_t m_acq_setup_nb_of_frames;
315 int64_t m_acq_status_frame_count;
318 std::shared_ptr<recif::RecStatus> m_active_recording;
319 int64_t m_exp_nb_of_frames;
320 int32_t m_max_sz_rec_history;
321 int32_t m_rec_history_exp;
322 bool m_cfg_auto_stop_acq_after_rec;
323 bool m_acq_auto_started_at_rec_start;
325 std::map<std::string, std::shared_ptr<recif::RecStatus>> m_rec_history;
326 std::vector<std::string> m_rec_id_history;
328 std::map<std::string, std::string> m_file_stored_to_pub_id;
331 std::map<std::string, std::shared_ptr<RecWaitRequest>> m_rec_wait_requests;
#define CCFLOC
Macro generating a location identifier: "<file>:<line>:<function>:<thread>".
Definition: base.hpp:387
Class to be used as parent for CCF application type of classes.
Definition: appBase.hpp:25
Class to be used as parent for CCF Communication Adapters.
Definition: comAdptBase.hpp:31
Class to be used as parent for CCF Execution Adapters.
Definition: execAdptBase.hpp:16
Class to be used as parent for CCF Monitor Adapters.
Definition: monAdptBase.hpp:20
Class used by a Publisher to handle its own publisher status.
Definition: pubBase.hpp:32
Responsible for the life-cycle management of actions and activities.
Definition: actionMgr.hpp:19
Implements the core CCF Control Application.
Definition: application.hpp:93
void UpdateRecordingStatus()
Disable assignment operator.
Definition: application.cpp:656
void RegisterExecAdapter(const EXEC_ADPT_TYPE &exec_adapter_factory_obj)
Method to allocate and register the Execution Adapter.
Definition: application.hpp:180
bool GetAcquisitionActive()
Definition: application.cpp:613
virtual ~Application()
Definition: application.cpp:58
ccf::common::ExecAdptBase & GetExecAdapter()
Return the reference to the Execution Adapter.
Definition: application.cpp:580
void LoadInitSetup()
Load the Initialisation Setup specified in the configuration and install it.
Definition: application.cpp:588
std::string GetRequestStatus(const std::string &request) const
Get the status of the given request.
Definition: application.cpp:1061
std::string GetState()
Return the current state (status) of the SCXML state machine.
Definition: application.cpp:651
void RegisterMonAdapter(const MON_ADPT_TYPE &mon_adapter_factory_obj)
Method to allocate and register the Monitor Adapters.
Definition: application.hpp:172
void CheckStopAcquistion()
Check if the conditions are met to stop an ongoing acqusition session.
Definition: application.cpp:785
static Application * s_app_instance
Singleton instance.
Definition: application.hpp:97
void CreateThreads()
Definition: application.cpp:414
void SetActiveRecStatusObj(std::shared_ptr< recif::RecStatus > &active_rec)
Set the Active Recording Status Object.
Definition: application.cpp:926
void StartAcquistion()
Instruct the system to start an acquisition (finite or infnite).
Definition: application.cpp:754
void DisconnectDevice()
Disconnect from the associated device.
Definition: application.cpp:382
void AcqAutoStartedAtRecStart()
Invoke to signal that the Acqusition was auto started at RecStart.
Definition: application.cpp:1088
const std::list< PubThread * > & GetPubThreads() const
Get the IDs of the Publisher Threads running.
Definition: application.cpp:646
ccf::common::ComAdptBase & GetComAdapter()
Definition: application.cpp:559
void StopAcquistion()
Definition: application.cpp:832
Application & operator=(const Application &)=delete
Disable copy constructor.
int Execute(int argc, char *argv[])
Initialise and execute the application.
Definition: application.cpp:69
bool IsPubThread(const std::string &thread_name)
Returns bool if the thread is a Publisher Thread.
Definition: application.cpp:1076
void SetRequestStatus(const std::string &request, const std::string &status)
Set status of the given request.
Definition: application.cpp:1055
ccf::common::MonAdptBase & GetMonAdapter()
Return the reference to the Monitoring Adapter.
Definition: application.cpp:572
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:155
void HandleSetup()
Handle the setup of the application.
Definition: application.cpp:597
void GetActiveRecStatus(std::shared_ptr< recif::RecStatus > &active_rec) const
Get the currently active Recording status.
Definition: application.cpp:855
bool IsProcThread(const std::string &thread_name)
Returns bool if the thread is a Processing Thread.
Definition: application.cpp:1071
void Dismantle()
Definition: application.cpp:276
std::string ListAdapters()
List the available adapters registered in this executable.
Definition: application.cpp:398
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:902
const std::vector< std::string > & GetProcThreadNames() const
Get the names of the Processing Threads running.
Definition: application.cpp:618
elt::mal::Mal & GetMal()
Return reference to the MAL (Singleton) instance.
Definition: application.cpp:63
void AddRecWaitRequest(std::shared_ptr< RecWaitRequest > &req_wait_req)
Add a ReqWaitRequest in the internal registry.
Definition: application.cpp:988
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:696
ProcThread & GetProcThread(const std::string &proc_thread_name)
Get reference to Processing Thread object.
Definition: application.cpp:635
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:863
void CheckRecWaitRequests(const bool recording_completed=false)
Check if there are pending requests from RecWait Requests and send response if needed.
Definition: application.cpp:996
void CleanUpRecWaitRequests()
Check if there are RecWait Requests that can be removed from the queue.
Definition: application.cpp:1034
void IncrementFrameCounter()
Increment frame counter, counting the number of complete frames received.
Definition: application.cpp:850
static Application & Instance()
Return reference to unique instance of the application class.
Definition: application.cpp:36
void UpdateControlSetupPars()
Update setup parameters used internally in the application for flow control.
Definition: application.cpp:1093
const std::vector< std::string > & GetPubThreadNames(const std::string &proc_thread_name) const
Get the names of the Publisher Threads running for a specific Processing Thread.
Definition: application.cpp:624
void ActivateRecording()
Selects publishers and activate the recording.
Definition: application.cpp:936
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:958
void ConnectDevice()
Connect to the associated device.
Definition: application.cpp:364
Application(const Application &)=delete
void UpdateRecStatusInDb()
Update the status of the current Recording Session in the DB.
Definition: application.cpp:724
void SetRecordingStatus(const ccf::PubStatus status)
Set the status of the an active Recording Session (Active Recording Object).
Definition: application.cpp:907
Processing Thread MPTK Thread implementation (see also ccf::mptk::Thread).
Definition: procThread.hpp:16
Definition: acqThread.cpp:10
const std::string THREAD_SIG_PUBLISH
Definition: application.hpp:52
const std::string OUTPUT_Q_TAG
Definition: application.hpp:44
const std::string ACTIVE_REC_MUTEX
Definition: application.hpp:62
const std::string INPUT_Q_TAG
Definition: application.hpp:43
const std::string REC_HISTORY_MUTEX
Definition: application.hpp:63
const std::string THREAD_SIG_START
Definition: application.hpp:53
const std::string MON_THR_TAG
Definition: application.hpp:41
const std::string THREAD_SIG_TERM
Definition: application.hpp:49
const std::string ACQ_THR_TAG
Definition: application.hpp:42
const std::string THREAD_SIG_SETUP
Definition: application.hpp:50
const std::string THREAD_SIG_NEW_DATA
Definition: application.hpp:51
void CcfRequestRejectHandler(const rad::AnyEvent &event, const std::string &state)
Template function RAD request rejection check/handler.
Definition: application.hpp:69
const std::string MUTEX_REC_WAIT_REQUESTS
Definition: application.hpp:64
Application & App()
Definition: application.hpp:334
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:63
log4cplus::Logger & Logger()
Definition: base.cpp:11
PubStatus
Defines the various possible states of a Data Publisher.
Definition: base.hpp:213
ExpoMode
Exposure modes.
Definition: base.hpp:241