NEST main@caf0ae8
 
Loading...
Searching...
No Matches
music_cont_out_proxy.h
Go to the documentation of this file.
1/*
2 * music_cont_out_proxy.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 MUSIC_CONT_OUT_PROXY_H
24#define MUSIC_CONT_OUT_PROXY_H
25
26// Generated includes:
27#include "config.h"
28
29
30#ifdef HAVE_MUSIC
31
32// C includes:
33#include <mpi.h>
34
35// C++ includes:
36#include <vector>
37
38// External includes:
39#include <music.hh>
40
41// Includes from nestkernel:
42#include "device_node.h"
43#include "nest_timeconverter.h"
44#include "nest_types.h"
45#include "node_collection.h"
46
47
48namespace nest
49{
50void register_music_cont_out_proxy( const std::string& name );
51
52/* BeginUserDocs: device, MUSIC
53
54Short description
55+++++++++++++++++
56
57A device which sends continuous data from NEST to MUSIC
58
59Description
60+++++++++++
61
62A ``music_cont_out_proxy`` can be used to send continuous data from
63neurons over MUSIC to remote applications. It works in a similar fashion like
64the multimeter model. The user has to specify the recordable values to observe
65(e.g. [``V_m``]) via the record_from parameter. The target neurons are specified
66by a list of global neuron ids which must be passed via the ``targets``
67parameter. The ``music_cont_out_proxy`` will be connected automatically to the
68specified target neurons. It is not possible to apply further changes to the
69list of target neurons or observed quantities once the simulation has been
70started for the first time.
71
72In case of multiple recordables the data can be read out (PyNEST only) of the
73receiving buffer via the following access pattern:
74
75 buffer[ target_node_id_index ][ recordable_index] = buffer[ target_node_id_index *
76 record_from.size() + recordable_index ]
77
78 For example:
79 target_node_ids = [ 2, 5, 4 ], record_from = ["V_m"] and
80
81 we want to get ``V_m`` for neuron with node ID 5: buffer[ 1*1 + 0 ]
82
83This model is only available if NEST was compiled with MUSIC.
84
85Parameters
86++++++++++
87
88The following properties are available in the status Dictionary:
89
90============ ======== ========================================================
91 interval ms Recording interval
92 targets array Global id list of neurons to be observed
93 port_name string The name of the MUSIC input port to listen to (default:
94 cont_in)
95 port_width integer The width of the MUSIC input port
96 published boolean A bool indicating if the port has been already published
97 with MUSIC
98 record_from array Array containing the names of variables to record
99 from, obtained from the /recordables entry of the
100 model from which one wants to record
101============ ======== ========================================================
102
103See also
104++++++++
105
106music_cont_in_proxy, music_event_out_proxy, music_event_in_proxy, music_message_in_proxy
107
108Examples using this model
109+++++++++++++++++++++++++
110
111.. listexamples:: music_cont_out_proxy
112
113EndUserDocs */
114
115class music_cont_out_proxy : public DeviceNode
116{
117
118public:
119 music_cont_out_proxy();
120 music_cont_out_proxy( const music_cont_out_proxy& );
121
122 bool
123 has_proxies() const
124 {
125 return false;
126 }
127 bool
128 local_receiver() const
129 {
130 return true;
131 }
132 bool
133 one_node_per_process() const
134 {
135 return false;
136 }
137
143 using Node::handle;
144 using Node::handles_test_event;
145 using Node::sends_signal;
146 size_t send_test_event( Node&, size_t, synindex, bool );
147
148 void handle( DataLoggingReply& );
149
150 SignalType sends_signal() const;
151
152 void get_status( Dictionary& ) const;
153 void set_status( const Dictionary& );
154
155 void calibrate_time( const TimeConverter& tc );
156
157protected:
158 void init_buffers_();
159 void pre_run_hook();
160 void finalize();
161
169 void update( Time const&, const long, const long );
170
171private:
172 struct State_;
173
174 struct Buffers_;
175
176 struct Parameters_
177 {
178 Parameters_();
179 Parameters_( const Parameters_& );
180
181 Time interval_;
182 std::string port_name_;
183 std::vector< std::string > record_from_;
184 NodeCollectionPTR targets_;
185
186 void get( Dictionary& ) const;
187 void set( const Dictionary&, const Node&, const State_&, const Buffers_& );
188 };
189
190 // ------------------------------------------------------------
191
192 struct State_
193 {
194 State_();
195 State_( const State_& );
196 bool published_;
198 size_t port_width_;
199 void get( Dictionary& ) const;
200 };
201
202 // ------------------------------------------------------------
203
204 struct Buffers_
205 {
206 Buffers_();
207 Buffers_( const Buffers_& );
208 bool has_targets_;
210 std::vector< double > data_;
211 };
212
213 // ------------------------------------------------------------
214
215 Parameters_ P_;
216 State_ S_;
217 Buffers_ B_;
218};
219
220inline SignalType
221music_cont_out_proxy::sends_signal() const
222{
223 return ALL;
224}
225
226inline void
227music_cont_out_proxy::calibrate_time( const TimeConverter& tc )
228{
229 P_.interval_ = tc.from_old_tics( P_.interval_.get_tics() );
230}
231
232} // namespace
233
234#endif /* #ifndef HAVE_MUSIC */
235#endif /* #ifndef MUSIC_CONT_OUT_PROXY_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
std::shared_ptr< NodeCollection > NodeCollectionPTR
Definition node_collection.h:50
SignalType
enum type of signal conveyed by spike events of a node.
Definition nest_types.h:165
@ ALL
Definition nest_types.h:169