statistics.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2013-2014, Dariush Forouher
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *   * Redistributions of source code must retain the above copyright notice,
00007  *     this list of conditions and the following disclaimer.
00008  *   * Redistributions in binary form must reproduce the above copyright
00009  *     notice, this list of conditions and the following disclaimer in the
00010  *     documentation and/or other materials provided with the distribution.
00011  *   * Neither the names of Willow Garage, Inc. nor the names of its
00012  *     contributors may be used to endorse or promote products derived from
00013  *     this software without specific prior written permission.
00014  *
00015  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00016  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00018  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00019  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00020  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00021  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00024  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00025  * POSSIBILITY OF SUCH DAMAGE.
00026  */
00027 
00028 #ifndef ROSCPP_STATISTICS_H
00029 #define ROSCPP_STATISTICS_H
00030 
00031 #include "forwards.h"
00032 #include "poll_set.h"
00033 #include "common.h"
00034 #include "publisher.h"
00035 #include <ros/time.h>
00036 #include "ros/subscription_callback_helper.h"
00037 #include <map>
00038 
00039 namespace ros
00040 {
00041 
00049 class ROSCPP_DECL StatisticsLogger
00050 {
00051 public:
00052 
00056   StatisticsLogger();
00057 
00061   void init(const SubscriptionCallbackHelperPtr& helper);
00062 
00066   void callback(const boost::shared_ptr<M_string>& connection_header, const std::string& topic, const std::string& callerid, const SerializedMessage& m, const uint64_t& bytes_sent, const ros::Time& received_time, bool dropped);
00067 
00068 private:
00069 
00070   // these are hard constrains
00071   int max_window;
00072   int min_window;
00073 
00074   // these are soft constrains
00075   int max_elements;
00076   int min_elements;
00077 
00078   bool enable_statistics;
00079 
00080   // remember, if this message type has a header
00081   bool hasHeader_;
00082 
00083   // frequency to publish statistics
00084   double pub_frequency_;
00085 
00086   // publisher for statistics data
00087   ros::Publisher pub_;
00088 
00089   struct StatData {
00090     // last time, we published /statistics data
00091     ros::Time last_publish;
00092     // arrival times of all messages within the current window
00093     std::list<ros::Time> arrival_time_list;
00094     // age of all messages within the current window (if available)
00095     std::list<ros::Duration> age_list;
00096     // number of dropped messages
00097     uint64_t dropped_msgs;
00098     // latest sequence number observered (if available)
00099     uint64_t last_seq;
00100     // latest total traffic volume observed
00101     uint64_t stat_bytes_last;
00102   };
00103 
00104   // storage for statistics data
00105   std::map<std::string, struct StatData> map_;
00106 };
00107 
00108 }
00109 
00110 #endif


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Thu Jun 6 2019 21:10:05