41 #ifdef MESSAGE_SUPPORT
42 void Measurement::toMessage(corbo::messages::Signal& message)
const
44 header.toMessage(*message.mutable_header());
45 message.mutable_measurement()->set_time(
_time);
46 google::protobuf::RepeatedField<double> values(
_values.begin(),
_values.end());
47 message.mutable_measurement()->mutable_values()->Swap(&values);
49 message.mutable_measurement()->clear_value_labels();
50 for (
const std::string& label :
_value_labels) message.mutable_measurement()->add_value_labels(label);
52 void Measurement::fromMessage(
const corbo::messages::Signal& message, std::stringstream* issues)
54 header.fromMessage(message.header(), issues);
55 _time = message.measurement().time();
56 _values.assign(message.measurement().values().begin(), message.measurement().values().end());
59 for (
int i = 0; i < message.measurement().value_labels_size(); ++i)
_value_labels.push_back(message.measurement().value_labels(i));
66 _time_series->add(measurement.getTime(), measurement.getValues());
68 if (!measurement.getValueLabels().empty() &&
_time_series->getValueLabels().empty())
70 _time_series->getValueLabelsRef() = measurement.getValueLabels();
87 double time_from_start)
99 #ifdef MESSAGE_SUPPORT
100 void TimeSeriesSignal::toMessage(corbo::messages::Signal& message)
const
102 header.toMessage(*message.mutable_header());
106 void TimeSeriesSignal::fromMessage(
const corbo::messages::Signal& message, std::stringstream* issues)
110 _time_series->fromMessage(message.time_series(), issues);
120 #ifdef MESSAGE_SUPPORT
121 void TimeSeriesSequenceSignal::toMessage(corbo::messages::Signal& message)
const
123 header.toMessage(*message.mutable_header());
126 void TimeSeriesSequenceSignal::fromMessage(
const corbo::messages::Signal& message, std::stringstream* issues)
128 header.fromMessage(message.header());
130 _ts_sequence->fromMessage(message.ts_sequence(), issues);
159 #ifdef MESSAGE_SUPPORT
160 void IndexedValuesSignal::toMessage(messages::IndexedValues& message)
const
163 google::protobuf::RepeatedField<double> values(
_values.begin(),
_values.end());
164 message.mutable_values()->Swap(&values);
167 void IndexedValuesSignal::fromMessage(
const messages::IndexedValues& message, std::stringstream* issues)
170 _values.assign(message.values().begin(), message.values().end());
183 std::copy(values.data(), values.data() + values.size(), std::back_inserter(
_values_map[index]));
196 if ((
int)elem.second.size() > max_dim) max_dim = (
int)elem.second.size();
201 #ifdef MESSAGE_SUPPORT
202 void IndexedValuesSetSignal::toMessage(messages::IndexedValuesSet& message)
const
206 messages::Vector& value_vec = (*message.mutable_indexed_values())[item.first];
207 for (
const double& value : item.second) value_vec.add_values(value);
211 void IndexedValuesSetSignal::fromMessage(
const messages::IndexedValuesSet& message, std::stringstream* issues)
215 for (
const auto& item : message.indexed_values())
217 std::vector<double>& value_vec =
_values_map[item.first];
218 value_vec.assign(item.second.values().begin(), item.second.values().end());
223 #ifdef MESSAGE_SUPPORT
224 void MatrixSignal::toMessage(messages::Matrix& message)
const
226 message.set_rows(
_matrix.rows());
227 message.set_cols(
_matrix.cols());
228 message.set_row_major(
true);
230 message.mutable_data()->Resize(
_matrix.rows() *
_matrix.cols(), 0);
233 message.set_label(
_label);
236 void MatrixSignal::fromMessage(
const messages::Matrix& message, std::stringstream* isses)
238 if (message.row_major())
260 #ifdef MESSAGE_SUPPORT
261 void MatrixSetSignal::toMessage(messages::MatrixSet& message)
const
265 messages::Matrix* mat_msg = message.add_matrices();
266 mat->toMessage(*mat_msg);
270 void MatrixSetSignal::fromMessage(
const messages::MatrixSet& message, std::stringstream* issues)
273 for (
int i = 0; i < message.matrices_size(); ++i)
276 matrix_signal->fromMessage(message.matrices(i));