ifw-ccf  1.0.0
Classes | Namespaces | Macros | Functions | Variables
base.hpp File Reference
#include <boost/exception/diagnostic_information.hpp>
#include <Recif.hpp>
#include <ctd/defines/defines.hpp>
#include <ctd/system/system.hpp>
#include <ctd/time/time.hpp>
#include <ctd/conversion/conversion.hpp>
#include <ccf/mptk/manager.hpp>

Go to the source code of this file.

Classes

class  ccf::common::Base
 Class to be used as parent all CCF classes. More...
 
class  CCF_TRACE_CLASS
 Class used to generate TRACE logs. More...
 

Namespaces

 ccf
 
 ccf::common
 

Macros

#define CCFLOC
 Macro generating a location identifier: "<file>:<line>:<function>:<thread>". More...
 
#define INFO_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::INFO)
 Guard for INFO logs. Ensures log text is only generated when the given log level is enabled. More...
 
#define DEBUG_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::DEBUG)
 Guard for DEBUG logs. Ensures log text is only generated when the given log level is enabled. More...
 
#define DEBUG2_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::DEBUG2)
 Guard for DEBUG2 logs. Ensures log text is only generated when the given log level is enabled. More...
 
#define DEBUG3_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::DEBUG3)
 Guard for DEBUG3 logs. Ensures log text is only generated when the given log level is enabled. More...
 
#define TRACE_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::TRACE)
 Guard for TRACE logs. Ensures log text is only generated when the given log level is enabled. More...
 
#define CCFERROR(msg)   LOG4CPLUS_ERROR(CcfLogger(), CCFLOC << ": " << msg)
 ERROR log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFWARNING(msg)   LOG4CPLUS_WARN(CcfLogger(), CCFLOC << ": " << msg)
 WARNING log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFSTATE(msg)   LOG4CPLUS_STATE(CcfLogger(), CCFLOC << ": " << msg)
 STATE log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFEVENT(msg)   LOG4CPLUS_EVENT(CcfLogger(), CCFLOC << ": " << msg)
 EVENT log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFACTION(msg)   LOG4CPLUS_ACTION(CcfLogger(), CCFLOC << ": " << msg)
 ACTION log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFINFO(msg)   INFO_LOG_GUARD { LOG4CPLUS_INFO(CcfLogger(), CCFLOC << ": " << msg); }
 INFO log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFDEBUG(msg)   DEBUG_LOG_GUARD { LOG4CPLUS_DEBUG(CcfLogger(), CCFLOC << ": " << msg); }
 DEBUG log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFDEBUG2(msg)   DEBUG2_LOG_GUARD { LOG4CPLUS_DEBUG(CcfLogger2(), CCFLOC << ": " << msg); }
 DEBUG2 log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFDEBUG3(msg)   DEBUG3_LOG_GUARD { LOG4CPLUS_DEBUG(CcfLogger3(), CCFLOC << ": " << msg); }
 DEBUG3 log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFTRACE   TRACE_LOG_GUARD { CCF_TRACE_CLASS _trace(CCFLOC, ""); }
 TRACE log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFTRACEX(scope)   TRACE_LOG_GUARD { CCF_TRACE_CLASS _trace(CCFLOC, scope); }
 TRACE + scope log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFTHROW(msg)   throw rad::Exception(CCFLOC + ": " + msg)
 Throw a "rad::Exception()". The location ("CCFLOC") for the throw statement is added to the message. More...
 

Functions

log4cplus::Logger & CcfLogger ()
 Returns reference to the CCF Logger object. More...
 
log4cplus::Logger & CcfLogger2 ()
 Returns reference to the CCF Logger object, for DEBUG2 type of logs. More...
 
log4cplus::Logger & CcfLogger3 ()
 Returns reference to the CCF Logger object, for DEBUG3 type of logs. More...
 
std::string CcfThreadName ()
 Return thread name allocated. More...
 
void CcfDebug (const std::string &location, const std::string &msg)
 

Variables

const std::string ccf::common::CCF_VERSION = "1.0.0"
 Version of CCF. More...
 
const std::string ccf::common::IFW_VERSION = "3.0"
 Version of IFW. More...
 
DB state nodes names.
const std::string ccf::common::DB_NODE_SM_STATUS_STATE = "sm.status.state"
 
const std::string ccf::common::DB_NODE_SM_STATUS_SUBSTATE = "sm.status.substate"
 
const std::string ccf::common::DB_NODE_SM_STATE = "sm.state"
 
Standard metadata keywords.
const std::string ccf::common::META_KEY_EXPO_RATE = "MetaExpoType"
 
const std::string ccf::common::META_KEY_EXPO_TIME = "MetaExpoTime"
 
