MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
StimulusTable Class Reference

#include <StimulusTable.h>

+ Inheritance diagram for StimulusTable:
+ Collaboration diagram for StimulusTable:

Public Member Functions

bool getDoLoop () const
 
double getLoopTime () const
 
double getStartTime () const
 
double getStepPosition () const
 
double getStepSize () const
 
double getStopTime () const
 
void process (const Eref &e, ProcPtr p)
 
void reinit (const Eref &e, ProcPtr p)
 
void setDoLoop (bool v)
 
void setLoopTime (double v)
 
void setStartTime (double v)
 
void setStepPosition (double v)
 
void setStepSize (double v)
 
void setStopTime (double v)
 
 StimulusTable ()
 
- Public Member Functions inherited from TableBase
void clearVec ()
 
void compareVec (vector< double > other, string op)
 
void compareXplot (string fname, string plotname, string op)
 
const vector< double > & data ()
 
double getOutputValue () const
 
string getPlotDump () const
 
vector< double > getVec () const
 
unsigned int getVecSize () const
 
double getY (unsigned int index) const
 
double interpolate (double x, double xmin, double xmax) const
 
void linearTransform (double scale, double offset)
 
void loadCSV (string fname, int startLine, int colNum, char separator)
 
void loadXplot (string fname, string plotname)
 
void loadXplotRange (string fname, string plotname, unsigned int start, unsigned int end)
 
double * lookupVec (unsigned int index)
 
void plainPlot (string file)
 
void setOutputValue (double val)
 
void setPlotDump (string v)
 
void setVec (vector< double > val)
 
void setVecSize (unsigned int num)
 
 TableBase ()
 
void xplot (string file, string plotname)
 

Static Public Member Functions

static const CinfoinitCinfo ()
 
- Static Public Member Functions inherited from TableBase
static const CinfoinitCinfo ()
 

Private Attributes

bool doLoop_
 
double loopTime_
 
double start_
 
double stepPosition_
 
double stepSize_
 
double stop_
 

Additional Inherited Members

- Protected Member Functions inherited from TableBase
vector< double > & vec ()
 

Detailed Description

Receives and records inputs. Handles plot and spiking data in batch mode.

Definition at line 16 of file StimulusTable.h.

Constructor & Destructor Documentation

StimulusTable::StimulusTable ( )

Definition at line 138 of file StimulusTable.cpp.

139  : start_( 0 ), stop_( 1 ), loopTime_( 1 ),
140  stepSize_( 0 ), stepPosition_( 0 ),
141  doLoop_( 0 )
142 { ; }
double stepSize_
Definition: StimulusTable.h:53
double loopTime_
Definition: StimulusTable.h:52
double stepPosition_
Definition: StimulusTable.h:54

Member Function Documentation

bool StimulusTable::getDoLoop ( ) const

Definition at line 243 of file StimulusTable.cpp.

References doLoop_.

Referenced by initCinfo().

244 {
245  return doLoop_;
246 }

+ Here is the caller graph for this function:

double StimulusTable::getLoopTime ( ) const

Definition at line 211 of file StimulusTable.cpp.

References loopTime_.

Referenced by initCinfo().

212 {
213  return loopTime_;
214 }
double loopTime_
Definition: StimulusTable.h:52

+ Here is the caller graph for this function:

double StimulusTable::getStartTime ( ) const

Definition at line 184 of file StimulusTable.cpp.

References start_.

Referenced by initCinfo().

185 {
186  return start_;
187 }

+ Here is the caller graph for this function:

double StimulusTable::getStepPosition ( ) const

Definition at line 231 of file StimulusTable.cpp.

References stepPosition_.

Referenced by initCinfo().

232 {
233  return stepPosition_;
234 }
double stepPosition_
Definition: StimulusTable.h:54

+ Here is the caller graph for this function:

double StimulusTable::getStepSize ( ) const

Definition at line 221 of file StimulusTable.cpp.

References stepSize_.

Referenced by initCinfo().

222 {
223  return stepSize_;
224 }
double stepSize_
Definition: StimulusTable.h:53

+ Here is the caller graph for this function:

double StimulusTable::getStopTime ( ) const

Definition at line 196 of file StimulusTable.cpp.

References stop_.

Referenced by initCinfo().

197 {
198  return stop_;
199 }

+ Here is the caller graph for this function:

const Cinfo * StimulusTable::initCinfo ( )
static

Definition at line 23 of file StimulusTable.cpp.

