void nest::spike_detector::handle( SpikeEvent& e ) { // accept spikes only if detector was active when spike was // emitted if ( device_.is_active( e.get_stamp() ) ) { assert( e.get_multiplicity() > 0 ); long dest_buffer; if ( kernel() .modelrange_manager.get_model_of_gid( e.get_sender_gid() ) ->has_proxies() ) // events from central queue dest_buffer = kernel().event_delivery_manager.read_toggle(); else // locally delivered events dest_buffer = kernel().event_delivery_manager.write_toggle(); for ( int i = 0; i < e.get_multiplicity(); ++i ) { // We store the complete events Event* event = e.clone(); B_.spikes_[ dest_buffer ].push_back( event ); } } }
void ginzburg::handle(SpikeEvent & e) { assert(e.get_delay() > 0); // The following logic implements the encoding: // A single spike signals a transition to 0 state, two spikes in same time step // signal the transition to 1 state. // // Remember the global id of the sender of the last spike being received // this assumes that several spikes being sent by the same neuron in the same time step // are received consecutively or are conveyed by setting the multiplicity accordingly. long_t m = e.get_multiplicity(); long_t gid = e.get_sender_gid(); const Time &t_spike = e.get_stamp(); if (m == 1) { //multiplicity == 1, either a single 1->0 event or the first or second of a pair of 0->1 events if (gid == S_.last_in_gid_ && t_spike == S_.t_last_in_spike_) { // received twice the same gid, so transition 0->1 // take double weight to compensate for subtracting first event B_.spikes_.add_value(e.get_rel_delivery_steps(network()->get_slice_origin()), 2.0*e.get_weight()); } else { // count this event negatively, assuming it comes as single event // transition 1->0 B_.spikes_.add_value(e.get_rel_delivery_steps(network()->get_slice_origin()), -e.get_weight()); } } else // multiplicity != 1 if (m == 2) { // count this event positively, transition 0->1 B_.spikes_.add_value(e.get_rel_delivery_steps(network()->get_slice_origin()), e.get_weight()); } S_.last_in_gid_ = gid; S_.t_last_in_spike_ = t_spike; }
void nest::spin_detector::handle( SpikeEvent& e ) { // accept spikes only if detector was active when spike was // emitted if ( device_.is_active( e.get_stamp() ) ) { assert( e.get_multiplicity() > 0 ); long_t dest_buffer; if ( kernel().modelrange_manager.get_model_of_gid( e.get_sender_gid() )->has_proxies() ) dest_buffer = kernel().event_delivery_manager.read_toggle(); // events from central queue else dest_buffer = kernel().event_delivery_manager.write_toggle(); // locally delivered events // The following logic implements the decoding // A single spike signals a transition to 0 state, two spikes in same time step // signal the transition to 1 state. // // Remember the global id of the sender of the last spike being received // this assumes that several spikes being sent by the same neuron in the same time step // are received consecutively or are conveyed by setting the multiplicity accordingly. long_t m = e.get_multiplicity(); index gid = e.get_sender_gid(); const Time& t_spike = e.get_stamp(); if ( m == 1 ) { // multiplicity == 1, either a single 1->0 event or the first or second of a pair of 0->1 // events if ( gid == last_in_gid_ && t_spike == t_last_in_spike_ ) { // received twice the same gid, so transition 0->1 // revise the last event written to the buffer ( *( B_.spikes_[ dest_buffer ].end() - 1 ) )->set_weight( 1. ); } else { // count this event negatively, assuming it comes as single event // transition 1->0 Event* event = e.clone(); // assume it will stay alone, so meaning a down tansition event->set_weight( 0 ); B_.spikes_[ dest_buffer ].push_back( event ); } } else // multiplicity != 1 if ( m == 2 ) { // count this event positively, transition 0->1 Event* event = e.clone(); event->set_weight( 1. ); B_.spikes_[ dest_buffer ].push_back( event ); } last_in_gid_ = gid; t_last_in_spike_ = t_spike; } }