YarpDataFeedReporter.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "config.h"
00031
00032 #include "YarpDataFeedReporter.hpp"
00033 #include "YarpDataFeedReconnectTask.hpp"
00034 #include "YarpDataFeedSetupTask.hpp"
00035
00036 #include <Service.hpp>
00037 #include <ActiveObject.hpp>
00038
00039 #include <iostream>
00040
00041 using namespace mermaid::support::communication;
00042
00043 YarpDataFeedReporter::YarpDataFeedReporter (YarpDataFeedInputPort * port)
00044 {
00045 port_ = port;
00046 };
00047
00048 YarpDataFeedReporter::~YarpDataFeedReporter()
00049 {
00050
00051 };
00052
00053 void YarpDataFeedReporter::report (const PortInfo &info)
00054 {
00055 std::cerr << "YarpDataFeedReporter::report" << std::endl;
00056
00057
00058 if (info.incoming == true) {
00059 std::cerr << "YarpDataFeedReporter::report : incoming connection" << std::endl;
00060 }
00061 else {
00062 std::cerr << "YarpDataFeedReporter::report : outgoing connection" << std::endl;
00063 }
00064
00065 if (info.created == true) {
00066 std::cerr << "YarpDataFeedReporter::report : connection created" << std::endl;
00067 }
00068 else {
00069 std::cerr << "YarpDataFeedReporter::report : connection failed" << std::endl;
00070 }
00071
00072 std::string portName (info.portName.c_str());
00073 std::string sourceName (info.sourceName.c_str());
00074 std::string targetName (info.targetName.c_str());
00075 std::string carrierName (info.carrierName.c_str());
00076 std::string message (info.message.c_str());
00077
00078 std::cerr << "YarpDataFeedReporter::report : portName=\"" << portName << "\"" << std::endl;
00079 std::cerr << "YarpDataFeedReporter::report : sourceName=\"" << sourceName << "\"" << std::endl;
00080 std::cerr << "YarpDataFeedReporter::report : targetName=\"" << targetName << "\"" << std::endl;
00081 std::cerr << "YarpDataFeedReporter::report : carrierName=\"" << carrierName << "\"" << std::endl;
00082 std::cerr << "YarpDataFeedReporter::report : message=\"" << message << "\"" << std::endl;
00083
00084
00085 if ( (info.incoming == true) && (info.created == false)) {
00086 #ifdef USE_COMM
00087
00088 shared_ptr<Task> setupTask (new YarpDataFeedSetupTask (port_->getConsumerService(), port_->getProducerEntityName(),
00089 port_->getProducerServiceName(), port_->getDataFeedName(), port_->getConsumerService()->getActiveObject()));
00090 port_->getConsumerService()->getActiveObject()->addTask (setupTask);
00091 #endif
00092
00093 shared_ptr<Task> reconnectTask (new YarpDataFeedReconnectTask (port_));
00094 port_->getConsumerService()->getActiveObject()->addTask (reconnectTask);
00095 }
00096 };