Class HDF5Meas

Class Documentation

class HDF5Meas

eCAL HDF5 measurement API

Public Types

typedef std::function<void(void)> CallbackFunction

Callback function type for pre file split notification.

Public Functions

HDF5Meas()

Constructor.

explicit HDF5Meas(const std::string &path, eAccessType access = eAccessType::RDONLY)

Constructor.

Parameters
  • path – Input file path / measurement directory path (see meas directory structure description bellow, in Open method).

  • access – Access type

~HDF5Meas()

Destructor.

HDF5Meas(const HDF5Meas &other) = delete

Copy operator.

HDF5Meas &operator=(const HDF5Meas &other) = delete
HDF5Meas(HDF5Meas&&) = default

Move operator.

HDF5Meas &operator=(HDF5Meas&&) = default
bool Open(const std::string &path, eAccessType access = eAccessType::RDONLY)

Open file.

Parameters
  • path – Input file path / measurement directory path.

                Default measurement directory structure:
                 - root directory e.g.: M:\measurement_directory\measurement01
                 - documents directory:                                |_doc
                 - hosts directories:                                  |_Host1 (e.g.: CARPC01)
                                                                       |_Host2 (e.g.: CARPC02)
    
                File path as input (eAccessType::RDONLY):
                 - root directory (e.g.: M:\measurement_directory\measurement01) in this case all hosts subdirectories will be iterated,
                 - host directory (e.g.: M:\measurement_directory\measurement01\CARPC01),
                 - file path, path to file from measurement (e.g.: M:\measurement_directory\measurement01\CARPC01\meas01_05.hdf5).
    
                File path as output (eAccessType::CREATE):
                 - full path to  measurement directory (recommended with host name) (e.g.: M:\measurement_directory\measurement01\CARPC01),
                 - to set the name of the actual hdf5 file use SetFileBaseName method.
    

  • access – Access type

Returns

true if output (eAccessType::CREATE) measurement directory structure can be accessed/created, false otherwise. true if input (eAccessType::RDONLY) measurement/file path was opened, false otherwise.

bool Close()

Close file.

Returns

true if succeeds, false if it fails

bool IsOk() const

Checks if file/measurement is ok.

Returns

true if meas can be opened(read) or location is accessible(write), false otherwise

std::string GetFileVersion() const

Get the File Type Version of the current opened file.

Returns

file version

size_t GetMaxSizePerFile() const

Gets maximum allowed size for an individual file.

Returns

maximum size in MB

void SetMaxSizePerFile(size_t size)

Sets maximum allowed size for an individual file.

Parameters

size – maximum size in MB

std::set<std::string> GetChannelNames() const

Get the available channel names of the current opened file / measurement.

Returns

channel names

bool HasChannel(const std::string &channel_name) const

Check if channel exists in measurement.

Parameters

channel_name – name of the channel

Returns

true if exists, false otherwise

std::string GetChannelDescription(const std::string &channel_name) const

Get the channel description for the given channel.

Parameters

channel_name – channel name

Returns

channel description

void SetChannelDescription(const std::string &channel_name, const std::string &description)

Set description of the given channel.

Parameters
  • channel_name – channel name

  • description – description of the channel

std::string GetChannelType(const std::string &channel_name) const

Gets the channel type of the given channel.

Parameters

channel_name – channel name

Returns

channel type

void SetChannelType(const std::string &channel_name, const std::string &type)

Set type of the given channel.

Parameters
  • channel_name – channel name

  • type – type of the channel

long long GetMinTimestamp(const std::string &channel_name) const

Gets minimum timestamp for specified channel.

Parameters

channel_name – channel name

Returns

minimum timestamp value

long long GetMaxTimestamp(const std::string &channel_name) const

Gets maximum timestamp for specified channel.

Parameters

channel_name – channel name

Returns

maximum timestamp value

bool GetEntriesInfo(const std::string &channel_name, EntryInfoSet &entries) const

Gets the header info for all data entries for the given channel Header = timestamp + entry id.

Parameters
  • channel_name[in] channel name

  • entries[out] header info for all data entries

Returns

true if succeeds, false if it fails

bool GetEntriesInfoRange(const std::string &channel_name, long long begin, long long end, EntryInfoSet &entries) const

Gets the header info for data entries for the given channel included in given time range (begin->end) Header = timestamp + entry id.

Parameters
  • channel_name[in] channel name

  • begin[in] time range begin timestamp

  • end[in] time range end timestamp

  • entries[out] header info for data entries in given range

Returns

true if succeeds, false if it fails

bool GetEntryDataSize(long long entry_id, size_t &size) const

Gets data size of a specific entry.

Parameters
  • entry_id[in] Entry ID

  • size[out] Entry data size

Returns

true if succeeds, false if it fails

bool GetEntryData(long long entry_id, void *data) const

Gets data from a specific entry.

Parameters
  • entry_id[in] Entry ID

  • data[out] Entry data

Returns

true if succeeds, false if it fails

void SetFileBaseName(const std::string &base_name)

Set measurement file base name (desired name for the actual hdf5 files that will be created)

Parameters

base_name – Name of the hdf5 files that will be created.

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)

Add entry to file.

Parameters
  • data – data to be added

  • size – size of the data

  • snd_timestamp – send time stamp

  • rcv_timestamp – receive time stamp

  • channel_name – channel name

  • id – message id

  • clock – message clock

Returns

true if succeeds, false if it fails

void ConnectPreSplitCallback(CallbackFunction cb)

Connect callback for pre file split notification.

Parameters

cb – callback function

void DisconnectPreSplitCallback()

Disconnect pre file split callback.