ros_source.h
Go to the documentation of this file.
00001 // *****************************************************************************
00002 //
00003 // Copyright (c) 2015, Southwest Research Institute® (SwRI®)
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms, with or without
00007 // modification, are permitted provided that the following conditions are met:
00008 //     * Redistributions of source code must retain the above copyright
00009 //       notice, this list of conditions and the following disclaimer.
00010 //     * Redistributions in binary form must reproduce the above copyright
00011 //       notice, this list of conditions and the following disclaimer in the
00012 //       documentation and/or other materials provided with the distribution.
00013 //     * Neither the name of Southwest Research Institute® (SwRI®) nor the
00014 //       names of its contributors may be used to endorse or promote products
00015 //       derived from this software without specific prior written permission.
00016 //
00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020 // ARE DISCLAIMED. IN NO EVENT SHALL Southwest Research Institute® BE LIABLE 
00021 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00022 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00023 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00024 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00025 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
00026 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00027 // DAMAGE.
00028 //
00029 // *****************************************************************************
00030 
00031 #ifndef SWRI_PROFILER_TOOLS_ROS_SOURCE_H_
00032 #define SWRI_PROFILER_TOOLS_ROS_SOURCE_H_
00033 
00034 #include <QObject>
00035 #include <QThread>
00036 #include <swri_profiler_msgs/ProfileIndexArray.h>
00037 #include <swri_profiler_msgs/ProfileDataArray.h>
00038 
00039 #include <swri_profiler_tools/profiler_msg_adapter.h>
00040 
00041 namespace swri_profiler_tools
00042 {
00043 // RosSource implements a Qt-friendly interface around ROS.  It
00044 // creates/monitors the connection with the ROS master and handles our
00045 // subscriptions.  Messages are provided via the Qt signal/slot
00046 // framework.  RosSource maintains a separate thread so that the GUI
00047 // doesn't block when some of the ROS functions are taking their sweet
00048 // time.
00049 class ProfileDatabase;
00050 class RosSourceBackend;
00051 class RosSource : public QObject
00052 {
00053   Q_OBJECT;
00054 
00055  public:
00056   RosSource(ProfileDatabase *db);
00057   ~RosSource();
00058 
00059   bool isConnected() const { return connected_; }
00060   const QString& masterUri() const { return master_uri_; }
00061 
00062   void start();
00063   
00064  Q_SIGNALS:
00065   void connected(bool connected, QString uri);
00066 
00067  private Q_SLOTS:
00068   void handleConnected(bool connected, QString uri);
00069   void handleIndex(swri_profiler_msgs::ProfileIndexArray msg);
00070   void handleData(swri_profiler_msgs::ProfileDataArray msg);
00071   
00072  private:
00073   ProfileDatabase *db_;
00074   
00075   QThread ros_thread_;
00076   RosSourceBackend *backend_;
00077 
00078   ProfilerMsgAdapter msg_adapter_;
00079   int profile_key_;
00080   
00081   bool connected_;
00082   QString master_uri_;
00083 };  // class RosSource
00084 }  // namespace swri_profiler_tools
00085 #endif // SWRI_PROFILER_TOOLS_ROS_SOURCE_H_


swri_profiler_tools
Author(s):
autogenerated on Sat Apr 27 2019 03:08:49