Skip to content

Commit

Permalink
Merge branch 'master' into OpenDDSBump
Browse files Browse the repository at this point in the history
  • Loading branch information
doug1234 committed Apr 1, 2024
2 parents bb33cc2 + 39c3857 commit c13f7e1
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 140 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
- windows-2019
- ubuntu-22.04
- ubuntu-20.04
- macos-13
- macos-12
- macos-11

runs-on: ${{ matrix.runner }}

Expand Down Expand Up @@ -160,6 +160,8 @@ jobs:
shell: bash
run: |
tar xvfJ ${{ env.MATRIX_MD5 }}.tar.xz
cd OpenDDS
git submodule init && git submodule update
- name: 'Configure & Build OpenDDS (Linux / macOS)'
if: steps.cache-build.outputs.cache-hit != 'true' && (runner.os == 'Linux' || runner.os == 'macOS')
shell: bash
Expand Down
21 changes: 13 additions & 8 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,18 @@ DDSMonitorMainWindow::DDSMonitorMainWindow() :
activateWindow();

// Join the DDS domain
CommonData::m_ddsManager = std::make_unique<DDSManager>();
m_participantPage = new ParticipantPage(mainTabWidget);
CommonData::m_ddsManager->joinDomain(domainID, "",
[page = m_participantPage](const ParticipantInfo& info) {page->addParticipant(info); },
[page = m_participantPage](const ParticipantInfo& info) {page->removeParticipant(info); });
m_publicationMonitor = std::make_unique<PublicationMonitor>();
m_subscriptionMonitor = std::make_unique<SubscriptionMonitor>();
try {
CommonData::m_ddsManager = std::make_unique<DDSManager>();
m_participantPage = new ParticipantPage(mainTabWidget);
CommonData::m_ddsManager->joinDomain(domainID, "", [page = m_participantPage](const ParticipantInfo& info) {page->addParticipant(info); },
[page = m_participantPage](const ParticipantInfo& info) {page->removeParticipant(info); });
m_publicationMonitor = std::make_unique<PublicationMonitor>();
m_subscriptionMonitor = std::make_unique<SubscriptionMonitor>();
}
catch (std::runtime_error &e) {
QMessageBox::information(nullptr, "Error Starting Open DDS", e.what());
exit(1);
}

// Send DDS configuration to the log screen
reportConfig();
Expand Down Expand Up @@ -208,7 +213,7 @@ void DDSMonitorMainWindow::on_topicTree_itemClicked(QTreeWidgetItem* item, int)
if (!selectedPartition.isEmpty())
{
partitionInfo.name.length(1);
partitionInfo.name[0] = selectedPartition.toUtf8().data();
partitionInfo.name[0] = selectedPartition.toStdString().c_str();
}

