Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.12: Reverted mcap changes #1152

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ if(HAS_HDF5)
add_subdirectory(contrib/ecalhdf5)
add_subdirectory(contrib/message)
endif()
add_subdirectory(contrib/measurement/base)

# --------------------------------------------------------
# ecal core python binding
Expand Down
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 <ecalhdf5/eh5_writer.h>

MeasurementExporter::MeasurementExporter():
_writer(std::make_unique<eCAL::eh5::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::eh5::eAccessType::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;
}
}
6 changes: 3 additions & 3 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,8 +43,8 @@ class MeasurementExporter
std::string getRootOutputPath() const;

private:
std::unique_ptr<eCAL::measurement::base::Writer> _writer;
std::string _current_channel_name;
std::unique_ptr<eCAL::eh5::HDF5Meas> _writer;
std::string _current_channel_name;
std::string _output_path;
std::string _root_output_path;
};
Expand Down
5 changes: 2 additions & 3 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 <ecalhdf5/eh5_reader.h>

MeasurementImporter::MeasurementImporter() :
_reader(std::make_unique<eCAL::eh5::Reader>()),
_reader(new eCAL::eh5::HDF5Meas),
_current_opened_channel_data()
{
}
Expand Down Expand Up @@ -80,7 +79,7 @@ void MeasurementImporter::openChannel(const std::string& channel_name)
_current_opened_channel_data._channel_info.description = _reader->GetChannelDescription(channel_name);
_current_opened_channel_data._channel_info.name = channel_name;

eCAL::measurement::base::EntryInfoSet entry_info_set;
eCAL::eh5::EntryInfoSet entry_info_set;
_reader->GetEntriesInfo(channel_name, entry_info_set);

for (const auto& entry_info : entry_info_set)
Expand Down
10 changes: 5 additions & 5 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,10 +53,10 @@ class MeasurementImporter
private:
bool isEcalMeasFile(const std::string& path);
bool isProtoChannel(const std::string& channel_type);
std::unique_ptr<eCAL::measurement::base::Reader> _reader;
eCALMeasCutterUtils::ChannelData _current_opened_channel_data;
std::string _loaded_path;
eCALMeasCutterUtils::ChannelNameSet _channel_names;
std::unique_ptr<eCAL::eh5::HDF5Meas> _reader;
eCALMeasCutterUtils::ChannelData _current_opened_channel_data;
std::string _loaded_path;
eCALMeasCutterUtils::ChannelNameSet _channel_names;
};

