INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

multiicestormutils.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This copy of Orca is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef ORCAICE_MULTI_ICESTORM_UTILITIES_H
00012 #define ORCAICE_MULTI_ICESTORM_UTILITIES_H
00013 
00014 #include <orcaice/icestormutils.h>
00015 // we only need the definition of Stoppable and checkedSleep() function.
00016 // (we don't need the actual Thread class).
00017 #include <gbxsickacfr/gbxiceutilacfr/threadutils.h>
00018 
00019 namespace orcaice
00020 {
00025 
00039 template<class ConsumerProxyType>
00040 IceStorm::TopicPrx
00041 connectToTopicWithString( const Context     & context,
00042                           ConsumerProxyType & publisher,
00043                           const std::string & topicName,
00044                           gbxutilacfr::Stoppable* activity, const std::string& subsysName="", 
00045                           int retryIntervalSec=2, int retryNumber=-1,
00046                           bool localReportingOnly=false )
00047 {
00048     assert( activity && "Null activity pointer" );
00049 
00050     IceStorm::TopicPrx topicPrx;
00051 
00052     int count = 0;
00053     while ( !activity->isStopping() && ( retryNumber<0 || count<retryNumber) )
00054     {
00055         try {
00056             topicPrx = connectToTopicWithString<ConsumerProxyType>( context, publisher, topicName );
00057             break;
00058         }
00059         catch ( const orcaice::NetworkException& e )  {
00060             std::stringstream ss;
00061             ss << "Failed to connect to topic with string "<<topicName<<". "
00062                 <<"Will retry in "<<retryIntervalSec<<"s."
00063                 << e.what();
00064             // not issuing status warnings because we would need to add localReportingOnly option
00065             context.tracer().warning( subsysName, ss.str(), 1, localReportingOnly );
00066         }
00067         ++count;
00068         gbxiceutilacfr::checkedSleep( activity, retryIntervalSec*1000 );
00069         if ( !subsysName.empty() ) {
00070             context.status().heartbeat( subsysName );
00071         }
00072     }
00073     return topicPrx;
00074 }
00075 
00091 template<class ConsumerProxyType>
00092 IceStorm::TopicPrx
00093 connectToTopicWithTag( const Context      & context,
00094                        ConsumerProxyType  & publisher,
00095                        const std::string  & interfaceTag,
00096                        const std::string  & subtopic,
00097                        gbxutilacfr::Stoppable* activity, const std::string& subsysName="", 
00098                        int retryIntervalSec=2, int retryNumber=-1,
00099                        bool localReportingOnly=false )
00100 {
00101     assert( activity && "Null activity pointer" );
00102 
00103     IceStorm::TopicPrx topicPrx;
00104 
00105     int count = 0;
00106     while ( !activity->isStopping() && ( retryNumber<0 || count<retryNumber) )
00107     {
00108         try {
00109             topicPrx = connectToTopicWithTag<ConsumerProxyType>( context, publisher, interfaceTag, subtopic );
00110             break;
00111         }
00112         catch ( const orcaice::NetworkException& e ) {
00113             std::stringstream ss;
00114             ss << "Failed to connect to topic with tag "<<interfaceTag<<". "
00115                 <<"Will retry in "<<retryIntervalSec<<"s."
00116                 << e.what();
00117             // not issuing status warnings because we would need to add localReportingOnly option
00118             context.tracer().warning( subsysName, ss.str(), 1, localReportingOnly );
00119         }
00120         ++count;
00121         gbxiceutilacfr::checkedSleep( activity, retryIntervalSec*1000 );
00122         if ( !subsysName.empty() ) {
00123             context.status().heartbeat( subsysName );
00124         }
00125     }
00126     return topicPrx;
00127 }
00128 
00130 
00131 } // namespace
00132 
00133 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5