References getDoLoop(), getLoopTime(), getStartTime(), getStepPosition(), getStepSize(), getStopTime(), TableBase::initCinfo(), output(), process(), reinit(), setDoLoop(), setLoopTime(), setStartTime(), setStepPosition(), setStepSize(), setStopTime(), and stimulusTableCinfo.

24 {
26  // Field Definitions
28  static ValueFinfo< StimulusTable, double > startTime(
29  "startTime",
30  "Start time used when table is emitting values. For lookup"
31  "values below this, the table just sends out its zero entry."
32  "Corresponds to zeroth entry of table.",
35  );
36 
38  "stopTime",
39  "Time to stop emitting values."
40  "If time exceeds this, then the table sends out its last entry."
41  "The stopTime corresponds to the last entry of table.",
44  );
45 
47  "loopTime",
48  "If looping, this is the time between successive cycle starts."
49  "Defaults to the difference between stopTime and startTime, "
50  "so that the output waveform cycles with precisely the same "
51  "duration as the table contents."
52  "If larger than stopTime - startTime, then it pauses at the "
53  "last table value till it is time to "
54  "go around again."
55  "If smaller than stopTime - startTime, then it begins the next "
56  "cycle even before the first one has reached the end of the "
57  "table.",
60  );
61 
63  "stepSize",
64  "Increment in lookup (x) value on every timestep. If it is"
65  "less than or equal to zero, the StimulusTable uses the current time"
66  "as the lookup value.",
69  );
70 
71  static ValueFinfo< StimulusTable, double > stepPosition(
72  "stepPosition",
73  "Current value of lookup (x) value."
74  "If stepSize is less than or equal to zero, this is set to"
75  "the current time to use as the lookup value.",
78  );
79 
81  "doLoop",
82  "Flag: Should it loop around to startTime once it has reached"
83  "stopTime. Default (zero) is to do a single pass.",
86  );
87 
89  // MsgDest Definitions
91 
92  static DestFinfo process( "process",
93  "Handles process call, updates internal time stamp.",
95  static DestFinfo reinit( "reinit",
96  "Handles reinit call.",
99  // SharedMsg Definitions
101  static Finfo* procShared[] = {
102  &process, &reinit
103  };
104  static SharedFinfo proc( "proc",
105  "Shared message for process and reinit",
106  procShared, sizeof( procShared ) / sizeof( const Finfo* )
107  );
108 
109  static Finfo* stimulusTableFinfos[] = {
110  &startTime,
111  &stopTime,
112  &loopTime,
113  &stepSize,
114  &stepPosition,
115  &doLoop,
116  output(), // SrcFinfo
117  &proc, // SharedFinfo
118  };
119 
120  static Dinfo< StimulusTable > dinfo;
121  static Cinfo stimulusTableCinfo (
122  "StimulusTable",
124  stimulusTableFinfos,
125  sizeof( stimulusTableFinfos ) / sizeof ( Finfo* ),
126  &dinfo
127  );
128 
129  return &stimulusTableCinfo;
130 }
double getStopTime() const
Definition: Dinfo.h:60
bool getDoLoop() const
double getStartTime() const
void setStopTime(double v)
void setDoLoop(bool v)
void setStepPosition(double v)
void setStepSize(double v)
static const Cinfo * initCinfo()
Definition: TableBase.cpp:15
void setStartTime(double v)
static const Cinfo * stimulusTableCinfo
static SrcFinfo1< double > * output()
void process(const Eref &e, ProcPtr p)
void setLoopTime(double v)
void reinit(const Eref &e, ProcPtr p)
double getStepPosition() const
double getStepSize() const
double getLoopTime() const
Definition: Cinfo.h:18
Definition: Finfo.h:12

+ Here is the call graph for this function:

void StimulusTable::process ( const Eref e,
ProcPtr  p 
)

Definition at line 148 of file StimulusTable.cpp.

References ProcInfo::currTime, doLoop_, TableBase::interpolate(), loopTime_, output(), TableBase::setOutputValue(), start_, stepPosition_, stepSize_, and stop_.

Referenced by initCinfo().

149 {
150  if ( stepSize_ > 0 )
152  else
153  stepPosition_ = p->currTime;
154 
155  double lookupPosition = stepPosition_;
156  if ( doLoop_ && ( stepPosition_ > start_ + loopTime_ ) ) {
157  unsigned int i = floor( ( stepPosition_ - start_ ) / loopTime_ );
158  lookupPosition = stepPosition_ - loopTime_ * i;
159  }
160 
161  double y = interpolate( start_, stop_, lookupPosition );
162  setOutputValue( y );
163 
164  output()->send( e, y );
165 }
double currTime
Definition: ProcInfo.h:19
double interpolate(double x, double xmin, double xmax) const
Definition: TableBase.cpp:440
double stepSize_
Definition: StimulusTable.h:53
void setOutputValue(double val)
Definition: TableBase.cpp:428
double loopTime_
Definition: StimulusTable.h:52
double stepPosition_
Definition: StimulusTable.h:54
static SrcFinfo1< double > * output()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void StimulusTable::reinit ( const Eref e,
ProcPtr  p 
)

Definition at line 167 of file StimulusTable.cpp.

References TableBase::interpolate(), output(), TableBase::setOutputValue(), start_, stepPosition_, and stop_.

Referenced by initCinfo().

168 {
169  stepPosition_ = 0.0;
170  double y = interpolate( start_, stop_, stepPosition_ );
171  setOutputValue( y );
172  output()->send( e, y );
173 }
double interpolate(double x, double xmin, double xmax) const
Definition: TableBase.cpp:440
void setOutputValue(double val)
Definition: TableBase.cpp:428
double stepPosition_
Definition: StimulusTable.h:54
static SrcFinfo1< double > * output()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void StimulusTable::setDoLoop ( bool  v)

Definition at line 236 of file StimulusTable.cpp.

References doLoop_, loopTime_, start_, and stop_.

Referenced by initCinfo().

237 {
238  doLoop_ = v;
239  if ( loopTime_ == 0 )
240  loopTime_ = stop_ - start_;
241 }
double loopTime_
Definition: StimulusTable.h:52

+ Here is the caller graph for this function:

void StimulusTable::setLoopTime ( double  v)

Definition at line 201 of file StimulusTable.cpp.

References loopTime_.

Referenced by initCinfo().

202 {
203  if ( loopTime_ >= 0 )
204  loopTime_ = v;
205  else
206  cout << "StimulusTable::setLoopTime: Warning: Cannot set to " <<
207  v << " as this value is below zero. Left unchanged at " <<
208  loopTime_ << "\n";
209 }
double loopTime_
Definition: StimulusTable.h:52

+ Here is the caller graph for this function:

void StimulusTable::setStartTime ( double  v)

Definition at line 179 of file StimulusTable.cpp.

References start_.

Referenced by initCinfo().

180 {
181  start_ = v;
182 }

+ Here is the caller graph for this function:

void StimulusTable::setStepPosition ( double  v)

Definition at line 226 of file StimulusTable.cpp.

References stepPosition_.

Referenced by initCinfo().

227 {
228  stepPosition_ = v;
229 }
double stepPosition_
Definition: StimulusTable.h:54

+ Here is the caller graph for this function:

void StimulusTable::setStepSize ( double  v)

Definition at line 216 of file StimulusTable.cpp.

References stepSize_.

Referenced by initCinfo().

217 {
218  stepSize_ = v;
219 }
double stepSize_
Definition: StimulusTable.h:53

+ Here is the caller graph for this function:

void StimulusTable::setStopTime ( double  v)

Definition at line 189 of file StimulusTable.cpp.

References doLoop_, doubleEq(), loopTime_, start_, and stop_.

Referenced by initCinfo().

190 {
191  if ( doLoop_ && doubleEq( loopTime_, stop_ - start_ ) )
192  loopTime_ = v - start_;
193  stop_ = v;
194 }
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
double loopTime_
Definition: StimulusTable.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool StimulusTable::doLoop_
private

Definition at line 55 of file StimulusTable.h.

Referenced by getDoLoop(), process(), setDoLoop(), and setStopTime().

double StimulusTable::loopTime_
private

Definition at line 52 of file StimulusTable.h.

Referenced by getLoopTime(), process(), setDoLoop(), setLoopTime(), and setStopTime().

double StimulusTable::start_
private

Definition at line 50 of file StimulusTable.h.

Referenced by getStartTime(), process(), reinit(), setDoLoop(), setStartTime(), and setStopTime().

double StimulusTable::stepPosition_
private

Definition at line 54 of file StimulusTable.h.

Referenced by getStepPosition(), process(), reinit(), and setStepPosition().

double StimulusTable::stepSize_
private

Definition at line 53 of file StimulusTable.h.

Referenced by getStepSize(), process(), and setStepSize().

double StimulusTable::stop_
private

Definition at line 51 of file StimulusTable.h.

Referenced by getStopTime(), process(), reinit(), setDoLoop(), and setStopTime().


The documentation for this class was generated from the following files: