Skip to content

Commit

Permalink
Revert "Measurement: Introduce Reader / Writer classes"
Browse files Browse the repository at this point in the history
This reverts commit d65ab25.
  • Loading branch information
FlorianReimold committed Jan 11, 2024
1 parent 0f16b39 commit 777163d
Show file tree
Hide file tree
Showing 18 changed files with 344 additions and 622 deletions.
7 changes: 3 additions & 4 deletions app/meas_cutter/src/measurement_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
*/

#include "measurement_exporter.h"
#include <ecal/measurement/hdf5/writer.h>

MeasurementExporter::MeasurementExporter():
_writer(std::make_unique<eCAL::measurement::hdf5::Writer>())
_writer(new eCAL::eh5::HDF5Meas)
{
}

void MeasurementExporter::setPath(const std::string& path, const std::string& base_name, const size_t& max_size_per_file)
{
_root_output_path = EcalUtils::Filesystem::CleanPath(path);
_output_path = EcalUtils::Filesystem::CleanPath(_root_output_path + EcalUtils::Filesystem::NativeSeparator(EcalUtils::Filesystem::OsStyle::Current) + eCALMeasCutterUtils::kDefaultFolderOutput, EcalUtils::Filesystem::OsStyle::Current);
if (!_writer->Open(_output_path))
if (!_writer->Open(_output_path, eCAL::measurement::base::CREATE))
{
throw ExporterException("Unable to create HDF5 protobuf output path " + path + ".");
}
Expand Down Expand Up @@ -92,4 +91,4 @@ std::string MeasurementExporter::getOutputPath() const
std::string MeasurementExporter::getRootOutputPath() const
{
return _root_output_path;
}
}
4 changes: 2 additions & 2 deletions app/meas_cutter/src/measurement_exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <unordered_map>
#include <map>

#include <ecal/measurement/base/writer.h>
#include <ecalhdf5/eh5_meas.h>
#include <ecal_utils/filesystem.h>
#include "utils.h"

Expand All @@ -43,7 +43,7 @@ class MeasurementExporter
std::string getRootOutputPath() const;

private:
std::unique_ptr<eCAL::measurement::base::Writer> _writer;
std::unique_ptr<eCAL::measurement::base::Measurement> _writer;
std::string _current_channel_name;
std::string _output_path;
std::string _root_output_path;
Expand Down
3 changes: 1 addition & 2 deletions app/meas_cutter/src/measurement_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
*/

#include "measurement_importer.h"
#include <ecal/measurement/hdf5/reader.h>

MeasurementImporter::MeasurementImporter() :
_reader(std::make_unique<eCAL::measurement::hdf5::Reader>()),
_reader(new eCAL::eh5::HDF5Meas),
_current_opened_channel_data()
{
}
Expand Down
4 changes: 2 additions & 2 deletions app/meas_cutter/src/measurement_importer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <array>

#include <ecal_utils/filesystem.h>
#include <ecal/measurement/base/reader.h>
#include <ecalhdf5/eh5_meas.h>

#include "utils.h"

Expand Down Expand Up @@ -53,7 +53,7 @@ class MeasurementImporter
private:
bool isEcalMeasFile(const std::string& path);
bool isProtoChannel(const std::string& channel_type);
std::unique_ptr<eCAL::measurement::base::Reader> _reader;
std::unique_ptr<eCAL::measurement::base::Measurement> _reader;
eCALMeasCutterUtils::ChannelData _current_opened_channel_data;
std::string _loaded_path;
eCALMeasCutterUtils::ChannelNameSet _channel_names;
Expand Down
6 changes: 3 additions & 3 deletions app/play/play_core/src/ecal_play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "ecal_play_logger.h"
#include "play_thread.h"
#include <ecal/measurement/hdf5/reader.h>
#include "ecalhdf5/eh5_meas.h"

#include <ecal_utils/string.h>
#include <ecal_utils/filesystem.h>
Expand Down Expand Up @@ -58,7 +58,7 @@ bool EcalPlay::LoadMeasurement(const std::string& path)
{
EcalPlayLogger::Instance()->info("Loading measurement...");

std::shared_ptr<eCAL::measurement::base::Reader> measurement(std::make_shared<eCAL::measurement::hdf5::Reader>());
std::shared_ptr<eCAL::measurement::base::Measurement> measurement(std::make_shared<eCAL::eh5::HDF5Meas>());

std::string meas_dir; // The directory of the measurement
std::string path_to_load; // The actual path we load the measurement from. May be a directory or a .hdf5 file
Expand Down Expand Up @@ -129,7 +129,7 @@ bool EcalPlay::LoadMeasurement(const std::string& path)
void EcalPlay::CloseMeasurement()
{
description_ = "";
play_thread_->SetMeasurement(std::shared_ptr<eCAL::measurement::base::Reader>(nullptr));
play_thread_->SetMeasurement(std::shared_ptr<eCAL::measurement::base::Measurement>(nullptr));
measurement_path_ = "";
clearScenariosPath();
channel_mapping_path_ = "";
Expand Down
5 changes: 2 additions & 3 deletions app/play/play_core/src/measurement_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
*/

#include "measurement_container.h"
#include <ecal/measurement/hdf5/reader.h>

#include <algorithm>
#include <math.h>
#include <stdlib.h>

MeasurementContainer::MeasurementContainer(std::shared_ptr<eCAL::measurement::base::Reader> hdf5_meas, const std::string& meas_dir, bool use_receive_timestamp)
MeasurementContainer::MeasurementContainer(std::shared_ptr<eCAL::measurement::base::Measurement> hdf5_meas, const std::string& meas_dir, bool use_receive_timestamp)
: hdf5_meas_ (hdf5_meas)
, meas_dir_ (meas_dir)
, use_receive_timestamp_ (use_receive_timestamp)
Expand Down Expand Up @@ -494,4 +493,4 @@ std::map<std::string, ContinuityReport> MeasurementContainer::CreateContinuityRe
}

return continuity_report;
}
}
6 changes: 3 additions & 3 deletions app/play/play_core/src/measurement_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
#include <memory>