const std::string ccf::common::META_KEY_EXPO_WIN_BINX = "MetaExpoWinBinX"
 
const std::string ccf::common::META_KEY_EXPO_WIN_BINY = "MetaExpoWinBinY"
 
const std::string ccf::common::META_KEY_EXPO_WIN_STARTX = "MetaExpoWinStartX"
 
const std::string ccf::common::META_KEY_EXPO_WIN_STARTY = "MetaExpoWinStartY"
 
const std::string ccf::common::META_KEY_SYSTEM = "MetaSystem"
 
const std::string ccf::common::META_KEY_CAM_NAME = "MetaCamName"
 
const std::string ccf::common::META_KEY_CAM_ID = "MetaCamId"
 
const std::string ccf::common::META_KEY_CAM_MODEL = "MetaCamModel"
 
const std::string ccf::common::META_KEY_CAM_CHIPMODEL = "MetaCamChipModel"
 
const std::string ccf::common::META_KEY_CAM_TYPE = "MetaCamType"
 
Setup parameter names.
const std::string ccf::common::SETUP_KEY_EXPO_TIME = "expo.time"
 
const std::string ccf::common::SETUP_KEY_EXPO_MODE = "expo.mode"
 
const std::string ccf::common::SETUP_KEY_EXPO_NB = "expo.nb"
 
const std::string ccf::common::SETUP_KEY_EXPO_WIN_START_X = "expo.win.start_x"
 
const std::string ccf::common::SETUP_KEY_EXPO_WIN_START_Y = "expo.win.start_y"
 
const std::string ccf::common::SETUP_KEY_EXPO_WIN_WIDTH = "expo.win.width"
 
const std::string ccf::common::SETUP_KEY_EXPO_WIN_HEIGHT = "expo.win.height"
 
const std::string ccf::common::SETUP_KEY_EXPO_BIN_X = "expo.bin_x"
 
const std::string ccf::common::SETUP_KEY_EXPO_BIN_Y = "expo.bin_y"
 
const std::string ccf::common::SETUP_KEY_EXPO_FRAME_RATE = "expo.frame.rate"
 
const std::string ccf::common::SETUP_KEY_EXPO_FRAME_RATE_LIMIT = "expo.frame.rate.limit"
 
const std::string ccf::common::SETUP_KEY_SIM_TYPE = "sim.type"
 
const std::string ccf::common::SETUP_KEY_SIM_FILE = "sim.file"
 
const std::string ccf::common::SETUP_KEY_SIM_MAX_SHIFT_PR_FRAME = "sim.max_shift_pr_frame"
 
const std::string ccf::common::SETUP_KEY_SIM_MAX_SHIFT = "sim.max_shift"
 
const std::string ccf::common::SETUP_KEY_SIM_NOISE = "sim.noise"
 
const std::string ccf::common::SETUP_KEY_PROC_ENABLED = "proc%d.enabled"
 
const std::string ccf::common::PROP_KEY_FRAME_RATE_LIMIT = "expo.frame.rate.limit"
 
Simulation type.
const std::string ccf::common::SIM_TYPE_FILE_STR = "File"
 
const std::string ccf::common::SIM_TYPE_PATTERN1_STR = "Pattern1"
 

States (composite).

enum  ccf::common::LogLevel {
  ccf::common::LogLevel::OFF = 60000, ccf::common::LogLevel::FATAL = 50000, ccf::common::LogLevel::ERROR = 40000, ccf::common::LogLevel::WARN = 30000,
  ccf::common::LogLevel::INFO = 20000, ccf::common::LogLevel::DEBUG = 10000, ccf::common::LogLevel::DEBUG2 = 9000, ccf::common::LogLevel::DEBUG3 = 8000,
  ccf::common::LogLevel::TRACE = 0, ccf::common::LogLevel::ALL = TRACE, ccf::common::LogLevel::NOT_SET = -1
}
 Log levels defined for CCF; adds two debugging levels: DEBUG2, DEBUG3. More...
 
enum  ccf::common::HwStatus { ccf::common::HwStatus::NOT_OK = 0, ccf::common::HwStatus::OK }
 HW status values. More...
 
enum  ccf::common::Status { ccf::common::Status::FAILURE = 0, ccf::common::Status::SUCCESS = 1 }
 General status variable. More...
 
const std::string ccf::common::STATE_ON_NOT_OP_NOT_READY = "On::NotOperational::NotReady"
 
const std::string ccf::common::STATE_ON_NOT_OP_READY = "On::NotOperational::Ready"
 
const std::string ccf::common::STATE_ON_OP_IDLE = "On::Operational::Idle"
 
const std::string ccf::common::STATE_ON_OP_ACQ = "On::Operational::Acquisition"
 
