Skip to content

Commit

Permalink
New recorder output file settings: timestamp-format and local-timesta…
Browse files Browse the repository at this point in the history
…mp (#81)

* New recorder output file settings: timestamp-format and local-timestamp

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Update documentation

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Apply suggestions

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

---------

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
  • Loading branch information
juanlofer-eprosima authored Sep 13, 2023
1 parent 912206c commit 9e1ac1e
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 17 deletions.
4 changes: 3 additions & 1 deletion ddsrecorder/src/cpp/tool/DdsRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ DdsRecorder::DdsRecorder(
std::string mcap_filename;
if (file_name == "")
{
mcap_filename = configuration.recorder_output_file + "_" + timestamp_to_string(now()) + ".mcap";
mcap_filename = configuration.output_filepath + "/" + timestamp_to_string(
now(), configuration.output_timestamp_format,
configuration.output_local_timestamp) + "_" + configuration.output_filename + ".mcap";
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ class DDSRECORDER_YAML_DllAPI RecorderConfiguration
std::set<utils::Heritable<ddspipe::core::types::IFilterTopic>> blocklist{};
std::set<utils::Heritable<ddspipe::core::types::DistributedTopic>> builtin_topics{};

// Output file params
std::string output_filepath = ".";
std::string output_filename = "output";
std::string output_timestamp_format = "%Y-%m-%d_%H-%M-%S_%Z";
bool output_local_timestamp = true;

// Recording params
std::string recorder_output_file = "./output";
unsigned int buffer_size = 100;
unsigned int event_window = 20;
bool log_publish_time = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ constexpr const char* RECORDER_RECORDER_TAG("recorder");

// Output related tags
constexpr const char* RECORDER_OUTPUT_TAG("output");
constexpr const char* RECORDER_PATH_FILE_TAG("path");
constexpr const char* RECORDER_FILE_NAME_TAG("filename");
constexpr const char* RECORDER_OUTPUT_PATH_FILE_TAG("path");
constexpr const char* RECORDER_OUTPUT_FILE_NAME_TAG("filename");
constexpr const char* RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG("timestamp-format");
constexpr const char* RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG("local-timestamp");

// Advanced recorder configuration options
constexpr const char* RECORDER_BUFFER_SIZE_TAG("buffer-size");
Expand Down
28 changes: 18 additions & 10 deletions ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,34 @@ void RecorderConfiguration::load_recorder_configuration_(
{
auto output_yml = YamlReader::get_value_in_tag(yml, RECORDER_OUTPUT_TAG);

// Default path and output values ("./output")
std::string path = ".";
std::string filename = "output";

/////
// Get optional file path
if (YamlReader::is_tag_present(output_yml, RECORDER_PATH_FILE_TAG))
if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_PATH_FILE_TAG))
{
path = YamlReader::get<std::string>(output_yml, RECORDER_PATH_FILE_TAG, version);
output_filepath = YamlReader::get<std::string>(output_yml, RECORDER_OUTPUT_PATH_FILE_TAG, version);
}

/////
// Get optional file name
if (YamlReader::is_tag_present(output_yml, RECORDER_FILE_NAME_TAG))
if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_FILE_NAME_TAG))
{
output_filename = YamlReader::get<std::string>(output_yml, RECORDER_OUTPUT_FILE_NAME_TAG, version);
}

/////
// Get optional timestamp format
if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG))
{
filename = YamlReader::get<std::string>(output_yml, RECORDER_FILE_NAME_TAG, version);
output_timestamp_format = YamlReader::get<std::string>(output_yml, RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG,
version);
}

// Generate complete output file name
recorder_output_file = path + "/" + filename;
/////
// Get optional timestamp format
if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG))
{
output_local_timestamp = YamlReader::get<bool>(output_yml, RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG, version);
}
}

/////
Expand Down
1 change: 1 addition & 0 deletions docs/rst/notes/forthcoming_version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Next release will include the following **DDS Recorder tool configuration featur

* Support :ref:`Compression Settings <recorder_usage_configuration_compression>`.
* Allow disabling the storage of received types (see :ref:`Record Types <recorder_usage_configuration_recordtypes>`).
* New configuration options (``timestamp-format`` and ``local-timestamp``) available for :ref:`output file <recorder_usage_configuration_outputfile>` settings.
23 changes: 20 additions & 3 deletions docs/rst/recording/usage/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,12 @@ Recorder Configuration

Configuration of data writing in the database.

.. _recorder_usage_configuration_outputfile:

Output File
^^^^^^^^^^^

The recorder output file does support the following configurations:
The recorder output file does support the following configuration settings under the ``output`` tag:

.. list-table::
:header-rows: 1
Expand All @@ -325,9 +326,23 @@ The recorder output file does support the following configurations:
- ``string``
- ``output``

When DDS Recorder application is launched (or when remotely controlled, every time a ``start`` command is received), a temporary file with ``filename`` name and ``.mcap.tmp~`` extension is created in ``path``.
* - Timestamp format
- ``timestamp-format``
- Configure the format of the output file |br|
timestamp (as in ``std::put_time``).
- ``string``
- ``%Y-%m-%d_%H-%M-%S_%Z``

* - Local timestamp
- ``local-timestamp``
- Whether to use a local or global (GMT) |br|
timestamp.
- ``boolean``
- ``true``

When DDS Recorder application is launched (or when remotely controlled, every time a ``start`` command is received), a temporary file with ``filename`` name (+timestamp prefix) and ``.mcap.tmp~`` extension is created in ``path``.
This file is not readable until the application is terminated (or a ``stop`` / ``close`` command is received).
On such event, the temporal file is renamed to ``filename`` with ``.mcap`` extension in the same location, and is then ready to be processed.
On such event, the temporal file is renamed to have ``.mcap`` extension in the same location, and is then ready to be processed.

Buffer size
^^^^^^^^^^^
Expand Down Expand Up @@ -591,6 +606,8 @@ A complete example of all the configurations described on this page can be found
output:
filename: "output"
path: "."
timestamp-format: "%Y-%m-%d_%H-%M-%S_%Z"
local-timestamp: false
buffer-size: 50
event-window: 60
Expand Down
2 changes: 2 additions & 0 deletions resources/configurations/recorder/complete_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ recorder:
output:
filename: "output"
path: "."
timestamp-format: "%Y-%m-%d_%H-%M-%S_%Z"
local-timestamp: false

buffer-size: 50
event-window: 60
Expand Down

0 comments on commit 9e1ac1e

Please sign in to comment.