topicInfo->subQos.partition = partitionInfo;
Expand Down
22 changes: 11 additions & 11 deletions src/topic_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ TopicMonitor::TopicMonitor(const QString& topicName) :
m_topicName(topicName),
m_filter(""),
m_typeCode(nullptr),
m_listener(OpenDDS::DCPS::make_rch<RecorderListener>(OpenDDS::DCPS::ref(*this))),
m_recorder_listener(OpenDDS::DCPS::make_rch<RecorderListener>(OpenDDS::DCPS::ref(*this))),
m_recorder(nullptr),
m_dr_listener(*this),
m_dr_listener(new DataReaderListenerImpl(*this)),
m_topic(nullptr),
m_paused(false)
{
Expand All @@ -36,12 +36,12 @@ TopicMonitor::TopicMonitor(const QString& topicName) :
OpenDDS::DCPS::Service_Participant* service = TheServiceParticipant;
DDS::DomainParticipant_var participant;
if (CommonData::m_ddsManager) {
participant = CommonData::m_ddsManager->getDomainParticipant();
participant = CommonData::m_ddsManager->getDomainParticipant();
}

if (!participant) {
std::cerr << "No domain participant" << std::endl;
return;
std::cerr << "No domain participant" << std::endl;
return;
}

if (topicInfo->typeCode) {
Expand All @@ -64,7 +64,7 @@ TopicMonitor::TopicMonitor(const QString& topicName) :
m_topic,
topicInfo->subQos,
topicInfo->readerQos,
m_listener);
m_recorder_listener);
if (!m_recorder) {
std::cerr << "Failed to created recorder for topic " << topicInfo->name << std::endl;
return;
Expand Down Expand Up @@ -94,7 +94,7 @@ TopicMonitor::TopicMonitor(const QString& topicName) :

m_dr = subscriber->create_datareader(m_topic,
topicInfo->readerQos,
&m_dr_listener,
m_dr_listener,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!m_dr) {
std::cerr << "Failed to create data reader for topic " << topicInfo->name << std::endl;
Expand Down Expand Up @@ -251,8 +251,8 @@ void TopicMonitor::on_sample_data_received(OpenDDS::DCPS::Recorder*,


QDateTime dataTime = QDateTime::fromMSecsSinceEpoch(
(static_cast<unsigned long long>(rawSample.source_timestamp_.sec) * 1000) +
(static_cast<unsigned long long>(rawSample.source_timestamp_.nanosec) * 1e-6));
(static_cast<unsigned long long>(rawSample.source_timestamp_.sec) * 1000) +
(static_cast<unsigned long long>(rawSample.source_timestamp_.nanosec) * 1e-6));

QString sampleName = dataTime.toString("HH:mm:ss.zzz");
CommonData::storeSample(m_topicName, sampleName, sample);
Expand Down Expand Up @@ -280,8 +280,8 @@ void TopicMonitor::on_data_available(DDS::DataReader_ptr dr)
if (infos[i].valid_data) {
// TODO: Apply content filtering when it's supported.
QDateTime dataTime = QDateTime::fromMSecsSinceEpoch(
(static_cast<unsigned long long>(infos[i].source_timestamp.sec) * 1000) +
(static_cast<unsigned long long>(infos[i].source_timestamp.nanosec) * 1e-6));
(static_cast<unsigned long long>(infos[i].source_timestamp.sec) * 1000) +
(static_cast<unsigned long long>(infos[i].source_timestamp.nanosec) * 1e-6));
QString sampleName = dataTime.toString("HH:mm:ss.zzz");
CommonData::storeDynamicSample(m_topicName, sampleName,
DDS::DynamicData::_duplicate(messages[i].in()));
Expand Down
4 changes: 2 additions & 2 deletions src/topic_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ class TopicMonitor
const CORBA::TypeCode* m_typeCode;

/// Listener for the recorder, calls back into this object
OpenDDS::DCPS::RcHandle<RecorderListener> m_listener;
OpenDDS::DCPS::RcHandle<RecorderListener> m_recorder_listener;

/// Stores the recorder object for this monitor.
OpenDDS::DCPS::Recorder* m_recorder;

/// Listener for a dynamic reader
DataReaderListenerImpl m_dr_listener;
DDS::DataReaderListener_var m_dr_listener;

/// A dynamic data reader for this topic
DDS::DataReader_var m_dr;
Expand Down
89 changes: 45 additions & 44 deletions src/topic_table_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,43 +662,43 @@ void TopicTableModel::setDataRow(DataRow* const data_row,
// When @bit_bound is supported, update this to call the right interface.
CORBA::Long value;
if (check_rc(data->get_int32_value(value, id), "get enum value failed")) {
DDS::DynamicType_var type = data->type();
const OpenDDS::XTypes::TypeKind tk = type->get_kind();
DDS::DynamicType_var enum_dt;
if (tk == OpenDDS::XTypes::TK_STRUCTURE || tk == OpenDDS::XTypes::TK_UNION) {
DDS::DynamicTypeMember_var enum_dtm;
if (type->get_member(enum_dtm, id) != DDS::RETCODE_OK) {
std::cerr << "get_member failed for enum member with Id "
<< id << std::endl;
break;
}
DDS::MemberDescriptor_var enum_md;
if (enum_dtm->get_descriptor(enum_md) != DDS::RETCODE_OK) {
std::cerr << "get_descriptor failed for enum member with Id "
<< id << std::endl;
break;
}
enum_dt = DDS::DynamicType::_duplicate(enum_md->type());
} else if (tk == OpenDDS::XTypes::TK_SEQUENCE || tk == OpenDDS::XTypes::TK_ARRAY) {
DDS::TypeDescriptor_var td;
if (type->get_descriptor(td) != DDS::RETCODE_OK) {
std::cerr << "get_descriptor failed" << std::endl;
break;
}
enum_dt = OpenDDS::XTypes::get_base_type(td->element_type());
}

DDS::DynamicTypeMember_var enum_lit_dtm;
if (enum_dt->get_member(enum_lit_dtm, value) != DDS::RETCODE_OK) {
std::cerr << "get_member failed for enum literal with value " << value << std::endl;
break;
}
DDS::MemberDescriptor_var enum_lit_md;
if (enum_lit_dtm->get_descriptor(enum_lit_md) != DDS::RETCODE_OK) {
std::cerr << "get_descriptor failed for enum literal with value " << value << std::endl;
break;
}
data_row->value = enum_lit_md->name();
DDS::DynamicType_var type = data->type();
const OpenDDS::XTypes::TypeKind tk = type->get_kind();
DDS::DynamicType_var enum_dt;
if (tk == OpenDDS::XTypes::TK_STRUCTURE || tk == OpenDDS::XTypes::TK_UNION) {
DDS::DynamicTypeMember_var enum_dtm;
if (type->get_member(enum_dtm, id) != DDS::RETCODE_OK) {
std::cerr << "get_member failed for enum member with Id "
<< id << std::endl;
break;
}
DDS::MemberDescriptor_var enum_md;
if (enum_dtm->get_descriptor(enum_md) != DDS::RETCODE_OK) {
std::cerr << "get_descriptor failed for enum member with Id "
<< id << std::endl;
break;
}
enum_dt = DDS::DynamicType::_duplicate(enum_md->type());
} else if (tk == OpenDDS::XTypes::TK_SEQUENCE || tk == OpenDDS::XTypes::TK_ARRAY) {
DDS::TypeDescriptor_var td;
if (type->get_descriptor(td) != DDS::RETCODE_OK) {
std::cerr << "get_descriptor failed" << std::endl;
break;
}
enum_dt = OpenDDS::XTypes::get_base_type(td->element_type());
}

DDS::DynamicTypeMember_var enum_lit_dtm;
if (enum_dt->get_member(enum_lit_dtm, value) != DDS::RETCODE_OK) {
std::cerr << "get_member failed for enum literal with value " << value << std::endl;
break;
}
DDS::MemberDescriptor_var enum_lit_md;
if (enum_lit_dtm->get_descriptor(enum_lit_md) != DDS::RETCODE_OK) {
std::cerr << "get_descriptor failed for enum literal with value " << value << std::endl;
break;
}
data_row->value = enum_lit_md->name();
}
break;
}
Expand Down Expand Up @@ -740,8 +740,8 @@ void TopicTableModel::parseCollection(const DDS::DynamicData_var& data, const st
if (ret != DDS::RETCODE_OK) {
std::cerr << "get_complex_value for element at index " << i << " failed" << std::endl;
} else {
std::string scoped_elem_name = namePrefix + "[" + std::to_string(i) + "]";
parseData(nested_data, scoped_elem_name);
std::string scoped_elem_name = namePrefix + "[" + std::to_string(i) + "]";
parseData(nested_data, scoped_elem_name);
}
continue;
}
Expand All @@ -751,8 +751,8 @@ void TopicTableModel::parseCollection(const DDS::DynamicData_var& data, const st
DataRow* data_row = new DataRow;
data_row->type = typekind_to_tckind(elem_tk);
data_row->isOptional = false; // TODO: Get the right value from the containing type
std::string scoped_elem_name = namePrefix + "[" + std::to_string(i) + "]";
data_row->name = scoped_elem_name.c_str();
std::string scoped_elem_name = namePrefix + "[" + std::to_string(i) + "]";
data_row->name = scoped_elem_name.c_str();
data_row->isKey = false; // TODO: Get the right value from the containing type

// Update the current editor delegate
Expand Down Expand Up @@ -793,8 +793,9 @@ void TopicTableModel::parseAggregated(const DDS::DynamicData_var& data, const st
continue;
}

std::string scoped_member_name = namePrefix.empty() ? md->name() : namePrefix + "." + md->name();
const OpenDDS::XTypes::TypeKind member_tk = OpenDDS::XTypes::get_base_type(md->type())->get_kind();
std::string scoped_member_name = namePrefix.empty() ? md->name() : namePrefix + "." + md->name();
const DDS::DynamicType_var base_type = OpenDDS::XTypes::get_base_type(md->type());
const OpenDDS::XTypes::TypeKind member_tk = base_type->get_kind();
switch (member_tk) {
case OpenDDS::XTypes::TK_SEQUENCE:
case OpenDDS::XTypes::TK_ARRAY:
Expand All @@ -805,7 +806,7 @@ void TopicTableModel::parseAggregated(const DDS::DynamicData_var& data, const st
if (ret != DDS::RETCODE_OK) {
std::cerr << "get_complex_value for member Id " << id << " failed" << std::endl;
} else {
parseData(nested_data, scoped_member_name);
parseData(nested_data, scoped_member_name);
}
continue;
}
Expand Down
45 changes: 10 additions & 35 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,22 @@ cmake_minimum_required(VERSION 3.20)

project(opendds-monitor-tests VERSION 0.0.1 LANGUAGES CXX)

add_executable(managed_testapp
managed.cpp
)

add_library(test_common INTERFACE)
target_compile_options(test_common INTERFACE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: -Wall -Wpedantic -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wundef -Werror> $<$<CXX_COMPILER_ID:MSVC>: /W4>)
if (MSVC)
target_compile_definitions(managed_testapp PRIVATE _CRT_SECURE_NO_WARNINGS)
target_compile_definitions(test_common INTERFACE _CRT_SECURE_NO_WARNINGS)
else()
target_compile_features(managed_testapp PRIVATE cxx_std_17)
target_compile_features(test_common INTERFACE cxx_std_17)
endif()

target_compile_options(managed_testapp PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: -Wall -Wpedantic -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wundef -Werror> $<$<CXX_COMPILER_ID:MSVC>: /W4>)

OPENDDS_TARGET_SOURCES(managed_testapp test.idl OPENDDS_IDL_OPTIONS "-Gxtypes-complete" SUPPRESS_ANYS OFF)

target_link_libraries(managed_testapp
OpenDDW
)

target_include_directories(managed_testapp PRIVATE
target_include_directories(test_common INTERFACE
../src
)

add_executable(unmanaged_testapp
unmanaged.cpp
)

if (MSVC)
target_compile_definitions(unmanaged_testapp PRIVATE _CRT_SECURE_NO_WARNINGS)
else ()
target_compile_features(unmanaged_testapp PRIVATE cxx_std_17)
endif()
add_executable(managed_testapp managed.cpp)
OPENDDS_TARGET_SOURCES(managed_testapp test.idl OPENDDS_IDL_OPTIONS "-Gxtypes-complete" SUPPRESS_ANYS OFF)
target_link_libraries(managed_testapp OpenDDW test_common)

add_executable(unmanaged_testapp unmanaged.cpp)
OPENDDS_TARGET_SOURCES(unmanaged_testapp test.idl OPENDDS_IDL_OPTIONS "-Gxtypes-complete" SUPPRESS_ANYS OFF)

target_compile_options(unmanaged_testapp PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: -Wall -Wpedantic -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wundef -Werror> $<$<CXX_COMPILER_ID:MSVC>: /W4>)

target_link_libraries(unmanaged_testapp
OpenDDS::Dcps
${OPENDDS_TARGETS}
)

target_include_directories(unmanaged_testapp PRIVATE
../src
)
target_link_libraries(unmanaged_testapp OpenDDS::Dcps test_common)
Loading

0 comments on commit c13f7e1

Please sign in to comment.