Skip to content
Snippets Groups Projects
Commit a60822c1 authored by Ed Maros's avatar Ed Maros
Browse files

Restored reading list of channels from file for createRDS command

parent cd41ee27
No related branches found
No related tags found
1 merge request!180Re-enabled channel names to come from text file for createRDS command
# Release 3.0.1 - July 21, 2023
- Restored reading list of channels from file for createRDS command
# Release 3.0.0 - July 7, 2023
- Modified channel query syntax to accept renaming (closes #170)
- Modified createRDS to handle analysis ready reduction (closes #167)
......
......@@ -157,6 +157,9 @@ rm -rf %{buildroot}
%changelog
# date +'%a %b %d %Y'
* Fri Jul 21 2023 Edward Maros <ed.maros@ligo.org> - 3.0.1-1
- Built for new release as described in ChangeLog.md
* Fri Jul 07 2023 Edward Maros <ed.maros@ligo.org> - 3.0.0-1
- Built for new release as described in ChangeLog.md
......
ldas-tools-frameapi (3.0.1-1) unstable; urgency=low
* Built for new release as described in ChangeLog.md
-- Edward Maros <ed.maros@ligo.org> Fri, 21 Jul 2023 20:29:16 -0700
ldas-tools-frameapi (3.0.0-1) unstable; urgency=low
* Built for new release as described in ChangeLog.md
......
......@@ -58,10 +58,12 @@
# 8:0:0 - ldas-tools-frameAPI-3.0.0
# * Added structure to allow for channel name renaming for createRDS methods
# * Heavily modified rdsreduce code to handle analysis ready reduction
# 8:1:0 - ldas-tools-frameAPI-3.0.1
# * Restored reading of channel names from a file.
#------------------------------------------------------------------------
set( libldasframe_la_CURRENT 8 )
set( libldasframe_la_REVISION 0 )
set( libldasframe_la_REVISION 1 )
set( libldasframe_la_AGE 0 )
set(HH_DIR frameAPI)
......
......@@ -28,6 +28,7 @@
//
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include "genericAPI/Logging.hh"
......@@ -64,17 +65,49 @@ namespace FrameAPI
{
static const char* caller =
"FrameAPI::channel_container_::ParseChannelName";
std::list< std::string > channel_names;
RDSFrame::channel_name_type::ParseChannelName(
ChannelNameString, names, resampling );
QUEUE_LOG_MESSAGE( "name: " << names.back( ).old_channel_name
<< " sampleRate: " << resampling.back( )
<< " rename: "
<< names.back( ).new_channel_name,
MT_DEBUG,
30,
caller,
"CMD_CREATE_RDS" );
if ( boost::filesystem::exists( ChannelNameString ) )
{
//-----------------------------------------------------------
// Read channel name descriptors from a filesystem
//
// channel_name_descriptor =>
// <old_channel_name> = <new_channel_name>
// | <old_channel_name>
// <old_channel_name> => <channel_name> ! <resample_factor>
// | <chanel_name>
// <new_channel_name> => <channel_name>
// <resample_factor => 1 | 2 | 4 | 8 | 16
//-----------------------------------------------------------
boost::filesystem::ifstream channel_name_stream(
ChannelNameString );
std::string channel_name_descriptor;
while (
std::getline( channel_name_stream, channel_name_descriptor ) )
{
channel_names.push_back( channel_name_descriptor );
}
}
else
{
channel_names.push_back( ChannelNameString );
}
for ( auto channel_name : channel_names )
{
RDSFrame::channel_name_type::ParseChannelName(
channel_name, names, resampling );
QUEUE_LOG_MESSAGE( "name: " << names.back( ).old_channel_name
<< " sampleRate: " << resampling.back( )
<< " rename: "
<< names.back( ).new_channel_name,
MT_DEBUG,
30,
caller,
"CMD_CREATE_RDS" );
}
}
void
......
......@@ -34,6 +34,8 @@
#define BOOST_TEST_MAIN
#include <boost/test/included/unit_test.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/filesystem.hpp>
#include <boost/range/counting_range.hpp>
struct rds_global_fixture
{
......@@ -69,6 +71,80 @@ struct rds_global_fixture
}
};
namespace testing
{
struct channel_name
{
std::string original_channel_name;
int resampling;
std::string renamed_channel_name;
};
void
construct_channel_file(
boost::filesystem::path& Filename,
std::vector< std::string > const& ChannelDescriptors )
{
boost::filesystem::ofstream channel_stream{ Filename };
for ( auto channel_descriptor : ChannelDescriptors )
{
channel_stream << channel_descriptor << std::endl;
}
channel_stream.close( );
}
void
validate( FrameAPI::channel_container_type const& GeneratedChannels,
std::vector< testing::channel_name > const& ExpectedChannels )
{
auto const size_expected = ExpectedChannels.size( );
BOOST_CHECK_MESSAGE( GeneratedChannels.names.size( ) == size_expected,
"GeneratedChannels.names.size( ) is '"
<< GeneratedChannels.names.size( )
<< "' instead of '" << size_expected << "'" );
BOOST_CHECK_MESSAGE( GeneratedChannels.resampling.size( ) ==
size_expected,
"GeneratedChannels.resampling.size( ) is '"
<< GeneratedChannels.resampling.size( )
<< "' instead of '" << size_expected << "'" );
if ( ( GeneratedChannels.names.size( ) != size_expected ) ||
( GeneratedChannels.resampling.size( ) != size_expected ) )
{
return;
}
for ( auto channel_index :
boost::counting_range( size_t( 0 ), size_t( size_expected ) ) )
{
BOOST_CHECK_MESSAGE(
GeneratedChannels.names[ channel_index ].old_channel_name ==
ExpectedChannels[ channel_index ].original_channel_name,
"GeneratedChannels.names[ "
<< channel_index << " ].old_channel_name is '"
<< GeneratedChannels.names[ channel_index ].old_channel_name
<< "' instead of '"
<< ExpectedChannels[ channel_index ].original_channel_name
<< "'" );
BOOST_CHECK_MESSAGE(
GeneratedChannels.names[ channel_index ].new_channel_name ==
ExpectedChannels[ channel_index ].renamed_channel_name,
"GeneratedChannels.names[ "
<< channel_index << " ].new_channel_name is '"
<< GeneratedChannels.names[ channel_index ].new_channel_name
<< "' instead of '"
<< ExpectedChannels[ channel_index ].renamed_channel_name
<< "'" );
BOOST_CHECK_MESSAGE(
GeneratedChannels.resampling[ channel_index ] ==
ExpectedChannels[ channel_index ].resampling,
"GeneratedChannels.resampling[ "
<< channel_index << " ] is '"
<< GeneratedChannels.resampling[ channel_index ]
<< "' instead of '"
<< ExpectedChannels[ channel_index ].resampling << "'" );
}
}
} // namespace testing
BOOST_GLOBAL_FIXTURE( rds_global_fixture );
BOOST_AUTO_TEST_CASE( channel_simple )
......@@ -94,15 +170,16 @@ BOOST_AUTO_TEST_CASE( channel_simple )
if ( ( channels.names.size( ) == 1 ) &&
( channels.resampling.size( ) == 1 ) )
{
BOOST_CHECK_MESSAGE( channels.names.front( ).old_channel_name == name_expected,
BOOST_CHECK_MESSAGE( channels.names.front( ).old_channel_name ==
name_expected,
"channels.names.front( ).old_channel_name is '"
<< channels.names.front( ).old_channel_name << "' instead of '"
<< name_expected << "'" );
BOOST_CHECK_MESSAGE( channels.names.front( ).new_channel_name == rename_expected,
"channels.names.front( ).new_channel_name is '"
<< channels.names.front( ).new_channel_name
<< "' instead of '" << rename_expected
<< "'" );
<< channels.names.front( ).old_channel_name
<< "' instead of '" << name_expected << "'" );
BOOST_CHECK_MESSAGE(
channels.names.front( ).new_channel_name == rename_expected,
"channels.names.front( ).new_channel_name is '"
<< channels.names.front( ).new_channel_name << "' instead of '"
<< rename_expected << "'" );
BOOST_CHECK_MESSAGE( channels.resampling.front( ) == resample_expected,
"channels.resampling.front( ) is '"
<< channels.resampling.front( )
......@@ -114,7 +191,8 @@ BOOST_AUTO_TEST_CASE( channel_simple )
BOOST_AUTO_TEST_CASE( channel_resample )
{
static const int size_expected = 1;
static const std::string test_channel_string( "H1:channel1!4" // channel name
static const std::string test_channel_string(
"H1:channel1!4" // channel name
);
static const std::string name_expected( "H1:channel1" );
static const int resample_expected = 4;
......@@ -134,15 +212,16 @@ BOOST_AUTO_TEST_CASE( channel_resample )
if ( ( channels.names.size( ) == 1 ) &&
( channels.resampling.size( ) == 1 ) )
{
BOOST_CHECK_MESSAGE( channels.names.front( ).old_channel_name == name_expected,
BOOST_CHECK_MESSAGE( channels.names.front( ).old_channel_name ==
name_expected,
"channels.names.front( ).old_channel_name is '"
<< channels.names.front( ).old_channel_name << "' instead of '"
<< name_expected << "'" );
BOOST_CHECK_MESSAGE( channels.names.front( ).new_channel_name == rename_expected,
"channels.names.front( ).new_channel_name is '"
<< channels.names.front( ).new_channel_name
<< "' instead of '" << rename_expected
<< "'" );
<< channels.names.front( ).old_channel_name
<< "' instead of '" << name_expected << "'" );
BOOST_CHECK_MESSAGE(
channels.names.front( ).new_channel_name == rename_expected,
"channels.names.front( ).new_channel_name is '"
<< channels.names.front( ).new_channel_name << "' instead of '"
<< rename_expected << "'" );
BOOST_CHECK_MESSAGE( channels.resampling.front( ) == resample_expected,
"channels.resampling.front( ) is '"
<< channels.resampling.front( )
......@@ -154,7 +233,8 @@ BOOST_AUTO_TEST_CASE( channel_resample )
BOOST_AUTO_TEST_CASE( channel_rename )
{
static const int size_expected = 1;
static const std::string test_channel_string( "H1:channel1=H1:channel1_AR" // channel name
static const std::string test_channel_string(
"H1:channel1=H1:channel1_AR" // channel name
);
static const std::string name_expected( "H1:channel1" );
static const int resample_expected = 1;
......@@ -174,15 +254,16 @@ BOOST_AUTO_TEST_CASE( channel_rename )
if ( ( channels.names.size( ) == 1 ) &&
( channels.resampling.size( ) == 1 ) )
{
BOOST_CHECK_MESSAGE( channels.names.front( ).old_channel_name == name_expected,
BOOST_CHECK_MESSAGE( channels.names.front( ).old_channel_name ==
name_expected,
"channels.names.front( ).old_channel_name is '"
<< channels.names.front( ).old_channel_name << "' instead of '"
<< name_expected << "'" );
BOOST_CHECK_MESSAGE( channels.names.front( ).new_channel_name == rename_expected,
"channels.names.front( ).new_channel_name is '"
<< channels.names.front( ).new_channel_name
<< "' instead of '" << rename_expected
<< "'" );
<< channels.names.front( ).old_channel_name
<< "' instead of '" << name_expected << "'" );
BOOST_CHECK_MESSAGE(
channels.names.front( ).new_channel_name == rename_expected,
"channels.names.front( ).new_channel_name is '"
<< channels.names.front( ).new_channel_name << "' instead of '"
<< rename_expected << "'" );
BOOST_CHECK_MESSAGE( channels.resampling.front( ) == resample_expected,
"channels.resampling.front( ) is '"
<< channels.resampling.front( )
......@@ -194,7 +275,8 @@ BOOST_AUTO_TEST_CASE( channel_rename )
BOOST_AUTO_TEST_CASE( channel_resample_and_rename )
{
static const int size_expected = 1;
static const std::string test_channel_string( "H1:channel1!4=H1:channel1_AR" // channel name
static const std::string test_channel_string(
"H1:channel1!4=H1:channel1_AR" // channel name
);
static const std::string name_expected( "H1:channel1" );
static const int resample_expected = 4;
......@@ -214,19 +296,76 @@ BOOST_AUTO_TEST_CASE( channel_resample_and_rename )
if ( ( channels.names.size( ) == 1 ) &&
( channels.resampling.size( ) == 1 ) )
{
BOOST_CHECK_MESSAGE( channels.names.front( ).old_channel_name == name_expected,
BOOST_CHECK_MESSAGE( channels.names.front( ).old_channel_name ==
name_expected,
"channels.names.front( ).old_channel_name is '"
<< channels.names.front( ).old_channel_name << "' instead of '"
<< name_expected << "'" );
BOOST_CHECK_MESSAGE( channels.names.front( ).new_channel_name == rename_expected,
"channels.names.front( ).new_channel_name is '"
<< channels.names.front( ).new_channel_name
<< "' instead of '" << rename_expected
<< "'" );
<< channels.names.front( ).old_channel_name
<< "' instead of '" << name_expected << "'" );
BOOST_CHECK_MESSAGE(
channels.names.front( ).new_channel_name == rename_expected,
"channels.names.front( ).new_channel_name is '"
<< channels.names.front( ).new_channel_name << "' instead of '"
<< rename_expected << "'" );
BOOST_CHECK_MESSAGE( channels.resampling.front( ) == resample_expected,
"channels.resampling.front( ) is '"
<< channels.resampling.front( )
<< "' instead of '" << resample_expected
<< "'" );
<< channels.resampling.front( )
<< "' instead of '" << resample_expected
<< "'" );
}
}
BOOST_AUTO_TEST_CASE( channel_filename )
{
static const std::vector< std::string > test_channel_strings = {
"H1:channel1!4=H1:channel1_AR", //
"H1:channel2=H1:channel2_AR", //
"H1:channel3" //
};
static const std::vector< testing::channel_name > expected_channels = {
{ "H1:channel1", 4, "H1:channel1_AR" },
{ "H1:channel2", 1, "H1:channel2_AR" },
{ "H1:channel3", 1, "H1:channel3" }
};
boost::filesystem::path channel_text_file(
boost::filesystem::current_path( ) );
channel_text_file /= "channel_filename_channels.txt";
testing::construct_channel_file( channel_text_file, test_channel_strings );
FrameAPI::channel_container_type channels;
channels.ParseChannelName( channel_text_file.string( ) );
validate( channels, expected_channels );
}
BOOST_AUTO_TEST_CASE( channel_from_filename_and_inline )
{
static std::string const channel_descriptor{
"H1:MyChannel=H1:MyChannel_AR"
};
static std::vector< std::string > const test_filename_channel_strings = {
"H2:channel1!4=H2:channel1_AR", //
"H2:channel2=H2:channel2_AR", //
"H2:channel3" //
};
static std::vector< testing::channel_name > const expected_channels = {
{ "H1:MyChannel", 1, "H1:MyChannel_AR" },
{ "H2:channel1", 4, "H2:channel1_AR" },
{ "H2:channel2", 1, "H2:channel2_AR" },
{ "H2:channel3", 1, "H2:channel3" }
};
boost::filesystem::path channel_text_file(
boost::filesystem::current_path( ) );
channel_text_file /= "channel_from_filename_and_inline_channels.txt";
testing::construct_channel_file( channel_text_file,
test_filename_channel_strings );
FrameAPI::channel_container_type channels;
channels.ParseChannelName( channel_descriptor );
channels.ParseChannelName( channel_text_file.string( ) );
validate( channels, expected_channels );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment