Changeset 120:780680ad94e9 in finroc_plugins_structure


Ignore:
Timestamp:
18.02.2019 08:24:41 (8 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Parents:
106:9994afeb1059 (diff), 119:4683da0fb7e6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge with 17.03

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • examples/mTestModule.cpp

    r119 r120  
    9191{ 
    9292  this->output_signal.Publish(this->counter); 
    93   std::cout << this->counter << " " << rrlib::time::ToIsoString(rrlib::time::Now()) << std::endl; 
     93  FINROC_LOG_PRINT(DEBUG, this->counter, " ", rrlib::time::ToIsoString(rrlib::time::Now())); 
    9494  this->counter++; 
    9595 
    9696  if (this->input_signal.HasChanged()) 
    9797  { 
    98     std::cout << "Received input signal: " << this->input_signal.Get() << " " << rrlib::time::ToIsoString(rrlib::time::Now()) << std::endl; 
     98    FINROC_LOG_PRINT(USER, "Received input signal: ", this->input_signal.Get(), " ", rrlib::time::ToIsoString(rrlib::time::Now())); 
    9999  } 
    100100} 
  • main_utilities.cpp

    r106 r120  
    5858#include "plugins/scheduling/tThreadContainerThread.h" 
    5959 
     60#ifdef _LIB_FINROC_PLUGINS_NETWORK_TRANSPORT_GENERIC_PROTOCOL_PRESENT_ 
     61#include "plugins/network_transport/generic_protocol/tLocalRuntimeInfo.h" 
     62#endif 
    6063#ifdef _LIB_FINROC_PLUGINS_TCP_PRESENT_ 
    61 #include "plugins/tcp/tPeer.h" 
     64#include "plugins/tcp/tTCPPlugin.h" 
    6265#endif 
    6366 
     
    118121#endif 
    119122 
    120 #ifdef _LIB_FINROC_PLUGINS_TCP_PRESENT_ 
    121 tcp::tPeer *tcp_peer; 
    122 #endif 
    123  
    124123/*! 
    125124 * Shuts down program cleanly by stopping all threads and deleting all framework elements. 
     
    197196  if (parameter_config->IsActive()) 
    198197  { 
    199     const std::string &file = rrlib::getopt::EvaluateValue(parameter_config); 
    200     if (!core::FinrocFileExists(file)) 
    201     { 
    202       FINROC_LOG_PRINT_STATIC(ERROR, "Could not find specified config file ", file); 
    203       return false; 
    204     } 
    205     else 
    206     { 
    207       FINROC_LOG_PRINT_STATIC(DEBUG, "Loading config file ", file); 
    208     } 
    209     parameters::tConfigurablePlugin::SetConfigFile(file); 
    210     core::tRuntimeEnvironment::GetInstance().AddAnnotation(*new parameters::tConfigFile(file)); 
     198    parameters::tConfigFile* config_file = nullptr; 
     199    for (auto & file : rrlib::getopt::EvaluateValueList(parameter_config)) 
     200    { 
     201      if (!core::FinrocFileExists(file)) 
     202      { 
     203        FINROC_LOG_PRINT_STATIC(ERROR, "Could not find specified config file ", file); 
     204        return false; 
     205      } 
     206      else 
     207      { 
     208        FINROC_LOG_PRINT_STATIC(DEBUG, "Loading config file ", file); 
     209      } 
     210      if (!config_file) 
     211      { 
     212        parameters::tConfigurablePlugin::SetConfigFile(file); 
     213        config_file = new parameters::tConfigFile(file); 
     214        core::tRuntimeEnvironment::GetInstance().AddAnnotation(*config_file); 
     215      } 
     216      else 
     217      { 
     218        try 
     219        { 
     220          config_file->Append(file); 
     221        } 
     222        catch (const std::exception& e) 
     223        { 
     224          FINROC_LOG_PRINT(ERROR, "Could not append config file '", file, "': ", e.what()); 
     225        } 
     226      } 
     227    } 
    211228  } 
    212229 
     
    223240    if (port < 1 || port > 65535) 
    224241    { 
    225       FINROC_LOG_PRINT_STATIC(ERROR, "Invalid port '", port, "'. Using default: ", tcp::tOptions::GetDefaultOptions().preferred_server_port); 
     242      FINROC_LOG_PRINT_STATIC(ERROR, "Invalid port '", port, "'. Using default: ", tcp::tTCPPlugin::GetInstance().par_preferred_server_port.Get()); 
    226243    } 
    227244    else 
    228245    { 
    229246      FINROC_LOG_PRINT_STATIC(DEBUG, "Listening on user defined port ", port, "."); 
    230       tcp::tOptions::GetDefaultOptions().preferred_server_port = port; 
     247      tcp::tTCPPlugin::GetInstance().par_preferred_server_port.Set(port); 
    231248    } 
    232249#endif 
     
    247264    for (auto & address : rrlib::getopt::EvaluateValueList(connect_option)) 
    248265    { 
    249       tcp::tOptions::GetDefaultOptions().connect_to.push_back(address); 
     266      tcp::tTCPPlugin::GetInstance().AddRuntimeToConnectTo(address); 
    250267      FINROC_LOG_PRINT_STATIC(DEBUG, "Connecting to ", address); 
    251268    } 
     
    258275  { 
    259276#ifdef _LIB_FINROC_PLUGINS_TCP_PRESENT_ 
    260     tcp::tOptions::GetDefaultOptions().server_listen_address = rrlib::getopt::EvaluateValue(listen_address_option); 
    261     FINROC_LOG_PRINT_STATIC(DEBUG, "Listening on ", tcp::tOptions::GetDefaultOptions().server_listen_address); 
     277    tcp::tTCPPlugin::GetInstance().par_server_listen_address.Set(rrlib::getopt::EvaluateValue(listen_address_option)); 
     278    FINROC_LOG_PRINT_STATIC(DEBUG, "Listening on ", tcp::tTCPPlugin::GetInstance().par_server_listen_address.Get()); 
    262279#endif 
    263280  } 
     
    340357{ 
    341358  rrlib::getopt::AddValue("log-config", 'l', "Log config file", &OptionsHandler, true); 
    342   rrlib::getopt::AddValue("config-file", 'c', "Parameter config file", &OptionsHandler, true); 
     359  rrlib::getopt::AddValue("config-file", 'c', "Parameter config file", &OptionsHandler); 
    343360  rrlib::getopt::AddValue("listen-address", 0, "Address on which to listen for connections (default: 0.0.0.0), set this to :: to enable IPv6", &OptionsHandler); 
    344361  rrlib::getopt::AddValue("port", 'p', "Network port to use", &OptionsHandler, true); 
     
    370387// ConnectTCPPeer 
    371388//---------------------------------------------------------------------- 
    372 void ConnectTCPPeer(const std::string &peer_name) 
    373 { 
    374 #ifdef _LIB_FINROC_PLUGINS_TCP_PRESENT_ 
    375   // Create and connect TCP peer 
    376   tcp::tOptions::GetDefaultOptions().peer_name = peer_name; 
    377   tcp_peer = new tcp::tPeer(); 
    378   tcp_peer->Init(); 
    379   try 
    380   { 
    381     tcp_peer->Connect(); 
    382   } 
    383   catch (const std::exception& e1) 
    384   { 
    385     FINROC_LOG_PRINT_STATIC(WARNING, "Error connecting Peer: ", e1); 
    386   } 
     389void SetRuntimeName(const std::string &name) 
     390{ 
     391#ifdef _LIB_FINROC_PLUGINS_NETWORK_TRANSPORT_GENERIC_PROTOCOL_PRESENT_ 
     392  network_transport::generic_protocol::tLocalRuntimeInfo::SetName(name); 
    387393#endif 
    388394} 
     
    417423  } 
    418424 
    419 #ifdef _LIB_FINROC_PLUGINS_TCP_PRESENT_ 
    420   if (tcp_peer->IsReady()) 
    421   { 
    422     tcp_peer->StartServingStructure(); 
    423   } 
     425#ifdef _LIB_FINROC_PLUGINS_NETWORK_TRANSPORT_GENERIC_PROTOCOL_PRESENT_ 
     426  network_transport::generic_protocol::tLocalRuntimeInfo::StartServingStructure(); 
    424427#endif 
    425428 
Note: See TracChangeset for help on using the changeset viewer.