ifw-ccf  2.0.0
Classes | Namespaces | Macros | Enumerations | Functions | Variables
base.hpp File Reference
#include <fmt/format.h>
#include <boost/exception/diagnostic_information.hpp>
#include <Recif.hpp>
#include <core/utils/base/base.hpp>
#include <core/utils/system/system.hpp>
#include <core/utils/time/time.hpp>
#include <core/utils/conversion/conversion.hpp>
#include <utils/bat/config.hpp>
#include <ccf/mptk/manager.hpp>
#include <ccf/common/dataType.hpp>

Go to the source code of this file.

Classes

class  ccf::Base
 Class to be used as parent all CCF classes. More...
 

Namespaces

 ccf
 
 ccf::loglevel
 

Macros

#define CCFLOC
 Macro generating a location identifier: "<file>:<line>:<function>:<thread>". More...
 
#define CCFL0C
 
#define INFO_LOG_GUARD   if (ccf::Base::GetLogLevel() >= ccf::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::Base::GetLogLevel() >= ccf::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::Base::GetLogLevel() >= ccf::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::Base::GetLogLevel() >= ccf::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::Base::GetLogLevel() >= ccf::LogLevel::TRACE)
 Guard for TRACE logs. Ensures log text is only generated when the given log level is enabled. More...
 
#define CCFERROR(logger, msg)   LOG4CPLUS_ERROR(logger, CCFLOC << ": " << msg)
 ERROR log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFWARNING(logger, msg)   LOG4CPLUS_WARN(logger, CCFLOC << ": " << msg)
 WARNING log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFINFO(logger, msg)   INFO_LOG_GUARD { LOG4CPLUS_INFO(logger, CCFLOC << ": " << msg); }
 INFO log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFDEBUG(logger, msg)   DEBUG_LOG_GUARD { LOG4CPLUS_DEBUG(logger, CCFLOC << ": " << msg); }
 DEBUG log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFDEBUG2(logger, msg)   DEBUG2_LOG_GUARD { LOG4CPLUS_DEBUG(logger, CCFLOC << ": " << msg); }
 DEBUG2 log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFDEBUG3(logger, msg)   DEBUG3_LOG_GUARD { LOG4CPLUS_DEBUG(logger, CCFLOC << ": " << msg); }
 DEBUG3 log macro. Includes the location ("CCFLOC") in the log message. More...
 
#define CCFTHROW(msg)   throw rad::Exception(CCFLOC + ": " + msg)
 

Enumerations

enum  ccf::LogLevel {
  ccf::LogLevel::OFF = 0, ccf::LogLevel::FATAL = 100, ccf::LogLevel::ERROR = 200, ccf::LogLevel::WARN = 300,
  ccf::LogLevel::INFO = 400, ccf::LogLevel::DEBUG = 500, ccf::LogLevel::DEBUG2 = 501, ccf::LogLevel::DEBUG3 = 502,
  ccf::LogLevel::TRACE = 600, ccf::LogLevel::NOT_SET = -1
}
 Log levels defined for CCF; adds two debugging levels: DEBUG2, DEBUG3. More...
 

Functions

log4cplus::Logger & ccf::Logger ()
 
std::string CcfThreadName ()
 Return thread name allocated. More...
 
void CcfDebug (const std::string &location, const std::string &msg)
 Class used to generate TRACE logs. More...
 

Variables

constexpr auto ccf::loglevel::OFF = "OFF"
 
constexpr auto ccf::loglevel::FATAL = "FATAL"
 
constexpr auto ccf::loglevel::ERROR = "ERROR"
 
constexpr auto ccf::loglevel::WARN = "WARN"
 
constexpr auto ccf::loglevel::INFO = "INFO"
 
constexpr auto ccf::loglevel::DEBUG = "DEBUG"
 
constexpr auto ccf::loglevel::DEBUG2 = "DEBUG2"
 
constexpr auto ccf::loglevel::DEBUG3 = "DEBUG3"
 
constexpr auto ccf::loglevel::TRACE = "TRACE"
 
DB state nodes names.
const std::string ccf::DB_DELIM = std::string(utils::bat::CONFIG_DB_DELIMITER)
 
const std::string ccf::DB_NODE_SM_STATUS_STATE
 
const std::string ccf::DB_NODE_SM_STATUS_SUBSTATE
 
const std::string ccf::DB_NODE_SM_STATE
 
Standard metadata keywords.
constexpr auto ccf::META_KEY_EXPO_RATE = "MetaExpoType"
 
constexpr auto ccf::META_KEY_EXPO_TIME = "MetaExpoTime"
 
constexpr auto ccf::META_KEY_EXPO_WIN_BINX = "MetaExpoWinBinX"
 
