Exemplo n.º 1
0
void Publisher::publish_timer_operation(const NAMESPACE::TimerEvent& event)
{
#ifdef USE_ROSMOD
  comp_queue.ROSMOD_LOGGER->log("DEBUG", "Entering Publisher::publish_timer_operation");
#endif

  boost::random::mt19937 rng;
  boost::random::uniform_int_distribution<> loop_iteration_random(2800000*0.6, 2800000);
  int loop_max = loop_iteration_random(rng);  
  
  // Business Logic for publish_timer_operation
  for(int i=0; i < loop_max; i++) {
    double result = 0.0;
    double x = 41865185131.214415;
    double y = 562056205.1515;
    result = x*y;
  }
  publish_subscribe_package::Message message_;
  message_.name = "Publisher";
#ifdef USE_ROSMOD
  comp_queue.ROSMOD_LOGGER->log("DEBUG", "ABOUT TO PUBLISH");
#endif
  publisher_port.publish(message_);
#ifdef USE_ROSMOD
  comp_queue.ROSMOD_LOGGER->log("DEBUG", "DONE PUBLISHING!");
#endif  
  logger->log("INFO", "Publisher::Published on Message topic!");
#ifdef USE_ROSMOD
  comp_queue.ROSMOD_LOGGER->log("DEBUG", "Exiting Publisher::publish_timer_operation");
#endif
}
Exemplo n.º 2
0
 /**
  * @brief A timer operation
  * This operation can be triggered by a periodic timer
  * Bind this operation to a periodic timer in the JSON configuration
  */   
 void Component_2::timer_function() {
   boost::random::mt19937 rng;
   boost::random::uniform_int_distribution<> loop_iteration_random(800000 * 0.6, 800000);
   int loop_max = loop_iteration_random(rng);    
 
   // Business Logic for Timer_2_operation
   for(int i=0; i < loop_max; i++) {
     double result = 0.0;
     double x = 41865185131.214415;
     double y = 562056205.1515;
     result = x*y;
   } 
   publisher("publisher_port")->send("Component_2");
   std::cout << "Component 2 : Timer : Published message: Component_2" << std::endl;    
 }
Exemplo n.º 3
0
  /**
   * @brief A subscriber operation
   * This operation can be bound to a subscriber
   * Bind this operation to a subscriber in the JSON configuration
   */     
  void Component_1::subscriber_function() {
    boost::random::mt19937 rng;
    boost::random::uniform_int_distribution<> loop_iteration_random(700000 * 0.6, 700000);
    int loop_max = loop_iteration_random(rng);  
  
    // Business Logic for Name_Subscriber_operation
    for(int i=0; i < loop_max; i++) {
      double result = 0.0;
      double x = 41865185131.214415;
      double y = 562056205.1515;
      result = x*y;
    }
    std::string received_message = subscriber("Name_Subscriber")->message();
    std::cout << "Component 1 : Subscriber : Received message: " 
	      << received_message << std::endl;
  }    
Exemplo n.º 4
0
 /**
  * @brief A server operation
  * This operation can be bound to a server and requested by some client
  * Bind this operation to a server in the JSON configuration
  */   
 void Component_2::server_function() {
   std::string request = server("server")->message();
   std::cout << "Component 2 : Server : Received request: " << request << std::endl;
   boost::random::mt19937 rng;
   boost::random::uniform_int_distribution<> loop_iteration_random(600000 * 0.6, 600000);
   int loop_max = loop_iteration_random(rng);  
 
   // Business Logic for Service_Server_operation
   for(int i=0; i < loop_max; i++) {
     double result = 0.0;
     double x = 41865185131.214415;
     double y = 562056205.1515;
     result = x*y;
   }
   publisher("publisher_port")->send("Component_2");
   std::cout << "Component 2 : Server : Published message: Component_2" << std::endl;
   server("server")->set_response("Component_2");
 }
Exemplo n.º 5
0
// Subscriber Operation - Name_Subscriber
//# Start Name_Subscriber_operation Marker
void Component_1::Name_Subscriber_operation(const ten_component::ComponentName::ConstPtr& received_data)
{
#ifdef USE_ROSMOD
  comp_queue.ROSMOD_LOGGER->log("DEBUG", "Entering Component_1::Name_Subscriber_operation");
#endif
  // Business Logic for Name_Subscriber_operation
  boost::random::mt19937 rng;
  boost::random::uniform_int_distribution<> loop_iteration_random(70000 * 0.6, 70000);
  int loop_max = loop_iteration_random(rng);  
  // Business Logic for Name_Subscriber_operation
  for(int i=0; i < loop_max; i++) {
    double result = 0.0;
    double x = 41865185131.214415;
    double y = 562056205.1515;
    result = x*y;
  }
  
#ifdef USE_ROSMOD
  comp_queue.ROSMOD_LOGGER->log("DEBUG", "Exiting Component_1::Name_Subscriber_operation");
#endif
}
Exemplo n.º 6
0
void All_Timers::Timer_2_operation(const NAMESPACE::WallTimerEvent& event)
{
#ifdef USE_ROSMOD
  comp_queue.ROSMOD_LOGGER->log("DEBUG", "Entering All_Timers::Timer_2_operation");
#endif
  // Business Logic for Timer_2_operation
  boost::random::mt19937 rng;
  boost::random::uniform_int_distribution<> loop_iteration_random(750000 * 0.6, 750000);
  int loop_max = loop_iteration_random(rng);  
  
  // Business Logic for Timer_2_operation
  for(int i=0; i < loop_max; i++) {
    double result = 0.0;
    double x = 41865185131.214415;
    double y = 562056205.1515;
    result = x*y;
  }
#ifdef USE_ROSMOD
  comp_queue.ROSMOD_LOGGER->log("DEBUG", "Exiting All_Timers::Timer_2_operation");
#endif
}