29 template <
typename HostNode>
30 nest::UniversalDataLogger<HostNode>::UniversalDataLogger(HostNode& host)
35 template <
typename HostNode>
36 void nest::UniversalDataLogger<HostNode>::reset()
38 for ( DLiter_ it = data_loggers_.begin() ; it != data_loggers_.end() ; ++it )
42 template <
typename HostNode>
43 void nest::UniversalDataLogger<HostNode>::init()
45 for ( DLiter_ it = data_loggers_.begin() ; it != data_loggers_.end() ; ++it )
49 template <
typename HostNode>
50 void nest::UniversalDataLogger<HostNode>::record_data(
long_t step)
52 for ( DLiter_ it = data_loggers_.begin() ; it != data_loggers_.end() ; ++it )
53 it->record_data(host_, step);
56 template <
typename HostNode>
57 void nest::UniversalDataLogger<HostNode>::handle(
const DataLoggingRequest& dlr)
61 assert(static_cast<size_t>(rport) <= data_loggers_.size());
62 data_loggers_[rport-1].handle(host_, dlr);
65 template <
typename HostNode>
66 void nest::UniversalDataLogger<HostNode>::DataLogger_::reset()
72 template <
typename HostNode>
73 void nest::UniversalDataLogger<HostNode>::DataLogger_::init()
80 if ( next_rec_step_ >= Node::network()->get_slice_origin().get_steps() )
89 rec_int_steps_ = recording_interval_.get_steps();
96 ( Node::network()->get_time().get_steps() / rec_int_steps_ + 1 ) * rec_int_steps_ - 1;
99 const long_t recs_per_slice =
100 static_cast<long_t>(std::ceil(Node::network()->get_min_delay()
101 / static_cast<double>(rec_int_steps_)));
104 DataLoggingReply::Container(recs_per_slice,
105 DataLoggingReply::Item(num_vars_)
110 next_rec_[0] = next_rec_[1] = 0;
113 template <
typename HostNode>
114 void nest::UniversalDataLogger<HostNode>::DataLogger_::record_data(
const HostNode& host,
long_t step)
116 if ( num_vars_ < 1 || step < next_rec_step_ )
119 const size_t wt = Node::network()->write_toggle();
121 assert(wt < next_rec_.size());
122 assert(wt < data_.size());
131 assert(next_rec_[wt] < data_[wt].size());
133 DataLoggingReply::Item& dest = data_[wt][next_rec_[wt]];
136 dest.timestamp = Time::step(step + 1);
139 for (
size_t j = 0 ; j < num_vars_ ; ++j )
140 dest.data[j] = ((host).*(node_access_[j]))();
142 next_rec_step_ += rec_int_steps_;
152 template <
typename HostNode>
153 void nest::UniversalDataLogger<HostNode>::DataLogger_::handle(HostNode& host,
154 const DataLoggingRequest& request)
161 assert(next_rec_.size() == 2);
162 assert(data_.size() == 2);
165 const size_t rt = Node::network()->read_toggle();
166 assert(not data_[rt].empty());
172 if ( data_[rt][0].timestamp <= Node::network()->get_previous_slice_origin() )
183 if ( next_rec_[rt] < data_[rt].size() )
184 data_[rt][next_rec_[rt]].timestamp = Time::neg_inf();
187 DataLoggingReply reply(data_[rt]);
192 reply.set_sender(host);
193 reply.set_sender_gid(host.get_gid());
194 reply.set_receiver(request.get_sender());
195 reply.set_port(request.get_port());
198 host.network()->send_to_node(reply);
Declarations for base class Node.
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
Declarations for class Network.
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96