NEST  2.6.0,not_revisioned_source_dir@0
music_event_in_proxy.h
Go to the documentation of this file.
1 /*
2  * music_event_in_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_IN_PROXY_H
24 #define MUSIC_EVENT_IN_PROXY_H
25 
26 #include "config.h"
27 
28 #ifdef HAVE_MUSIC
29 
30 
31 #include <vector>
32 #include "nest.h"
33 #include "event.h"
34 #include "node.h"
35 #include "scheduler.h"
36 #include "connection.h"
37 
38 /*BeginDocumentation
39 
40 Name: music_event_in_proxy - A device which receives spikes from MUSIC.
41 
42 Description:
43 A music_event_in_proxy can be used to pass spikes to nodes within NEST
44 which are received from another application.
45 
46 It uses the MUSIC library to receive spike events from other
47 applications. The music_event_in_proxy represents one channel on a port
48 to which MUSIC can connect an event source. The music_event_in_proxy can
49 be connected to local neurons or devices within NEST to receive
50 the events. Multiple music_in_proxies can be configured to listen
51 on the same port, but each channel can only listened to by a
52 single proxy.
53 
54 Parameters:
55 The following properties are available in the status dictionary:
56 
57 port_name - The name of the MUSIC input port to listen to (default:
58  event_in)
59 music_channel - The MUSIC global index on the input port to listen to
60 registered - A bool indicating if the port has been already registered
61  with the corresponding MUSIC event handler
62 
63 The parameters port_name and music_channel can be set using SetStatus.
64 The acceptable latency of the MUSIC input port can be set using the
65 command SetAcceptableLatency.
66 
67 Examples:
68 /music_event_in_proxy Create /meip Set
69 meip << /music_channel 2 >> SetStatus
70 /iaf_neuron Create /n Set
71 (event_in) 0.2 SetAcceptableLatency
72 meip n Connect
73 
74 Author: Moritz Helias, Jochen Martin Eppler
75 FirstVersion: October 2008
76 Availability: Only when compiled with MUSIC
77 
78 SeeAlso: SetAcceptableLatency, music_event_out_proxy, music_cont_in_proxy, music_message_in_proxy
79 */
80 
81 namespace nest
82 {
88  class music_event_in_proxy : public Node
89  {
90 
91  public:
94 
95  bool has_proxies() const {return false;} // a copy on each process
96  bool one_node_per_process() const {return true;}
97 
102  using Node::handle;
104 
105  void handle(SpikeEvent &);
107 
108  void get_status(DictionaryDatum &) const;
109  void set_status(const DictionaryDatum &);
110 
111  private:
112 
113  void init_state_(const Node&);
114  void init_buffers_();
115  void calibrate();
116 
117  void update(Time const &, const long_t, const long_t) {}
118 
119  // ------------------------------------------------------------
120  struct State_;
121 
122  struct Parameters_ {
123  std::string port_name_;
124  int channel_;
125 
126  Parameters_();
127  Parameters_(const Parameters_&);
128 
129  void get(DictionaryDatum&) const;
130 
134  void set(const DictionaryDatum&, State_&);
135  };
136 
137  // ------------------------------------------------------------
138 
139  struct State_ {
140  bool registered_;
141 
142  State_();
143 
144  void get(DictionaryDatum&) const;
145  void set(const DictionaryDatum&, const Parameters_&);
146  };
147 
148  // ------------------------------------------------------------
149 
152  };
153 
154 inline
156 {
157  SpikeEvent e;
158  e.set_sender(*this);
159 
160  return target.handles_test_event(e, receptor_type);
161 }
162 
163 } // namespace
164 
165 #endif
166 
167 #endif /* #ifndef MUSIC_EVENT_IN_PROXY_H */
void set(const DictionaryDatum &, State_ &)
Set values from dicitonary.
Definition: music_event_in_proxy.cpp:65
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
Definition: music_event_in_proxy.h:122
Definition: lockptrdatum.h:40
Declarations for base class Node.
Parameters_()
Sets default parameter values.
Definition: music_event_in_proxy.cpp:41
void set_status(const DictionaryDatum &)
Definition: music_event_in_proxy.cpp:132
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: music_event_in_proxy.h:117
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
void get_status(DictionaryDatum &) const
Definition: music_event_in_proxy.cpp:126
State_ S_
Definition: music_event_in_proxy.h:151
std::string port_name_
the name of MUSIC port to connect to
Definition: music_event_in_proxy.h:123
Definition: nest_time.h:130
bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: music_event_in_proxy.h:95
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: music_event_in_proxy.cpp:148
int channel_
the MUSIC channel of the port
Definition: music_event_in_proxy.h:124
music_event_in_proxy()
Definition: music_event_in_proxy.cpp:87
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
State_()
Sets default state value.
Definition: music_event_in_proxy.cpp:51
void set(const DictionaryDatum &, const Parameters_ &)
Set values from dicitonary.
Definition: music_event_in_proxy.cpp:79
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
Definition: music_event_in_proxy.h:139
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
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
Default types used by the NEST kernel.
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: music_event_in_proxy.h:155
Event for spike information.
Definition: event.h:320
void calibrate()
Re-calculate dependent parameters of the node.
Definition: music_event_in_proxy.cpp:116
Base class for all NEST network objects.
Definition: node.h:96
Parameters_ P_
Definition: music_event_in_proxy.h:150
void init_state_(const Node &)
Private function to initialize the state of a node to model defaults.
Definition: music_event_in_proxy.cpp:106
bool registered_
indicates whether this node has been registered already with MUSIC
Definition: music_event_in_proxy.h:140
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_in_proxy.h:96
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
Emit spikes at times received from another application via a MUSIC port.
Definition: music_event_in_proxy.h:88
const double e
Definition: numerics.cpp:62
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: music_event_in_proxy.cpp:113