NEST main@caf0ae8
 
Loading...
Searching...
No Matches
connection.h
Go to the documentation of this file.
1/*
2 * connection.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef CONNECTION_H
24#define CONNECTION_H
25
26// Includes from nestkernel:
28#include "connection_label.h"
29#include "connector_base_impl.h"
30#include "delay_checker.h"
31#include "event.h"
32#include "kernel_manager.h"
33#include "nest.h"
34#include "nest_names.h"
35#include "nest_time.h"
36#include "nest_timeconverter.h"
37#include "nest_types.h"
38#include "node.h"
39#include "spikecounter.h"
40#include "syn_id_delay.h"
41
42namespace nest
43{
44
45class ConnectorModel;
46
67{
68 void
69 pre_run_hook() override
70 {
71 }
72 void
73 update( const Time&, long, long ) override
74 {
75 }
76 void
77 set_status( const Dictionary& ) override
78 {
79 }
80 void
81 get_status( Dictionary& ) const override
82 {
83 }
84 void
85 init_state_() override
86 {
87 }
88 void
89 init_buffers_() override
90 {
91 }
92};
93
108template < typename targetidentifierT >
110{
111
112public:
113 // properties used when registering a connection with the ModelManager
115
116 // Whether this connection type supports flush events.
117 static constexpr bool supports_flush_event = false;
118
120 : target_()
121 , syn_id_delay_( 1.0 )
122 {
123 }
124
127
134 std::unique_ptr< SecondaryEvent > get_secondary_event();
135
139 void get_status( Dictionary& d ) const;
140
147 void set_status( const Dictionary& d, ConnectorModel& cm );
148
161 void check_synapse_params( const Dictionary& d ) const;
162
166 void calibrate( const TimeConverter& );
167
171 double
172 get_delay() const
173 {
175 }
176
180 long
182 {
183 return syn_id_delay_.delay;
184 }
185
189 void
190 set_delay( const double delay )
191 {
193 }
194
198 void
199 set_delay_steps( const long delay )
200 {
201 syn_id_delay_.delay = delay;
202 }
203
207 void
209 {
210 syn_id_delay_.syn_id = syn_id;
211 }
212
218 {
219 return syn_id_delay_.syn_id;
220 }
221
222 long
223 get_label() const
224 {
226 }
227
233 void trigger_update_weight( const size_t,
234 const std::vector< spikecounter >&,
235 const double,
237
238 Node*
239 get_target( const size_t tid ) const
240 {
241 return target_.get_target_ptr( tid );
242 }
243 size_t
244 get_rport() const
245 {
246 return target_.get_rport();
247 }
248
255 void
256 set_source_has_more_targets( const bool more_targets )
257 {
259 }
260
267 bool
272
278 void
280 {
282 }
283
289 bool
291 {
292 return syn_id_delay_.is_disabled();
293 }
294
295protected:
305 void check_connection_( Node& dummy_target, Node& source, Node& target, const size_t receptor_type );
306
307 // The order of the members below is critical as it influcences the size of the object.
308 // Please leave unchanged!
309 targetidentifierT target_;
310 // syn_id (9 bit), delay (21 bit) in timesteps of this connection and more_targets and disabled flags (each 1 bit)
312};
313
314template < typename targetidentifierT >
316
317template < typename targetidentifierT >
318inline void
320 Node& source,
321 Node& target,
322 const size_t receptor_type )
323{
324 // 1. does this connection support the event type sent by source
325 // try to send event from source to dummy_target
326 // this line might throw an exception
327 source.send_test_event( dummy_target, receptor_type, get_syn_id(), true );
328
329 // 2. does the target accept the event type sent by source
330 // try to send event from source to target
331 // this returns the port of the incoming connection
332 // p must be stored in the base class connection
333 // this line might throw an exception
334 target_.set_rport( source.send_test_event( target, receptor_type, get_syn_id(), false ) );
335
336 // 3. do the events sent by source mean the same thing as they are
337 // interpreted in target?
338 // note that we here use a bitwise and operation (&), because we interpret
339 // each bit in the signal type as a collection of individual flags
340 if ( not( source.sends_signal() & target.receives_signal() ) )
341 {
342 throw IllegalConnection( "Source and target neuron are not compatible (e.g., spiking vs binary neuron)." );
343 }
344
345 target_.set_target( &target );
346}
347
348template < typename targetidentifierT >
349inline void
351{
352 d[ names::delay ] = syn_id_delay_.get_delay_ms();
353 target_.get_status( d );
354}
355
356template < typename targetidentifierT >
357inline void
359{
360 double delay;
361 if ( d.update_value( names::delay, delay ) )
362 {
364 syn_id_delay_.set_delay_ms( delay );
365 }
366 // no call to target_.set_status() because target and rport cannot be changed
367}
368
369template < typename targetidentifierT >
370inline void
374
375template < typename targetidentifierT >
376inline void
378{
379 Time t = tc.from_old_steps( syn_id_delay_.delay );
380 syn_id_delay_.delay = t.get_steps();
381
382 if ( syn_id_delay_.delay == 0 )
383 {
384 syn_id_delay_.delay = 1;
385 }
386}
387
388template < typename targetidentifierT >
389inline void
391 const std::vector< spikecounter >&,
392 const double,
394{
395 throw IllegalConnection( "Connection does not support updates that are triggered by a volume transmitter." );
396}
397
398template < typename targetidentifierT >
399std::unique_ptr< SecondaryEvent >
401{
402 assert( false and "Non-primary connections have to provide get_secondary_event()" );
403 return nullptr;
404}
405
406} // namespace nest
407
408#endif /* CONNECTION_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Class containing the common properties for all connections of a certain type.
Definition common_synapse_properties.h:50
Base class for dummy nodes used in connection testing.
Definition connection.h:67
void update(const Time &, long, long) override
Advance the state of the node in time through the given interval.
Definition connection.h:73
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition connection.h:69
void init_buffers_() override
Configure persistent internal data structures.
Definition connection.h:89
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition connection.h:81
void init_state_() override
Configure state variables depending on runtime information.
Definition connection.h:85
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition connection.h:77
DelayChecker & get_delay_checker()
Returns the delay checker for the current thread.
Definition connection_manager.cpp:207
Base class for representing connections.
Definition connection.h:110
bool source_has_more_targets() const
Returns a flag denoting whether the connection has source subsequent targets.
Definition connection.h:268
Connection & operator=(const Connection< targetidentifierT > &rhs)=default
void check_connection_(Node &dummy_target, Node &source, Node &target, const size_t receptor_type)
This function calls check_connection() on the sender to check if the receiver accepts the event type ...
Definition connection.h:319
long get_delay_steps() const
Return the delay of the connection in steps.
Definition connection.h:181
SynIdDelay syn_id_delay_
Definition connection.h:311
synindex get_syn_id() const
Get the synapse id of the connection.
Definition connection.h:217
Node * get_target(const size_t tid) const
Definition connection.h:239
static constexpr bool supports_flush_event
Definition connection.h:117
void trigger_update_weight(const size_t, const std::vector< spikecounter > &, const double, const CommonSynapseProperties &)
Triggers an update of a synaptic weight.
Definition connection.h:390
void set_syn_id(synindex syn_id)
Set the synapse id of the connection.
Definition connection.h:208
long get_label() const
Definition connection.h:223
size_t get_rport() const
Definition connection.h:244
void disable()
Disables the connection.
Definition connection.h:279
static constexpr ConnectionModelProperties properties
Definition connection.h:114
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
Connection(const Connection< targetidentifierT > &rhs)=default
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition connection.h:350
void calibrate(const TimeConverter &)
Calibrate the delay of this connection to the desired resolution.
Definition connection.h:377
void check_synapse_params(const Dictionary &d) const
Check syn_spec dictionary for parameters that are not allowed with the given connection.
Definition connection.h:371
std::unique_ptr< SecondaryEvent > get_secondary_event()
Get a pointer to an instance of a SecondaryEvent if this connection supports secondary events.
Definition connection.h:400
void set_delay_steps(const long delay)
Set the delay of the connection in steps.
Definition connection.h:199
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition connection.h:358
void set_delay(const double delay)
Set the delay of the connection.
Definition connection.h:190
Connection()
Definition connection.h:119
void set_source_has_more_targets(const bool more_targets)
Sets a flag in the connection to signal that the following connection has the same source.
Definition connection.h:256
targetidentifierT target_
Definition connection.h:309
bool is_disabled() const
Returns a flag denoting if the connection is disabled.
Definition connection.h:290
Definition connector_model.h:69
void assert_valid_delay_ms(double)
Raise exception if delay value in milliseconds is invalid.
Definition delay_checker.cpp:149
To be thrown if a connection is not possible.
Definition exceptions.h:490
Base class for all NEST network objects.
Definition node.h:99
Class to convert times from one representation to another.
Definition nest_timeconverter.h:42
Time from_old_steps(long s_old) const
Converts a given number of steps with respect to old representation into a time object in current rep...
Definition nest_timeconverter.cpp:38
Definition nest_time.h:135
long get_steps() const
Definition nest_time.h:504
ConnectionManager connection_manager
Definition kernel_manager.h:239
const std::string delay("delay")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
KernelManager & kernel()
Definition kernel_manager.h:311
static const long UNLABELED_CONNECTION
Connections are unlabeled by default.
Definition connection_label.h:38
ConnectionModelProperties
Definition connector_model.h:49
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Declarations for base class Node.
Definition syn_id_delay.h:34
double get_delay_ms() const
Return the delay of the connection in ms.
Definition syn_id_delay.h:55
bool source_has_more_targets() const
Definition syn_id_delay.h:76
void disable()
Disables the synapse.
Definition syn_id_delay.h:87
unsigned int syn_id
Definition syn_id_delay.h:36
void set_source_has_more_targets(const bool more_targets)
Definition syn_id_delay.h:70
unsigned int delay
Definition syn_id_delay.h:35
void set_delay_ms(const double d)
Set the delay of the connection specified in ms.
Definition syn_id_delay.h:64
bool is_disabled() const
Returns a flag denoting if the synapse is disabled.
Definition syn_id_delay.h:98