AnalogLevelBasedInputNeuron.cpp

Go to the documentation of this file.
00001 #include "AnalogLevelBasedInputNeuron.h"
00002 
00003 #include <iostream>
00004 using std::cerr;
00005 using std::endl;
00006 
00007 AnalogLevelBasedInputNeuron::AnalogLevelBasedInputNeuron()
00008 {
00009     curr_level = 0;
00010     curr_timestep = 0;
00011 }
00012 
00013 AnalogLevelBasedInputNeuron::AnalogLevelBasedInputNeuron(const vector<double> &levels, const vector<double> & durations)
00014 {
00015     this->levels = levels;
00016     this->durations = durations;
00017 }
00018 
00019 AnalogLevelBasedInputNeuron::~AnalogLevelBasedInputNeuron()
00020 {
00021 }
00022 
00023 void AnalogLevelBasedInputNeuron::setAnalogValues(const vector<double> &levels, const vector<double> & durations)
00024 {
00025     this->levels = levels;
00026     this->durations = durations;
00027 }
00028 
00029 const vector<double> & AnalogLevelBasedInputNeuron::getLevels() const
00030 {
00031     return levels;
00032 }
00033 
00034 const vector<double> & AnalogLevelBasedInputNeuron::getDurations() const
00035 {
00036     return durations;
00037 }
00038 
00039 
00040 double AnalogLevelBasedInputNeuron::getAnalogOutput(analog_port_id_t port) const
00041 {   
00042     return levels[curr_level];
00043 }
00044 
00045 
00046 int AnalogLevelBasedInputNeuron::advance(AdvanceInfo const & ai)
00047 {       
00048     curr_timestep++;
00049     
00050     if (curr_timestep >= curr_numsteps)
00051     {
00052         curr_level++;
00053         if (curr_level > levels.size())
00054                 curr_level = 0;
00055         curr_timestep = 0;
00056         curr_numsteps = int(durations[curr_level]/ai.dt.in_sec());
00057     }
00058 
00059     Vm = levels[curr_level];
00060     return 0;
00061 }
00062 
00063 int AnalogLevelBasedInputNeuron::reset( double dt )
00064 {
00065     curr_level = 0;
00066     curr_timestep = 0;
00067     curr_numsteps = int(durations[curr_level]/dt);
00068     return 0;
00069 }
00070 

Generated on Wed Jul 9 16:34:38 2008 for PCSIM by  doxygen 1.5.5