00001 #ifndef RESETKernelSpikeResponse_H_
00002 #define RESETKernelSpikeResponse_H_
00003
00004 #include "EvSimObject.h"
00005 #include "DirectEventSender.h"
00006 #include "SharedArray.h"
00007 #include "SharedArrayTypes.h"
00008 #include "SpikeResponse.h"
00009 #include "EvSimObjectTypeUtils.h"
00010
00011
00012 class ResetKernelSpikeResponse : public SpikeResponse, public DirectEventSender {
00013
00014 EV_SIM_OBJECT( ResetKernelSpikeResponse )
00015
00016 public:
00017
00018 ResetKernelSpikeResponse() : resp_shape_amplitudes(0), resp_shape_timepoints(0) {};
00019
00020 ResetKernelSpikeResponse(const SharedArray<double> &resp_shape_amplitudes,
00021 const SharedArray<double> &resp_shape_timepoints)
00022 : resp_shape_amplitudes(resp_shape_amplitudes.get()),
00023 resp_shape_timepoints(resp_shape_timepoints.get())
00024 {}
00025
00026 virtual ~ResetKernelSpikeResponse() {};
00027
00028
00029 void setResponseKernel(const SharedArray<double> &resp_shape_amplitudes,
00030 const SharedArray<double> &resp_shape_timepoints) {
00031 this->resp_shape_amplitudes = resp_shape_amplitudes.get();
00032 this->resp_shape_timepoints = resp_shape_timepoints.get();
00033 }
00034
00035 virtual void eventHit(SimContext & sim_info, Time time, port_id_t port);
00036
00037 virtual void updateState(SimContext &sim_info, Time time, update_id_t upd_id) {};
00038
00039 virtual unsigned numInputPorts() const
00040 {
00041 return 2;
00042 };
00043
00044 virtual unsigned numOutputPorts() const
00045 {
00046 return 1;
00047 };
00048
00049
00050 virtual PortType getInputPortType(port_id_t p) const
00051 {
00052 if (p < 2)
00053 return eventPortDirect;
00054 return portUndefined;
00055 };
00056
00057 virtual PortType getOutputPortType(port_id_t p) const
00058 {
00059 if (p == 0)
00060 return eventPortDirect;
00061 return portUndefined;
00062 };
00063
00064 virtual void reset(SimContext &sim_ctxt)
00065 {
00066 curr_timepoint = RESPONSE_NOT_ACTIVE;
00067 next_expected_time = MAX_TIME;
00068 r = r_old = 0;
00069 };
00070
00071 virtual void postAddedInNetwork(EvSimNetwork &net, EvSimObject::ID self);
00072
00073 protected:
00074 static const unsigned RESPONSE_NOT_ACTIVE = ~(0u);
00075
00076 const vector<double> * resp_shape_amplitudes;
00077 const vector<double> * resp_shape_timepoints;
00078
00079 unsigned curr_timepoint;
00080 double next_expected_time;
00081 };
00082
00083 #endif
00084