cooling/cooling.cc
/// Attempt to load the config file and populate parameters.  This can
/// throw a config error if the file is missing or contents are
/// invalid. Does not run anything or have filesystem or GPIO side effects,
/// but it WILL modify this Cooling instance.
///
/// * May throw a Cooling_config_exception.
///
Attempt to load the config file and populate parameters.  This can
throw a config error if the file is missing or contents are
invalid. Does not run anything or have filesystem or GPIO side effects,
but it WILL modify this Cooling instance.

May throw a Cooling_config_exception.
Attempt to load the config file and populate parameters . This can throw a config error if the file is missing or contents are invalid . Does not run anything or have filesystem or GPIO side effects but it WILL modify this Cooling instance . May throw a Cooling_config_exception .
void Cooling::initialize(bool debug)
{
    Config cfg(m_cfg_path.c_str());
    m_debug = debug;
    cfg.read_config();  
    if (cfg.get_schema() != "1.1") {
        LOG_ERROR(Lgr) << "Invalid schema ('" << cfg.get_schema()
                       << "') in " << m_cfg_path;
        throw Cooling_config_exception();
    }
    if (not m_logging_up) {
        auto  logpath = expand_home( "~/logs/cooling_%5N.log" );
        int flags = LF_FILE;
        if (m_console_log) { flags |= LF_CONSOLE; }
        if (m_test_mode) { flags = LF_CONSOLE; }
        if (m_debug) { flags |= LF_DEBUG; }
        init_logging( AppName, logpath.c_str(), flags );
        m_logging_up = true;
    }
    cfg.log_about();
    m_cfgversion = "?";
    cfg.get_string("General","version",m_cfgversion);
    m_cfgdesc = "?";
    cfg.get_string("General","description",m_cfgdesc);
    std::string cfg_appname;
    cfg.get_string("General","application", cfg_appname);
    if (cfg_appname != AppName) {
        LOG_WARNING(Lgr) << "unexpected application name: '"
                         << cfg_appname << "' in " << m_cfg_path;
    }
     General: Polling etc
    const long DefaultPollMsec=1000;
    const long MAX_POLL_MSEC = 5000;
    long poll_msec = DefaultPollMsec;
    cfg.get_long("General","poll_msec",poll_msec);
    if ((poll_msec > MAX_POLL_MSEC) or (poll_msec < 1)) {
        LOG_ERROR(Lgr) << "poll_msec must be between 1 and " << MAX_POLL_MSEC;
        poll_msec = DefaultPollMsec;
        LOG_INFO(Lgr) << "poll_msec := " <<poll_msec;
    }
    m_poll_timespec.tv_sec = poll_msec/1000;
    poll_msec -= 1000 * m_poll_timespec.tv_sec;
    m_poll_timespec.tv_nsec = (poll_msec * 1'000'000);
    cfg.get_unsigned("General","poll_trace",m_poll_trace);
    LOG_DEBUG(Lgr) << "poll_timespec: "
                   << m_poll_timespec.tv_sec << "s + "
                   << m_poll_timespec.tv_nsec <<  "ns";
     Other sections:
    init_rsked( cfg );
    init_cooling( cfg );
    init_snooze_button( cfg );
    init_panel_leds( cfg );
    log_banner(true);
}
void Cooling :: initialize ( bool debug ) { Config cfg ( m_cfg_path . c_str ( ) ) ; m_debug = debug ; cfg . read_config ( ) ; if ( cfg . get_schema ( ) != " " ) { LOG_ERROR ( Lgr ) << " " << cfg . get_schema ( ) << " " << m_cfg_path ; throw Cooling_config_exception ( ) ; } if ( not m_logging_up ) { auto logpath = expand_home ( " " ) ; int flags = LF_FILE ; if ( m_console_log ) { flags |= LF_CONSOLE ; } if ( m_test_mode ) { flags = LF_CONSOLE ; } if ( m_debug ) { flags |= LF_DEBUG ; } init_logging ( AppName , logpath . c_str ( ) , flags ) ; m_logging_up = true ; } cfg . log_about ( ) ; m_cfgversion = " " ; cfg . get_string ( " " , " " , m_cfgversion ) ; m_cfgdesc = " " ; cfg . get_string ( " " , " " , m_cfgdesc ) ; std :: string cfg_appname ; cfg . get_string ( " " , " " , cfg_appname ) ; if ( cfg_appname != AppName ) { LOG_WARNING ( Lgr ) << " " << cfg_appname << " " << m_cfg_path ; } const long DefaultPollMsec = 1000 ; const long MAX_POLL_MSEC = 5000 ; long poll_msec = DefaultPollMsec ; cfg . get_long ( " " , " " , poll_msec ) ; if ( ( poll_msec > MAX_POLL_MSEC ) or ( poll_msec < 1 ) ) { LOG_ERROR ( Lgr ) << " " << MAX_POLL_MSEC ; poll_msec = DefaultPollMsec ; LOG_INFO ( Lgr ) << " " << poll_msec ; } m_poll_timespec . tv_sec = poll_msec / 1000 ; poll_msec -= 1000 * m_poll_timespec . tv_sec ; m_poll_timespec . tv_nsec = ( poll_msec * 1'000'000 ) ; cfg . get_unsigned ( " " , " " , m_poll_trace ) ; LOG_DEBUG ( Lgr ) << " " << m_poll_timespec . tv_sec << " " << m_poll_timespec . tv_nsec << " " ; init_rsked ( cfg ) ; init_cooling ( cfg ) ; init_snooze_button ( cfg ) ; init_panel_leds ( cfg ) ; log_banner ( true ) ; }
Attempt to load the config file and populate parameters.
Attempt to load the config file and populate parameters .
// may throw // Logging -- don't do this if it has been done once already // General: version, application // // General: Polling etc // Other sections: //