class ImporterException : public std::exception
Expand Down
2 changes: 1 addition & 1 deletion app/meas_cutter/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,6 @@ namespace eCALMeasCutterUtils
{
ChannelInfo _channel_info;
TimestampSet _timestamps;
std::unordered_map<Timestamp, eCAL::measurement::base::EntryInfo> _timestamp_entry_info_map;
std::unordered_map<Timestamp, eCAL::eh5::SEntryInfo> _timestamp_entry_info_map;
};
}
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 "ecalhdf5/eh5_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::eh5::Reader>());
std::shared_ptr<eCAL::eh5::HDF5Meas> 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::eh5::HDF5Meas>(nullptr));
measurement_path_ = "";
clearScenariosPath();
channel_mapping_path_ = "";
Expand Down
9 changes: 4 additions & 5 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 <ecalhdf5/eh5_meas.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::eh5::HDF5Meas> 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 All @@ -49,7 +48,7 @@ void MeasurementContainer::CreateFrameTable()
auto channel_names = hdf5_meas_->GetChannelNames();
for (auto& channel_name : channel_names)
{
eCAL::measurement::base::EntryInfoSet entry_info_set;
eCAL::eh5::EntryInfoSet entry_info_set;
if (hdf5_meas_->GetEntriesInfo(channel_name, entry_info_set))
{
for (auto& entry_info : entry_info_set)
Expand Down Expand Up @@ -84,7 +83,7 @@ void MeasurementContainer::CalculateEstimatedSizeForChannels()
auto channel_names = hdf5_meas_->GetChannelNames();
for (auto& channel_name : channel_names)
{
eCAL::measurement::base::EntryInfoSet entry_info_set;
eCAL::eh5::EntryInfoSet entry_info_set;
if (hdf5_meas_->GetEntriesInfo(channel_name, entry_info_set))
{
auto size = entry_info_set.size();
Expand Down Expand Up @@ -452,7 +451,7 @@ std::map<std::string, ContinuityReport> MeasurementContainer::CreateContinuityRe
auto channel_names = hdf5_meas_->GetChannelNames();
for (auto& channel_name : channel_names)
{
eCAL::measurement::base::EntryInfoSet entry_info_set;
eCAL::eh5::EntryInfoSet entry_info_set;
if (hdf5_meas_->GetEntriesInfo(channel_name, entry_info_set))
{

Expand Down
10 changes: 5 additions & 5 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::eh5::HDF5Meas> hdf5_meas, const std::string& meas_dir = "", bool use_receive_timestamp = true);
~MeasurementContainer();

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

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

std::vector<MeasurementFrame> frame_table_;
std::map<std::string, size_t> total_estimated_channel_size_map_;
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(std::shared_ptr<eCAL::eh5::HDF5Meas> 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 @@ -80,7 +80,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(std::shared_ptr<eCAL::eh5::HDF5Meas> measurement, const std::string& path = "");

/**
* @brief Returns whether a measurement has successfully been loaded
Expand Down
5 changes: 2 additions & 3 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 <ecalhdf5/eh5_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::eh5::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::eh5::eAccessType::CREATE))
{
#ifndef NDEBUG
EcalRecLogger::Instance()->debug("Hdf5WriterThread::Open(): Successfully opened HDF5-Writer with path \"" + hdf5_dir + "\"");
Expand Down
6 changes: 3 additions & 3 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 @@ -93,8 +93,8 @@ namespace eCAL
bool new_topic_info_map_available_; /**< Telling that a new topic info map has been set from the outside. */
mutable RecHdf5JobStatus last_status_;

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


std::atomic<bool> flushing_;
Expand Down
5 changes: 1 addition & 4 deletions contrib/ecalhdf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ set(ecalhdf5_header_base
include/ecal/measurement/omeasurement.h
include/ecalhdf5/eh5_defs.h
include/ecalhdf5/eh5_meas.h
include/ecalhdf5/eh5_reader.h
include/ecalhdf5/eh5_types.h
include/ecalhdf5/eh5_writer.h
include/ecalhdf5/eh5_types.h
)

ecal_add_library(${PROJECT_NAME} ${ecalhdf5_src} ${ecalhdf5_header_base})
Expand Down Expand Up @@ -87,7 +85,6 @@ target_link_libraries(${PROJECT_NAME}

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)

target_link_libraries(${PROJECT_NAME} PUBLIC eCAL::measurement_base)
if (${ECAL_LINK_HDF5_SHARED})
if (TARGET hdf5::hdf5-shared)
target_link_libraries(${PROJECT_NAME} PRIVATE
Expand Down
22 changes: 11 additions & 11 deletions contrib/ecalhdf5/include/ecal/measurement/imeasurement.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <utility>
#include <stdexcept>

#include <ecalhdf5/eh5_reader.h>
#include <ecalhdf5/eh5_meas.h>
#include <ecal/measurement/measurement.h>

namespace eCAL
Expand All @@ -35,14 +35,14 @@ namespace eCAL
class IBinaryChannel
{
public:
IBinaryChannel(std::shared_ptr<base::Reader> meas_, std::string name_)
IBinaryChannel(std::shared_ptr<eh5::HDF5Meas> meas_, std::string name_)
: channel_name(name_)
, meas(meas_)
{
meas->GetEntriesInfo(channel_name, entry_infos);
}

virtual BinaryFrame operator[](const base::EntryInfo& entry)
virtual BinaryFrame operator[](const eh5::SEntryInfo& entry)
{
size_t message_size;
meas->GetEntryDataSize(entry.ID, message_size);
Expand All @@ -64,7 +64,7 @@ namespace eCAL
, m_entry_iterator(owner_.entry_infos.begin())
{};

iterator(IBinaryChannel& owner_, const measurement::base::EntryInfoSet::iterator& it)
iterator(IBinaryChannel& owner_, const eh5::EntryInfoSet::iterator& it)
: m_owner(owner_)
, m_entry_iterator(it)
{};
Expand Down Expand Up @@ -96,7 +96,7 @@ namespace eCAL
bool operator!=(const iterator& rhs) const { return !(operator==(rhs)); };
private:
IBinaryChannel& m_owner;
measurement::base::EntryInfoSet::iterator m_entry_iterator;
eh5::EntryInfoSet::iterator m_entry_iterator;
mutable std::string m_msg;
};

Expand All @@ -115,8 +115,8 @@ namespace eCAL

private:
const std::string channel_name;
std::shared_ptr<base::Reader> meas;
mutable base::EntryInfoSet entry_infos;
std::shared_ptr<eh5::HDF5Meas> meas;
mutable eh5::EntryInfoSet entry_infos;
mutable std::string data;
};

Expand All @@ -125,7 +125,7 @@ namespace eCAL
class IChannel
{
public:
IChannel(std::shared_ptr<base::Reader> meas_, std::string name_)
IChannel(std::shared_ptr<eh5::HDF5Meas> meas_, std::string name_)
: binary_channel(meas_, name_)
{
}
Expand All @@ -134,7 +134,7 @@ namespace eCAL
bool operator!=(const IChannel& rhs) const { return !(operator==(rhs)); }

//virtual Entry<T> operator[](unsigned long long timestamp);
virtual Frame<T> operator[](const base::EntryInfo& entry)
virtual Frame<T> operator[](const eh5::SEntryInfo& entry)
{
auto binary_entry = binary_channel[entry];
eCAL::message::Deserialize(binary_entry.message, message);
Expand Down Expand Up @@ -225,11 +225,11 @@ namespace eCAL
IChannel<T> Get(const std::string& channel) const;

private:
std::shared_ptr<base::Reader> meas;
std::shared_ptr<eh5::HDF5Meas> meas;
};

inline IMeasurement::IMeasurement(const std::string& path)
: meas{ std::make_shared<eh5::Reader>(path) }
: meas{ std::make_shared<eh5::HDF5Meas>(path, eh5::RDONLY) }
{
}

Expand Down
Loading