23 #ifndef UNIVERSAL_DATA_LOGGER_H
24 #define UNIVERSAL_DATA_LOGGER_H
86 template <
typename HostNode>
87 class UniversalDataLogger {
94 UniversalDataLogger(HostNode&);
108 port connect_logging_device(
const DataLoggingRequest&,
109 const RecordablesMap<HostNode>&);
121 void handle(
const DataLoggingRequest&);
153 DataLogger_(
const DataLoggingRequest&,
154 const RecordablesMap<HostNode>&);
155 index get_mm_gid()
const {
return multimeter_; }
156 void handle(HostNode&,
const DataLoggingRequest&);
157 void record_data(
const HostNode&,
long_t);
165 Time recording_interval_;
170 std::vector<typename RecordablesMap<HostNode>::DataAccessFct> node_access_;
179 std::vector<DataLoggingReply::Container> data_;
182 std::vector<size_t> next_rec_;
191 std::vector<DataLogger_> data_loggers_;
192 typedef typename std::vector<DataLogger_>::iterator DLiter_;
195 UniversalDataLogger(
const UniversalDataLogger&);
198 UniversalDataLogger
const& operator=(
const UniversalDataLogger&);
203 template <
typename HostNode>
204 port nest::UniversalDataLogger<HostNode>::connect_logging_device(
const DataLoggingRequest& req,
205 const RecordablesMap<HostNode>& rmap)
208 if ( req.get_rport() != 0 )
209 throw IllegalConnection(
"UniversalDataLogger::connect_logging_device(): "
210 "Connections from multimeter to node must request rport 0.");
213 const index mm_gid = req.get_sender().get_gid();
214 const size_t n_loggers = data_loggers_.size();
216 while ( j < n_loggers && data_loggers_[j].get_mm_gid() != mm_gid )
219 throw IllegalConnection(
"UniversalDataLogger::connect_logging_device(): "
220 "Each multimeter can only be connected once to a given node.");
223 data_loggers_.push_back(DataLogger_(req, rmap));
226 return data_loggers_.size();
229 template <
typename HostNode>
230 nest::UniversalDataLogger<HostNode>::DataLogger_::DataLogger_(
const DataLoggingRequest& req,
231 const RecordablesMap<HostNode>& rmap):
232 multimeter_(req.get_sender().get_gid()),
234 recording_interval_(Time::neg_inf()),
241 const std::vector<Name>& recvars = req.record_from();
242 for (
size_t j = 0 ; j < recvars.size() ; ++j )
244 typename RecordablesMap<HostNode>::const_iterator rec
245 = rmap.find(recvars[j].toString());
248 if ( rec == rmap.end() )
252 node_access_.clear();
253 throw IllegalConnection(
"UniversalDataLogger::connect_logging_device(): "
254 "Unknown recordable " + recvars[j].toString());
257 node_access_.push_back(rec->second);
260 num_vars_ = node_access_.size();
262 if ( num_vars_ > 0 && req.get_recording_interval() < Time::step(1) )
263 throw IllegalConnection(
"UniversalDataLogger::connect_logging_device(): "
264 "recording interval must be >= resolution.");
266 recording_interval_ = req.get_recording_interval();
271 #endif // UNIVERSAL_DATA_LOGGER_H
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
Default types used by the NEST kernel.
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96