NEST  2.6.0,not_revisioned_source_dir@0
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 #include "config.h"
27 #ifdef HAVE_MUSIC
28 
29 #include <vector>
30 #include "nest.h"
31 #include "event.h"
32 #include "node.h"
33 #include "exceptions.h"
34 #include "music.hh"
35 
36 /* BeginDocumentation
37 
38 Name: music_event_out_proxy - Device to forward spikes to remote applications using MUSIC.
39 
40 Description:
41 A music_event_out_proxy is used to send spikes to a remote application that
42 also uses MUSIC.
43 
44 The music_event_out_proxy represents a complete MUSIC event output
45 port. The channel on the port to which a source node forwards its
46 events is determined during connection setup by using the parameter
47 music_channel of the connection. The name of the port is set via
48 SetStatus (see Parameters section below).
49 
50 Parameters:
51 The following properties are available in the status dictionary:
52 
53 port_name - The name of the MUSIC output_port to forward events to
54  (default: event_out)
55 port_width - The width of the MUSIC input port
56 published - A bool indicating if the port has been already published
57  with MUSIC
58 
59 The parameter port_name can be set using SetStatus.
60 
61 Examples:
62 /iaf_neuron Create /n Set
63 /music_event_out_proxy Create /meop Set
64 n meop << /music_channel 2 >> Connect
65 
66 Author: Moritz Helias, Jochen Martin Eppler
67 FirstVersion: March 2009
68 Availability: Only when compiled with MUSIC
69 
70 SeeAlso: music_event_in_proxy, music_cont_in_proxy, music_message_in_proxy
71 */
72 
73 namespace nest
74 {
75  class music_event_out_proxy : public Node
76  {
77 
78  public:
79 
83 
84  bool has_proxies() const { return false; }
85  bool local_receiver() const {return true;}
86  bool one_node_per_process() const {return true;}
87 
92  using Node::handle;
94 
95  void handle(SpikeEvent &);
96 
98 
99  void get_status(DictionaryDatum &) const;
100  void set_status(const DictionaryDatum &) ;
101 
102  private:
103 
104  void init_state_(Node const&);
105  void init_buffers_();
106  void calibrate();
107 
108  void update(Time const &, const long_t, const long_t) {}
109 
110  // ------------------------------------------------------------
111 
112  struct State_;
113 
114  struct Parameters_ {
115  std::string port_name_;
116 
117  Parameters_();
118  Parameters_(const Parameters_&);
119 
120  void get(DictionaryDatum&) const;
121  void set(const DictionaryDatum&, State_&);
122  };
123 
124  // ------------------------------------------------------------
125 
126  struct State_ {
127  bool published_;
129 
130  State_();
131 
132  void get(DictionaryDatum&) const;
133  void set(const DictionaryDatum&, const Parameters_&);
134  };
135 
136  // ------------------------------------------------------------
137 
138  struct Variables_ {
139  MUSIC::EventOutputPort *MP_;
140  std::vector<MUSIC::GlobalIndex> index_map_;
141  MUSIC::PermutationIndex *music_perm_ind_;
142  };
143 
144  // ------------------------------------------------------------
145 
149  };
150 
151  inline
153  {
154  // receptor_type i is mapped to channel i of the MUSIC port so we
155  // have to generate the index map here, that assigns the channel
156  // number to the local index of this connection the local index
157  // equals the number of connection
158 
159  if (!S_.published_)
160  V_.index_map_.push_back(static_cast<int>(receptor_type));
161  else
163 
164  return receptor_type;
165  }
166 
167 } // namespace
168 
169 #endif /* #ifndef MUSIC_EVENT_OUT_PROXY_H */
170 
171 #endif
bool one_node_per_process() const
Returns true if the node exists only once per process, but does not have proxies on remote threads...
Definition: music_event_out_proxy.h:86
void set_status(const DictionaryDatum &)
Definition: music_event_out_proxy.cpp:173
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
Definition: music_event_out_proxy.h:114
Definition: lockptrdatum.h:40
Declarations for base class Node.
void init_state_(Node const &)
Private function to initialize the state of a node to model defaults.
Definition: music_event_out_proxy.cpp:108
void get_status(DictionaryDatum &) const
Definition: music_event_out_proxy.cpp:156
std::string port_name_
the name of MUSIC port to connect to
Definition: music_event_out_proxy.h:115
void set(const DictionaryDatum &, State_ &)
Set values from dicitonary.
Definition: music_event_out_proxy.cpp:63
std::vector< MUSIC::GlobalIndex > index_map_
Definition: music_event_out_proxy.h:140
MUSIC::EventOutputPort * MP_
The MUSIC event port for output of spikes.
Definition: music_event_out_proxy.h:139
music_event_out_proxy()
Definition: music_event_out_proxy.cpp:87
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
Variables_ V_
Definition: music_event_out_proxy.h:148
Parameters_()
Sets default parameter values.
Definition: music_event_out_proxy.cpp:41
Definition: music_event_out_proxy.h:126
Definition: nest_time.h:130
void calibrate()
Re-calculate dependent parameters of the node.
Definition: music_event_out_proxy.cpp:116
std::string get_name() const
Return class name.
Definition: node.cpp:83
Definition: music_event_out_proxy.h:138
State_ S_
Definition: music_event_out_proxy.h:147
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: music_event_out_proxy.h:152
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: music_event_out_proxy.h:108
Parameters_ P_
Definition: music_event_out_proxy.h:146
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
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: music_event_out_proxy.cpp:113
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
Exception to be thrown if the user tries to change the name of an already published port...
Definition: exceptions.h:779
void set(const DictionaryDatum &, const Parameters_ &)
Set values from dicitonary.
Definition: music_event_out_proxy.cpp:79
bool local_receiver() const
Returns true if the node only receives events from nodes/devices on the same thread.
Definition: music_event_out_proxy.h:85
bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: music_event_out_proxy.h:84
~music_event_out_proxy()
Definition: music_event_out_proxy.cpp:99
Default types used by the NEST kernel.
Event for spike information.
Definition: event.h:320
Definition: music_event_out_proxy.h:75
Base class for all NEST network objects.
Definition: node.h:96
State_()
Sets default state value.
Definition: music_event_out_proxy.cpp:49
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: music_event_out_proxy.cpp:186
MUSIC::PermutationIndex * music_perm_ind_
The permutation index needed to map the ports of MUSIC.
Definition: music_event_out_proxy.h:141
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
int port_width_
the width of the MUSIC port
Definition: music_event_out_proxy.h:128
bool published_
indicates whether this node has been published already with MUSIC
Definition: music_event_out_proxy.h:127