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

#include <TimeTable.h>

+ Inheritance diagram for TimeTable:
+ Collaboration diagram for TimeTable:

Public Member Functions

string getFilename () const
 
int getMethod () const
 
double getState () const
 
void process (const Eref &e, ProcPtr p)
 
void reinit (const Eref &e, ProcPtr p)
 
void setFilename (string filename)
 
void setMethod (int method)
 
 TimeTable ()
 
 ~TimeTable ()
 
- 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

unsigned int curPos_
 
string filename_
 
int method_
 
double state_
 
vector< double > timeTable_
 

Additional Inherited Members

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

Detailed Description

Definition at line 12 of file TimeTable.h.

Constructor & Destructor Documentation

TimeTable::TimeTable ( )

Definition at line 101 of file TimeTable.cpp.

102  :
103  filename_(""),
104  state_( 0.0 ),
105  curPos_( 0 ),
106  method_( 4 )
107 { ; }
int method_
Definition: TimeTable.h:57
double state_
Definition: TimeTable.h:50
unsigned int curPos_
Definition: TimeTable.h:53
string filename_
Definition: TimeTable.h:44
TimeTable::~TimeTable ( )

Definition at line 109 of file TimeTable.cpp.

110 { ; }

Member Function Documentation

string TimeTable::getFilename ( ) const

Definition at line 117 of file TimeTable.cpp.

References filename_.

Referenced by initCinfo().

118 {
119  return filename_;
120 }
string filename_
Definition: TimeTable.h:44

+ Here is the caller graph for this function:

int TimeTable::getMethod ( ) const

Definition at line 166 of file TimeTable.cpp.

References method_.

Referenced by initCinfo().

167 {
168  return method_;
169 }
int method_
Definition: TimeTable.h:57

+ Here is the caller graph for this function:

double TimeTable::getState ( ) const

Definition at line 172 of file TimeTable.cpp.

References state_.

Referenced by initCinfo().

173 {
174  return state_;
175 }
double state_
Definition: TimeTable.h:50

+ Here is the caller graph for this function:

const Cinfo * TimeTable::initCinfo ( )
static

Definition at line 24 of file TimeTable.cpp.

References eventOut(), getFilename(), getMethod(), getState(), TableBase::initCinfo(), process(), reinit(), setFilename(), setMethod(), and timeTableCinfo.

