35 YAML::Emitter yaml_emitter;
45 YAML::Emitter yaml_emitter;
55 YAML::Emitter yaml_emitter;
65 YAML::Emitter yaml_emitter;
75 YAML::Emitter yaml_emitter;
84 YAML::Emitter yaml_emitter;
93 YAML::Emitter yaml_emitter;
102 YAML::Emitter yaml_emitter;
111 if (wrap_in_map) emitter << YAML::BeginMap;
113 emitter << YAML::Key << signal_group.group_name;
114 emitter << YAML::Value;
116 emitter << YAML::BeginMap;
118 if (!signal_group.group_signals.empty())
126 const TimeSeriesSignal* ts_signal =
dynamic_cast<const TimeSeriesSignal*
>(signal.get());
132 const TimeSeriesSequenceSignal* ts_seq_signal =
dynamic_cast<const TimeSeriesSequenceSignal*
>(signal.get());
138 const IndexedValuesSignal* indexed_values_signal =
dynamic_cast<const IndexedValuesSignal*
>(signal.get());
139 if (indexed_values_signal)
144 const IndexedValuesSetSignal* indexed_values_set_signal =
dynamic_cast<const IndexedValuesSetSignal*
>(signal.get());
145 if (indexed_values_set_signal)
150 const MatrixSignal* matrix_signal =
dynamic_cast<const MatrixSignal*
>(signal.get());
156 const MatrixSetSignal* matrix_set_signal =
dynamic_cast<const MatrixSetSignal*
>(signal.get());
157 if (matrix_set_signal)
162 PRINT_WARNING_NAMED(
"Signal '" << signal->header.name <<
"' cannot be exported (not implemented).");
169 if (!signal_group.children.empty())
172 for (
const CommonSignalTarget::SignalGroup& child : signal_group.children)
179 emitter << YAML::EndMap;
181 if (wrap_in_map) emitter << YAML::EndMap;
187 if (wrap_in_map) emitter << YAML::BeginMap;
189 std::vector<std::string> labels = time_series.getValueLabels();
190 emitter << YAML::Key <<
"label";
191 emitter << YAML::Value << YAML::Flow << labels;
193 emitter << YAML::Key <<
"time";
194 emitter << YAML::Value << YAML::Flow << time_series.getTime();
196 emitter << YAML::Key <<
"rows";
197 emitter << YAML::Value << time_series.getValuesMatrixView().rows();
199 emitter << YAML::Key <<
"cols";
200 emitter << YAML::Value << time_series.getValuesMatrixView().cols();
202 emitter << YAML::Key <<
"is_column_major";
204 emitter << YAML::Value << (
int)time_series.isColumnMajor();
206 emitter << YAML::Key <<
"values";
207 emitter << YAML::Value << YAML::Flow << time_series.getValues();
209 emitter << YAML::Key <<
"time_from_start";
210 emitter << YAML::Value << time_series.getTimeFromStart();
212 if (wrap_in_map) emitter << YAML::EndMap;
217 if (wrap_in_map) emitter << YAML::BeginMap;
219 emitter << YAML::Key << signal.header.getShortName();
220 emitter << YAML::Value << YAML::BeginMap;
224 if (signal.getTimeSeries())
226 const TimeSeries& time_series = *signal.getTimeSeries();
227 std::vector<std::string> labels = time_series.getValueLabels();
228 emitter << YAML::Key <<
"label";
229 emitter << YAML::Value << YAML::Flow << labels;
231 emitter << YAML::Key <<
"time";
232 emitter << YAML::Value << YAML::Flow << time_series.getTime();
234 emitter << YAML::Key <<
"rows";
235 emitter << YAML::Value << time_series.getValuesMatrixView().rows();
237 emitter << YAML::Key <<
"cols";
238 emitter << YAML::Value << time_series.getValuesMatrixView().cols();
240 emitter << YAML::Key <<
"is_column_major";
242 emitter << YAML::Value << (
int)!time_series.getValuesMatrixView().IsRowMajor;
244 emitter << YAML::Key <<
"values";
245 emitter << YAML::Value << YAML::Flow << time_series.getValues();
247 emitter << YAML::Key <<
"time_from_start";
248 emitter << YAML::Value << time_series.getTimeFromStart();
250 emitter << YAML::EndMap;
251 if (wrap_in_map) emitter << YAML::EndMap;
256 if (wrap_in_map) emitter << YAML::BeginMap;
258 emitter << YAML::Key << signal.header.getShortName();
259 emitter << YAML::Value << YAML::BeginMap;
263 if (!signal.isEmpty())
265 emitter << YAML::Key <<
"ts_seq";
266 emitter << YAML::Value << YAML::BeginSeq;
271 emitter << YAML::EndSeq;
274 emitter << YAML::EndMap;
276 if (wrap_in_map) emitter << YAML::EndMap;
281 if (wrap_in_map) emitter << YAML::BeginMap;
283 emitter << YAML::Key << signal.header.getShortName();
284 emitter << YAML::Value << YAML::BeginMap;
288 emitter << YAML::Key <<
"values";
289 emitter << YAML::Value << YAML::Flow << YAML::BeginSeq;
292 emitter << YAML::BeginSeq;
295 emitter << signal.getIndex();
298 emitter << signal.getValues();
301 emitter << YAML::EndSeq;
303 emitter << YAML::EndSeq;
304 emitter << YAML::EndMap;
305 if (wrap_in_map) emitter << YAML::EndMap;
311 if (wrap_in_map) emitter << YAML::BeginMap;
313 emitter << YAML::Key << signal.header.getShortName();
314 emitter << YAML::Value << YAML::BeginMap;
318 emitter << YAML::Key <<
"values";
319 emitter << YAML::Value << YAML::BeginSeq;
321 const std::map<int, std::vector<double>>& map = signal.getData();
322 auto it = map.begin();
324 while (it != map.end())
327 emitter << YAML::Flow << YAML::BeginSeq;
330 emitter << it->first;
333 emitter << it->second;
337 emitter << YAML::EndSeq;
341 emitter << YAML::EndSeq;
342 emitter << YAML::EndMap;
343 if (wrap_in_map) emitter << YAML::EndMap;
348 if (wrap_in_map) emitter << YAML::BeginMap;
350 emitter << YAML::Key << signal.header.getShortName();
351 emitter << YAML::Value << YAML::BeginMap;
355 if (!signal.isEmpty())
357 emitter << YAML::Key <<
"label";
358 emitter << YAML::Value << signal.getLabel();
360 emitter << YAML::Key <<
"rows";
361 emitter << YAML::Value << signal.getRowDimension();
363 emitter << YAML::Key <<
"cols";
364 emitter << YAML::Value << signal.getColDimension();
366 emitter << YAML::Key <<
"is_column_major";
368 emitter << YAML::Value << 1;
370 emitter << YAML::Key <<
"values";
371 emitter << YAML::Value << YAML::Flow << YAML::BeginSeq;
372 for (
int col_idx = 0; col_idx < signal.getMatrix().cols(); ++col_idx)
373 for (
int row_idx = 0; row_idx < signal.getMatrix().rows(); ++row_idx) emitter << signal.getMatrix()(row_idx, col_idx);
375 emitter << YAML::EndSeq;
378 emitter << YAML::EndMap;
379 if (wrap_in_map) emitter << YAML::EndMap;
384 if (wrap_in_map) emitter << YAML::BeginMap;
386 emitter << YAML::Key << signal.header.getShortName();
387 emitter << YAML::Value << YAML::BeginMap;
391 if (!signal.isEmpty())
393 emitter << YAML::Key <<
"mat_seq";
394 emitter << YAML::Value << YAML::BeginSeq;
399 emitter << YAML::EndSeq;
402 emitter << YAML::EndMap;
404 if (wrap_in_map) emitter << YAML::EndMap;
409 emitter << YAML::Key <<
"header";
410 emitter << YAML::Value << YAML::BeginMap;
412 emitter << YAML::Key <<
"name";
413 emitter << YAML::Value << header.name;
415 emitter << YAML::Key <<
"time_stamp";
416 emitter << YAML::Value << header.time.toSec();
418 emitter << YAML::EndMap;
427 file << emitter.c_str();
439 #endif // YAML_SUPPORT #define PRINT_WARNING_NAMED(msg)
bool exportTimeSeriesSignal(const std::string &filename, const TimeSeriesSignal &signal) override
bool exportIndexedValuesSetSignal(const std::string &filename, const IndexedValuesSetSignal &signal) override
bool exportTimeSeries(const std::string &filename, const TimeSeries &time_series) override
void emitIndexedValuesSet(const IndexedValuesSetSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
void emitTimeSeriesSequence(const TimeSeriesSequenceSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
void emitIndexedValues(const IndexedValuesSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
bool exportMatrixSetSignal(const std::string &filename, const MatrixSetSignal &signal) override
void emitHeader(const SignalHeader &header, YAML::Emitter &emitter)
bool write_file(const YAML::Emitter &emitter, const std::string &filename)
std::shared_ptr< SignalInterface > Ptr
bool exportSignalGroup(const std::string &filename, const CommonSignalTarget::SignalGroup &signal_group) override
bool exportTimeSeriesSequenceSignal(const std::string &filename, const TimeSeriesSequenceSignal &signal) override
bool exportIndexedValuesSignal(const std::string &filename, const IndexedValuesSignal &signal) override
void emitMatrix(const MatrixSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
bool exportMatrixSignal(const std::string &filename, const MatrixSignal &signal) override
std::shared_ptr< MatrixSignal > Ptr
void emitSignalGroup(const CommonSignalTarget::SignalGroup &signal_group, YAML::Emitter &emitter, bool wrap_in_map=true)
void emitMatrixSet(const MatrixSetSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
void emitTimeSeries(const TimeSeries &time_series, YAML::Emitter &emitter, bool wrap_in_map=true)
std::shared_ptr< TimeSeries > Ptr