const std::string ccf::common::STATE_ON_OP_ACQ_NOT_REC = "On::Operational::Acquisition::NotRecording"
 
const std::string ccf::common::STATE_ON_OP_ACQ_REC = "On::Operational::Acquisition::Recording"
 
const std::string ccf::common::CFG_KEY_SYS_IMAGE_DIR = "sys.image.dir"
 Cfg parameter defining the directory in the DATAROOT where data will be stored. More...
 
void ccf::common::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. More...
 
bool ccf::common::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. More...
 
void ccf::common::DecomposeSmStatus (const std::string &sm_state, std::string &sum_state, std::string &sum_substate)
 
void ccf::common::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. More...
 

Execution status.

enum  ccf::common::ImageDataType {
  ccf::common::ImageDataType::UNKNOWN = -1, ccf::common::ImageDataType::BYTE = 8, ccf::common::ImageDataType::PRESCALED = -8, ccf::common::ImageDataType::INT16 = 16,
  ccf::common::ImageDataType::UINT16 = -16, ccf::common::ImageDataType::INT32 = 32, ccf::common::ImageDataType::FLOAT = -32, ccf::common::ImageDataType::INT64 = 64,
  ccf::common::ImageDataType::DOUBLE = -64
}
 CCF image data types. Based on the values defined for BITPIX in the FITS standard. More...
 
enum  ccf::common::PubType { ccf::common::PubType::UNDEFINED = -1, ccf::common::PubType::RECORDING = 1, ccf::common::PubType::NOT_RECORDING }
 A Publisher may be Recording or Not-Recording. A Recording Publisher publishes data into files. More...
 
enum  ccf::common::PubStatus {
  ccf::common::PubStatus::ACTIVE = recif::RecStatusNames::Active, ccf::common::PubStatus::COMPLETED = recif::RecStatusNames::Completed, ccf::common::PubStatus::STOPPED = recif::RecStatusNames::Stopped, ccf::common::PubStatus::ABORTED = recif::RecStatusNames::Aborted,
  ccf::common::PubStatus::FAILED = recif::RecStatusNames::Failed, ccf::common::PubStatus::UNDEFINED = recif::RecStatusNames::Undefined
}
 Defines the various possible states of a Data Publisher. More...
 
enum  ccf::common::ProcStatus {
  ccf::common::ProcStatus::UNDEFINED = -1, ccf::common::ProcStatus::IDLE = 1, ccf::common::ProcStatus::PROCESSING = 32, ccf::common::ProcStatus::FINISHED = 128,
  ccf::common::ProcStatus::FAILED = 256
}
 Possible states for a Processing Recipe defined. More...
 
enum  ccf::common::ExpoMode { ccf::common::ExpoMode::FINITE = 1, ccf::common::ExpoMode::CONTINUOUS, ccf::common::ExpoMode::INACTIVE }
 Exposure modes. More...
 
const std::string ccf::common::SUCCESS = "Success"
 
const std::string ccf::common::FAILURE = "Failure"
 
std::string ccf::common::StatusToStr (ccf::common::Status status)
 Convert the status from number to string. More...
 
void ccf::common::ResetRecStatusObj (std::shared_ptr< recif::RecStatus > &rec_status_obj, const recif::RecStatusNames rec_status=recif::RecStatusNames::Undefined)
 Reset the members of the Recording Status Object. More...
 
void ccf::common::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. More...
 

Exposure modes.

enum  ccf::common::SimType { ccf::common::SimType::FILE = 1, ccf::common::SimType::PATTERN1 }
 Simulation type. More...
 
const std::string ccf::common::EXPO_MODE_FINITE = "Finite"
 
const std::string ccf::common::EXPO_MODE_CONTINUOUS = "Continuous"
 
const std::string ccf::common::EXPO_MODE_INACTIVE = "Inactive"
 
const std::string ccf::common::REC_ID_PREFIX = "RecId"
 
ExpoMode ccf::common::ExpoModeToNb (const std::string &expo_mode)
 Convert exposure mode from number representation to string. More...
 

Publisher Status names.

const std::string ccf::common::PUB_STAT_NAME_ACTIVE = "Active"
 
const std::string ccf::common::PUB_STAT_NAME_COMPLETED = "Completed"
 
const std::string ccf::common::PUB_STAT_NAME_STOPPED = "Stopped"
 
const std::string ccf::common::PUB_STAT_NAME_ABORTED = "Aborted"
 
const std::string ccf::common::PUB_STAT_NAME_FAILED = "Failed"
 
const std::string ccf::common::PUB_STAT_NAME_UNDEFINED = "Undefined"
 
std::string ccf::common::RecStatusNameToStr (recif::RecStatusNames rec_status_nb)
 Recording Status name, number to string representation. More...
 