constexpr auto ccf::META_KEY_EXPO_WIN_BINY = "MetaExpoWinBinY"
 
constexpr auto ccf::META_KEY_EXPO_WIN_STARTX = "MetaExpoWinStartX"
 
constexpr auto ccf::META_KEY_EXPO_WIN_STARTY = "MetaExpoWinStartY"
 
constexpr auto ccf::META_KEY_SYSTEM = "MetaSystem"
 
constexpr auto ccf::META_KEY_CAM_NAME = "MetaCamName"
 
constexpr auto ccf::META_KEY_CAM_ID = "MetaCamId"
 
constexpr auto ccf::META_KEY_CAM_MODEL = "MetaCamModel"
 
constexpr auto ccf::META_KEY_CAM_CHIPMODEL = "MetaCamChipModel"
 
constexpr auto ccf::META_KEY_CAM_TYPE = "MetaCamType"
 
Configuration parameter names.
constexpr auto ccf::CFG_NODE_ACQUISITION = "acquisition"
 
constexpr auto ccf::CFG_NODE_MONITORING = "monitoring"
 
constexpr auto ccf::CFG_NODE_PROCESSING = "processing"
 
constexpr auto ccf::CFG_NODE_RECORDING = "recording"
 
constexpr auto ccf::CFG_NODE_SERVER = "server"
 
constexpr auto ccf::CFG_NODE_TASKS = "tasks"
 
constexpr auto ccf::CFG_KEY_ADAPTER = "adapter"
 
constexpr auto ccf::CFG_KEY_ADDRESS = "address"
 
constexpr auto ccf::CFG_KEY_ALLOW_FRAME_SKIPPING = "allow_frame_skipping"
 
constexpr auto ccf::CFG_KEY_ALLOW_LOST_FRAMES = "allow_lost_frames"
 
constexpr auto ccf::CFG_KEY_DEVICES = "devices"
 
constexpr auto ccf::CFG_KEY_HEIGHT = "height"
 
constexpr auto ccf::CFG_KEY_ID = "id"
 
constexpr auto ccf::CFG_KEY_IMAGE_DIR = "image_dir"
 
constexpr auto ccf::CFG_KEY_INIT_SETUP = "init_setup"
 
constexpr auto ccf::CFG_KEY_INPUT_QUEUE_SIZE = "input_queue_size"
 
constexpr auto ccf::CFG_KEY_MANUFACTURER = "manufacturer"
 
constexpr auto ccf::CFG_KEY_MAPPING = "mapping"
 
constexpr auto ccf::CFG_KEY_MAX_RATE = "max_rate"
 
constexpr auto ccf::CFG_KEY_MAX_RESOLUTION = "max_resolution"
 
constexpr auto ccf::CFG_KEY_METADATA_MAP = "metadata_map"
 
constexpr auto ccf::CFG_KEY_MODEL = "model"
 
constexpr auto ccf::CFG_KEY_NAME = "name"
 
constexpr auto ccf::CFG_KEY_NAMES = "names"
 
constexpr auto ccf::CFG_KEY_NB_OF_SAMPLES = "nb_of_samples"
 
constexpr auto ccf::CFG_KEY_OUPUT_QUEUE_SIZE = "output_queue_size"
 
constexpr auto ccf::CFG_KEY_PERIOD = "period"
 
constexpr auto ccf::CFG_KEY_PIPELINE = "pipeline"
 
constexpr auto ccf::CFG_KEY_PROPERTIES = "properties"
 
constexpr auto ccf::CFG_KEY_PROTOCOL = "protocol"
 
constexpr auto ccf::CFG_KEY_PUBLISHERS = "publishers"
 
constexpr auto ccf::CFG_KEY_RECIPES = "recipes"
 
constexpr auto ccf::CFG_KEY_REC_HIST_EXP = "rec_hist_expiration"
 
constexpr auto ccf::CFG_KEY_REC_HIST_SIZE = "rec_hist_size"
 
constexpr auto ccf::CFG_KEY_RESOLUTION = "resolution"
 
constexpr auto ccf::CFG_KEY_SDK = "sdk"
 
constexpr auto ccf::CFG_KEY_SIMULATION = "simulation"
 
constexpr auto ccf::CFG_KEY_SIM_ADDRESS = "sim_address"
 
constexpr auto ccf::CFG_KEY_TYPE = "type"
 
constexpr auto ccf::CFG_KEY_VALUE = "value"
 
constexpr auto ccf::CFG_KEY_WIDTH = "width"
 
Setup parameter names.
constexpr auto ccf::SETUP_NODE_EXPO = "expo"
 
constexpr auto ccf::SETUP_NODE_SIM = "sim"
 
