NEST main@caf0ae8
 
Loading...
Searching...
No Matches
music_event_out_proxy.h
Go to the documentation of this file.
1/*
2 * music_event_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_EVENT_OUT_PROXY_H
24#define MUSIC_EVENT_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
43namespace nest
44{
45void register_music_event_out_proxy( const std::string& name );
46
47/* BeginUserDocs: device, MUSIC, spike
48
49Short description
50+++++++++++++++++
51
52Device to forward spikes to remote applications using MUSIC
53
54Description
55+++++++++++
56
57A ``music_event_out_proxy`` is used to send spikes to a remote application that
58also uses MUSIC.
59
60The ``music_event_out_proxy`` represents a complete MUSIC event output
61port. The channel on the port to which a source node forwards its
62events is determined during connection setup by using the parameter
63``music_channel`` of the connection. The name of the port is set via
64SetStatus (see Parameters section below).
65
66This model is only available if NEST was compiled with MUSIC.
67
68Parameters
69++++++++++
70
71The following properties are available in the status Dictionary:
72
73=========== ======= ========================================================
74 port_name string The name of the MUSIC output_port to forward events to
75 (default: event_out)
76 port_width integer The width of the MUSIC input port
77 published boolean A bool indicating if the port has been already published
78 with MUSIC
79=========== ======= ========================================================
80
81The parameter port_name can be set using SetStatus.
82
83See also
84++++++++
85
86music_event_in_proxy, music_cont_in_proxy, music_message_in_proxy
87
88Examples using this model
89+++++++++++++++++++++++++
90
91.. listexamples:: music_event_out_proxy
92
93EndUserDocs */
94
95class music_event_out_proxy : public DeviceNode
96{
97
98public:
99 music_event_out_proxy();
100 music_event_out_proxy( const music_event_out_proxy& );
101 ~music_event_out_proxy();
102
103 bool
104 has_proxies() const
105 {
106 return false;
107 }
108 bool
109 local_receiver() const
110 {
111 return true;
112 }
113 bool
114 one_node_per_process() const
115 {
116 return true;
117 }
118
124 using Node::handle;
125 using Node::handles_test_event;
126
127 void handle( SpikeEvent& );
128
129 size_t handles_test_event( SpikeEvent&, size_t );
130
131 void get_status( Dictionary& ) const;
132 void set_status( const Dictionary& );
133
134private:
135 void init_buffers_();
136 void pre_run_hook();
137
138 void
139 update( Time const&, const long, const long )
140 {
141 }
142
143 // ------------------------------------------------------------
144
145 struct State_;
146
147 struct Parameters_
148 {
149 std::string port_name_;
150
151 Parameters_();
152
153 void get( Dictionary& ) const;
154 void set( const Dictionary&, State_& );
155 };
156
157 // ------------------------------------------------------------
158
159 struct State_
160 {
161 bool published_;
163 int port_width_;
164
165 State_();
166
167 void get( Dictionary& ) const;
169 void set( const Dictionary&, const Parameters_& );
170 };
171
172 // ------------------------------------------------------------
173
174 struct Variables_
175 {
176 MUSIC::EventOutputPort* MP_;
177 std::vector< MUSIC::GlobalIndex > index_map_;
178 MUSIC::PermutationIndex* music_perm_ind_;
180 };
181
182 // ------------------------------------------------------------
183
184 Parameters_ P_;
185 State_ S_;
186 Variables_ V_;
187};
188
189inline size_t
190music_event_out_proxy::handles_test_event( SpikeEvent&, size_t receptor_type )
191{
192 // receptor_type i is mapped to channel i of the MUSIC port so we
193 // have to generate the index map here, that assigns the channel
194 // number to the local index of this connection the local index
195 // equals the number of connection
196
197 if ( not S_.published_ )
198 {
199 V_.index_map_.push_back( static_cast< int >( receptor_type ) );
200 }
201 else
202 {
203 throw MUSICPortAlreadyPublished( get_name(), P_.port_name_ );
204 }
205
206 return receptor_type;
207}
208
209} // namespace
210
211#endif /* HAVE_MUSIC */
212
213#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