reward_in_proxy.h
1 /*
2  * This file is part of SPORE.
3  *
4  * Copyright (C) 2016, the SPORE team (see AUTHORS).
5  *
6  * SPORE is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * SPORE is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPORE. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * For more information see: https://github.com/IGITUGraz/spore-nest-module
20  *
21  * File: reward_in_proxy.h
22  * Author: Hoff
23  *
24  * This file is based on music_cont_in_proxy.h which is part of NEST
25  * (Copyright (C) 2004 The NEST Initiative).
26  * See: http://nest-initiative.org/
27  */
28 
29 #ifndef REWARD_IN_PROXY_H
30 #define REWARD_IN_PROXY_H
31 
32 #include "nest.h"
33 #include "event.h"
34 #include "ring_buffer.h"
35 #include "spikecounter.h"
36 #include "connection.h"
37 
38 #include "namedatum.h"
39 #include "universal_data_logger.h"
40 
41 #include <music.hh>
42 
43 #include "tracing_node.h"
44 
45 namespace spore
46 {
47 
61 class RewardInProxy : public TracingNode
62 {
63 public:
64 
65  RewardInProxy();
66 
67  bool has_proxies() const
68  {
69  return false;
70  }
71 
72  bool one_node_per_process() const
73  {
74  return true;
75  }
76 
77  virtual void get_status(DictionaryDatum& d) const;
78  virtual void set_status(const DictionaryDatum& d);
79 
80 protected:
81 
82  virtual void init_buffers_();
83  virtual void init_state_(const Node&);
84 
85  virtual void calibrate();
86 
87  virtual void update(nest::Time const&, const long, const long);
88 
89  MUSIC::ContInputPort* reward_in_;
90  std::vector< double > reward_in_buffer_;
91 
92  // ------------------------------------------------------------
93 
97  struct State_
98  {
99  State_();
100 
101  void get(DictionaryDatum&) const;
102 
103  bool published_;
105  };
106 
110  struct Parameters_
111  {
112  Parameters_();
113 
114  void get(DictionaryDatum&) const;
115  void set(const DictionaryDatum&, State_&);
116 
117  std::string port_name_;
118  float delay_;
119  };
120 
121  State_ S_;
122  Parameters_ P_;
123 };
124 
125 }
126 
127 #endif
MUSIC::ContInputPort * reward_in_
The MUSIC cont port for reward input.
Definition: reward_in_proxy.h:89
std::string port_name_
the name of MUSIC port to read from
Definition: reward_in_proxy.h:117
int port_width_
the width of the MUSIC port
Definition: reward_in_proxy.h:104
Base class to all nodes that record traces.
Definition: tracing_node.h:52
float delay_
the accepted delay for the MUSIC connection
Definition: reward_in_proxy.h:118
bool published_
indicates whether this node has been published already with MUSIC
Definition: reward_in_proxy.h:103
Class holding state variables of the proxy.
Definition: reward_in_proxy.h:97
State_()
Sets default state value.
Definition: reward_in_proxy.cpp:68
virtual void get_status(DictionaryDatum &d) const
Definition: reward_in_proxy.cpp:171
virtual void set_status(const DictionaryDatum &d)
Definition: reward_in_proxy.cpp:181
A device allows to receive reward traces from another process.
Definition: reward_in_proxy.h:61
Class holding parameter variables of the proxy.
Definition: reward_in_proxy.h:110
Global namespace holding all classes of the SPORE NEST module.
Definition: circular_buffer.h:31
std::vector< double > reward_in_buffer_
The mapped buffer for receiving the reward values via MPI.
Definition: reward_in_proxy.h:90