NEST  2.6.0,not_revisioned_source_dir@0
spin_detector.h
Go to the documentation of this file.
1 /*
2  * spin_detector.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 SPIN_DETECTOR_H
24 #define SPIN_DETECTOR_H
25 
26 
27 #include <vector>
28 #include "nest.h"
29 #include "event.h"
30 #include "node.h"
31 #include "recording_device.h"
32 #include "exceptions.h"
33 
34 /* BeginDocumentation
35 
36 Name: spin_detector - Device for detecting single spikes.
37 
38 Description:
39 The spin_detector device is a recording device. It is used to record
40 spikes from a single neuron, or from multiple neurons at once. Data
41 is recorded in memory or to file as for all RecordingDevices.
42 By default, GID and time of each spike is recorded.
43 
44 The spike detector can also record spike times with full precision
45 from neurons emitting precisely timed spikes. Set /precise_times to
46 achieve this.
47 
48 Any node from which spikes are to be recorded, must be connected to
49 the spike detector using a normal connect command. Any connection weight
50 and delay will be ignored for that connection.
51 
52 Simulations progress in cycles defined by the minimum delay. During each
53 cycle, the spike detector records (stores in memory or writes to screen/file)
54 the spikes generated during the previous cycle. As a consequence, any
55 spikes generated during the cycle immediately preceding the end of the simulation
56 time will not be recorded. Setting the /stop parameter to at the latest one
57 min_delay period before the end of the simulation time ensures that all spikes
58 desired to be recorded, are recorded.
59 
60 Spike are not necessarily written to file in chronological order.
61 
62 Receives: SpikeEvent
63 
64 SeeAlso: spike_detector, Device, RecordingDevice
65 */
66 
67 
68 namespace nest
69 {
70 
71  class Network;
72 
96  class spin_detector : public Node
97  {
98 
99  public:
100 
101  spin_detector();
103 
104  bool has_proxies() const { return false; }
105  bool local_receiver() const {return true;}
106 
111  using Node::handle;
113 
114  void handle(SpikeEvent &);
115 
117 
118  void get_status(DictionaryDatum &) const;
119  void set_status(const DictionaryDatum &) ;
120 
121  private:
122 
123  void init_state_(Node const&);
124  void init_buffers_();
125  void calibrate();
126  void finalize();
127 
137  void update(Time const &, const long_t, const long_t);
138 
158  struct Buffers_ {
159  std::vector<std::vector<Event*> > spikes_;
160  };
161 
167  };
168 
169  inline
171  {
172  if (receptor_type != 0)
173  throw UnknownReceptorType(receptor_type, get_name());
174  return 0;
175  }
176 
177  inline
179  {
180  device_.finalize();
181  }
182 
183 } // namespace
184 
185 #endif /* #ifndef SPIN_DETECTOR_H */
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
Time t_last_in_spike_
Definition: spin_detector.h:165
void calibrate()
Re-calculate dependent parameters of the node.
Definition: spin_detector.cpp:65
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
RecordingDevice device_
Definition: spin_detector.h:162
Definition: lockptrdatum.h:40
Declarations for base class Node.
std::vector< std::vector< Event * > > spikes_
Definition: spin_detector.h:159
void get_status(DictionaryDatum &) const
Definition: spin_detector.cpp:96
Buffers_ B_
Definition: spin_detector.h:163
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: spin_detector.cpp:121
Buffer for incoming spikes.
Definition: spin_detector.h:158
Base class for all recording devices.
Definition: recording_device.h:214
spin_detector()
Definition: spin_detector.cpp:34
Definition: nest_time.h:130
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: spin_detector.h:170
std::string get_name() const
Return class name.
Definition: node.cpp:83
Exception to be thrown if the specified receptor type does not exist in the node. ...
Definition: exceptions.h:254
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: spin_detector.cpp:57
bool local_receiver() const
Returns true if the node only receives events from nodes/devices on the same thread.
Definition: spin_detector.h:105
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition: node.cpp:198
virtual port handles_test_event(SpikeEvent &, rport receptor_type)
Check if the node can handle a particular event and receptor type.
Definition: node.cpp:203
Spike detector class.
Definition: spin_detector.h:96
index last_in_gid_
Definition: spin_detector.h:164
void update(Time const &, const long_t, const long_t)
Update detector by recording spikes.
Definition: spin_detector.cpp:80
Default types used by the NEST kernel.
Event for spike information.
Definition: event.h:320
bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: spin_detector.h:104
void finalize()
Flush output stream if requested.
Definition: recording_device.cpp:456
Base class for all NEST network objects.
Definition: node.h:96
void init_state_(Node const &)
Private function to initialize the state of a node to model defaults.
Definition: spin_detector.cpp:50
bool user_set_precise_times_
Definition: spin_detector.h:166
void finalize()
Finalize node.
Definition: spin_detector.h:178
void set_status(const DictionaryDatum &)
Definition: spin_detector.cpp:112
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96