00001 #ifndef SPIKINGINPUTNEURON_H_ 00002 #define SPIKINGINPUTNEURON_H_ 00003 00004 00005 #include "SimObject.h" 00006 #include "SpikeSender.h" 00007 00008 #include <vector> 00009 00010 #include <algorithm> 00011 00013 class SpikingInputNeuron : public SimObject, public SingleOutputSpikeSender 00014 { 00015 00016 SIMOBJECT( SpikingInputNeuron, AdvancePhase::One ) 00017 00018 public: 00019 00020 SpikingInputNeuron(); 00021 explicit SpikingInputNeuron(const std::vector<double> &spikeTimes); 00022 00023 virtual int reset( double dt ); 00024 00025 virtual int reset( double dt, double startT); 00026 00027 virtual int advance(AdvanceInfo const &); 00028 00030 void setSpikes(const std::vector<double> &theSpikeTimes); 00031 00032 const std::vector<double> &getSpikeTimes() const; 00033 00035 void addSpike( double st, bool force_sort = true ); 00036 00037 void printSpikeTimes(void); 00038 00039 double getLastSpikeTime() { return out_port.spikeTime(); }; 00040 00041 virtual double getManagedDelay() const { return 0; } 00042 virtual int nSpikeInputPorts() const { return 0; }; 00043 virtual int nSpikeOutputPorts() const { return 1; }; 00044 virtual int nAnalogInputPorts() const { return 0; }; 00045 virtual int nAnalogOutputPorts() const { return 0; }; 00046 virtual PortType outputPortType(port_t o) const 00047 { 00048 if( o==0) return spiking; else return undefined; 00049 }; 00050 virtual PortType inputPortType(port_t i) const 00051 { 00052 return undefined; 00053 }; 00054 00055 void adjustSpikesToTimeGrid( double dt ); 00056 00057 void sort_spikes(); 00058 00059 protected: 00060 00061 private: 00062 00063 std::vector<double> spikeTimes; 00064 size_t nextSpikeIdx; 00065 long numStepsToNextSpike; 00066 double t; 00067 long currentStep; 00068 bool sorted; 00069 00070 00071 }; 00072 00073 #endif /*SPIKINGINPUTNEURON_H_*/