NEST  2.6.0,not_revisioned_source_dir@0
stimulating_device.h
Go to the documentation of this file.
1 /*
2  * stimulating_device.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 STIMULATING_DEVICE_H
24 #define STIMULATING_DEVICE_H
25 
26 #include "device.h"
27 
28 #include "dictutils.h"
29 
30 class SpikeEvent;
31 class CurrentEvent;
32 class DoubleDataEvent;
33 
34  /* BeginDocumentation
35  Name: StimulatingDevice - General properties of stimulating devices.
36  Description:
37 
38  Stimulating devices inject signals into a network, either as analog signals
39  such a currents or as spike trains. Most stimulating devices are implemented
40  so that they are replicated on each virtual process. Many, but not all devices
41  generating noise or stochastic spike trains provide different signals to each
42  of their recipients; see the documentation of the individual device.
43 
44  Stimulating devices share the start, stop, and origin parameters global to
45  devices. Start and stop have the following meaning for stimulating devices
46  (origin is just a global offset):
47  - For spike-emitting devices, only spikes with times t that fulfill
48  start < t <= stop
49  are emitted. Note that spikes that have time t==start are NOT emitted.
50  - For current-emitting devices, the current is activated and deactivated such
51  that the current first affects the target dynamics during the update step
52  (start, start+h], i.e., an effect can be recorded at the earliest at time
53  start+h. The last interval during which the current affects the target's
54  dynamics is (stop-h, stop].
55 
56  Parameters:
57  /start - Actication time, relative to origin.
58  /stop - Inactivation time, relative to origin.
59  /origin - Reference time for start and stop.
60 
61  SeeAlso: Device, RecordingDevice
62  */
63 
64 namespace nest {
65 
116  template <typename EmittedEvent>
117  class StimulatingDevice : public Device
118  {
119  public:
122  virtual ~StimulatingDevice() {}
123 
129  bool is_active(const Time&) const;
130  void get_status(DictionaryDatum &d) const;
131 
134 
135  private:
136 
145  };
146 
147  template <typename EmittedEvent>
149  : Device(),
150  first_syn_id_(invalid_synindex)
151  {}
152 
153  template <typename EmittedEvent>
156  : Device(sd),
157  first_syn_id_(invalid_synindex) // a new instance can have no connections
158  {}
159 
160  // specializations must be declared inside namespace
161  template <>
162  inline
164  {
165  /* We have t_min_ = origin_ + start_, t_max_ = origin_ + stop_ in steps.
166  We need to check if
167  t_min_ - 1 <= T.get_steps() <= t_max_ - 2
168  This is equivalent to checking
169  t_min_ <= T.get_steps() + 1 < t_max_
170  */
171  const long_t step = T.get_steps() + 1;
172  return get_t_min_() <= step && step < get_t_max_();
173  }
174 
175  template <>
176  inline
178  {
179  // same as for the CurrentEvent
180  const long_t step = T.get_steps() + 1;
181  return get_t_min_() <= step && step < get_t_max_();
182  }
183 
184  template <>
185  inline
187  {
188  /* Input is the time stamp of the spike to be emitted. */
189  const long_t stamp = T.get_steps();
190  return get_t_min_() < stamp && stamp <= get_t_max_();
191  }
192 
193  template <typename EmittedEvent>
194  inline
196  {
198  Device::get_status(d);
199  }
200 
201  template <typename EmittedEvent>
202  inline
204  {
205  if ( first_syn_id_ == invalid_synindex )
206  first_syn_id_ = syn_id;
207 
208  if ( syn_id != first_syn_id_ )
209  throw IllegalConnection("All outgoing connections from a device must use the same synapse type.");
210  }
211 } // namespace nest
212 
213 #endif
Definition: lockptrdatum.h:40
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Base class for common properties of Stimulating Devices.
Definition: stimulating_device.h:117
To be thrown if a connection is not possible.
Definition: exceptions.h:317
void enforce_single_syn_type(synindex)
Throws IllegalConnection if synapse id differs from initial synapse id.
Definition: stimulating_device.h:203
delay get_steps() const
Definition: nest_time.h:395
const synindex invalid_synindex
Definition: nest.h:116
const Name element_type("element_type")
Node type.
Definition: nest_names.h:117
synindex first_syn_id_
Synapse type of the first outgoing connection made by the Device.
Definition: stimulating_device.h:144
Class implementing common interface and properties common for all devices.
Definition: device.h:94
virtual ~StimulatingDevice()
Definition: stimulating_device.h:122
Definition: nest_time.h:130
StimulatingDevice()
Definition: stimulating_device.h:148
void get_status(DictionaryDatum &d) const
Definition: stimulating_device.h:195
const Name stimulator("stimulator")
Node type.
Definition: nest_names.h:267
Definition: namedatum.h:90
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
bool is_active(const Time &) const
Determine whether device is active.
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96