constexpr auto ccf::SETUP_KEY_ADDRESS = "address"
 
constexpr auto ccf::SETUP_KEY_BASENAME = "basename"
 
constexpr auto ccf::SETUP_KEY_BIN_X = "bin_x"
 
constexpr auto ccf::SETUP_KEY_BIN_Y = "bin_y"
 
constexpr auto ccf::SETUP_KEY_DELAY = "delay"
 
constexpr auto ccf::SETUP_KEY_ENABLED = "enabled"
 
constexpr auto ccf::SETUP_KEY_FILE = "file"
 
constexpr auto ccf::SETUP_KEY_FORMAT = "format"
 
constexpr auto ccf::SETUP_KEY_FRAME_RATE = "frame_rate"
 
constexpr auto ccf::SETUP_KEY_FRAME_RATE_LIMIT = "frame_rate_limit"
 
constexpr auto ccf::SETUP_KEY_MAX_RATE = "max_rate"
 
constexpr auto ccf::SETUP_KEY_MAX_SHIFT = "max_shift"
 
constexpr auto ccf::SETUP_KEY_MAX_SHIFT_PR_FRAME = "max_shift_pr_frame"
 
constexpr auto ccf::SETUP_KEY_MAX_SIZE = "max_size"
 
constexpr auto ccf::SETUP_KEY_MODE = "mode"
 
constexpr auto ccf::SETUP_KEY_NB = "nb"
 
constexpr auto ccf::SETUP_KEY_RATE = "rate"
 
constexpr auto ccf::SETUP_KEY_NOISE = "noise"
 
constexpr auto ccf::SETUP_KEY_PORT = "port"
 
constexpr auto ccf::SETUP_KEY_TIME = "time"
 
constexpr auto ccf::SETUP_KEY_TYPE = "type"
 
constexpr auto ccf::SETUP_KEY_WIN_START_X = "win_start_x"
 
constexpr auto ccf::SETUP_KEY_WIN_START_Y = "win_start_y"
 
constexpr auto ccf::SETUP_KEY_WIN_WIDTH = "win_width"
 
constexpr auto ccf::SETUP_KEY_WIN_HEIGHT = "win_height"
 
Simulation type.
constexpr auto ccf::SIM_TYPE_FILE_STR = "File"
 
constexpr auto ccf::SIM_TYPE_PATTERN1_STR = "Pattern1"
 

Logging levels literal names.

constexpr auto ccf::CCF_VERSION = "1.2.0"
 Version of CCF. More...
 
constexpr auto ccf::IFW_VERSION = "4.0"
 Version of IFW. More...
 
constexpr auto ccf::NO_VALUE = "__NO__VALUE__"
 
LogLevel ccf::LogLevelToNb (const std::string &log_level)
 
std::string ccf::LogLevelToString (const LogLevel log_level)
 

States (composite).

enum  ccf::ThreadType {
  ccf::ThreadType::MONITOR = 1, ccf::ThreadType::ACQUISITION, ccf::ThreadType::PROCESSING, ccf::ThreadType::PUBLISHER,
  ccf::ThreadType::UNDEFINED = -1
}
 
enum  ccf::HwStatus { ccf::HwStatus::NOT_OK = 0, ccf::HwStatus::OK }
 HW status values. More...
 
enum  ccf::Status { ccf::Status::FAILURE = 0, ccf::Status::SUCCESS = 1 }
 General status variable. More...
 
constexpr auto ccf::STATE_ON_NOT_OP_NOT_READY = "On::NotOperational::NotReady"
 
constexpr auto ccf::STATE_ON_NOT_OP_READY = "On::NotOperational::Ready"
 
constexpr auto ccf::STATE_ON_OP_IDLE = "On::Operational::Idle"
 
constexpr auto ccf::STATE_ON_OP_ACQ = "On::Operational::Acquisition"
 
constexpr auto ccf::STATE_ON_OP_ACQ_NOT_REC = "On::Operational::Acquisition::NotRecording"
 
constexpr auto ccf::STATE_ON_OP_ACQ_REC = "On::Operational::Acquisition::Recording"
 
void ccf::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::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::DecomposeSmStatus (const std::string &sm_state, std::string &sum_state, std::string &sum_substate)
 
void ccf::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. More...
 

Execution status.

enum  ccf::Bitpix {
  ccf::Bitpix::UNKNOWN = -1, ccf::Bitpix::BYTE = 8, ccf::Bitpix::PRESCALED = -8, ccf::Bitpix::INT16 = 16,
  ccf::Bitpix::UINT16 = -16, ccf::Bitpix::INT32 = 32, ccf::Bitpix::FLOAT = -32, ccf::Bitpix::INT64 = 64,
  ccf::Bitpix::DOUBLE = -64
}
 CCF image data types. Based on the values defined for BITPIX in the FITS standard. More...
 
