YarpDataFeedReporter.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright 2007, 2008, 2009, 2010, 2011 Instituto de Sistemas e Robotica, Instituto Superior Tecnico
00003 
00004 This file is part of MeRMaID.
00005 
00006 MeRMaID is free software: you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation, either version 3 of the License, or
00009 (at your option) any later version.
00010 
00011 MeRMaID is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU Lesser General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with MeRMaID.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 
00022 /**
00023  * @Filename YarpDataFeedReporter.cpp
00024  * @Description YarpDataFeedReporter implementation
00025  * @Status Work in Progress
00026  * @Version $Id: YarpDataFeedReporter.cpp 1 2011-03-04 18:13:18Z jreis $
00027  * @Maintainer
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 }; // YarpDataFeedReporter
00047 
00048 YarpDataFeedReporter::~YarpDataFeedReporter()
00049 {
00050 
00051 }; // ~YarpDataFeedReporter
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   //check if incoming connection failed
00085   if ( (info.incoming == true) && (info.created == false)) {
00086 #ifdef USE_COMM
00087     //schedule datafeed (re)setup
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     //schedule port reconnection
00093     shared_ptr<Task> reconnectTask (new YarpDataFeedReconnectTask (port_));
00094     port_->getConsumerService()->getActiveObject()->addTask (reconnectTask);
00095   }
00096 }; // report()
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3