Changeset 141:357b3b9eaeb6 in finroc_plugins_structure


Ignore:
Timestamp:
04.10.2020 23:21:22 (2 weeks ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adds command line option --default-clock - with the default set to 'steady-initial-system-time', as this is typically the least error-prone due to its steadyness. Before, the behavior of 'system' was the default.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main_utilities.cpp

    r140 r141  
    113113bool enable_crash_handler = true; 
    114114#endif 
     115rrlib::time::tTimeMode time_mode = rrlib::time::tTimeMode::STEADY_INITIAL_SYSTEM_TIME; 
    115116 
    116117// We do not use stuff from rrlib_thread, because we have the rare case that in signal handler 
     
    316317  } 
    317318 
     319  // default clock 
     320  rrlib::getopt::tOption default_clock_option(name_to_option_map.at("default-clock")); 
     321  if (default_clock_option->IsActive()) 
     322  { 
     323    std::string mode = rrlib::getopt::EvaluateValue(default_clock_option); 
     324    if (mode == "system") 
     325    { 
     326      time_mode = rrlib::time::tTimeMode::SYSTEM_TIME; 
     327    } 
     328    else if (mode == "steady-initial-system-time") 
     329    { 
     330      time_mode = rrlib::time::tTimeMode::STEADY_INITIAL_SYSTEM_TIME; 
     331    } 
     332    else 
     333    { 
     334      FINROC_LOG_PRINT_STATIC(ERROR, "Option --default-clock needs to be either 'system' or 'steady-initial-system-time'"); 
     335      return false; 
     336    } 
     337  } 
    318338  return true; 
    319339} 
     
    369389  rrlib::getopt::AddFlag("disable-component-visualization", 0, "Disables component visualization (no dedicated visualization ports will be created)", &OptionsHandler); 
    370390  rrlib::getopt::AddFlag("offline", 0, "Disables online services which would retard software startup time.", &OptionsHandler); 
     391  rrlib::getopt::AddValue("default-clock", 0, "Default clock used for processing timestamps and durations ('system' and 'steady-initial-system-time' (default))", &OptionsHandler); 
    371392} 
    372393 
     
    402423int InitializeAndRunMainLoop(const std::string &program_name) 
    403424{ 
     425  { 
     426    auto current_time_mode = rrlib::time::GetTimeMode(); 
     427    if (current_time_mode == rrlib::time::tTimeMode::SYSTEM_TIME && current_time_mode != time_mode) 
     428    { 
     429      rrlib::time::SetTimeMode(time_mode); 
     430    } 
     431  } 
     432 
    404433  core::tRuntimeEnvironment &runtime_environment = core::tRuntimeEnvironment::GetInstance(); 
    405434 
Note: See TracChangeset for help on using the changeset viewer.