enum  ccf::PubType { ccf::PubType::UNDEFINED = -1, ccf::PubType::RECORDING = 1, ccf::PubType::NOT_RECORDING }
 A Publisher may be Recording or Not-Recording. A Recording Publisher publishes data into files. More...
 
enum  ccf::PubStatus {
  ccf::PubStatus::ACTIVE = recif::RecStatusNames::Active, ccf::PubStatus::COMPLETED = recif::RecStatusNames::Completed, ccf::PubStatus::STOPPED = recif::RecStatusNames::Stopped, ccf::PubStatus::ABORTED = recif::RecStatusNames::Aborted,
  ccf::PubStatus::FAILED = recif::RecStatusNames::Failed, ccf::PubStatus::UNDEFINED = recif::RecStatusNames::Undefined
}
 Defines the various possible states of a Data Publisher. More...
 
enum  ccf::ProcStatus {
  ccf::ProcStatus::UNDEFINED = -1, ccf::ProcStatus::IDLE = 1, ccf::ProcStatus::PROCESSING = 32, ccf::ProcStatus::FINISHED = 128,
  ccf::ProcStatus::FAILED = 256
}
 Possible states for a Processing Recipe defined. More...
 
enum  ccf::ExpoMode { ccf::ExpoMode::FINITE = 1, ccf::ExpoMode::CONTINUOUS, ccf::ExpoMode::INACTIVE }
 Exposure modes. More...
 
constexpr auto ccf::SUCCESS = "Success"
 
constexpr auto ccf::FAILURE = "Failure"
 
std::string ccf::StatusToStr (ccf::Status status)
 Convert the status from number to string. More...
 
DataTypes ccf::BitpixToDataType (const Bitpix bitpix)
 Converts the FITS BITPIX value into a data type. More...
 
void ccf::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::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::SimType { ccf::SimType::FILE = 1, ccf::SimType::PATTERN1 }
 Simulation type. More...
 
constexpr auto ccf::EXPO_MODE_FINITE = "Finite"
 
constexpr auto ccf::EXPO_MODE_CONTINUOUS = "Continuous"
 
constexpr auto ccf::EXPO_MODE_INACTIVE = "Inactive"
 
constexpr auto ccf::REC_ID_PREFIX = "RecId"
 
ExpoMode ccf::ExpoModeToNb (const std::string &expo_mode)
 Convert exposure mode from number representation to string. More...
 

Publisher Status names.

constexpr auto ccf::PUB_STAT_NAME_ACTIVE = "Active"
 
constexpr auto ccf::PUB_STAT_NAME_COMPLETED = "Completed"
 
constexpr auto ccf::PUB_STAT_NAME_STOPPED = "Stopped"
 
constexpr auto ccf::PUB_STAT_NAME_ABORTED = "Aborted"
 
constexpr auto ccf::PUB_STAT_NAME_FAILED = "Failed"
 
constexpr auto ccf::PUB_STAT_NAME_UNDEFINED = "Undefined"
 
std::string ccf::RecStatusNameToStr (recif::RecStatusNames rec_status_nb)
 Recording Status name, number to string representation. More...
 
std::string ccf::PubStatusNameToStr (PubStatus pub_status_nb)
 Publisher status, number representation to string. More...
 
std::string ccf::BuildKey (const std::vector< std::string > &elements)
 Build a concatenated key from a number of elements (<el1>.<el2.>...). More...
 
std::vector< std::string > ccf::SplitKey (const std::string &key)
 Split up a concatenated key. More...
 

Macro Definition Documentation

◆ CCFDEBUG

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

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

◆ CCFDEBUG2

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

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

◆ CCFDEBUG3

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

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

◆ CCFERROR

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

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

◆ CCFINFO

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

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

◆ CCFL0C

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

◆ CCFLOC

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

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

◆ 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.

◆ CCFWARNING

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

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

◆ DEBUG2_LOG_GUARD

#define DEBUG2_LOG_GUARD   if (ccf::Base::GetLogLevel() >= ccf::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::Base::GetLogLevel() >= ccf::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::Base::GetLogLevel() >= ccf::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::Base::GetLogLevel() >= ccf::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::Base::GetLogLevel() >= ccf::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

Class used to generate TRACE logs.

The trace class is used to automatically log a scope entry and exit trace log. When entering the scope, an enter log is generated in the constructor. When exiting the scope, the trace class destructor generated a scope leaving log including the time spent in the scope. 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".

◆ CcfThreadName()

std::string CcfThreadName ( )
inline

Return thread name allocated.

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