Resolves latest issues in Lts/Common Lts/DDS

This commit is contained in:
torsten committed 2026-09-06 18:45:59 +02:00
1 parent e398f4903d
commit b656e1aaa9
25 files changed
+537 -47

No files matched your search

@@ -49,6 +49,7 @@ NGL_TARGET_LINK_LIBRARIES(LtsSessionDataDds
$<$<BOOL:${BUILD_RTI}>:$<IF:$<TARGET_EXISTS:ddsconnector>,ddsconnector,>>
PUBLIC
$<$<BOOL:${BUILD_RTI}>:nddscore>
$<$<BOOL:${BUILD_RTI}>:ddsQoS>
NGLLogger
Qt6::Core
)
@@ -56,6 +57,7 @@ IF(BUILD_RTI)
NGL_TARGET_INCLUDE_DIRECTORIES(LtsSessionDataDds
PUBLIC
${RTI_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/Lts
)
NGL_TARGET_LINK_DIRECTORIES(LtsSessionDataDds
PRIVATE
@@ -13,12 +13,37 @@
#ifdef BUILD_RTI
#include <DDS/DDSConnector/dds_connector.h>
#include <DDS/DTC/generic_dtc_impl.h>
#include <DDS/QosProfile/DDS_DefaultQos>
#include <DDS/QosProfile/DDS_DefaultQos.h>
#include <Lts/Common/ProjectConfig/project_defines.h>
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <QtCore/QDebug>
#include <QtCore/QSet>
#include <QtCore/QVector>
namespace
{
// Convert LtsSession::PartitionType to IDL::PartitionType
IDL::PartitionType toIdlPartitionType(LtsSession::PartitionType type)
{
switch (type)
{
case LtsSession::PartitionType::Any:
return IDL::PartitionType::Any;
case LtsSession::PartitionType::Global:
return IDL::PartitionType::Global;
case LtsSession::PartitionType::Exercise:
return IDL::PartitionType::Exercise;
case LtsSession::PartitionType::AllExercises:
return IDL::PartitionType::AllExercises;
case LtsSession::PartitionType::Replay:
return IDL::PartitionType::Replay;
case LtsSession::PartitionType::Invalid:
default:
return IDL::PartitionType::Any;
}
}
} // namespace
namespace LtsSession
{
/**
@@ -217,7 +242,7 @@ bool LtsSessionDataDds::init(const DdsConnectionParams& connParams)
#endif
m_ddsConnector = std::make_shared<DDSConnector::DdsConnector>(
connParams.domainId, connParams.partitionType, connParams.partitionId,
connParams.domainId, toIdlPartitionType(connParams.partitionType), connParams.partitionId,
connParams.exerciseId, // same as partition Id in live but not in replay
type);
s_ddsConnections()->insertConnection(connParams, m_ddsConnector);
@@ -252,7 +277,7 @@ bool LtsSessionDataDds::init(const dds::domain::DomainParticipant& dp, const Dds
if (m_ddsConnector == nullptr)
{
m_ddsConnector =
std::make_shared<DDSConnector::DdsConnector>(dp, connParams.partitionType, type, connParams.partitionId);
std::make_shared<DDSConnector::DdsConnector>(dp, toIdlPartitionType(connParams.partitionType), type, connParams.partitionId);
s_ddsConnections()->insertConnection(connParams, m_ddsConnector);
}
@@ -286,6 +311,19 @@ QString LtsSessionDataDds::partitionTypeString(PartitionType partitionType)
return QStringLiteral("Invalid (%1)").arg(int(partitionType));
}
LtsSession::PartitionType LtsSessionDataDds::toPartitionType(IDL::PartitionType idlType)
{
switch (idlType)
{
case IDL::PartitionType::Any: return PartitionType::Any;
case IDL::PartitionType::Exercise: return PartitionType::Exercise;
case IDL::PartitionType::Replay: return PartitionType::Replay;
case IDL::PartitionType::AllExercises: return PartitionType::AllExercises;
case IDL::PartitionType::Global: return PartitionType::Global;
default: return PartitionType::Invalid;
}
}
QString LtsSessionDataDds::toString() const
{
return QStringLiteral("(LtsSessionDataDds: id=%1, partitionId=%2, partitionType=%3(%4), exerciseId=%5)")
@@ -313,7 +351,7 @@ int LtsSessionDataDds::partitionId() const
PartitionType LtsSessionDataDds::partitionType() const
{
return m_ddsConnector ? m_ddsConnector->getPartitionType() : PartitionType::Global;
return m_ddsConnector ? toPartitionType(m_ddsConnector->getPartitionType()) : PartitionType::Global;
}
QStringList LtsSessionDataDds::qosFile() const
@@ -23,14 +23,15 @@
#ifdef BUILD_RTI
#include <dds/domain/DomainParticipant.hpp>
#include "INGLLogger.h"
#include "DDS/Core/core_dtc_types.h"
namespace DDSConnector { class DdsConnector; }
namespace DTC { template<typename T> class GenericDTCImpl; }
namespace Core { struct PartitionTime; }
namespace DataPluginBase { class Interface; }
class Fetcher;
namespace GuiPluginBase { class Interface; }
#else
// Forward declarations for stub types
namespace DataPluginBase { class Interface; }
namespace GuiPluginBase { class Interface; }
#endif
namespace LtsSession
@@ -46,6 +47,8 @@ enum class PartitionType {
Invalid = -1
};
class Fetcher;
struct DdsConnectionParams
{
int domainId = -1;
@@ -150,6 +153,26 @@ class LTSSESSIONDATADDS_EXPORT LtsSessionDataDds : public QObject
template<typename T, typename S>
bool getDtc(std::shared_ptr<S> &val) const;
// Foreign GUI interface retrieval - used by Fetcher helper class
template<typename S>
bool getForeignGuiInterface(std::shared_ptr<S> &val) const
{
#ifdef BUILD_RTI
for (const auto &i : m_guiPluginInterfaces)
{
val = std::dynamic_pointer_cast<S>(i);
if (val)
return true;
}
val.reset();
if (m_logger.isDebug())
m_logger.debug() << "Cannot find foreign gui ifc " << typeid(S).name() << " in " << toString();
#else
val.reset();
#endif
return false;
}
signals:
void partitionTimeChanged(qint64 newPartitionTime);
void partitionTimeChangedInternal();
@@ -158,6 +181,7 @@ class LTSSESSIONDATADDS_EXPORT LtsSessionDataDds : public QObject
#ifdef BUILD_RTI
bool initInternal();
void onPartitionTimeChangedInternal();
static LtsSession::PartitionType toPartitionType(IDL::PartitionType idlType);
// Member variables - only with RTI
int m_exerciseId;
@@ -170,6 +194,8 @@ class LTSSESSIONDATADDS_EXPORT LtsSessionDataDds : public QObject
std::shared_ptr<DTC::GenericDTCImpl<Core::PartitionTime>> m_dtcPartitionTime;
NGL::INGLLogger& m_logger;
QMap<QString, std::shared_ptr<DataPluginBase::Interface>> m_dataPluginInterfaces;
QMap<QString, std::shared_ptr<GuiPluginBase::Interface>> m_guiPluginInterfaces;
QStringList m_qosFileList;
#else
// Stub implementation - minimal members
bool initInternal();
@@ -183,6 +209,65 @@ class LTSSESSIONDATADDS_EXPORT LtsSessionDataDds : public QObject
#endif
};
#ifdef BUILD_RTI
class Fetcher
{
public:
Fetcher(LtsSessionDataDds *sessionDataDds, const QString &caller)
: m_sessionDataDds(sessionDataDds)
, m_errors(false)
, m_caller(caller)
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsSession.Fetcher"))
, m_optional(false)
{
}
LtsSessionDataDds *m_sessionDataDds;
bool m_errors;
QString m_caller;
QString m_whatWillNotWork;
NGL::INGLLogger &m_logger;
bool m_optional;
QString m_resultType;
QString m_getterFunctionType;
template <typename ForeignGuiInterface>
void getForeignGuiInterface(std::shared_ptr<ForeignGuiInterface> &foreignGuiInterface, const QString &whatWillNotWork /* only fill if optional */, bool optional)
{
if (!m_sessionDataDds->getForeignGuiInterface(foreignGuiInterface))
{
m_whatWillNotWork = whatWillNotWork;
m_optional = optional;
m_resultType = QString::fromUtf8(typeid(ForeignGuiInterface).name());
m_getterFunctionType = QStringLiteral("gui interface");
print();
}
}
bool status() const
{
return !m_errors;
}
void print()
{
m_errors = true;
QString msg(QStringLiteral("%1 cannot find '%2' in %3 %4"));
if (m_optional)
{
INFO_LOG(m_logger) << msg.arg(m_caller, m_resultType, m_sessionDataDds->toString(), QStringLiteral("' - optional but %1 will not work").arg(m_whatWillNotWork));
}
else // critical
{
ERROR_LOG(m_logger) << msg.arg(m_caller, m_resultType, m_sessionDataDds->toString(), QStringLiteral(" which is required"));
}
}
};
#endif
} // namespace LtsSession
// Template method implementations - must be in header