00001 #include "SingleThreadSpikeScheduler.h"
00002 #include <iostream>
00003
00004 using std::cout;
00005 using std::endl;
00006 using std::cerr;
00007
00008
00009 void SingleThreadSpikeScheduler::scheduleSpike(local_objectid_t senderid, float offsetFraction, engineid_t engine)
00010 {
00011
00012 LocalDelayMap::const_iterator delay_iter = delayMap.beginDelays( senderid);
00013 LocalDelayMap::const_iterator delay_end_iter = delayMap.endDelays(senderid);
00014
00015 while (delay_iter != delay_end_iter) {
00016
00017 spikeBuffer.scheduleSpikeTargetGroup( delay_iter->second, delay_iter->first, offsetFraction );
00018 ++delay_iter ;
00019 }
00020 }
00021
00022 void SingleThreadSpikeScheduler::deliverSpikes(SpikeReceiverList &listActiveSynapses, engineid_t engine, double simTime, int stepOffset)
00023 {
00024
00025 PropagatedSpikeBuffer::const_iterator srg_iter;
00026 PropagatedSpikeBuffer::const_iterator srg_iter_end = spikeBuffer.endSpikeTargetGroups(stepOffset);
00027
00028 SpikeTargetGroupPool::const_iterator target_syn_iter;
00029 SpikeTargetGroupPool::const_iterator target_syn_iter_end;
00030
00031 SpikeEvent spike( simTime, 0, 1.0, simParam.dt );
00032 for( srg_iter = spikeBuffer.beginSpikeTargetGroups(stepOffset); srg_iter != srg_iter_end; ++srg_iter ) {
00033 target_syn_iter_end = tgtGrpPool.endSpikeTargetGroup(*srg_iter);
00034 for(target_syn_iter = tgtGrpPool.beginSpikeTargetGroup(*srg_iter); target_syn_iter != target_syn_iter_end; ++target_syn_iter ) {
00035
00036 spike.delta = simParam.dt.in_sec() * srg_iter->offsetFraction;
00037 if( ( target_syn_iter->receiver->spikeHit( target_syn_iter->port, spike ) ) & SPIKEHITFLAG_ACTIVATE ) {
00038 listActiveSynapses.push_back( target_syn_iter->receiver );
00039 SimObject *obj = target_syn_iter->receiver;
00040 while ( (obj = obj->getChainedObject()) != NULL) {
00041 if (obj->toBeActivated()) listActiveSynapses.push_back( obj );
00042 }
00043 }
00044 }
00045 }
00046 }