NEST  2.6.0,not_revisioned_source_dir@0
device.h
Go to the documentation of this file.
1 /*
2  * 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 DEVICE_H
24 #define DEVICE_H
25 
26 
27 #include "nest.h"
28 #include "node.h"
29 #include "dictdatum.h"
30 #include "nest_time.h"
31 
32 namespace nest
33 {
34 
35  /* BeginDocumentation
36  Name: Device - General properties of devices.
37  Description:
38 
39  Devices are elements that inject signals into a network (stimulating
40  devices) or record data from it (recording devices). The specific
41  properties of these classes of devices are documents in separate
42  documents for each of these two classes, and the specific devices.
43  This page only documents general properties.
44 
45  The only general properties for all devices are activation and
46  inactivation times. These are controlled by the parameters start, stop
47  and origin. Briefly speaking a device is active from start to stop,
48  while origin provides a global offset, i.e., actual start and stop
49  times are origin+start and origin+stop. This can be used to implement
50  experiment repetitions, where only origin needs to be increased.
51 
52  The precise meaning of start and stop depends on the type of the
53  device and is documented in the specific documentation pages. Generally
54  speaking, any device emitting signals will emit signals in [start, stop),
55  while a recording device will pick up signals with time stamps
56  (start, stop].
57 
58  In general, the following must hold:
59  1. start+origin > 0
60  2. stop >= start
61  3. If stop == start, the device is inactive.
62 
63  Parameters:
64  /start - Actication time, relative to origin.
65  /stop - Inactivation time, relative to origin.
66  /origin - Reference time for start and stop.
67 
68  SeeAlso: StimulatingDevice, RecordingDevice
69  */
70 
94  class Device
95  {
96  public:
97  Device();
98  Device(const Device& n);
99  virtual ~Device(){}
100 
102  virtual void init_parameters(const Device&);
103 
105  virtual void init_state(const Device&) {}
106 
108  virtual void init_buffers() {}
109 
111  virtual void calibrate();
112 
114  virtual void finalize() {}
115 
116  virtual void get_status(DictionaryDatum &) const;
117  virtual void set_status(const DictionaryDatum &);
118 
123  virtual bool is_active(Time const& T) const =0;
124 
130  long_t get_t_min_() const;
131 
137  long_t get_t_max_() const;
138 
139  Time const & get_origin() const;
140  Time const & get_start() const;
141  Time const & get_stop() const;
142 
143  private:
144 
145  // ----------------------------------------------------------------
146 
150  struct Parameters_ {
153 
156 
159 
160  Parameters_();
161 
163  Parameters_(const Parameters_&);
164 
165  void get(DictionaryDatum&) const;
166  void set(const DictionaryDatum&);
167  };
168 
169 
170  // ----------------------------------------------------------------
171 
175  struct Variables_ {
176 
185 
194  };
195 
196  // ----------------------------------------------------------------
197 
200 
201  };
202 
203 } // namespace
204 
205 inline
207 {
208  P_.get(d);
209 }
210 
211 inline
213 {
214  Parameters_ ptmp = P_; // temporary copy in case of errors
215  ptmp.set(d); // throws if BadProperty
216 
217  // if we get here, temporaries contain consistent set of properties
218  P_ = ptmp;
219 }
220 
221 inline
223 {
224  return P_.origin_;
225 }
226 
227 inline
229 {
230  return P_.start_;
231 }
232 
233 inline
235 {
236  return P_.stop_;
237 }
238 
239 inline
241 {
242  return V_.t_min_;
243 }
244 
245 inline
247 {
248  return V_.t_max_;
249 }
250 
251 #endif // DEVICE_H
virtual bool is_active(Time const &T) const =0
Returns true if the device is active at the given time stamp.
long_t t_max_
Time step of device deactivation.
Definition: device.h:193
long_t t_min_
Time step of device activation.
Definition: device.h:184
Definition: lockptrdatum.h:40
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Declarations for base class Node.
virtual void get_status(DictionaryDatum &) const
Definition: device.h:206
Time const & get_origin() const
Definition: device.h:222
void set(const DictionaryDatum &)
Set values from dictionary.
Definition: device.cpp:70
Device()
Definition: device.cpp:94
Parameters_()
Sets default parameter values.
Definition: device.cpp:38
Internal variables of the model.
Definition: device.h:175
virtual void init_state(const Device &)
Reset dynamic state to that of model.
Definition: device.h:105
Time start_
Stop time, relative to origin. Defaults to "infinity".
Definition: device.h:155
virtual void calibrate()
Set internal variables, including opening files.
Definition: device.cpp:112
virtual void set_status(const DictionaryDatum &)
Definition: device.h:212
Class implementing common interface and properties common for all devices.
Definition: device.h:94
Definition: nest_time.h:130
virtual void finalize()
Housekeeping at end of simulation, eg close files.
Definition: device.h:114
Independent parameters of the model.
Definition: device.h:150
Time const & get_start() const
Definition: device.h:228
Time const & get_stop() const
Definition: device.h:234
virtual void init_parameters(const Device &)
Reset parameters to those of model; also resets state.
Definition: device.cpp:107
long_t get_t_max_() const
Return upper limit in steps.
Definition: device.h:246
virtual void init_buffers()
Reset buffers.
Definition: device.h:108
long_t get_t_min_() const
Return lower limit in steps.
Definition: device.h:240
virtual ~Device()
Definition: device.h:99
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: device.cpp:63
Time origin_
Origin of device time axis, relative to network time. Defaults to 0.
Definition: device.h:152
const Name n("n")
Number of synaptic release sites (int >=0) (Tsodyks2_connection)
Definition: nest_names.h:202
Default types used by the NEST kernel.
Parameters_ P_
Definition: device.h:198
Variables_ V_
Definition: device.h:199
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
Time stop_
Definition: device.h:158