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

[measurement] HDF5 v6 - Store channel ID in measurement #1375

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions app/meas_cutter/src/measurement_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ void MeasurementExporter::setData(eCALMeasCutterUtils::Timestamp timestamp, cons
const auto sender_timestamp = (iter != meta_data.end()) ? iter->second.sender_timestamp : static_cast<eCALMeasCutterUtils::Timestamp>(0);

iter = meta_data.find(eCALMeasCutterUtils::MetaDatumKey::SENDER_ID);
const auto sender_id = (iter != meta_data.end()) ? iter->second.sender_id : static_cast<uint64_t>(0);
const auto sender_id = (iter != meta_data.end()) ? iter->second.sender_id : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

  const auto sender_id = (iter != meta_data.end()) ? iter->second.sender_id : 0;
                                                                  ^


iter = meta_data.find(eCALMeasCutterUtils::MetaDatumKey::SENDER_CLOCK);
const auto sender_clock = (iter != meta_data.end()) ? iter->second.sender_clock : static_cast<uint64_t>(0);
const auto sender_clock = (iter != meta_data.end()) ? iter->second.sender_clock : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

  const auto sender_clock = (iter != meta_data.end()) ? iter->second.sender_clock : 0;
                                                                     ^


if (!_writer->AddEntryToFile(payload.data(), payload.size(), sender_timestamp, timestamp, _current_channel_name, sender_id, sender_clock))
if (!_writer->AddEntryToFile(payload.data(), payload.size(), sender_timestamp, timestamp, eCAL::experimental::measurement::base::Channel{ _current_channel_name, sender_id }, sender_clock))
{
throw ExporterException("Unable to export protobuf message.");
}
Expand Down
6 changes: 3 additions & 3 deletions app/meas_cutter/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ namespace eCALMeasCutterUtils
{
Timestamp receiver_timestamp;
Timestamp sender_timestamp;
uint64_t sender_id;
uint64_t sender_clock;
int64_t sender_id;
int64_t sender_clock;

std::array<char,64> __union_size;
std::array<char,64> __union_size;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: declaration uses identifier '__union_size', which is a reserved identifier [bugprone-reserved-identifier]

Suggested change
std::array<char,64> __union_size;
std::array<char,64> _union_size;

};

typedef std::unordered_map<MetaDatumKey, MetaDatumValue, MetaDatumHash> MetaData;
Expand Down
3 changes: 1 addition & 2 deletions app/rec/rec_client_core/src/job/hdf5_writer_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ namespace eCAL
frame->data_.size(),
std::chrono::duration_cast<std::chrono::microseconds>(frame->ecal_publish_time_.time_since_epoch()).count(),
std::chrono::duration_cast<std::chrono::microseconds>(frame->ecal_receive_time_.time_since_epoch()).count(),
frame->topic_name_,
frame->id_,
eCAL::experimental::measurement::base::Channel{ frame->topic_name_, frame->id_ },
frame->clock_
))
{
Expand Down
6 changes: 6 additions & 0 deletions contrib/ecalhdf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ set(ecalhdf5_src
src/eh5_meas_file_v4.h
src/eh5_meas_file_v5.cpp
src/eh5_meas_file_v5.h
src/eh5_meas_file_v6.cpp
src/eh5_meas_file_v6.h
src/eh5_meas_file_writer_v5.cpp
src/eh5_meas_file_writer_v5.h
src/eh5_meas_file_writer_v6.cpp
src/eh5_meas_file_writer_v6.h
src/eh5_meas_impl.h
src/hdf5_helper.h
src/hdf5_helper.cpp
src/escape.cpp
src/escape.h
)
Expand Down
106 changes: 100 additions & 6 deletions contrib/ecalhdf5/include/ecalhdf5/eh5_meas.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@

#pragma once

#include <cstdint>
#include <functional>
#include <set>
#include <string>
#include <memory>

#include "eh5_types.h"

#if defined(ECAL_EH5_NO_DEPRECATION_WARNINGS)
#define ECAL_EH5_DEPRECATE(__message__) //!< Don't print deprecation warnigns
#else
#define ECAL_EH5_DEPRECATE(__message__) [[deprecated(__message__)]] //!< Deprecate the following function
#endif

namespace eCAL
{
namespace eh5
Expand Down Expand Up @@ -171,6 +178,21 @@ namespace eCAL
**/
std::set<std::string> GetChannelNames() const;

/**
* @brief Get the available channel names of the current opened file / measurement
*
* @return Channels (channel name & id)
**/
std::set<SChannel> GetChannels() const;

/**
* @brief Get the available channel names of the current opened file / measurement
*
* @param channel_name name of the channel
* @return channel names & ids
**/
std::set<SChannel> GetChannels(const std::string & channel_name) const;

/**
* @brief Check if channel exists in measurement
*
Expand All @@ -180,14 +202,23 @@ namespace eCAL
**/
bool HasChannel(const std::string& channel_name) const;

/**
* @brief Check if channel exists in measurement
*
* @param channel channel name & id
*
* @return true if exists, false otherwise
**/
bool HasChannel(const eCAL::eh5::SChannel& channel) const;

/**
* @brief Get the channel description for the given channel
*
* @param channel_name channel name
*
* @return channel description
**/
[[deprecated("Please use GetChannelDataTypeInformation instead")]]
ECAL_EH5_DEPRECATE("Please use GetChannelDataTypeInformation instead")
std::string GetChannelDescription(const std::string& channel_name) const;

/**
Expand All @@ -196,7 +227,7 @@ namespace eCAL
* @param channel_name channel name
* @param description description of the channel
**/
[[deprecated("Please use SetChannelDataTypeInformation instead")]]
ECAL_EH5_DEPRECATE("Please use SetChannelDataTypeInformation instead")
void SetChannelDescription(const std::string& channel_name, const std::string& description);

/**
Expand All @@ -206,7 +237,7 @@ namespace eCAL
*
* @return channel type
**/
[[deprecated("Please use GetChannelDataTypeInformation instead")]]
ECAL_EH5_DEPRECATE("Please use GetChannelDataTypeInformation instead")
std::string GetChannelType(const std::string& channel_name) const;

/**
Expand All @@ -215,7 +246,7 @@ namespace eCAL
* @param channel_name channel name
* @param type type of the channel
**/
[[deprecated("Please use SetChannelDataTypeInformation instead")]]
ECAL_EH5_DEPRECATE("Please use SetChannelDataTypeInformation instead")
void SetChannelType(const std::string& channel_name, const std::string& type);

/**
Expand All @@ -225,7 +256,7 @@ namespace eCAL
*
* @return channel type
**/
DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const;
DataTypeInformation GetChannelDataTypeInformation(const SChannel& channel) const;

/**
* @brief Set data type information of the given channel
Expand All @@ -235,7 +266,7 @@ namespace eCAL
*
* @return channel type
**/
void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info);
void SetChannelDataTypeInformation(const SChannel& channel, const DataTypeInformation& info);

/**
* @brief Gets minimum timestamp for specified channel
Expand All @@ -244,17 +275,37 @@ namespace eCAL
*
* @return minimum timestamp value
**/
ECAL_EH5_DEPRECATE("Please use the overload GetMinTimestamp(const SChannel&)")
long long GetMinTimestamp(const std::string& channel_name) const;

/**
* @brief Gets minimum timestamp for specified channel
*
* @param channel channel (name & id)
*
* @return minimum timestamp value
**/
long long GetMinTimestamp(const SChannel& channel) const;

/**
* @brief Gets maximum timestamp for specified channel
*
* @param channel_name channel name
*
* @return maximum timestamp value
**/
ECAL_EH5_DEPRECATE("Please use the overload GetMaxTimestamp(const SChannel&)")
long long GetMaxTimestamp(const std::string& channel_name) const;

/**
* @brief Gets maximum timestamp for specified channel
*
* @param channel channel (name & id)
*
* @return maximum timestamp value
**/
long long GetMaxTimestamp(const SChannel& channel) const;

/**
* @brief Gets the header info for all data entries for the given channel
* Header = timestamp + entry id
Expand All @@ -264,7 +315,20 @@ namespace eCAL
*
* @return true if succeeds, false if it fails
**/
ECAL_EH5_DEPRECATE("Please use the overload GetEntriesInfo(const SChannel&, EntryInfoSet&)")
bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const;

/**
* @brief Gets the header info for all data entries for the given channel
* Header = timestamp + entry id
*
* @param [in] channel channel (name & id)
* @param [out] entries header info for all data entries
*
* @return true if succeeds, false if it fails
**/
bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const;


/**
* @brief Gets the header info for data entries for the given channel included in given time range (begin->end)
Expand All @@ -277,8 +341,22 @@ namespace eCAL
*
* @return true if succeeds, false if it fails
**/
ECAL_EH5_DEPRECATE("Please use the overload GetEntriesInfoRange(const SChannel&, long long, long long, EntryInfoSet&)")
bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const;

/**
* @brief Gets the header info for data entries for the given channel included in given time range (begin->end)
* Header = timestamp + entry id
*
* @param [in] channel channel (name & id)
* @param [in] begin time range begin timestamp
* @param [in] end time range end timestamp
* @param [out] entries header info for data entries in given range
*
* @return true if succeeds, false if it fails
**/
bool GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const;

/**
* @brief Gets data size of a specific entry
*
Expand Down Expand Up @@ -319,8 +397,24 @@ namespace eCAL
*
* @return true if succeeds, false if it fails
**/
ECAL_EH5_DEPRECATE("Please use the overload AddEntryToFile(const void*, const unsigned long long&, const long long, const long long&, const SChannel&, long long)")
bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock);

