SpikeOutputPort.cpp

Go to the documentation of this file.
00001 
00002 #include "SpikeOutputPort.h"
00003 #include "SingleThreadSimEngine.h"
00004 #include "SimObject.h"
00005 
00006 #include <iostream>
00007 using std::cout;
00008 using std::endl;
00009 
00010 void SpikeOutputPort::setSpikeByOffsetFraction( AdvanceInfo const &ai, float offsetFraction, bool calcSpikeTime )
00011 {
00012     _hasSpike  = true;
00013     if( calcSpikeTime ) {
00014         _spikeTime =  ai.t.in_sec() + ai.dt.in_sec() * offsetFraction;
00015     }
00016     if( _id != INVALID_SPIKE_PORT_ID ) {
00017         const SingleThreadSimEngine *E = ai.eng;
00018         SpikeScheduler *S = E->getSpikeScheduler();
00019         S->scheduleSpike( _id, offsetFraction, E->getLocalEid() );
00020     }
00021 }
00022 
00023 void SpikeOutputPort::setSpikeByOffset( AdvanceInfo const &ai, double delta, bool calcSpikeTime )
00024 {
00025     setSpikeByOffsetFraction( ai, (float)( delta / ai.dt.in_sec() ), false );
00026     if( calcSpikeTime ) {
00027         _spikeTime = ai.t.in_sec() + delta;
00028     }
00029 }
00030 
00031 void SpikeOutputPort::setSpike( AdvanceInfo const &ai, double t )
00032 {
00033     // cerr << "t=" << t << ", simtime=" << getEnginePtr()->getSimulationTime().in_sec() << endl;
00034     setSpikeByOffset( ai, t - ai.t.in_sec(), false );
00035     _spikeTime = t;
00036 }
00037 
00038 void SpikeOutputPort::setSpike( AdvanceInfo const &ai )
00039 {
00040     setSpikeByOffsetFraction( ai, 1.0, false );
00041     Time t = ai.t;
00042     t += ai.dt;
00043     _spikeTime = t.in_sec();
00044 }

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