25 {
27  // Field definitions
29  static ValueFinfo< TimeTable, string > filename( "filename",
30  "File to read lookup data from. The file should be contain two columns\n"
31  "separated by any space character.",
34 
35  static ValueFinfo< TimeTable, int > method( "method",
36  "Method to use for filling up the entries. Currently only method 4\n"
37  "(loading from file) is supported.",
40 
41  static ReadOnlyValueFinfo <TimeTable, double> state( "state",
42  "Current state of the time table.",
44 
46  // MsgDest Definitions
48  static DestFinfo process("process",
49  "Handle process call",
51 
52  static DestFinfo reinit("reinit",
53  "Handles reinit call",
55 
57  // SharedMsg Definitions
59  static Finfo* procShared[] = {
60  &process, &reinit
61  };
62 
63  static SharedFinfo proc( "proc",
64  "Shared message for process and reinit",
65  procShared, sizeof( procShared ) / sizeof( const Finfo* ));
66 
67  static Finfo * timeTableFinfos[] = {
68  &filename,
69  &method,
70  &state,
71  eventOut(),
72  &proc,
73  };
74 
75  static string doc[] = {
76  "Name", "TimeTable",
77  "Author", "Johannes Hjorth, 2008, KTH, Stockholm. Ported to buildQ branch using new API by Subhasis Ray, NCBS, Bangalore, 2013.",
78  "Description", "TimeTable: Read in spike times from file and send out eventOut messages\n"
79  "at the specified times.",
80  };
81 
82  static Dinfo< TimeTable > dinfo;
83  static Cinfo timeTableCinfo(
84  "TimeTable",
86  timeTableFinfos,
87  sizeof( timeTableFinfos )/sizeof(Finfo *),
88  &dinfo,
89  doc,
90  sizeof(doc)/sizeof(string));
91 
92  return &timeTableCinfo;
93 }
void setFilename(string filename)
Definition: TimeTable.cpp:122
Definition: Dinfo.h:60
void process(const Eref &e, ProcPtr p)
Definition: TimeTable.cpp:187
void setMethod(int method)
Definition: TimeTable.cpp:155
static const Cinfo * initCinfo()
Definition: TableBase.cpp:15
double getState() const
Definition: TimeTable.cpp:172
static const Cinfo * timeTableCinfo
Definition: TimeTable.cpp:95
void reinit(const Eref &e, ProcPtr p)
Definition: TimeTable.cpp:181
int getMethod() const
Definition: TimeTable.cpp:166
string getFilename() const
Definition: TimeTable.cpp:117
static SrcFinfo1< double > * eventOut()
Definition: TimeTable.cpp:17
Definition: Cinfo.h:18
Definition: Finfo.h:12

+ Here is the call graph for this function:

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

The process function called by scheduler on every tick

Definition at line 187 of file TimeTable.cpp.

References curPos_, ProcInfo::currTime, eventOut(), state_, and TableBase::vec().

Referenced by initCinfo().

188 {
189 
190  // Two ways of telling the world about the spike events, both
191  // happening in parallel
192  //
193  // state is a continous variable, switching from 0 to 1 when spiking
194  // event is an event, that happens at the time of a spike
195  //
196 
197  state_ = 0;
198 
199  if ( curPos_ < vec().size() &&
200  p->currTime >= vec()[curPos_] ) {
201  eventOut()->send( e, vec()[curPos_]);
202  curPos_++;
203  state_ = 1;
204  }
205 }
vector< double > & vec()
Definition: TableBase.cpp:492
double currTime
Definition: ProcInfo.h:19
double state_
Definition: TimeTable.h:50
unsigned int curPos_
Definition: TimeTable.h:53
static SrcFinfo1< double > * eventOut()
Definition: TimeTable.cpp:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

The reinit function called by scheduler for the reset

Definition at line 181 of file TimeTable.cpp.

References curPos_, and state_.

Referenced by initCinfo().

182 {
183  curPos_ = 0;
184  state_ = 0;
185 }
double state_
Definition: TimeTable.h:50
unsigned int curPos_
Definition: TimeTable.h:53

+ Here is the caller graph for this function:

void TimeTable::setFilename ( string  filename)

Definition at line 122 of file TimeTable.cpp.

References filename_, and TableBase::vec().

Referenced by initCinfo().

123 {
124  filename_ = filename;
125 
126  std::ifstream fin( filename_.c_str() );
127  string line;
128 
129  if( !fin.good()) {
130  cout << "Error: TimeTable::innerload: Unable to open file"
131  << filename_ << endl;
132  }
133 
134  //~ If lines need to be skipped:
135  //~ for(unsigned int i = 0; (i < skipLines) & fin.good() ; i++)
136  //~ getline( fin, line );
137 
138  vec().clear();
139 
140  double dataPoint, dataPointOld = -1000;
141  while( fin >> dataPoint ) {
142  vec().push_back(dataPoint);
143 
144  if(dataPoint < dataPointOld) {
145  cerr << "TimeTable: Warning: Spike times in file " << filename_
146  << " are not in increasing order."
147  << endl;
148  }
149 
150  dataPointOld = dataPoint;
151  }
152 }
vector< double > & vec()
Definition: TableBase.cpp:492
string filename_
Definition: TimeTable.h:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TimeTable::setMethod ( int  method)

Definition at line 155 of file TimeTable.cpp.

References method_.

Referenced by initCinfo().

156 {
157  if ( method != 4 ) {
158  cerr <<
159  "Error: TimeTable::setMethod: "
160  "Currently only method 4 (loading from file) supported.\n";
161  return;
162  }
163  method_ = method;
164 }
int method_
Definition: TimeTable.h:57

+ Here is the caller graph for this function:

Member Data Documentation

unsigned int TimeTable::curPos_
private

Definition at line 53 of file TimeTable.h.

Referenced by process(), and reinit().

string TimeTable::filename_
private

Definition at line 44 of file TimeTable.h.

Referenced by getFilename(), and setFilename().

int TimeTable::method_
private

Definition at line 57 of file TimeTable.h.

Referenced by getMethod(), and setMethod().

double TimeTable::state_
private

Definition at line 50 of file TimeTable.h.

Referenced by getState(), process(), and reinit().

vector< double > TimeTable::timeTable_
private

Definition at line 47 of file TimeTable.h.


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