/**
* @brief Add entry to file
*
* @param data data to be added
* @param size size of the data
* @param snd_timestamp send time stamp
* @param rcv_timestamp receive time stamp
* @param channel channel channel (name & id)
* @param id message id
* @param clock message clock
*
* @return true if succeeds, false if it fails
**/
bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const SChannel& channel, long long clock);

/**
* @brief Callback function type for pre file split notification
**/
Expand Down
15 changes: 12 additions & 3 deletions contrib/ecalhdf5/include/ecalhdf5/eh5_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,26 @@ namespace eCAL
const std::string kChnNameAttribTitle ("Channel Name");
const std::string kChnDescAttrTitle ("Channel Description");
const std::string kChnTypeAttrTitle ("Channel Type");
const std::string kChnIdTypename ("TypeName");
const std::string kChnIdEncoding ("TypeEncoding");
const std::string kChnIdDescriptor ("TypeDescriptor");
const std::string kChnIdData ("DataTable");
const std::string kFileVerAttrTitle ("Version");
const std::string kTimestampAttrTitle ("Timestamps");
const std::string kChnAttrTitle ("Channels");

// Remove @eCAL6 -> backwards compatibility with old interface!
using SChannel = eCAL::experimental::measurement::base::Channel;
using SEntryInfo = eCAL::experimental::measurement::base::EntryInfo;
using EntryInfoSet = eCAL::experimental::measurement::base::EntryInfoSet;
using EntryInfoVect = eCAL::experimental::measurement::base::EntryInfoVect;
using eAccessType = eCAL::experimental::measurement::base::AccessType;
using eCAL::experimental::measurement::base::RDONLY;
using eCAL::experimental::measurement::base::CREATE;

enum eAccessType
{
RDONLY, //!< ReadOnly - the measurement can only be read
CREATE, //!< Create - a new measurement will be created
CREATE_V5 //!< Create a legacy V5 hdf5 measurement (For testing purpose only!)
};

using eCAL::experimental::measurement::base::DataTypeInformation;
//!< @endcond
Expand Down
Loading
Loading