NEST main@caf0ae8
 
Loading...
Searching...
No Matches
music_rate_out_proxy.h
Go to the documentation of this file.
1/*
2 * music_rate_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_RATE_OUT_PROXY_H
24#define MUSIC_RATE_OUT_PROXY_H
25
26// Generated includes:
27#include "config.h"
28
29#ifdef HAVE_MUSIC
30
31// C++ includes:
32#include <vector>
33
34// External includes:
35#include <music.hh>
36
37// Includes from nestkernel:
38#include "device_node.h"
39#include "event.h"
40#include "exceptions.h"
41#include "nest_types.h"
42#include "node.h"
43
44/* BeginUserDocs: device, rate, MUSIC
45
46Short description
47+++++++++++++++++
48
49Device to forward rates to remote applications using MUSIC
50
51Description
52+++++++++++
53
54A ``music_rate_out_proxy`` is used to send rates to a remote application that
55also uses MUSIC.
56
57The ``music_rate_out_proxy`` represents a complete MUSIC rate output
58port. The channel on the port to which a source node forwards its
59events is determined during connection setup by using the parameter
60``music_channel`` of the connection. The name of the port is set via
61``SetStatus`` (see Parameters section below).
62
63Parameters
64++++++++++
65
66The following properties are available in the status Dictionary:
67
68port_name - The name of the MUSIC output_port to forward events to (default: `rate_out`)
69
70port_width - The width of the MUSIC input port
71
72published - A bool indicating if the port has been already published with MUSIC
73
74The parameter port_name can be set using ``SetStatus``.
75
76Availability: Only when compiled with MUSIC
77
78See also
79++++++++
80
81music_rate_in_proxy, music_cont_out_proxy
82
83Examples using this model
84+++++++++++++++++++++++++
85
86.. listexamples:: music_rate_out_proxy
87
88EndUserDocs */
89
90namespace nest
91{
92void register_music_rate_out_proxy( const std::string& name );
93
94class music_rate_out_proxy : public DeviceNode
95{
96
97public:
98 music_rate_out_proxy();
99 music_rate_out_proxy( const music_rate_out_proxy& );
100 ~music_rate_out_proxy();
101
102 bool
103 has_proxies() const
104 {
105 return false;
106 }
107 bool
108 local_receiver() const
109 {
110 return true;
111 }
112 bool
113 one_node_per_process() const
114 {
115 return true;
116 }
117
123 using Node::handle;
124 using Node::handles_test_event;
125
126 void handle( InstantaneousRateConnectionEvent& );
127
128 size_t handles_test_event( InstantaneousRateConnectionEvent&, size_t );
129
130 void get_status( Dictionary& ) const;
131 void set_status( const Dictionary& );
132
133private:
134 void init_buffers_();
135 void pre_run_hook();
136
137 void
138 update( Time const&, const long, const long )
139 {
140 }
141
142 // ------------------------------------------------------------
143
144 struct State_;
145
146 struct Parameters_
147 {
148 std::string port_name_;
149
150 Parameters_();
151
152 void get( Dictionary& ) const;
153 void set( const Dictionary&, State_& );
154 };
155
156 // ------------------------------------------------------------
157
158 struct State_
159 {
160 bool published_;
162 int port_width_;
163
164 State_();
165
166 void get( Dictionary& ) const;
168 void set( const Dictionary&, const Parameters_& );
169 };
170
171 // ------------------------------------------------------------
172
173 struct Variables_
174 {
175 MUSIC::ContOutputPort* MP_;
176 std::vector< MUSIC::GlobalIndex > index_map_;
177 };
178
179 struct Buffers_
180 {
181 Buffers_();
182 Buffers_( const Buffers_& );
183 std::vector< double > data_;
184 };
185
186 // ------------------------------------------------------------
187
188 Parameters_ P_;
189 State_ S_;
190 Variables_ V_;
191 Buffers_ B_;
192};
193
194inline size_t
195music_rate_out_proxy::handles_test_event( InstantaneousRateConnectionEvent&, size_t receptor_type )
196{
197 // receptor_type i is mapped to channel i of the MUSIC port so we
198 // have to generate the index map here, that assigns the channel
199 // number to the local index of this connection the local index
200 // equals the number of connection
201
202 if ( not S_.published_ )
203 {
204 V_.index_map_.push_back( static_cast< int >( receptor_type ) );
205 }
206 else
207 {
208 throw MUSICPortAlreadyPublished( "", P_.port_name_ );
209 }
210
211 return receptor_type;
212}
213
214} // namespace
215
216#endif /* HAVE_MUSIC */
217
218#endif
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
const std::string receptor_type("receptor_type")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
Declarations for base class Node.