FiniteSpikeResponse.h

Go to the documentation of this file.
00001 #ifndef FINITESPIKERESPONSE_H_
00002 #define FINITESPIKERESPONSE_H_
00003 
00004 #include "SimObject.h"
00005 #include <cmath>
00006 
00007 class FiniteSpikeResponse : public SimObject
00008 {
00009 public:
00010     FiniteSpikeResponse()
00011     {
00012         psr = 0;
00013         steps2cutoff = 0;
00014     }
00015 
00016     virtual ~FiniteSpikeResponse()
00017     { /* NOOP */ }
00018 
00019     // Reset to initial condition.
00020     virtual int reset( double dt )
00021     {
00022         steps2cutoff = 0;
00023         psr = 0;
00024         return 0;
00025     }
00026 
00028     /* Return the number of time steps it will take from the
00029      * time a spike arrives until the postynaptic response has vanished.
00030      */
00031     virtual int psrLength(double dt) const = 0;
00032 
00033     double psr;
00034 
00035     virtual double getAnalogOutput(analog_port_id_t p) const
00036     {
00037         if (p == 0)
00038                 return psr;        
00039         return steps2cutoff;
00040     };
00041 
00042     virtual int nSpikeInputPorts() const { return 1; };
00043     virtual int nSpikeOutputPorts() const { return 0; };
00044     virtual int nAnalogInputPorts() const { return 0; };
00045     virtual int nAnalogOutputPorts() const { return 1; };
00046     virtual PortType outputPortType(port_t o) const
00047     {
00048         if ( o== 0 || o == 1) return analog; else return undefined;
00049     };
00050     virtual PortType inputPortType(port_t i) const
00051     {
00052         if( i==0) return spiking; else return undefined;
00053     };
00054     
00055     virtual bool isActive()
00056     {
00057         return steps2cutoff;    
00058     }
00059     
00060 
00061 protected:
00062 
00063     inline int spikeHitReturn(AdvanceInfo const &ai)
00064     {
00065         /* do we need to activate this synapse? */
00066         int register activate = (steps2cutoff == 0) * SPIKEHITFLAG_ACTIVATE;
00067         /* now calc the new cutoff point */
00068         steps2cutoff = psrLength(ai.dt.in_sec()); // (int)(PSR_MULTIPLE_TAU*tau/DT+0.5);
00069         return activate;
00070     }
00071 
00072     inline int advanceReturn(void)
00073     {
00074         if (--steps2cutoff > 0) {
00075             // signal nothing special to the sim engine by returning 0
00076             return 0;
00077         } else {
00078             // the psr has vanished, so we set it to zero and signal the sim engine that we are idle now
00079             psr = 0;
00080             return ADVANCEFLAG_DEACTIVATE;
00081         }
00082     }
00083 
00084 
00085     int steps2cutoff;
00086 
00087 };
00088 
00089 #endif /*FINITESPIKERESPONSE_H_*/

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