00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00154
00155
00156
00157
00158
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;
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