NEST  2.6.0,not_revisioned_source_dir@0
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 #include "nest_time.h"
27 #include "nest_timeconverter.h"
28 #include "nest.h"
29 #include "node.h"
30 #include "event.h"
31 #include "dict.h"
32 #include "dictutils.h"
33 #include "arraydatum.h"
34 #include "doubledatum.h"
36 #include "nest_names.h"
37 #include "spikecounter.h"
38 #include "syn_id_delay.h"
39 
40 namespace nest
41 {
42 
43 class ConnectorModel;
44 
65  {
66  void calibrate() {}
68  void set_status(const DictionaryDatum&) {}
69  void get_status(DictionaryDatum&) const {}
70  void init_node_(const nest::Node&) {}
71  void init_state_(const nest::Node&) {}
72  void init_buffers_() {}
73  };
74 
75 
76 
84 template<typename targetidentifierT>
86 {
87 
88  public:
89 
91  target_(),
92  syn_id_delay_(1.0)
93  { }
94 
96  target_(rhs.target_),
98  { }
99 
100 
104  void get_status(DictionaryDatum & d) const;
105 
111  void set_status(const DictionaryDatum & d, ConnectorModel& cm);
112 
116  void calibrate(const TimeConverter &);
117 
122 
127 
132 
137 
141  void set_syn_id(synindex syn_id) { syn_id_delay_.syn_id = syn_id; }
142 
147 
148 
153  void trigger_update_weight(const thread, const std::vector<spikecounter> &, const double_t, const CommonSynapseProperties &);
154 
155  Node *get_target(thread t) const { return target_.get_target_ptr(t); }
156  rport get_rport() const { return target_.get_rport(); }
157 
158 protected:
159 
168  void check_connection_(Node& dummy_target, Node& source, Node& target, rport receptor_type);
169 
170  /* the order of the members below is critical
171  as it influcences the size of the object. Please leave unchanged
172  as
173  targetidentifierT target_;
174  SynIdDelay syn_id_delay_; //!< syn_id (char) and delay (24 bit) in timesteps of this connection
175  */
176  targetidentifierT target_;
178 };
179 
180 
181 template<typename targetidentifierT>
182 inline
184 {
185  // 1. does this connection support the event type sent by source
186  // try to send event from source to dummy_target
187  // this line might throw an exception
188  source.send_test_event(dummy_target, receptor_type, get_syn_id(), true);
189 
190  // 2. does the target accept the event type sent by sourc
191  // try to send event from source to target
192  // this returns the port of the incoming connection
193  // p must be stored in the base class connection
194  // this line might throw an exception
195  target_.set_rport(source.send_test_event(target, receptor_type, get_syn_id(), false));
196 
197  target_.set_target(&target);
198 }
199 
200 template<typename targetidentifierT>
201 inline
203 {
204  def<double_t>(d, names::delay, syn_id_delay_.get_delay_ms());
205  target_.get_status(d);
206 }
207 
208 template<typename targetidentifierT>
209 inline
211 {
212  double_t delay;
213  if (updateValue<double_t>(d, names::delay, delay))
214  {
215  cm.assert_valid_delay_ms(delay);
216  syn_id_delay_.set_delay_ms(delay);
217  }
218  // no call to target_.set_status() because target and rport cannot be changed
219 }
220 
221 template<typename targetidentifierT>
222 inline
224 {
225  Time t = tc.from_old_steps(syn_id_delay_.delay);
226  syn_id_delay_.delay = t.get_steps();
227 
228  if (syn_id_delay_.delay == 0)
229  syn_id_delay_.delay = 1;
230 }
231 
232 template<typename targetidentifierT>
233 inline
234 void Connection<targetidentifierT>::trigger_update_weight(const thread, const std::vector<spikecounter>&, const double_t, const CommonSynapseProperties&)
235 {
236  throw IllegalConnection("Connection::trigger_update_weight: "
237  "Connection does not support updates that are triggered by the volume transmitter.");
238 }
239 
240 } // namespace nest
241 
242 #endif // CONNECTION_H
void init_node_(const nest::Node &)
Definition: connection.h:70
void trigger_update_weight(const thread, const std::vector< spikecounter > &, const double_t, const CommonSynapseProperties &)
triggers an update of a synaptic weight this function is needed for neuromodulated synaptic plasticit...
Definition: connection.h:234
void calibrate(const TimeConverter &)
Calibrate the delay of this connection to the desired resolution.
Definition: connection.h:223
const Name delay("delay")
Connection parameters.
Definition: nest_names.h:92
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Declarations for base class Node.
void init_state_(const nest::Node &)
Private function to initialize the state of a node to model defaults.
Definition: connection.h:71
long_t get_delay_steps() const
Return the delay of the connection in steps.
Definition: connection.h:126
void check_connection_(Node &dummy_target, Node &source, Node &target, rport receptor_type)
This function calls check_connection() on the sender to check if the receiver accepts the event type ...
Definition: connection.h:183
To be thrown if a connection is not possible.
Definition: exceptions.h:317
void update(const nest::Time &, nest::long_t, nest::long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: connection.h:67
delay get_steps() const
Definition: nest_time.h:395
Time from_old_steps(long_t 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:34
virtual port send_test_event(Node &receiving_node, rport receptor_type, synindex syn_id, bool dummy_target)
Send an event to the receiving_node passed as an argument.
Definition: node.cpp:169
void calibrate()
Re-calculate dependent parameters of the node.
Definition: connection.h:66
SynIdDelay syn_id_delay_
syn_id (char) and delay (24 bit) in timesteps of this connection
Definition: connection.h:177
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
void set_status(const DictionaryDatum &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition: connection.h:210
Node * get_target(thread t) const
Definition: connection.h:155
double_t get_delay() const
Return the delay of the connection in ms.
Definition: connection.h:121
void set_delay_steps(const long_t delay)
Set the delay of the connection in steps.
Definition: connection.h:136
void set_delay_ms(const double_t d)
Set the delay of the connection specified in ms.
Definition: syn_id_delay.h:55
void set_syn_id(synindex syn_id)
Set the synapse id of the connection.
Definition: connection.h:141
Definition: nest_time.h:130
unsigned syn_id
Definition: syn_id_delay.h:33
void set_status(const DictionaryDatum &)
Definition: connection.h:68
Connection()
Definition: connection.h:90
const Name source("source")
Connection parameters.
Definition: nest_names.h:260
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
void set_delay(const double_t delay)
Set the delay of the connection.
Definition: connection.h:131
Base class for dummy nodes used in connection testing.
Definition: connection.h:64
Class to convert times from one representation to another.
Definition: nest_timeconverter.h:45
Definition: syn_id_delay.h:31
void get_status(DictionaryDatum &) const
Definition: connection.h:69
unsigned delay
Definition: syn_id_delay.h:34
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: connection.h:72
double double_t
Double precision floating point numbers.
Definition: nest.h:93
synindex get_syn_id() const
Get the synapse id of the connection.
Definition: connection.h:146
rport get_rport() const
Definition: connection.h:156
double_t get_delay_ms() const
Return the delay of the connection in ms.
Definition: syn_id_delay.h:50
Class containing the common properties for all connections of a certain type.
Definition: common_synapse_properties.h:44
void get_status(DictionaryDatum &d) const
Get all properties of this connection and put them into a dictionary.
Definition: connection.h:202
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
long_t delay
Delay of a connection.
Definition: nest.h:178
Part of definition of volume_transmitter to record and manage spike times and multiplicity of neurons...
Default types used by the NEST kernel.
Base class for representing connections.
Definition: connection.h:85
Base class for all NEST network objects.
Definition: node.h:96
targetidentifierT target_
Definition: connection.h:176
void assert_valid_delay_ms(double_t)
Raise exception if delay value in milliseconds is invalid.
Definition: connector_model.cpp:67
Definition: connector_model.h:38
int_t thread
Thread index type.
Definition: nest.h:133
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
Connection(const Connection< targetidentifierT > &rhs)
Definition: connection.h:95