#include <ecal/ecal.h>
#include <ecal/measurement/base/reader.h>
#include <ecalhdf5/eh5_meas.h>

#include "continuity_report.h"

class MeasurementContainer
{
public:
MeasurementContainer(std::shared_ptr<eCAL::measurement::base::Reader> hdf5_meas, const std::string& meas_dir = "", bool use_receive_timestamp = true);
MeasurementContainer(std::shared_ptr<eCAL::measurement::base::Measurement> hdf5_meas, const std::string& meas_dir = "", bool use_receive_timestamp = true);
~MeasurementContainer();

void CreatePublishers();
Expand Down Expand Up @@ -108,7 +108,7 @@ class MeasurementContainer
PublisherInfo* publisher_info_;
};

std::shared_ptr<eCAL::measurement::base::Reader> hdf5_meas_;
std::shared_ptr<eCAL::measurement::base::Measurement> hdf5_meas_;
std::string meas_dir_;
bool use_receive_timestamp_;

Expand Down
2 changes: 1 addition & 1 deletion app/play/play_core/src/play_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ void PlayThread::LogChannelMapping(const std::map<std::string, std::string>& cha
//// Measurement ////
////////////////////////////////////////////////////////////////////////////////

void PlayThread::SetMeasurement(const std::shared_ptr<eCAL::measurement::base::Reader>& measurement, const std::string& path)
void PlayThread::SetMeasurement(const std::shared_ptr<eCAL::measurement::base::Measurement>& measurement, const std::string& path)
{
std::unique_ptr<MeasurementContainer> new_measurment_container;

Expand Down
2 changes: 1 addition & 1 deletion app/play/play_core/src/play_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class PlayThread : public InterruptibleThread
* @param measurement The new measurement
* @param path The (optional) path from where the measurement was loaded
*/
void SetMeasurement(const std::shared_ptr<eCAL::measurement::base::Reader>& measurement, const std::string& path = "");
void SetMeasurement(const std::shared_ptr<eCAL::measurement::base::Measurement>& measurement, const std::string& path = "");

/**
* @brief Returns whether a measurement has successfully been loaded
Expand Down
7 changes: 3 additions & 4 deletions app/rec/rec_client_core/src/job/hdf5_writer_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

#include "hdf5_writer_thread.h"
#include <ecal/measurement/hdf5/writer.h>

#include "rec_client_core/ecal_rec_logger.h"

Expand All @@ -42,7 +41,7 @@ namespace eCAL
, new_topic_info_map_available_(true)
, flushing_ (false)
{
hdf5_writer_ = std::make_unique<eCAL::measurement::hdf5::Writer>();
hdf5_writer_ = std::make_unique<eCAL::eh5::HDF5Meas>();
}

Hdf5WriterThread::~Hdf5WriterThread()
Expand Down Expand Up @@ -265,7 +264,7 @@ namespace eCAL
#endif // NDEBUG
std::unique_lock<decltype(hdf5_writer_mutex_)> hdf5_writer_lock(hdf5_writer_mutex_);

if (hdf5_writer_->Open(hdf5_dir))
if (hdf5_writer_->Open(hdf5_dir, eCAL::measurement::base::AccessType::CREATE))
{
#ifndef NDEBUG
EcalRecLogger::Instance()->debug("Hdf5WriterThread::Open(): Successfully opened HDF5-Writer with path \"" + hdf5_dir + "\"");
Expand Down Expand Up @@ -307,4 +306,4 @@ namespace eCAL
}
}
}
}
}
4 changes: 2 additions & 2 deletions app/rec/rec_client_core/src/job/hdf5_writer_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#pragma once
#include <ThreadingUtils/InterruptibleThread.h>

#include <ecal/measurement/base/writer.h>
#include <ecalhdf5/eh5_meas.h>

#include <mutex>
#include <deque>
Expand Down Expand Up @@ -94,7 +94,7 @@ namespace eCAL
mutable RecHdf5JobStatus last_status_;

mutable std::mutex hdf5_writer_mutex_;
std::unique_ptr<eCAL::measurement::base::Writer> hdf5_writer_;
std::unique_ptr<eCAL::measurement::base::Measurement> hdf5_writer_;


std::atomic<bool> flushing_;
Expand Down
2 changes: 1 addition & 1 deletion contrib/ecalhdf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ set(ecalhdf5_src
set(ecalhdf5_header_base
include/ecalhdf5/eh5_defs.h
include/ecalhdf5/eh5_meas.h
include/ecalhdf5/eh5_types.h
include/ecalhdf5/eh5_types.h
)

ecal_add_library(${PROJECT_NAME} ${ecalhdf5_src} ${ecalhdf5_header_base})
Expand Down
Loading

0 comments on commit 777163d

Please sign in to comment.