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>
70 auto req = rad::GetPayloadNothrow<T>(event);
72 CCFERROR(event.GetId() <<
" has no associated request!");
75 req->SetException(rad::Exception(
"Request rejected in state " + state));
100 int Execute(
int argc,
char* argv[]);
135 const std::string& status);
144 template <
class COM_ADPT_TYPE,
class SIM_COM_ADPT_TYPE>
146 const SIM_COM_ADPT_TYPE& sim_com_adapter_factory_obj) {
148 if (m_com_adapter != NULL) {
149 delete m_com_adapter;
151 if (m_sim_com_adapter != NULL) {
152 delete m_sim_com_adapter;
154 m_com_adapter =
new(std::nothrow)COM_ADPT_TYPE;
156 m_sim_com_adapter =
new(std::nothrow)SIM_COM_ADPT_TYPE;
170 const std::vector<std::string>&
GetPubThreadIds(
const std::string& proc_thread_id)
const;
199 std::shared_ptr<recif::RecStatus>& active_rec);
206 std::shared_ptr<recif::RecStatus>& active_rec)
const;
226 rad::cii::Replier* m_mal_replier;
227 elt::mal::Mal* m_mal;
231 bool m_dismantle_invoked;
233 std::map<std::string, std::string> m_request_status_map;
238 std::map<std::string, ccf::common::FrameQueue*> m_frame_queues;
240 std::vector<std::string> m_proc_thread_ids;
241 std::map<std::string, std::vector<std::string>> m_pub_thread_ids;
244 std::list<PubThread*> m_pub_threads;
248 int64_t m_acq_setup_nb_of_frames;
249 int64_t m_acq_status_frame_count;
252 std::shared_ptr<recif::RecStatus> m_active_recording;
253 int64_t m_exp_nb_of_frames;
254 int32_t m_max_sz_rec_history;
255 int32_t m_rec_history_exp;
257 std::map<std::string, std::shared_ptr<recif::RecStatus>> m_rec_history;
258 std::vector<std::string> m_rec_id_history;
260 std::map<std::string, std::string> m_file_stored_to_pub_id;
263 std::map<std::string, std::shared_ptr<RecWaitRequest>> m_rec_wait_requests;
268 #endif // CCFCONTROL_APPLICATION_HPP_
PubStatus
Defines the various possible states of a Data Publisher.
Definition: base.hpp:173
const std::string MON_THR_NAME
Definition: application.hpp:38
Implements the core CCF Control Application.
Definition: application.hpp:82
const std::string PUB_THR_TAG
Definition: application.hpp:41
RAD Action Group for the actions in connection with the "stdif".
Definition: stdActions.hpp:47
void SetActiveRecStatusObj(std::shared_ptr< recif::RecStatus > &active_rec)
Set the Active Recording Status Object.
Definition: application.cpp:716
Provides access to the command line options and the configuration parameters stored in the configurat...
Definition: config.hpp:44
const std::string ACTIVE_REC_MUTEX
Definition: application.hpp:61
void Dismantle()
Definition: application.cpp:187
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:484
Config & GetCfg()
Return reference to the configuration object.
Definition: application.cpp:290
Class to be used as parent for CCF application type of classes.
Definition: appBase.hpp:25
ExpoMode
Exposure modes.
Definition: base.hpp:201
Responsible for the life-cycle management of actions and activities.
Definition: actionMgr.hpp:19
ccf::common::ComAdptBase & GetComAdapter()
Return the reference to the appropriate Communication Adapter (real mode or simulation adapter).
Definition: application.cpp:433
const std::list< PubThread * > & GetPubThreads() const
Get the IDs of the Publisher Threads running.
Definition: application.cpp:494
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:656
elt::mal::Mal & GetMal()
Return reference to the MAL (Singleton) instance.
Definition: application.cpp:59
std::string GetState()
Return the current state (status) of the SCXML state machine.
Definition: application.cpp:499
const std::string REC_HISTORY_MUTEX
Definition: application.hpp:62
Class used by a Publisher to handle its own publisher status.
Definition: pubBase.hpp:38
const std::string OUTPUT_Q_NAME
Definition: application.hpp:43
#define CCFLOC
Macro generating a location identifier: "<file>:<line>:<function>:<thread>".
Definition: base.hpp:292
void CreateThreads()
Create the internal worker threads according to the configuration loaded. Existing threads will be de...
Definition: application.cpp:295
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:759
int Execute(int argc, char *argv[])
Initialise and execute the application.
Definition: application.cpp:65
void HandleSetup()
Handle the setup of the application.
Definition: application.cpp:458
void IncrementFrameCounter()
Increment frame counter, counting the number of complete frames received.
Definition: application.cpp:644
void AssertPtr(const void *ptr, const std::string &object, const std::string &location)
Check that pointer is not NULL and raise rad::exception in case it is.
Definition: base.cpp:49
const std::vector< std::string > & GetProcThreadIds() const
Get the IDs of the Processing Threads running.
Definition: application.cpp:479
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:541
void StartAcquistion()
Instruct the system to start an acquisition (finite or infnite).
Definition: application.cpp:584
const std::string INPUT_Q_NAME
Definition: application.hpp:42
const std::string THREAD_SIG_SETUP
Definition: application.hpp:49
void MoveActiveRecStatusToHistory(const ccf::common::PubStatus status, std::shared_ptr< recif::RecStatus > &active_rec)
Move the Active Rec Status object to the Rec Status History.
Definition: application.cpp:725
void ConnectDevice()
Connect to the associated device.
Definition: application.cpp:256
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:145
virtual ~Application()
Definition: application.cpp:54
std::string GetRequestStatus(const std::string &request) const
Get the status of the given request.
Definition: application.cpp:819
void UpdateRecStatusInDb()
Update the status of the current Recording Session in the DB.
Definition: application.cpp:566
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:695
bool GetAcquisitionActive()
Returns true if image acquisition is active.
Definition: application.cpp:474
void SetRequestStatus(const std::string &request, const std::string &status)
Set status of the given request.
Definition: application.cpp:813
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:612
void LoadInitSetup()
Load the Initialisation Setup specified in the configuration and install it.
Definition: application.cpp:445
void GetActiveRecStatus(std::shared_ptr< recif::RecStatus > &active_rec) const
Get the currently active Recording status.
Definition: application.cpp:649
const std::string THREAD_SIG_NEW_DATA
Definition: application.hpp:50
std::string ListAdapters()
List the available adapters registered in this executable.
Definition: application.cpp:270
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:33
const std::string PROC_THR_TAG
Definition: application.hpp:40
#define CCFTRACE
TRACE log macro. Includes the location ("CCFLOC") in the log message.
Definition: base.hpp:403
void StopAcquistion()
Instruct the system to stopt an ongoing acquisition. If none is active, no actions are performed.
Definition: application.cpp:629
Provides access to the application run-time data.
Definition: dataContext.hpp:20
Definition: acqThread.cpp:10
const std::string ACQ_THR_NAME
Definition: application.hpp:39
void AddRecWaitRequest(std::shared_ptr< RecWaitRequest > &req_wait_req)
Add a ReqWaitRequest in the internal registry.
Definition: application.cpp:751
void SetRecordingStatus(const ccf::common::PubStatus status)
Set the status of the an active Recording Session (Active Recording Object).
Definition: application.cpp:700
Application & operator=(const Application &)=delete
Disable copy constructor.
static Application * s_app_instance
Singleton instance.
Definition: application.hpp:86
void CleanUpRecWaitRequests()
Check if there are RecWait Requests that can be removed from the queue.
Definition: application.cpp:792
void UpdateRecordingStatus()
Disable assignment operator.
Definition: application.cpp:504
#define CCFERROR(msg)
ERROR log macro. Includes the location ("CCFLOC") in the log message.
Definition: base.hpp:376
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