Go to the documentation of this file.
5 #ifndef CCF_COMMON_BASE_HPP_H_
6 #define CCF_COMMON_BASE_HPP_H_
8 #include <boost/exception/diagnostic_information.hpp>
11 #include <ctd/defines/defines.hpp>
12 #include <ctd/system/system.hpp>
13 #include <ctd/time/time.hpp>
14 #include <ctd/conversion/conversion.hpp>
76 const std::string& sender_thread_id,
77 const std::string& receiver_thread_id,
78 const std::string& data);
82 const double time_out,
89 std::string& sum_state,
90 std::string& sum_substate);
120 std::string m_class_name;
128 const std::string&
object,
129 const std::string& location);
174 ACTIVE = recif::RecStatusNames::Active,
175 COMPLETED = recif::RecStatusNames::Completed,
176 STOPPED = recif::RecStatusNames::Stopped,
177 ABORTED = recif::RecStatusNames::Aborted,
178 FAILED = recif::RecStatusNames::Failed,
179 UNDEFINED = recif::RecStatusNames::Undefined
184 const recif::RecStatusNames rec_status = recif::RecStatusNames::Undefined);
187 void CopyRecStatusObj(
const std::shared_ptr<recif::RecStatus>& src_rec_status_obj,
188 const std::shared_ptr<recif::RecStatus>& trg_rec_status_obj);
286 char thread_name[32];
287 pthread_getname_np(pthread_self(), thread_name, 32);
292 #define CCFLOC (std::string(__FILE__) + ":" + std::to_string(__LINE__) + ":" + \
293 std::string(__FUNCTION__) + ":" + CcfThreadName())
308 const std::string& scope =
"") {
311 s_padding_chars =
"********************************************************************************"
312 "********************";
315 m_time_at_scope_entry = ctd::time::Time();
316 m_location = location;
318 m_id = ctd::defines::GenUniqueId();
321 location +
":" + scope));
331 m_location +
":" + m_scope +
" (" +
332 ctd::conversion::NbToStr((ctd::time::Time() - m_time_at_scope_entry),
"%.6E") +
" s)"));
336 ctd::conversion::NbToStr((ctd::time::Time() - m_time_at_scope_entry),
"%.6E") +
" s)"));
344 double m_time_at_scope_entry;
345 std::string m_location;
353 const std::string& msg) {
354 fprintf(stdout,
"%s:%s#> %s\n", ctd::time::IsoTimeNow().c_str(), location.c_str(), msg.c_str());
360 #define INFO_LOG_GUARD if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::INFO)
363 #define DEBUG_LOG_GUARD if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::DEBUG)
366 #define DEBUG2_LOG_GUARD if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::DEBUG2)
369 #define DEBUG3_LOG_GUARD if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::DEBUG3)
372 #define TRACE_LOG_GUARD if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::TRACE)
376 #define CCFERROR(msg) LOG4CPLUS_ERROR(CcfLogger(), CCFLOC << ": " << msg)
379 #define CCFWARNING(msg) LOG4CPLUS_WARN(CcfLogger(), CCFLOC << ": " << msg)
382 #define CCFSTATE(msg) LOG4CPLUS_STATE(CcfLogger(), CCFLOC << ": " << msg)
385 #define CCFEVENT(msg) LOG4CPLUS_EVENT(CcfLogger(), CCFLOC << ": " << msg)
388 #define CCFACTION(msg) LOG4CPLUS_ACTION(CcfLogger(), CCFLOC << ": " << msg)
391 #define CCFINFO(msg) INFO_LOG_GUARD { LOG4CPLUS_INFO(CcfLogger(), CCFLOC << ": " << msg); }
394 #define CCFDEBUG(msg) DEBUG_LOG_GUARD { LOG4CPLUS_DEBUG(CcfLogger(), CCFLOC << ": " << msg); }
397 #define CCFDEBUG2(msg) DEBUG2_LOG_GUARD { LOG4CPLUS_DEBUG(CcfLogger2(), CCFLOC << ": " << msg); }
400 #define CCFDEBUG3(msg) DEBUG3_LOG_GUARD { LOG4CPLUS_DEBUG(CcfLogger3(), CCFLOC << ": " << msg); }
403 #define CCFTRACE TRACE_LOG_GUARD { CCF_TRACE_CLASS _trace(CCFLOC, ""); }
406 #define CCFTRACEX(scope) TRACE_LOG_GUARD { CCF_TRACE_CLASS _trace(CCFLOC, scope); }
410 #define CCFTHROW(msg) throw rad::Exception(CCFLOC + ": " + msg)
412 #endif // CCF_COMMON_BASE_HPP_H_
const std::string PUB_STAT_NAME_STOPPED
Definition: base.hpp:259
static ccf::mptk::Manager & Mptk()
Return reference to internal MPTK instance (singleton).
Definition: base.hpp:97
PubStatus
Defines the various possible states of a Data Publisher.
Definition: base.hpp:173
ImageDataType
CCF image data types. Based on the values defined for BITPIX in the FITS standard.
Definition: base.hpp:153
const std::string FAILURE
Definition: base.hpp:146
const std::string STATE_ON_NOT_OP_NOT_READY
Definition: base.hpp:51
const std::string META_KEY_EXPO_TIME
Definition: base.hpp:36
const std::string SETUP_KEY_EXPO_WIN_WIDTH
Definition: base.hpp:214
const std::string STATE_ON_NOT_OP_READY
Definition: base.hpp:52
std::string CcfThreadName()
Return thread name allocated.
Definition: base.hpp:285
void SetClassName(const std::string &class_name)
Set the name of the class in question.
Definition: base.cpp:68
std::string PubStatusNameToStr(PubStatus pub_status_nb)
Publisher status, number representation to string.
Definition: base.cpp:118
const std::string SETUP_KEY_EXPO_WIN_START_X
Definition: base.hpp:212
const std::string SETUP_KEY_EXPO_BIN_Y
Definition: base.hpp:217
const std::string SETUP_KEY_EXPO_TIME
Definition: base.hpp:209
const std::string PROP_KEY_FRAME_RATE_LIMIT
Definition: base.hpp:228
const std::string CFG_KEY_SYS_IMAGE_DIR
Cfg parameter defining the directory in the DATAROOT where data will be stored.
Definition: base.hpp:124
static std::string s_padding_chars
Definition: base.hpp:303
const std::string SETUP_KEY_EXPO_BIN_X
Definition: base.hpp:216
const std::string STATE_ON_OP_ACQ
Definition: base.hpp:54
const std::string DB_NODE_SM_STATE
Definition: base.hpp:30
ExpoMode
Exposure modes.
Definition: base.hpp:201
Status
General status variable.
Definition: base.hpp:138
Class used to generate TRACE logs.
Definition: base.hpp:300
const std::string SETUP_KEY_EXPO_NB
Definition: base.hpp:211
const std::string META_KEY_EXPO_RATE
Definition: base.hpp:35
LogLevel
Log levels defined for CCF; adds two debugging levels: DEBUG2, DEBUG3.
Definition: base.hpp:60
log4cplus::Logger & CcfLogger3()
Returns reference to the CCF Logger object, for DEBUG3 type of logs.
Definition: base.cpp:22
const std::string META_KEY_EXPO_WIN_STARTY
Definition: base.hpp:40
Class to be used as parent all CCF classes.
Definition: base.hpp:93
~CCF_TRACE_CLASS()
Destructor generating the scope exit trace log.
Definition: base.hpp:328
const std::string SETUP_KEY_PROC_ENABLED
Definition: base.hpp:225
const std::string PUB_STAT_NAME_COMPLETED
Definition: base.hpp:258
static ccf::common::LogLevel GetLogLevel()
Return the current CCF log level.
Definition: base.cpp:78
IFW CTD Multiprocessing Toolkit Manager class.
Definition: manager.hpp:21
const std::string IFW_VERSION
Version of IFW.
Definition: base.hpp:24
const std::string & GetClassName() const
Return the allocated name of the class.
Definition: base.cpp:63
void CcfDebug(const std::string &location, const std::string &msg)
Definition: base.hpp:352
const std::string SETUP_KEY_EXPO_MODE
Definition: base.hpp:210
const std::string SETUP_KEY_SIM_MAX_SHIFT
Definition: base.hpp:223
CCF_TRACE_CLASS(const std::string &location, const std::string &scope="")
Definition: base.hpp:307
const std::string SETUP_KEY_SIM_MAX_SHIFT_PR_FRAME
Definition: base.hpp:222
SimType
Simulation type.
Definition: base.hpp:244
static int8_t s_nesting_level
Definition: base.hpp:302
const std::string META_KEY_CAM_MODEL
Definition: base.hpp:44
void ResetRecStatusObj(std::shared_ptr< recif::RecStatus > &rec_status_obj, const recif::RecStatusNames rec_status)
Reset the members of the Recording Status Object.
Definition: base.cpp:135
const std::string CCF_VERSION
Version of CCF.
Definition: base.hpp:21
const std::string META_KEY_EXPO_WIN_BINX
Definition: base.hpp:37
~Base()
Definition: base.cpp:61
const std::string META_KEY_EXPO_WIN_STARTX
Definition: base.hpp:39
const std::string REC_ID_PREFIX
Definition: base.hpp:238
const std::string SETUP_KEY_EXPO_WIN_HEIGHT
Definition: base.hpp:215
bool ReceiveThrMsg(const std::string &receiver_thread_id, const double time_out, ccf::mptk::Message &message)
Receive a message from the given thread. Returns true if message received.
Definition: base.cpp:41
std::string StatusToStr(ccf::common::Status status)
Convert the status from number to string.
Definition: base.cpp:110
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::string SETUP_KEY_EXPO_FRAME_RATE_LIMIT
Definition: base.hpp:219
const std::string META_KEY_EXPO_WIN_BINY
Definition: base.hpp:38
const std::string PUB_STAT_NAME_FAILED
Definition: base.hpp:261
IFW CTD Multiprocessing Toolkit Message class.
Definition: message.hpp:17
const std::string SETUP_KEY_EXPO_FRAME_RATE
Definition: base.hpp:218
void CopyRecStatusObj(const std::shared_ptr< recif::RecStatus > &src_rec_status_obj, const std::shared_ptr< recif::RecStatus > &trg_rec_status_obj)
Cope the members of one Recording Status Object to another.
Definition: base.cpp:153
const std::string EXPO_MODE_CONTINUOUS
Definition: base.hpp:233
log4cplus::Logger & CcfLogger()
Returns reference to the CCF Logger object.
Definition: base.cpp:12
ProcStatus
Possible states for a Processing Recipe defined.
Definition: base.hpp:191
static void SetLogLevel(const ccf::common::LogLevel log_level)
Set the log level.
Definition: base.cpp:73
const std::string PUB_STAT_NAME_UNDEFINED
Definition: base.hpp:262
const std::string META_KEY_CAM_CHIPMODEL
Definition: base.hpp:45
const std::string SUCCESS
Definition: base.hpp:145
const std::string SETUP_KEY_SIM_NOISE
Definition: base.hpp:224
std::string RecStatusNameToStr(recif::RecStatusNames rec_status_nb)
Recording Status name, number to string representation.
Definition: base.cpp:130
const std::string META_KEY_CAM_TYPE
Definition: base.hpp:46
const std::string SETUP_KEY_SIM_FILE
Definition: base.hpp:221
const std::string STATE_ON_OP_ACQ_NOT_REC
Definition: base.hpp:55
const std::string META_KEY_CAM_ID
Definition: base.hpp:43
ExpoMode ExpoModeToNb(const std::string &expo_mode)
Convert exposure mode from number representation to string.
Definition: base.cpp:82
Definition: appBase.cpp:8
const std::string SETUP_KEY_SIM_TYPE
Definition: base.hpp:220
void DecomposeSmStatus(const std::string &sm_state, std::string &sum_state, std::string &sum_substate)
Definition: base.cpp:170
const std::string SETUP_KEY_EXPO_WIN_START_Y
Definition: base.hpp:213
log4cplus::Logger & CcfLogger2()
Returns reference to the CCF Logger object, for DEBUG2 type of logs.
Definition: base.cpp:17
Base()
Definition: base.cpp:59
const std::string EXPO_MODE_FINITE
Definition: base.hpp:232
const std::string STATE_ON_OP_IDLE
Definition: base.hpp:53
const std::string DB_NODE_SM_STATUS_SUBSTATE
Definition: base.hpp:29
const std::string SIM_TYPE_FILE_STR
Definition: base.hpp:251
const std::string PUB_STAT_NAME_ACTIVE
Definition: base.hpp:257
const std::string META_KEY_CAM_NAME
Definition: base.hpp:42
LogLevel LogLevelStrToNb(const std::string &log_level)
Log level string to number representation.
Definition: base.cpp:94
const std::string SIM_TYPE_PATTERN1_STR
Definition: base.hpp:252
const std::string STATE_ON_OP_ACQ_REC
Definition: base.hpp:56
HwStatus
HW status values.
Definition: base.hpp:132
PubType
A Publisher may be Recording or Not-Recording. A Recording Publisher publishes data into files.
Definition: base.hpp:166
const std::string META_KEY_SYSTEM
Definition: base.hpp:41
const std::string DB_NODE_SM_STATUS_STATE
Definition: base.hpp:28
void SendThrMsg(const std::string &command, const std::string &sender_thread_id, const std::string &receiver_thread_id, const std::string &data)
Send MPTK message via internal Message Bus.
Definition: base.cpp:32
const std::string EXPO_MODE_INACTIVE
Definition: base.hpp:234
const std::string PUB_STAT_NAME_ABORTED
Definition: base.hpp:260