plotoption.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *    guettler@informatik.uni-leipzig.de                                   *
00007  *    joergweide84@aol.com (robot12)                                       *
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  *   This program is distributed in the hope that it will be useful,       *
00015  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017  *   GNU General Public License for more details.                          *
00018  *                                                                         *
00019  *   You should have received a copy of the GNU General Public License     *
00020  *   along with this program; if not, write to the                         *
00021  *   Free Software Foundation, Inc.,                                       *
00022  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00023  ***************************************************************************
00024  *                                                                         *
00025  *  DESCRIPTION                                                            *
00026  *                                                                         *
00027  *                                                                         *
00028  *                                                                         *
00029  *  $Log: plotoption.h,v $
00030  *  Revision 1.4  2009/10/27 11:44:30  robot14
00031  *  matrixvis added
00032  *
00033  *  Revision 1.3  2009/08/05 22:53:02  martius
00034  *  redesigned
00035  *   works as a stand alone object now
00036  *   added init function
00037  *   configurables are now in engine and not in plotoptions
00038  *   works with wiredcontroller
00039  *
00040  *  Revision 1.2  2009/07/21 08:50:16  robot12
00041  *  finish of the split
00042  *  to do: add some comments....
00043  *
00044  *  Revision 1.1  2009/06/02 09:55:24  robot12
00045  *  Splitting of WiredController and PlotOption into WiredController : public PlotOptionEngine and
00046  *  PlotOption (used by ga_tools). Further refactorings needed.
00047  *                                                                                 *
00048  *                                                                         *
00049  **************************************************************************/
00050 
00051 
00052 #ifndef PLOTOPTION_H_
00053 #define PLOTOPTION_H_
00054 
00055 #include <stdio.h>
00056 #include <list>
00057 #include <utility>
00058 #include <string>
00059 
00060 class Configurable;
00061 class Inspectable;
00062 
00063 /** Output mode for agent.
00064  */
00065 enum PlotMode {
00066   /// dummy (does nothing) is there for compatibility, might be removed later
00067   NoPlot,
00068   /// write into file
00069   File,
00070   /// plotting with guilogger (gnuplot)
00071   GuiLogger,
00072   /// plotting with guiscreen (gnuplot) in file logging mode
00073   GuiLogger_File,
00074   /// plotting with matrixVisualiser
00075   MatrixVis,
00076   /// net visualiser
00077   NeuronViz,
00078 
00079   /// Acustic output of robotic values via external SoundMan
00080   SoundMan,
00081 
00082   /// gui for ECBRobots (see lpzrobots/ecbrobots), should be usable with OdeRobots, too
00083   ECBRobotGUI,
00084 
00085   /// dummy used for upper bound of plotmode type
00086   LastPlot
00087 };
00088 
00089 
00090 /** This class contains options for the use of an external plot utility like guilogger or neuronviz
00091     or just simply file output
00092  */
00093 class PlotOption {
00094 public:
00095   friend class WiredController;
00096   friend class PlotOptionEngine;
00097 
00098   PlotOption(){ mode=NoPlot; interval=1; pipe=0; parameter="";}
00099   /**
00100      creates a new plotting object
00101      @param mode output type @see PlotMode
00102      @param interval every i-th step is plotted
00103      @param parameter free parameters for plotting tool
00104      Note: the argument whichSensor is removed. You can adjust this in the wirings now.
00105    */
00106   PlotOption( PlotMode mode, int interval = 1, std::string parameter="")
00107     : interval(interval), mode(mode), parameter(parameter)
00108   {
00109     pipe=0;
00110   }
00111 
00112   virtual ~PlotOption(){}
00113 
00114   virtual PlotMode getPlotOptionMode() const { return mode; }
00115   // flushes pipe (depending on mode)
00116   virtual void flush(long step);
00117 
00118   /// nice predicate function for finding by mode
00119   struct matchMode : public std::unary_function<const PlotOption&, bool> {
00120     matchMode(PlotMode mode) : mode(mode) {}
00121     int mode;
00122     bool operator()(const PlotOption& m) { return (m.mode == mode); }
00123 
00124   };
00125 
00126   void addConfigurable(const Configurable*);
00127   void setName(const std::string& name) { this->name = name;}
00128 
00129   bool open(); ///< opens the connections to the plot tool
00130   void close();///< closes the connections to the plot tool
00131 
00132   FILE* pipe;
00133   long t;
00134   int interval;
00135   std::string name;
00136 
00137 private:
00138 
00139   PlotMode mode;
00140   std::string parameter; ///< additional parameter for external command
00141 };
00142 
00143 #endif /* PLOTOPTION_H_ */

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7