std::string ccf::common::PubStatusNameToStr (PubStatus pub_status_nb)
 Publisher status, number representation to string. More...
 
LogLevel ccf::common::LogLevelStrToNb (const std::string &log_level)
 Log level string to number representation. More...
 

Macro Definition Documentation

◆ CCFACTION

#define CCFACTION (   msg)    LOG4CPLUS_ACTION(CcfLogger(), CCFLOC << ": " << msg)

ACTION log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFDEBUG

#define CCFDEBUG (   msg)    DEBUG_LOG_GUARD { LOG4CPLUS_DEBUG(CcfLogger(), CCFLOC << ": " << msg); }

DEBUG log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFDEBUG2

#define CCFDEBUG2 (   msg)    DEBUG2_LOG_GUARD { LOG4CPLUS_DEBUG(CcfLogger2(), CCFLOC << ": " << msg); }

DEBUG2 log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFDEBUG3

#define CCFDEBUG3 (   msg)    DEBUG3_LOG_GUARD { LOG4CPLUS_DEBUG(CcfLogger3(), CCFLOC << ": " << msg); }

DEBUG3 log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFERROR

#define CCFERROR (   msg)    LOG4CPLUS_ERROR(CcfLogger(), CCFLOC << ": " << msg)

ERROR log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFEVENT

#define CCFEVENT (   msg)    LOG4CPLUS_EVENT(CcfLogger(), CCFLOC << ": " << msg)

EVENT log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFINFO

#define CCFINFO (   msg)    INFO_LOG_GUARD { LOG4CPLUS_INFO(CcfLogger(), CCFLOC << ": " << msg); }

INFO log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFLOC

#define CCFLOC
Value:
(std::string(__FILE__) + ":" + std::to_string(__LINE__) + ":" + \
std::string(__FUNCTION__) + ":" + CcfThreadName())

Macro generating a location identifier: "<file>:<line>:<function>:<thread>".

◆ CCFSTATE

#define CCFSTATE (   msg)    LOG4CPLUS_STATE(CcfLogger(), CCFLOC << ": " << msg)

STATE log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFTHROW

#define CCFTHROW (   msg)    throw rad::Exception(CCFLOC + ": " + msg)

Throw a "rad::Exception()". The location ("CCFLOC") for the throw statement is added to the message.

◆ CCFTRACE

#define CCFTRACE   TRACE_LOG_GUARD { CCF_TRACE_CLASS _trace(CCFLOC, ""); }

TRACE log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFTRACEX

#define CCFTRACEX (   scope)    TRACE_LOG_GUARD { CCF_TRACE_CLASS _trace(CCFLOC, scope); }

TRACE + scope log macro. Includes the location ("CCFLOC") in the log message.

◆ CCFWARNING

#define CCFWARNING (   msg)    LOG4CPLUS_WARN(CcfLogger(), CCFLOC << ": " << msg)

WARNING log macro. Includes the location ("CCFLOC") in the log message.

◆ DEBUG2_LOG_GUARD

#define DEBUG2_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::DEBUG2)

Guard for DEBUG2 logs. Ensures log text is only generated when the given log level is enabled.

◆ DEBUG3_LOG_GUARD

#define DEBUG3_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::DEBUG3)

Guard for DEBUG3 logs. Ensures log text is only generated when the given log level is enabled.

◆ DEBUG_LOG_GUARD

#define DEBUG_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::DEBUG)

Guard for DEBUG logs. Ensures log text is only generated when the given log level is enabled.

◆ INFO_LOG_GUARD

#define INFO_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::INFO)

Guard for INFO logs. Ensures log text is only generated when the given log level is enabled.

◆ TRACE_LOG_GUARD

#define TRACE_LOG_GUARD   if (ccf::common::Base::GetLogLevel() <= ccf::common::LogLevel::TRACE)

Guard for TRACE logs. Ensures log text is only generated when the given log level is enabled.

Function Documentation

◆ CcfDebug()

void CcfDebug ( const std::string &  location,
const std::string &  msg 
)
inline

Used for debugging purposes to print out info to "stdout". It is attempted to flush the "stdout" file descriptor to ensure the message is displayed on "stdout".

◆ CcfLogger()

log4cplus::Logger& CcfLogger ( )

Returns reference to the CCF Logger object.

◆ CcfLogger2()

log4cplus::Logger& CcfLogger2 ( )

Returns reference to the CCF Logger object, for DEBUG2 type of logs.

◆ CcfLogger3()

log4cplus::Logger& CcfLogger3 ( )

Returns reference to the CCF Logger object, for DEBUG3 type of logs.

◆ CcfThreadName()

std::string CcfThreadName ( )
inline

Return thread name allocated.

CcfThreadName
std::string CcfThreadName()
Return thread name allocated.
Definition: base.hpp:285