Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

displaypipe.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           displaypipe.h  -  description
00003                              -------------------
00004     begin                : Mit Jun 5 2002
00005     copyright            : (C) 2002 by Peter Haase
00006     email                : mail@p-haase.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 
00029 #ifndef DISPLAYPIPE_H
00030 #define DISPLAYPIPE_H
00031 
00032 #include <cstdio>
00033 #include <iosfwd>
00034 #include <simthetic/basicdevicefactory.h>
00035 #include <simthetic/basicdevice.h>
00036 #include <simthetic/phbib.h>
00037 
00038 
00039 namespace simthlib
00040 {
00041 
00042 using simth::Complex;
00043 
00078 class Displaypipe : public simth::Device
00079 {
00080   private:
00081 
00082     std::string filename_;
00083     bool saveData_;
00084 
00085   protected:
00086 
00087     std::string filename() const {return filename_;}
00088     bool saveData() const {return saveData_;}
00089     FILE *gnuplotProcess;
00090     bool suppressMonitor;
00091     void writeToGnuplot(const std::string &piped_text);
00092     void writeToGnuplot(const std::ostringstream &ostr);
00093 
00094   public:
00095 
00102     Displaypipe(int deviceID, simth::DeviceSystemIntf* system, 
00103         const simth::PropertyList& pl);
00104 
00105     ~Displaypipe();
00106 
00107     virtual void updateInputLengths();
00108     virtual void updateOutputLengths();
00109 
00110     virtual void endOfSimulation();
00111 
00112     void print(std::ostream &os) const;
00113 
00114     enum Interface_Mode {FIRST, SECOND, BOTH};
00115     enum View_Mode {COMPLEX, PHASE, COMPLEX_EQUALIZE, PHASE_EQUALIZE, PHASE_POLAR,
00116                     CYLINDRICAL, CYLINDRICAL_ANIMATED, NO_DISPLAY, ABS, RE, IM, AMPL};
00117     struct Range
00118     {
00119       double lower;
00120       double upper;
00121     };
00122 
00123     static void init(const std::string& filename, simth::Device** dev,
00124                      simth::DeviceSystemIntf* sysPtr, int ID,
00125                      const std::string& regionQualifier = "");
00126     static void init(simth::DeviceFactory& registration);
00127 
00128   protected:
00129     std::string writeLabelUsing(const std::string& ylabel,
00130                 const std::string& usingstr,
00131                 const std::string& name);
00132     std::string writeLabelUsing(const std::string& ylabel,
00133                 const std::string& usingstr,
00134                 const std::vector<std::string>& names);
00135 };
00136 
00137 
00148 template<class seqT>
00149 class DisplaypipeSeqT : public Displaypipe
00150 {
00151   protected:
00152 
00153     /* Returns the filename used to store the
00154         input date for the given interface.
00155 
00156         Appends '_i' to the filename specified
00157         in the base class where i is the given
00158         interface number.
00159     */
00160     std::string filenameIntf(int interfaceNumber) const;
00161 
00162     View_Mode vMode;
00163     Interface_Mode iMode;
00164 
00166     unsigned iports;
00167 
00168   private:
00169     void setAutoscale();
00170     void standardDisplay();
00171     void equalizeDisplay(bool phaseDisplay);
00172     void polarDisplay( );
00173     void cylindricalDisplay( );
00174     void noDisplay();
00175 
00176     void cylindricalAnimated( );
00177 
00178     const int zWidth;
00179     const int increment;
00180     const int delayInSeconds;
00181 
00182     static const int stdDelayInSeconds; // Standard delay in milliseconds (for animation)
00183     static const int stdIncrement;
00184     static const int stdZWidth;
00185 
00186   public:
00187 
00188     DisplaypipeSeqT(int deviceID, 
00189             simth::DeviceSystemIntf* system,
00190             const simth::PropertyList& pl);
00191 
00192     DisplaypipeSeqT(int deviceID, simth::DeviceSystemIntf* system,
00193                     const simth::PropertyList& pl,
00194             Displaypipe::View_Mode vMode,
00195                     Displaypipe::Interface_Mode iMode);
00196 
00197     DisplaypipeSeqT(int deviceID, simth::DeviceSystemIntf* system,
00198             const simth::PropertyList& pl,
00199             int zWidth, int increment, int delayInSeconds,
00200             Displaypipe::Interface_Mode iMode);
00201 
00202     ~DisplaypipeSeqT();
00203 
00204     virtual void process();
00205 
00206     void print(std::ostream &os) const;
00207 };
00208 
00209 
00210 
00211 }
00212 
00213 #endif

Generated on Tue Aug 9 14:35:10 2005 for simtheticlib by  doxygen 1.4.1