Adds succesfull lts/proxies migration & testsuite

This commit is contained in:
torsten committed 2026-09-19 09:18:18 +00:00
1 parent 9e38583785
commit a1914cb7d9
59 files changed
+754 -273

No files matched your search

@@ -184,9 +184,28 @@ class DtsGenerator(object):
class DtcGenerator(object):
def generate( self, outfile, parser ):
outputHeader( outfile, parser, 'DTC' )
outfile.write('\n')
outfile.write('/**\n')
outfile.write('* %s definitions\n' % 'DTC')
outfile.write('*/\n')
outfile.write('\n')
outfile.write('// warning: this file is generated with command\n')
outfile.write('// %s\n' % ( " ".join(sys.argv) ))
outfile.write('// at %s\n' % time.strftime( '%c' ))
outfile.write('// it will be overwritten by next run - do not modify!\n')
outfile.write('\n')
outfile.write('#pragma once\n')
outfile.write('\n')
# Include Qt headers FIRST to avoid namespace conflicts with DDS
outfile.write('#include <QtCore/QObject>\n')
outfile.write('#include <QtCore/QTimer>\n')
outfile.write('\n')
# Include DDS headers BEFORE project headers to avoid namespace conflicts
outfile.write('#include <DDS/Generic/generic_data_reader.h>\n')
outfile.write('#include <DDS/DTC/generic_dtc.h>\n')
outfile.write('#include <DDS/DTC/generic_dtc_impl.h>\n')
outfile.write('\n')
outfile.write('#include "%s.hpp"\n' % ( parser.service_abbr ))
outfile.write('\n')
outfile.write('/**\n')
outfile.write(' * Type definitions \n')
@@ -30,7 +30,7 @@ Dao::Dao(int exerciseId)
, m_bEmitMessageOnError(true)
, m_bCanHandleSchemas(true)
, m_ownDatabaseConnection(true)
, m_logger(getLogger("Db"))
, m_logger(&getLogger("Db"))
{}
Dao::~Dao()
@@ -55,7 +55,7 @@ bool Dao::init(const QString &dbUser,
{
m_ownDatabaseConnection = true;
m_dbConnection = DBConnection::open(m_logger, dbUser, dbPasswd, dbDriver, dbHost, dbName, schemaName());
m_dbConnection = DBConnection::open(*m_logger, dbUser, dbPasswd, dbDriver, dbHost, dbName, schemaName());
return initInternal();
}
@@ -65,15 +65,15 @@ bool Dao::initInternal()
QSqlDriver *driver = m_dbConnection.driver();
if (!driver)
{
WARNING_LOG(m_logger) << "No SQL driver loaded - no database available!";
WARNING_LOG(*m_logger) << "No SQL driver loaded - no database available!";
return false;
}
const QString driverName = m_dbConnection.driverName();
DEBUG_LOG(m_logger) << "Connected to database " << m_dbConnection.databaseName() << "@" << m_dbConnection.hostName()
DEBUG_LOG(*m_logger) << "Connected to database " << m_dbConnection.databaseName() << "@" << m_dbConnection.hostName()
<< ", schema: " << schemaName() << ", used driver: " << driverName;
if (!m_dbConnection.isOpen())
{
WARNING_LOG(m_logger) << "Database connection is no open - can not initialize database interface";
WARNING_LOG(*m_logger) << "Database connection is no open - can not initialize database interface";
return false;
}
if (driverName == QLatin1String("QSQLITE"))
@@ -82,7 +82,7 @@ bool Dao::initInternal()
{% if has_db_notifications %}
if (!driver->hasFeature(QSqlDriver::EventNotifications))
{
WARNING_LOG(m_logger) << "Can not subscribe to notifications - sqldriver does not support this feature!";
WARNING_LOG(*m_logger) << "Can not subscribe to notifications - sqldriver does not support this feature!";
}
else
{
@@ -91,7 +91,7 @@ bool Dao::initInternal()
{% for cpp_struct in cpp_structs %}{% for db_notify in cpp_struct.dbNotifications %}driver->subscribeToNotification(QStringLiteral("{{ db_notify }}"));{% endfor %}{% endfor %}
}
{% endif %}
m_query = std::unique_ptr<NSqlQuery>(new NSqlQuery(m_dbConnection, m_logger));
m_query = std::unique_ptr<NSqlQuery>(new NSqlQuery(m_dbConnection, *m_logger));
return true;
}
@@ -134,7 +134,7 @@ QSqlError Dao::getLastError() const
{% if has_db_notifications %}
void Dao::onNotification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload)
{
DEBUG_LOG(m_logger) << "Notification source = " << source;
DEBUG_LOG(*m_logger) << "Notification source = " << source;
if (source == QSqlDriver::SelfSource)
return;
// search coresponding signal
@@ -73,7 +73,7 @@ protected:
bool m_bEmitMessageOnError;
bool m_bCanHandleSchemas;
bool m_ownDatabaseConnection;
LOGGER_T m_logger;
NGL::INGLLogger* m_logger;
private:
bool initInternal();
@@ -50,7 +50,7 @@ DatabaseInterfaceImpl::DatabaseInterfaceImpl(int exerciseId)
, m_bEmitMessageOnError(true)
, m_bCanHandleSchemas(true)
, m_ownDatabaseConnection(true)
, m_logger(getLogger("Db"))
, m_logger(&getLogger("Db"))
{}
DatabaseInterfaceImpl::~DatabaseInterfaceImpl()
@@ -83,7 +83,7 @@ bool DatabaseInterfaceImpl::init(const QString &dbUser,
{
m_ownDatabaseConnection = true;
m_dbConnection = DBConnection::open(m_logger, dbUser, dbPasswd, dbDriver, dbHost, dbName, schemaName());
m_dbConnection = DBConnection::open(*m_logger, dbUser, dbPasswd, dbDriver, dbHost, dbName, schemaName());
return initInternal();
}
@@ -93,15 +93,15 @@ bool DatabaseInterfaceImpl::initInternal()
QSqlDriver *driver = m_dbConnection.driver();
if (!driver)
{
WARNING_LOG(m_logger) << "No SQL driver loaded - no database available!";
WARNING_LOG(*m_logger) << "No SQL driver loaded - no database available!";
return false;
}
const QString driverName = m_dbConnection.driverName();
DEBUG_LOG(m_logger) << "Connected to database " << m_dbConnection.databaseName() << "@" << m_dbConnection.hostName()
DEBUG_LOG(*m_logger) << "Connected to database " << m_dbConnection.databaseName() << "@" << m_dbConnection.hostName()
<< ", schema: " << schemaName() << ", used driver: " << driverName;
if (!m_dbConnection.isOpen())
{
WARNING_LOG(m_logger) << "Database connection is no open - can not initialize database interface";
WARNING_LOG(*m_logger) << "Database connection is no open - can not initialize database interface";
return false;
}
if (driverName == QLatin1String("QSQLITE"))
@@ -110,7 +110,7 @@ bool DatabaseInterfaceImpl::initInternal()
{% if has_db_notifications %}
if (!driver->hasFeature(QSqlDriver::EventNotifications))
{
WARNING_LOG(m_logger) << "Can not subscribe to notifications - sqldriver does not support this feature!";
WARNING_LOG(*m_logger) << "Can not subscribe to notifications - sqldriver does not support this feature!";
}
else
{
@@ -120,7 +120,7 @@ bool DatabaseInterfaceImpl::initInternal()
driver->subscribeToNotification(QStringLiteral("{{ db_notify }}"));{% endfor %}{% endfor %}
}
{% endif %}
m_query = std::unique_ptr<NSqlQuery>(new NSqlQuery(m_dbConnection, m_logger));
m_query = std::unique_ptr<NSqlQuery>(new NSqlQuery(m_dbConnection, *m_logger));
return true;
}
@@ -163,7 +163,7 @@ QSqlError DatabaseInterfaceImpl::getLastError() const
{% if has_db_notifications %}
void DatabaseInterfaceImpl::onNotification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload)
{
DEBUG_LOG(m_logger) << "Notification source = " << source;
DEBUG_LOG(*m_logger) << "Notification source = " << source;
// no need to emit notification signals
if (source == QSqlDriver::SelfSource)
return;
@@ -561,7 +561,7 @@ bool DatabaseInterfaceImpl::selectBy{{ fk.cppMemberNameCc }}(QVector<Database::{
SqlQueryJanitor janitor(m_query);
if (!selectPrepareInternal{{ cpp_struct.name }}(QStringLiteral(" WHERE {{ fk.dbColumnName }} = :{{ fk.dbColumnName }}") + orderBy))
{
ERROR_LOG(m_logger) << "Error preparing query: " << m_query->lastError().text();
ERROR_LOG(*m_logger) << "Error preparing query: " << m_query->lastError().text();
m_lastError = m_query->lastError();
return false;
}
@@ -578,7 +578,7 @@ bool DatabaseInterfaceImpl::selectBy{{ fk.cppMemberNameCc }}(const std::function
SqlQueryJanitor janitor(m_query);
if (!selectPrepareInternal{{ cpp_struct.name }}(QStringLiteral(" WHERE {{ fk.dbColumnName }} = :{{ fk.dbColumnName }}") + orderBy))
{
ERROR_LOG(m_logger) << "Error preparing query: " << m_query->lastError().text();
ERROR_LOG(*m_logger) << "Error preparing query: " << m_query->lastError().text();
m_lastError = m_query->lastError();
return false;
}
@@ -658,7 +658,7 @@ bool DatabaseInterfaceImpl::remove{{ cpp_struct.nameCc }}By{{ fk.cppMemberNameCc
if (!m_query->prepare(stmt))
{
ERROR_LOG(m_logger) << "Error preparing query: " << m_query->lastError().text();
ERROR_LOG(*m_logger) << "Error preparing query: " << m_query->lastError().text();
m_lastError = m_query->lastError();
return false;
}
@@ -94,7 +94,7 @@ protected:
bool m_bEmitMessageOnError;
bool m_bCanHandleSchemas;
bool m_ownDatabaseConnection;
LOGGER_T m_logger;
NGL::INGLLogger* m_logger;
private:
bool initInternal();
};// class DatabaseInterfaceImpl
@@ -13,6 +13,7 @@
{% if custom_dtc_procs %}
#include <{{ include_prefix }}/{{ namespace_abbr }}_dtc_impl_custom.h>
{% endif %}
#include <NGLLogger/INGLLogger.h>
#include <DDS/DTC/generic_dtc_impl.h>
#include <dds/core/cond/StatusCondition.hpp>
#include <dds/core/cond/WaitSet.hpp>
@@ -20,6 +21,8 @@
#include <QCoreApplication>
#include <QThread>
using namespace NGL;
namespace {{ namespace }}
{
namespace Interface
@@ -58,7 +61,7 @@ std::shared_ptr<Dtc> Dtc::create(const std::shared_ptr<DDSConnector::DdsConnecto
DtcImpl::DtcImpl(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
: Dtc()
, m_ddsConnector(ddsConnector)
, m_logger(getLogger("Dtc"))
, m_logger(&ProjectDataManagement::getLogger("Dtc"))
{}
DtcImpl::~DtcImpl()
@@ -70,7 +73,7 @@ bool DtcImpl::enableAll(bool enable)
{ {% for dt in dataTopics.member %} {% if dt.dtcImpl %} {% if dt.autosubscribe %}
if (!enable{{ dt.name }}(enable))
{
ERROR_LOG(m_logger) << "Error initializing data topic {{ dt.name }}";
ERROR_LOG(*m_logger) << "Error initializing data topic {{ dt.name }}";
return false;
}
{% endif %} {% endif %} {% endfor %}
@@ -92,7 +95,7 @@ bool DtcImpl::checkEnabled(const DTC &dtc) const
if (!dtc)
{
using TOPIC = typename DtcConstraints<DTC>::TOPIC ;
WARNING_LOG(m_logger) << "Error retrieving data topic "
WARNING_LOG(*m_logger) << "Error retrieving data topic "
<< DDS::topic_type_name<TOPIC>::value() << " - not enabled";
Q_ASSERT(false);
return false;
@@ -171,7 +174,7 @@ bool DtcImpl::enable{{ dt.name }}(bool enable)
{
if (m_dtc{{ dt.name }})
{
INFO_LOG(m_logger) << "{{ dt.name }} already enabled!";
INFO_LOG(*m_logger) << "{{ dt.name }} already enabled!";
return true;
}
m_dtc{{ dt.name }}.reset(m_ddsConnector->createDTC<DTC::{{ dt.name }}Impl>());
@@ -195,7 +198,7 @@ bool DtcImpl::waitForHistoricalData{{ dt.name }}(int timeoutMSec)
if (!is{{ dt.name }}Enabled())
{
enable{{ dt.name }}();
DEBUG_LOG(m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
DEBUG_LOG(*m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
}
if (!waitForHistoricalData(m_dtc{{ dt.name }}, timeoutMSec))
@@ -215,7 +218,7 @@ bool DtcImpl::waitForHistoricalData{{ dt.name }}(int timeoutMSec)
template <>
{{ dt.key.cppType }} getKey(const {{ dt.type }} &val)
{
return val.{{ dt.key.name }}();
return val.{{ dt.key.name }};
}
QMap<{{ dt.key.cppType }},::{{ namespace }}::{{ dt.type }}> DtcImpl::{{ dt.nameFlc }}s()
@@ -223,7 +226,7 @@ QMap<{{ dt.key.cppType }},::{{ namespace }}::{{ dt.type }}> DtcImpl::{{ dt.nameF
if (!is{{ dt.name }}Enabled())
{
enable{{ dt.name }}();
DEBUG_LOG(m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
DEBUG_LOG(*m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
waitForHistoricalData{{ dt.name }}(10);
}
return m_{{ dt.nameFlc }}Cont;
@@ -234,7 +237,7 @@ bool DtcImpl::{{ dt.nameFlc }}s(const std::function<void(const ::{{ namespace }}
if (!is{{ dt.name }}Enabled())
{
enable{{ dt.name }}();
DEBUG_LOG(m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
DEBUG_LOG(*m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
waitForHistoricalData{{ dt.name }}(10);
}
return iterateAll(m_dtc{{ dt.name }}, m_{{ dt.nameFlc }}Cont, cb);
@@ -245,7 +248,7 @@ bool DtcImpl::{{ dt.nameFlc }}s(const std::function<bool(const ::{{ namespace }}
if (!is{{ dt.name }}Enabled())
{
enable{{ dt.name }}();
DEBUG_LOG(m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
DEBUG_LOG(*m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
waitForHistoricalData{{ dt.name }}(10);
}
return iterateUntil(m_dtc{{ dt.name }}, m_{{ dt.nameFlc }}Cont, cb);
@@ -256,7 +259,7 @@ bool DtcImpl::{{ dt.nameFlc }}s(const std::function<bool(const ::{{ namespace }}
if (!is{{ dt.name }}Enabled())
{
enable{{ dt.name }}();
DEBUG_LOG(m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
DEBUG_LOG(*m_logger) << "NEED TO ENABLE ! {{ dt.name }}" ;
waitForHistoricalData{{ dt.name }}(10);
}
return getOne(m_dtc{{ dt.name }}, m_{{ dt.nameFlc }}Cont, {{ dt.key.nameFlc }});
@@ -10,11 +10,15 @@
// filename: {{ namespace_abbr }}_dtc_impl.h
#pragma once
#include <DDS/DTC/generic_dtc.h>
#include <DDS/DTC/generic_dtc_impl.h>
#include <DDS/Generic/generic_data_reader.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <{{ include_prefix }}/{{ namespace_abbr }}_dtc.h>
#include <{{ include_prefix }}/{{ namespace_abbr }}_dtc_types.h>
#include <{{ include_prefix }}/logger.h>
#include <DDS/DDSConnector/dds_connector.h>
using namespace NGL;
#if !defined(MAKE_SVC{{ namespace_abbr_upper }}CLIENT_LIB)
#error "You are not allowed to include this file in your code!"
@@ -91,7 +95,13 @@ protected:
::{{ namespace }}::{{ dt.type }} m_{{ dt.nameFlc }};
{% endif %} {% endif %} {% endfor %}
LOGGER_T m_logger;
NGL::INGLLogger* m_logger;
signals:
{% for dt in dataTopics.member %}
{% if dt.dtcImpl %}
void {{ dt.nameFlc }}Changed(const ::{{ namespace }}::{{ dt.type }} &data, DataModification modType);
{% endif %} {% endfor %}
};
} // namespace Interface
@@ -25,7 +25,7 @@ std::shared_ptr<Dts> Dts::create(const std::shared_ptr<DDSConnector::DdsConnecto
DtsImpl::DtsImpl(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
: Dts()
, m_ddsConnector(ddsConnector)
, m_logger(getLogger("Dts"))
, m_logger(&getLogger("Dts"))
{}
DtsImpl::~DtsImpl()
@@ -38,7 +38,7 @@ bool DtsImpl::enableAll(bool enable)
{% for dt in dataTopics.member %} {% if dt.dtsImpl %}
if (!enable{{ dt.name }}(enable))
{
WARNING_LOG(m_logger) << "Error initializing data topic {{ dt.name }}";
WARNING_LOG(*m_logger) << "Error initializing data topic {{ dt.name }}";
return false;
}
{% endif %} {% endfor %}
@@ -55,7 +55,7 @@ bool DtsImpl::enable{{ dt.name }}(bool enable)
{
if (m_dts{{ dt.name }})
{
INFO_LOG(m_logger) << "{{ ft.name }} already enabled!";
INFO_LOG(*m_logger) << "{{ ft.name }} already enabled!";
return true;
}
m_dts{{ dt.name }}.reset(m_ddsConnector->createDTS<DTS::{{ dt.name }}Impl>());
@@ -72,7 +72,7 @@ bool DtsImpl::publish(const {{ namespace }}::{{ dt.type }} &data)
{
if (!m_dts{{ dt.name }})
{
WARNING_LOG(m_logger) << "Error publishing data topic {{ dt.name }} - not enabled";
WARNING_LOG(*m_logger) << "Error publishing data topic {{ dt.name }} - not enabled";
Q_ASSERT(false);
return false;
}
@@ -84,12 +84,12 @@ bool DtsImpl::remove{{ dt.name }}ByKey({{ dt.key.cppTypeCr }} {{ dt.key.nameFlc
{
if (!m_dts{{ dt.name }})
{
WARNING_LOG(m_logger) << "Error removing data topic {{ dt.name }} - not enabled";
WARNING_LOG(*m_logger) << "Error removing data topic {{ dt.name }} - not enabled";
Q_ASSERT(false);
return false;
}
{{ namespace }}::{{ dt.name }} data;
data.{{ dt.key.name }}({{ dt.key.name }});
data.{{ dt.key.name }} = {{ dt.key.name }};
return m_dts{{ dt.name }}->remove(data, errorMsgIfSampleDoesNotExists);
}
{% endif %}
@@ -50,7 +50,7 @@ protected:
{% for dt in dataTopics.member %} {% if dt.dtsImpl %}
std::unique_ptr<DTS::{{ dt.name }}> m_dts{{ dt.name }};
{% endif %} {% endfor %}
LOGGER_T m_logger;
NGL::INGLLogger* m_logger;
};
} // namespace Interface
@@ -53,14 +53,14 @@ Q_DECL_EXPORT std::shared_ptr<Ftc> Ftc::create(const std::shared_ptr<DDSConnecto
FtcImpl::FtcImpl(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
: Ftc()
, m_ddsConnector(ddsConnector)
, m_logger(getLogger("Ftc"))
, m_logger(&getLogger("Ftc"))
{}
bool FtcImpl::enableAll(bool enable)
{ {% for ft in functionTopics.member %}
if (!enable{{ ft.name }}(enable))
{
ERROR_LOG(m_logger) << "Error initializing function topic {{ ft.name }}";
ERROR_LOG(*m_logger) << "Error initializing function topic {{ ft.name }}";
return false;
}
{% endfor %}
@@ -80,7 +80,7 @@ bool FtcImpl::enable{{ ft.name }}(bool enable)
{
if (m_ftc{{ ft.name }})
{
INFO_LOG(m_logger) << "{{ ft.name }} already enabled!";
INFO_LOG(*m_logger) << "{{ ft.name }} already enabled!";
return true;
}
m_ftc{{ ft.name }}.reset(
@@ -116,9 +116,9 @@ static T buildErrorReason(int reason, int requestId)
}
T reply;
reply.id(requestId);
reply.errorString(errString);
reply.errorParams(errArgs);
reply.id = requestId;
reply.errorString = errString;
reply.errorParams = errArgs;
return reply;
}
@@ -135,7 +135,7 @@ int64_t FtcImpl::{{ ft.requestFlc }}(const {{ ft.requestType }} &request, const
{
if (!m_ftc{{ ft.name }})
{
WARNING_LOG(m_logger) << "Error requesting function topic {{ ft.name }} - not enabled";
WARNING_LOG(*m_logger) << "Error requesting function topic {{ ft.name }} - not enabled";
Q_ASSERT(false);
return 0;
}
@@ -202,7 +202,7 @@ int64_t FtcImpl::{{ ft.requestFlc }}(const {{ ft.requestType }} &request, const
if (fro.error())
{
ERROR_LOG(m_logger) << "FTC call failed: " << fro.translated();
ERROR_LOG(*m_logger) << "FTC call failed: " << fro.translated();
throw std::runtime_error(fro.translated().toStdString().c_str());
}
@@ -219,7 +219,7 @@ void FtcImpl::{{ ft.onReply }}(const {{ namespace }}::{{ ft.reply }} &reply, int
auto it = m_{{ ft.replyHandlerFlc }}.find(uniqueId);
if (it == m_{{ ft.replyHandlerFlc }}.end())
{
WARNING_LOG(m_logger) << "Error replying function topic {{ ft.name }} - no replyHandler";
WARNING_LOG(*m_logger) << "Error replying function topic {{ ft.name }} - no replyHandler";
Q_ASSERT(false);
return;
}
@@ -74,7 +74,7 @@ private:
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
LOGGER_T m_logger;
NGL::INGLLogger* m_logger;
};
} // namespace Interface
} // namespace {{ namespace }}
@@ -24,7 +24,7 @@ std::shared_ptr<Fts> Fts::create(const std::shared_ptr<DDSConnector::DdsConnecto
FtsImpl::FtsImpl(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
: Fts()
, m_ddsConnector(ddsConnector)
, m_logger(getLogger("Fts"))
, m_logger(&getLogger("Fts"))
{}
FtsImpl::~FtsImpl()
@@ -34,11 +34,11 @@ FtsImpl::~FtsImpl()
bool FtsImpl::enableAll(bool enable)
{
DEBUG_LOG(m_logger) << "FtsImpl::enableAll(" << (enable ? "true" : "false") << ")";
DEBUG_LOG(*m_logger) << "FtsImpl::enableAll(" << (enable ? "true" : "false") << ")";
{% for ft in functionTopics.member %}
if (!enable{{ ft.name }}(enable))
{
ERROR_LOG(m_logger) << "Error initializing function topic {{ ft.name }}";
ERROR_LOG(*m_logger) << "Error initializing function topic {{ ft.name }}";
return false;
}
{% endfor %}
@@ -55,7 +55,7 @@ bool FtsImpl::enable{{ ft.name }}(bool enable)
{
if (m_fts{{ ft.name }})
{
INFO_LOG(m_logger) << "{{ ft.name }} already enabled!";
INFO_LOG(*m_logger) << "{{ ft.name }} already enabled!";
return true;
}
m_fts{{ ft.name }}.reset(m_ddsConnector->createFTS<FTS::{{ ft.name }}>());
@@ -73,7 +73,7 @@ bool FtsImpl::{{ ft.replyFlc }}(const rti::core::SampleIdentity &cookie, const {
{
if (!m_fts{{ ft.name }})
{
WARNING_LOG(m_logger) << "Error publishing function topic {{ dt.name }} - not enabled";
WARNING_LOG(*m_logger) << "Error publishing function topic {{ dt.name }} - not enabled";
Q_ASSERT(false);
return false;
}
@@ -96,10 +96,10 @@ void FtsImpl::set{{ ft.requestHandler }}({{ ft.requestHandler }} *handler)
void FtsImpl::{{ ft.onRequest }}(const rti::core::SampleIdentity &cookie,
const {{ namespace }}::{{ ft.request }} &request)
{
DEBUG_LOG(m_logger) << "{{ ft.onRequest }}";
DEBUG_LOG(*m_logger) << "{{ ft.onRequest }}";
if (!m_{{ ft.requestHandlerFlc }})
{
WARNING_LOG(m_logger) << "Incoming {{ ft.request }} without registered handler!";
WARNING_LOG(*m_logger) << "Incoming {{ ft.request }} without registered handler!";
Q_ASSERT(false);
return;
}
@@ -8,6 +8,7 @@
{% autoescape off %}
// filename: {{ namespace_abbr }}_fts_impl.h
#pragma once
#include <DDS/FTS/generic_fts_impl.h>
#include <{{ include_prefix }}/{{ namespace_abbr }}_fts.h>
#include <{{ include_prefix }}/{{ namespace_abbr }}_fts_types.h>
#include <{{ include_prefix }}/logger.h>
@@ -58,7 +59,7 @@ private:
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
LOGGER_T m_logger;
NGL::INGLLogger* m_logger;
};
} // namespace Interface
@@ -338,7 +338,7 @@ RecordReplayPlugin::RecordReplayPlugin()
: m_exerciseId(0)
, m_bCanHandleSchemasRead(true)
, m_bCanHandleSchemasWrite(true)
, m_logger(getLogger("RecordReplay"))
, m_logger(&getLogger("RecordReplay"))
{}
RecordReplayPlugin::~RecordReplayPlugin() = default;
@@ -465,7 +465,7 @@ std::map<QString, std::vector<RecordReplayPlugin::RecSnapshot>> RecordReplayPlug
{
// the current snapshot data does not match the starting time -> reread m_{{ dt.nameFlc }}Keys
readLastSnapshotKeysFor{{ dt.name }}(q, nextSampleTime);
//DEBUG_LOG(m_logger) << "fromTime: " << fromTime << ", m_snapshotParticipantMapTime: " << m_snapshotParticipantMapTime
//DEBUG_LOG(*m_logger) << "fromTime: " << fromTime << ", m_snapshotParticipantMapTime: " << m_snapshotParticipantMapTime
// << " - rereading snapshot times! Map now contains " << m_snapshot{{ dt.name }}Map.size() << " entries";
}
@@ -541,7 +541,7 @@ bool RecordReplayPlugin::write{{ dt.name }}(NSqlQuery &q, QHash<QString, qint64>
if (m_dtc{{ dt.name }}->hasSamples())
{
TRACE_LOG(m_logger) << "m_dtc{{ dt.name }}->hasSamples() == true ";
TRACE_LOG(*m_logger) << "m_dtc{{ dt.name }}->hasSamples() == true ";
const QString stmt(QStringLiteral("INSERT INTO ") + getTableName(QStringLiteral("{{ dt.recTable.name }}"), m_bCanHandleSchemasWrite) +
QStringLiteral(" ( dds_is_alive, {% for row in dt.recTable.cppMember %} {{ row.dbColumnName }}{% if not forloop.last %}, {% endif %}{% endfor %}) VALUES "
@@ -551,11 +551,11 @@ bool RecordReplayPlugin::write{{ dt.name }}(NSqlQuery &q, QHash<QString, qint64>
return false;
dds::sub::LoanedSamples<DATA> samples = m_dtc{{ dt.name }}->takeAlive();
TRACE_LOG(m_logger) << "samples count: " << samples.length();
TRACE_LOG(*m_logger) << "samples count: " << samples.length();
for (const auto &sample : samples)
{
const DATA &data = sample.data();
INFO_LOG(m_logger) << "m_dtc{{ dt.name }} {{ dt.recTable.ddsKey.cppMemberName }}: " << data.{{ dt.recTable.ddsKey.cppMemberName }}();
INFO_LOG(*m_logger) << "m_dtc{{ dt.name }} {{ dt.recTable.ddsKey.cppMemberName }}: " << data.{{ dt.recTable.ddsKey.cppMemberName }}();
{% for row in dt.recTable.cppMember %}
q.bindValue(QStringLiteral(":{{ row.dbColumnName }}"), {{ row.ddsToQVariant }});
@@ -579,7 +579,7 @@ bool RecordReplayPlugin::write{{ dt.name }}(NSqlQuery &q, QHash<QString, qint64>
if (!q.prepare(stmt))
return false;
DEBUG_LOG(m_logger) << "disposedSamples count: " << disposedSamples.length();
DEBUG_LOG(*m_logger) << "disposedSamples count: " << disposedSamples.length();
auto dr = m_dtc{{ dt.name }}->dataReader()->dataReader();
{{ dt.name }} data;
for (const auto &sample : disposedSamples)
@@ -615,12 +615,12 @@ bool RecordReplayPlugin::readLastSnapshotFor{{ dt.name }}(NSqlQuery &q, qint64 s
if (!q.exec(stmt))
{
ERROR_LOG(m_logger) << "Error while fetch max(time_stamp) for topic {{ dt.name }}";
ERROR_LOG(*m_logger) << "Error while fetch max(time_stamp) for topic {{ dt.name }}";
return false;
}
if (!q.next() || q.value(0).isNull())
{
INFO_LOG(m_logger) << "No snapshot available for topic {{ dt.name }}";
INFO_LOG(*m_logger) << "No snapshot available for topic {{ dt.name }}";
return true;
}
const qint64 idSnapshot = q.value(0).toLongLong();
@@ -693,7 +693,7 @@ bool RecordReplayPlugin::updateSnapshotKeys{{ dt.name }}(NSqlQuery &q, qint64 fr
QStringLiteral(" AND sample_time <= ") + QString::number(toTime) +
QStringLiteral(" ORDER BY sample_time "));
DEBUG_LOG(m_logger) << "stmt: " << stmt;
DEBUG_LOG(*m_logger) << "stmt: " << stmt;
if (!q.exec(stmt))
return false;
@@ -705,13 +705,13 @@ bool RecordReplayPlugin::updateSnapshotKeys{{ dt.name }}(NSqlQuery &q, qint64 fr
const bool isAlive = q.value(2).toBool();
if (isAlive)
{
DEBUG_LOG(m_logger) << "INSERT {{ dt.name }} key: " << key << ", pk: " << pk << ", isAlive: " << isAlive;
DEBUG_LOG(*m_logger) << "INSERT {{ dt.name }} key: " << key << ", pk: " << pk << ", isAlive: " << isAlive;
m_snapshot{{ dt.name }}Map[key] = pk;
m_{{ dt.nameFlc }}Keys.insert(key);
}
else
{
DEBUG_LOG(m_logger) << "REMOVE {{ dt.name }} key: " << key << ", pk: " << pk << ", isAlive: " << isAlive;
DEBUG_LOG(*m_logger) << "REMOVE {{ dt.name }} key: " << key << ", pk: " << pk << ", isAlive: " << isAlive;
m_snapshot{{ dt.name }}Map.erase(key);
m_{{ dt.nameFlc }}Keys.erase(key);
}
@@ -720,7 +720,7 @@ bool RecordReplayPlugin::updateSnapshotKeys{{ dt.name }}(NSqlQuery &q, qint64 fr
// new validity time for snapshot data
m_snapshot{{ dt.name }}MapTime = toTime;
DEBUG_LOG(m_logger) << "updateSnapshotKeys{{ dt.name }}(" << fromTime << ", " << toTime << ") = "
DEBUG_LOG(*m_logger) << "updateSnapshotKeys{{ dt.name }}(" << fromTime << ", " << toTime << ") = "
<< m_snapshot{{ dt.name }}Map.size();
return true;
@@ -737,13 +737,13 @@ bool RecordReplayPlugin::readLastSnapshotKeysFor{{ dt.name }}(NSqlQuery &q, qint
return false;
if (!q.next() || q.value(0).isNull())
{
DEBUG_LOG(m_logger) << "no snapshot entry for {{ dt.name }} found";
DEBUG_LOG(*m_logger) << "no snapshot entry for {{ dt.name }} found";
return true;
}
m_snapshot{{ dt.name }}Map = LtsUtils::BigintArray2D::fromPgString(q.value(0).toString())();
DEBUG_LOG(m_logger) << "Map size {{ dt.name }}: " << m_snapshot{{ dt.name }}Map.size();
DEBUG_LOG(*m_logger) << "Map size {{ dt.name }}: " << m_snapshot{{ dt.name }}Map.size();
return true;
}
@@ -758,7 +758,7 @@ qint64 RecordReplayPlugin::getNextSampleTimeFor{{ dt.name }}(NSqlQuery &q, qint6
if (q.execAndFetch(stmt) && !q.value(0).isNull())
ret = q.value(0).toLongLong();
DEBUG_LOG(m_logger) << "next min sampleTime for {{ dt.name }} is " << ret << " (> " << fromTime << ")";
DEBUG_LOG(*m_logger) << "next min sampleTime for {{ dt.name }} is " << ret << " (> " << fromTime << ")";
return ret;
}
@@ -812,12 +812,12 @@ bool RecordReplayPlugin::copyInitialData{{ dt.name }}(NSqlQuery &queryFrom, NSql
if (!queryFrom.exec(stmt))
{
ERROR_LOG(m_logger) << "Error while fetch max(time_stamp) for topic {{ dt.name }}";
ERROR_LOG(*m_logger) << "Error while fetch max(time_stamp) for topic {{ dt.name }}";
return false;
}
if (!queryFrom.next() || queryFrom.value(0).isNull())
{
INFO_LOG(m_logger) << "No snapshot available for topic {{ dt.name }}";
INFO_LOG(*m_logger) << "No snapshot available for topic {{ dt.name }}";
return true;
}
const qint64 idSnapshot = queryFrom.value(0).toLongLong();
@@ -119,7 +119,7 @@ protected:
int64_t m_snapshot{{ dt.name }}MapTime = -1; // time for which the snapshot is valid
{% endif %} {% endfor %}
LOGGER_T m_logger;
NGL::INGLLogger* m_logger;
};
}
@@ -4,31 +4,8 @@
#include <QtCore/QDataStream>
using namespace LtsUtils;
double QPoint3D::distanceToLine(const QPoint3D& point, const QPoint3D& direction) const
namespace LtsUtils
{
if (direction.isNull())
return (*this - point).length();
QPoint3D p = point + dotProduct(*this - point, direction) * direction;
return (*this - p).length();
}
double QPoint3D::distanceToPlane(const QPoint3D& plane, const QPoint3D& normal) const
{
return dotProduct(*this - plane, normal);
}
double QPoint3D::distanceToPlane(const QPoint3D& plane1, const QPoint3D& plane2, const QPoint3D& plane3) const
{
QPoint3D n = normal(plane2 - plane1, plane3 - plane1);
return dotProduct(*this - plane1, n);
}
double QPoint3D::distanceToPoint(const QPoint3D& point) const
{
return (*this - point).length();
}
QDataStream& operator<<(QDataStream& s, const QPoint3D& p)
{
@@ -47,3 +24,5 @@ QDataStream& operator>>(QDataStream& s, QPoint3D& p)
p.rz() = z;
return s;
}
} // namespace LtsUtils
@@ -6,6 +6,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qdatastream.h>
#include <cmath>
#include <sstream>
@@ -17,8 +18,8 @@ class QPoint3D
public:
enum class Axis { X, Y, Z };
Q_DECL_CONSTEXPR QPoint3D() = default;
Q_DECL_CONSTEXPR QPoint3D(double xpos, double ypos, double zpos);
constexpr QPoint3D() = default;
constexpr QPoint3D(double xpos, double ypos, double zpos);
template <typename T> explicit QPoint3D(const T& data) : xp(data.offsetX()), yp(data.offsetY()), zp(data.offsetZ())
{
@@ -26,18 +27,18 @@ class QPoint3D
inline bool isNull() const;
Q_DECL_CONSTEXPR inline double x() const;
Q_DECL_CONSTEXPR inline double y() const;
Q_DECL_CONSTEXPR inline double z() const;
Q_DECL_RELAXED_CONSTEXPR inline void setX(double xpos);
Q_DECL_RELAXED_CONSTEXPR inline void setY(double ypos);
Q_DECL_RELAXED_CONSTEXPR inline void setZ(double zpos);
constexpr inline double x() const;
constexpr inline double y() const;
constexpr inline double z() const;
constexpr inline void setX(double xpos);
constexpr inline void setY(double ypos);
constexpr inline void setZ(double zpos);
Q_DECL_RELAXED_CONSTEXPR inline double& rx();
Q_DECL_RELAXED_CONSTEXPR inline double& ry();
Q_DECL_RELAXED_CONSTEXPR inline double& rz();
constexpr inline double& rx();
constexpr inline double& ry();
constexpr inline double& rz();
Q_DECL_CONSTEXPR inline QPointF toPointF() const;
constexpr inline QPointF toPointF() const;
static QPoint3D fromQPointF(const QPointF& p)
{
@@ -115,40 +116,56 @@ class QPoint3D
return p;
}
inline double distanceToLine(const QPoint3D& point, const QPoint3D& direction) const;
inline double distanceToPlane(const QPoint3D& plane, const QPoint3D& normal) const;
inline double distanceToPlane(const QPoint3D& plane1, const QPoint3D& plane2, const QPoint3D& plane3) const;
inline double distanceToPoint(const QPoint3D& point) const;
inline double distanceToLine(const QPoint3D& point, const QPoint3D& direction) const
{
if (direction.isNull())
return (*this - point).length();
QPoint3D p = point + dotProduct(*this - point, direction) * direction;
return (*this - p).length();
}
inline double distanceToPlane(const QPoint3D& plane, const QPoint3D& normal) const
{
return dotProduct(*this - plane, normal);
}
inline double distanceToPlane(const QPoint3D& plane1, const QPoint3D& plane2, const QPoint3D& plane3) const
{
QPoint3D n = normal(plane2 - plane1, plane3 - plane1);
return dotProduct(*this - plane1, n);
}
inline double distanceToPoint(const QPoint3D& point) const
{
return (*this - point).length();
}
friend Q_DECL_CONSTEXPR inline bool operator==(const QPoint3D& p1, const QPoint3D& p2);
friend Q_DECL_CONSTEXPR inline bool operator!=(const QPoint3D& p1, const QPoint3D& p2);
friend constexpr inline bool operator==(const QPoint3D& p1, const QPoint3D& p2);
friend constexpr inline bool operator!=(const QPoint3D& p1, const QPoint3D& p2);
friend Q_DECL_CONSTEXPR inline QPoint3D operator+(const QPoint3D& p1, const QPoint3D& p2)
friend constexpr inline QPoint3D operator+(const QPoint3D& p1, const QPoint3D& p2)
{
return QPoint3D(p1.xp + p2.xp, p1.yp + p2.yp, p1.zp + p2.zp);
}
friend Q_DECL_CONSTEXPR inline QPoint3D operator-(const QPoint3D& p1, const QPoint3D& p2)
friend constexpr inline QPoint3D operator-(const QPoint3D& p1, const QPoint3D& p2)
{
return QPoint3D(p1.xp - p2.xp, p1.yp - p2.yp, p1.zp - p2.zp);
}
friend Q_DECL_CONSTEXPR inline QPoint3D operator*(const QPoint3D& p1, double factor)
friend constexpr inline QPoint3D operator*(const QPoint3D& p1, double factor)
{
return QPoint3D(p1.xp * factor, p1.yp * factor, p1.zp * factor);
}
friend Q_DECL_CONSTEXPR inline QPoint3D operator*(double factor, const QPoint3D& p1)
friend constexpr inline QPoint3D operator*(double factor, const QPoint3D& p1)
{
return QPoint3D(p1.xp * factor, p1.yp * factor, p1.zp * factor);
}
friend Q_DECL_CONSTEXPR inline QPoint3D operator/(const QPoint3D& p1, double factor)
friend constexpr inline QPoint3D operator/(const QPoint3D& p1, double factor)
{
return QPoint3D(p1.xp / factor, p1.yp / factor, p1.zp / factor);
}
Q_DECL_RELAXED_CONSTEXPR inline QPoint3D& operator+=(const QPoint3D& o)
constexpr inline QPoint3D& operator+=(const QPoint3D& o)
{
xp += o.xp;
yp += o.yp;
@@ -156,7 +173,7 @@ class QPoint3D
return *this;
}
Q_DECL_RELAXED_CONSTEXPR inline QPoint3D& operator-=(const QPoint3D& o)
constexpr inline QPoint3D& operator-=(const QPoint3D& o)
{
xp -= o.xp;
yp -= o.yp;
@@ -164,7 +181,7 @@ class QPoint3D
return *this;
}
Q_DECL_RELAXED_CONSTEXPR inline QPoint3D& operator*=(double factor)
constexpr inline QPoint3D& operator*=(double factor)
{
xp *= factor;
yp *= factor;
@@ -172,7 +189,7 @@ class QPoint3D
return *this;
}
Q_DECL_RELAXED_CONSTEXPR inline QPoint3D& operator/=(double divisor)
constexpr inline QPoint3D& operator/=(double divisor)
{
xp /= divisor;
yp /= divisor;
@@ -180,12 +197,12 @@ class QPoint3D
return *this;
}
Q_DECL_CONSTEXPR static inline double dotProduct(const QPoint3D& v1, const QPoint3D& v2)
constexpr static inline double dotProduct(const QPoint3D& v1, const QPoint3D& v2)
{
return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp;
}
Q_DECL_CONSTEXPR static inline QPoint3D crossProduct(const QPoint3D& v1, const QPoint3D& v2)
constexpr static inline QPoint3D crossProduct(const QPoint3D& v1, const QPoint3D& v2)
{
return QPoint3D(v1.yp * v2.zp - v1.zp * v2.yp, v1.zp * v2.xp - v1.xp * v2.zp, v1.xp * v2.yp - v1.yp * v2.xp);
}
@@ -200,7 +217,10 @@ class QPoint3D
return crossProduct((v2 - v1), (v3 - v1)).normalized();
}
Q_DECL_CONSTEXPR friend inline bool qFuzzyCompare(const QPoint3D& v1, const QPoint3D& v2);
friend inline bool qFuzzyCompare(const QPoint3D& v1, const QPoint3D& v2)
{
return ::qFuzzyCompare(v1.xp, v2.xp) && ::qFuzzyCompare(v1.yp, v2.yp) && ::qFuzzyCompare(v1.zp, v2.zp);
}
private:
double xp = 0;
@@ -208,81 +228,76 @@ class QPoint3D
double zp = 0;
};
LTSUTILSCORE_EXPORT QDataStream& operator<<(QDataStream& s, const QPoint3D& p);
LTSUTILSCORE_EXPORT QDataStream& operator>>(QDataStream& s, QPoint3D& p);
// QDataStream& operator<<(QDataStream& s, const QPoint3D& p);
// QDataStream& operator>>(QDataStream& s, QPoint3D& p);
Q_DECL_CONSTEXPR inline QPoint3D::QPoint3D(double xpos, double ypos, double zpos) : xp(xpos), yp(ypos), zp(zpos) {}
constexpr inline QPoint3D::QPoint3D(double xpos, double ypos, double zpos) : xp(xpos), yp(ypos), zp(zpos) {}
inline bool QPoint3D::isNull() const
{
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
}
Q_DECL_CONSTEXPR inline double QPoint3D::x() const
constexpr inline double QPoint3D::x() const
{
return xp;
}
Q_DECL_CONSTEXPR inline double QPoint3D::y() const
constexpr inline double QPoint3D::y() const
{
return yp;
}
Q_DECL_CONSTEXPR inline double QPoint3D::z() const
constexpr inline double QPoint3D::z() const
{
return zp;
}
Q_DECL_RELAXED_CONSTEXPR inline void QPoint3D::setX(double xpos)
constexpr inline void QPoint3D::setX(double xpos)
{
xp = xpos;
}
Q_DECL_RELAXED_CONSTEXPR inline void QPoint3D::setY(double ypos)
constexpr inline void QPoint3D::setY(double ypos)
{
yp = ypos;
}
Q_DECL_RELAXED_CONSTEXPR inline void QPoint3D::setZ(double zpos)
constexpr inline void QPoint3D::setZ(double zpos)
{
zp = zpos;
}
Q_DECL_RELAXED_CONSTEXPR inline double& QPoint3D::rx()
constexpr inline double& QPoint3D::rx()
{
return xp;
}
Q_DECL_RELAXED_CONSTEXPR inline double& QPoint3D::ry()
constexpr inline double& QPoint3D::ry()
{
return yp;
}
Q_DECL_RELAXED_CONSTEXPR inline double& QPoint3D::rz()
constexpr inline double& QPoint3D::rz()
{
return zp;
}
Q_DECL_CONSTEXPR inline QPointF QPoint3D::toPointF() const
constexpr inline QPointF QPoint3D::toPointF() const
{
return QPointF(xp, yp);
}
Q_DECL_CONSTEXPR inline bool operator==(const QPoint3D& p1, const QPoint3D& p2)
constexpr inline bool operator==(const QPoint3D& p1, const QPoint3D& p2)
{
return p1.xp == p2.xp && p1.yp == p2.yp && p1.zp == p2.zp;
}
Q_DECL_CONSTEXPR inline bool operator!=(const QPoint3D& p1, const QPoint3D& p2)
constexpr inline bool operator!=(const QPoint3D& p1, const QPoint3D& p2)
{
return p1.xp != p2.xp || p1.yp != p2.yp || p1.zp != p2.zp;
}
Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QPoint3D& v1, const QPoint3D& v2)
{
return ::qFuzzyCompare(v1.xp, v2.xp) && ::qFuzzyCompare(v1.yp, v2.yp) && ::qFuzzyCompare(v1.zp, v2.zp);
}
inline std::ostream& operator<<(std::ostream& stream, const QPoint3D& pos)
{
stream << "(" << pos.x() << "," << pos.y() << "," << pos.z() << ")";
@@ -291,4 +306,4 @@ inline std::ostream& operator<<(std::ostream& stream, const QPoint3D& pos)
} // namespace LtsUtils
Q_DECLARE_TYPEINFO(LtsUtils::QPoint3D, Q_MOVABLE_TYPE);
// Q_DECLARE_METATYPE(LtsUtils::QPoint3D)
@@ -1,6 +1,11 @@
#pragma once
// Include Qt headers FIRST to prevent namespace pollution when RTI DDS headers include Qt
#include <QtCore/QString>
#include <QtCore/QUrl>
#include <QtCore/QFlag>
#include <LtsUtils/LtsUtilsCore/data_modification_enum.h>
#include <dds/sub/LoanedSamples.hpp>
@@ -36,6 +41,18 @@ template <typename DRO_OBJECT>
class GenericDtc
: public GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, DataModification)>>
{
public:
using BaseClass = GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, DataModification)>>;
using TopicType = typename BaseClass::TopicType;
// Explicitly expose base class methods for accessibility through smart pointers
void setSubscriberCallback(std::function<void(const TopicType&, DataModification)> callback) { BaseClass::setSubscriberCallback(callback); }
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
bool hasSamples() const { return BaseClass::hasSamples(); }
std::shared_ptr<DRO_OBJECT> dataReader() { return BaseClass::dataReader(); }
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
};
template <typename DRO_OBJECT>
@@ -43,6 +60,18 @@ class GenericDtcSampleInfo
: public GenericDtcSC<DRO_OBJECT,
std::function<void(const typename DRO_OBJECT::TopicType&, const dds::sub::SampleInfo&)>>
{
public:
using BaseClass = GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const dds::sub::SampleInfo&)>>;
using TopicType = typename BaseClass::TopicType;
// Explicitly expose base class methods for accessibility through smart pointers
void setSubscriberCallback(std::function<void(const TopicType&, const dds::sub::SampleInfo&)> callback) { BaseClass::setSubscriberCallback(callback); }
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
bool hasSamples() const { return BaseClass::hasSamples(); }
std::shared_ptr<DRO_OBJECT> dataReader() { return BaseClass::dataReader(); }
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
};
template <typename DRO_OBJECT>
@@ -50,6 +79,18 @@ class Ddtc
: public GenericDtcSC<
DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const std::string&, DataModification)>>
{
public:
using BaseClass = GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const std::string&, DataModification)>>;
using TopicType = typename BaseClass::TopicType;
// Explicitly expose base class methods for accessibility through smart pointers
void setSubscriberCallback(std::function<void(const TopicType&, const std::string&, DataModification)> callback) { BaseClass::setSubscriberCallback(callback); }
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
bool hasSamples() const { return BaseClass::hasSamples(); }
std::shared_ptr<DRO_OBJECT> dataReader() { return BaseClass::dataReader(); }
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
};
template <typename DRO_OBJECT>
@@ -57,5 +98,17 @@ class DdtcSampleInfo
: public GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const std::string&,
const dds::sub::SampleInfo&)>>
{
public:
using BaseClass = GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const std::string&, const dds::sub::SampleInfo&)>>;
using TopicType = typename BaseClass::TopicType;
// Explicitly expose base class methods for accessibility through smart pointers
void setSubscriberCallback(std::function<void(const TopicType&, const std::string&, const dds::sub::SampleInfo&)> callback) { BaseClass::setSubscriberCallback(callback); }
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
bool hasSamples() const { return BaseClass::hasSamples(); }
std::shared_ptr<DRO_OBJECT> dataReader() { return BaseClass::dataReader(); }
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
};
} // namespace DTC
@@ -2,19 +2,22 @@
#pragma once
// Include Qt headers FIRST to prevent namespace pollution when RTI DDS headers include Qt
#include <QtCore/QString>
#include <QtCore/QUrl>
#include <QtCore/QFlag>
#include <QtCore/QTimer>
#include "generic_dtc.h"
#include <DDS/Generic/generic_data_reader.h>
#include <DDS/Generic/generic_logger.h>
#include <DDS/Generic/subscriber_listener.h>
#include <QtCore/QTimer>
#include <dds/core/cond/StatusCondition.hpp>
#include <dds/core/cond/WaitSet.hpp>
namespace DDSGeneric
{
class DynamicDataReader;
}
} // namespace DDSGeneric
namespace DTC
{
@@ -154,7 +157,7 @@ class GenericDtcImplSubscriberTemplate : public DDSGeneric::SubscriberListenerCa
if (dr.subscription_matched_status().current_count() == 0)
{
dds::core::cond::WaitSet ws;
dds::core::cond::StatusCondition cond(dr);
auto cond = dds::core::cond::StatusCondition(dr);
cond.enabled_statuses(dds::core::status::StatusMask::subscription_matched());
ws.attach_condition(cond);
const dds::core::Duration waitTimeout(bWaitForever ? dds::core::Duration::infinite()
@@ -4,7 +4,15 @@
#if BUILD_RTI
// Include Qt headers FIRST, before any other includes, to prevent Qt symbols
// from being resolved in connext namespace when RTI DDS headers include Qt
#include <QtCore/QString>
#include <QtCore/QUrl>
#include <QtCore/QFlag>
#include <QtCore/QByteArray>
#include <NGLLogger/NGLLoggerBootstrap.h>
#include "TrainingAreaBase/logger.h"
#include <dds/core/cond/GuardCondition.hpp>
#include <dds/core/cond/StatusCondition.hpp>
#include <dds/core/cond/WaitSet.hpp>
@@ -282,7 +290,7 @@ template <typename REQUEST, typename REPLY> class Requester final : public Reply
, m_dataReader(nullptr)
, m_contentFilteredTopic(nullptr)
, m_curInstanceHandle(dds::core::InstanceHandle::nil())
, m_logger(NGL::getNGLLogger("connext.requester"))
{
}
@@ -312,7 +320,7 @@ template <typename REQUEST, typename REPLY> class Requester final : public Reply
m_contentFilteredTopic->filter(dds::topic::Filter(filterContent.data()));
}
DEBUG_LOG(m_logger) << "content filter for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
DEBUG_LOG(::TrainingAreaBase::getLogger("connext")) << "content filter for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
<< " - related_sample_identity should be: " << writerGuid;
}
@@ -345,7 +353,7 @@ template <typename REQUEST, typename REPLY> class Requester final : public Reply
m_dataWriter->write(request.data(), request.info());
const rti::core::SampleIdentity currentSampleIdentity = request.info().identity();
DEBUG_LOG(m_logger) << "send_request for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
DEBUG_LOG(::TrainingAreaBase::getLogger("connext")) << "send_request for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
<< ", m_currentSampleIdentity: " << DebugInfo::toReadable(currentSampleIdentity);
}
@@ -362,13 +370,13 @@ template <typename REQUEST, typename REPLY> class Requester final : public Reply
if (m_dataReader->take(reply.data(), reply.info()) && reply.info().valid())
{
DEBUG_LOG(m_logger) << "receive_reply for topic "
DEBUG_LOG(::TrainingAreaBase::getLogger("connext")) << "receive_reply for topic "
<< ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
<< ", SampleIdentity - original publication virtual: "
<< DebugInfo::toReadable(
reply.info()->original_publication_virtual_sample_identity());
DEBUG_LOG(m_logger) << "receive_reply for topic "
DEBUG_LOG(::TrainingAreaBase::getLogger("connext")) << "receive_reply for topic "
<< ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
<< ", SampleIdentity - related original: "
<< DebugInfo::toReadable(
@@ -381,7 +389,7 @@ template <typename REQUEST, typename REPLY> class Requester final : public Reply
dds::core::cond::WaitSet::ConditionSeq activeConditionsSeq = waitset.wait(duration);
if (activeConditionsSeq.empty())
{
ERROR_LOG(m_logger) << "Bailing out!";
ERROR_LOG(::TrainingAreaBase::getLogger("connext")) << "Bailing out!";
break;
}
}
@@ -392,7 +400,7 @@ template <typename REQUEST, typename REPLY> class Requester final : public Reply
if (!m_curInstanceHandle.is_nil())
{
DEBUG_LOG(m_logger) << "Keyed topic - disposing instance: "
DEBUG_LOG(::TrainingAreaBase::getLogger("connext")) << "Keyed topic - disposing instance: "
<< ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name();
m_dataWriter.dispose_instance(m_curInstanceHandle);
}
@@ -431,7 +439,7 @@ template <typename REQUEST, typename REPLY> class Replier final : public ReplyRe
, m_dataReader(dds::sub::DataReader<REQUEST>(replierParams.subscriber(),
ReplyRequestBase<REQUEST, REPLY>::m_requestTopic,
replierParams.datareader_qos()))
, m_logger(NGL::getNGLLogger("connext.replier"))
{
}
@@ -447,7 +455,7 @@ template <typename REQUEST, typename REPLY> class Replier final : public ReplyRe
void send_reply(connext::WriteSampleRef<REPLY>& reply, const rti::core::SampleIdentity& identity,
bool bLastSample = true)
{
DEBUG_LOG(m_logger) << "send_reply for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
DEBUG_LOG(::TrainingAreaBase::getLogger("connext")) << "send_reply for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
<< ", sampleIdentity: " << DebugInfo::toReadable(identity);
rti::core::SampleFlag sf = reply.info().flag();
@@ -457,7 +465,7 @@ template <typename REQUEST, typename REPLY> class Replier final : public ReplyRe
sf |= rti::core::SampleFlag::intermediate_reply_sequence();
reply.info().flag(sf);
reply.info().related_sample_identity(identity);
DEBUG_LOG(m_logger) << "send_reply for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
DEBUG_LOG(::TrainingAreaBase::getLogger("connext")) << "send_reply for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
<< ", related sampleIdentity: "
<< DebugInfo::toReadable(reply.info().related_sample_identity());
@@ -471,7 +479,7 @@ template <typename REQUEST, typename REPLY> class Replier final : public ReplyRe
if (request.info().valid())
{
DEBUG_LOG(m_logger) << "receive_request for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
DEBUG_LOG(::TrainingAreaBase::getLogger("connext")) << "receive_request for topic " << ReplyRequestBase<REQUEST, REPLY>::m_requestTopic.name()
<< ", sampleIdentity publication_virtual_sample_identity: "
<< DebugInfo::toReadable(request.info()->publication_virtual_sample_identity())
<< ", original_publication_virtual_sample_identity: "
@@ -9,6 +9,7 @@
#include <DDS/Core/core.hpp>
#include <DDS/FTS/generic_fts.h>
#include "generic_fts_internal.h"
#include "connext.h"
#include <DDS/Generic/wait_set_handler.h>
@@ -63,8 +64,8 @@ private:
connext::WriteSample<ReplyTopic> reply;
reply.data().replyState(replyState);
bool bLastTelegram = ((replyState != Core::FtReplyState_def::InProgress) &&
(replyState != Core::FtReplyState_def::NotStarted));
bool bLastTelegram = ((replyState != Core::FtReplyState::InProgress) &&
(replyState != Core::FtReplyState::NotStarted));
m_replier->send_reply(reply, requestSampleIdentity, bLastTelegram);
}
@@ -233,8 +234,8 @@ protected:
<< "[s], -> age: " << age
<< "[s], data: " << s;
ReplyTopic rt;
rt.errorString(tr_lts("dds", "Topic %1 was outdated and therefore ignored. Does the client time match the server time?"));
rt.errorParams({TopicNameHelper::requestTopicName()});
rt.errorString = tr_lts("dds", "Topic %1 was outdated and therefore ignored. Does the client time match the server time?");
rt.errorParams = {TopicNameHelper::requestTopicName()};
sendReply(request.identity(), rt);
return;
}
@@ -2,8 +2,13 @@
#pragma once
#include <DDS/Generic/generic_base.h>
// Include ALL headers BEFORE opening DDSGeneric namespace to prevent Qt symbols
// from being resolved in DDSGeneric namespace when RTI DDS headers include Qt
#include <QtCore/QString>
#include <QtCore/QUrl>
#include <QtCore/QFlag>
#include <DDS/Generic/generic_logger.h>
#include <DDS/Generic/generic_base.h>
#include <LtsUtils/LtsUtilsCore/data_modification_enum.h>
#include <dds/core/xtypes/StructType.hpp>
#include <dds/sub/DataReader.hpp>
@@ -2,6 +2,10 @@
#pragma once
// Include Qt headers FIRST to prevent namespace pollution when RTI DDS headers include Qt
#include <QtCore/QString>
#include <QtCore/QUrl>
#include <QtCore/QFlag>
#include <DDS/Generic/generic_base.h>
#include <DDS/Generic/generic_logger.h>
#include <LtsUtils/LtsUtilsCore/data_modification_enum.h>
@@ -2,6 +2,10 @@
#pragma once
// Include Qt headers FIRST to prevent namespace pollution when RTI DDS headers include Qt
#include <QtCore/QString>
#include <QtCore/QUrl>
#include <QtCore/QFlag>
#include <DDS/Generic/generic_base.h>
#include <DDS/Generic/generic_logger.h>
#include <dds/pub/DataWriter.hpp>
@@ -2,19 +2,16 @@
#pragma once
#include <QMetaMethod>
// Include Qt headers FIRST to prevent namespace pollution when RTI DDS headers include Qt
#include <QtCore/QObject>
#include <QtCore/QMetaMethod>
#include <QtCore/QReadWriteLock>
#include <NGLLogger/INGLLogger.h>
#include <dds/sub/AnyDataReader.hpp>
#include <dds/sub/SubscriberListener.hpp>
#include <dds/topic/Topic.hpp>
#include <ddsgen_export.h>
namespace NGL
{
class INGLLogger;
}
namespace DDSGeneric
{
class DDSGEN_EXPORT SubscriberListenerCallback : public QObject
@@ -2,6 +2,10 @@
#pragma once
// Include Qt headers FIRST to prevent namespace pollution when RTI DDS headers include Qt
#include <QtCore/QString>
#include <QtCore/QUrl>
#include <QtCore/QFlag>
#include <dds/core/xtypes/StructType.hpp>
namespace DDSGeneric
@@ -2,6 +2,10 @@
#pragma once
// Include Qt headers FIRST to prevent namespace pollution when RTI DDS headers include Qt
#include <QtCore/QString>
#include <QtCore/QUrl>
#include <QtCore/QFlag>
#include <dds/core/cond/Condition.hpp>
#include <dds/core/cond/GuardCondition.hpp>
#include <dds/core/cond/WaitSet.hpp>
@@ -45,6 +45,7 @@ NGL_TARGET_LINK_LIBRARIES(BuildingControlBsm
Qt6::Core
Qt6::Network
BuildingControlCommon
svcTabCommon
)
NGL_ADD_EXECUTABLE(AAR SV BuildingControlTestBsm bsm_test_main.cpp)
@@ -52,3 +53,4 @@ NGL_TARGET_LINK_LIBRARIES(BuildingControlTestBsm
BuildingControlBsm
nglcoreapplication
)
add_test(NAME bld_bsm_test COMMAND $<TARGET_FILE:BuildingControlTestBsm>)
@@ -11,7 +11,7 @@ namespace BSM
Api::Api(QObject *parent)
: QObject(parent)
, m_socketHandler(new SocketHandler(this))
, m_logger(BuildingControlUnit::getLogger("BSM.Api"))
, m_logger(TrainingAreaBase::getLogger("BSM.Api"))
{
connect(m_socketHandler, &SocketHandler::opticalShot,
this, &Api::opticalShot);
@@ -18,7 +18,7 @@ Socket::Socket(const Bsm &cfg, QObject *parent)
, m_tcpSocket(new QTcpSocket(this))
, m_reconnectTimer(nullptr)
, m_aliveTimer(new QTimer(this))
, m_logger(BuildingControlUnit::getLogger("BSM.Socket"))
, m_logger(TrainingAreaBase::getLogger("BSM.Socket"))
{
m_aliveTimer->setTimerType(Qt::VeryCoarseTimer);
m_aliveTimer->setSingleShot(true);
@@ -29,7 +29,7 @@ Socket::Socket(const Bsm &cfg, QObject *parent)
this, &Socket::onConnected);
connect(m_tcpSocket, &QTcpSocket::disconnected,
this, &Socket::onDisconnected);
connect(m_tcpSocket, QOverload<QAbstractSocket::SocketError>::of(&QTcpSocket::error),
connect(m_tcpSocket, &QTcpSocket::errorOccurred,
this, &Socket::onError);
connect(m_tcpSocket, &QTcpSocket::readyRead,
this, &Socket::onReadyRead);
@@ -23,7 +23,7 @@ static const qint64 s_opticalTimeSlot = 100;
SocketHandler::SocketHandler(QObject *parent)
: QObject(parent)
, m_logger(BuildingControlUnit::getLogger("BSM.SocketHandler"))
, m_logger(TrainingAreaBase::getLogger("BSM.SocketHandler"))
{
connect(&m_cleanupQueueTimer, &QTimer::timeout,
this, &SocketHandler::onCleanupQueue);
@@ -99,7 +99,7 @@ QByteArray Telegram::toBytestream() const
Telegram *Telegram::telegramFromBytestream(const QByteArray &data_)
{
NGL::INGLLogger &logger = BuildingControlUnit::getLogger("BSM.Telegrams");
NGL::INGLLogger &logger = TrainingAreaBase::getLogger("BSM.Telegrams");
QByteArray data = desubstituteData(data_);
if (data.size() < 2)
return nullptr;
@@ -35,7 +35,7 @@ QByteArray PanDirectFire::payload() const
Telegram *PanDirectFire::fromBytestream(const QByteArray &data)
{
NGL::INGLLogger &logger = getLogger("PanDirectFire");
NGL::INGLLogger &logger = TrainingAreaBase::getLogger("PanDirectFire");
DEBUG_LOG(logger) << "data.length=" << data.length();
if (data.length() < 9)
return nullptr;
@@ -4,16 +4,20 @@
# $Author:
#
# Make ${Qt6_WebSockets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::WebSockets)
set(Qt6_WebSockets ${Qt6_WebSockets})
# Make ${Qt6_WebSockets} optional (doesn't require GUI)
if(TARGET Qt6::WebSockets)
set(Qt6_WebSockets Qt6::WebSockets)
set(BUILDINGCONTROLJSON_AVAILABLE TRUE)
else()
set(Qt6_WebSockets "")
set(BUILDINGCONTROLJSON_AVAILABLE FALSE)
endif()
ADD_SUBDIRECTORY(BSM)
ADD_SUBDIRECTORY(Json)
if(BUILDINGCONTROLJSON_AVAILABLE)
ADD_SUBDIRECTORY(Json)
endif()
ADD_SUBDIRECTORY(VWM)
ADD_SUBDIRECTORY(ControlEffects)
@@ -51,6 +55,9 @@ NGL_TARGET_LINK_LIBRARIES(BuildingControlCommon
NGL_TARGET_INCLUDE_DIRECTORIES(BuildingControlCommon
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/Lts/Proxies/Buildings/BuildingControlUnit
${CMAKE_SOURCE_DIR}/Lts/Proxies/TrainingAreaBase
${CMAKE_BINARY_DIR}/Lts/Proxies/TrainingAreaBase
)
NGL_ADD_EXECUTABLE(AAR SV BuildingControlUnit ${bc_SRCS})
@@ -63,7 +70,7 @@ NGL_TARGET_LINK_LIBRARIES(BuildingControlUnit
Qt6::Concurrent
BuildingControlBsm
BuildingControlCommon
BuildingControlJson
$<$<BOOL:${BUILDINGCONTROLJSON_AVAILABLE}>:BuildingControlJson>
BuildingControlVwm
ControlEffects
LtsCommandLineParser
@@ -4,9 +4,9 @@
# $Author$
#
# Make ${Qt6_WebSockets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::WebSockets)
set(Qt6_WebSockets ${Qt6_WebSockets})
# Make ${Qt6_WebSockets} optional (doesn't require GUI)
if(TARGET Qt6::WebSockets)
set(Qt6_WebSockets Qt6::WebSockets)
else()
set(Qt6_WebSockets "")
endif()
@@ -31,18 +31,22 @@ SET(vwm_SRCS
)
NGL_ADD_LIBRARY2(AAR SV BuildingControlVwm SHARED ${vwm_SRCS})
if(QT6_GUI_AVAILABLE)
NGL_TARGET_LINK_LIBRARIES(BuildingControlVwm
PRIVATE
ngltools
Qt6::Xml
PUBLIC
Qt6::Core
${Qt6_Gui}
LtsUtilsCoreHeaderOnly
BuildingControlCommon
)
endif()
NGL_TARGET_LINK_LIBRARIES(BuildingControlVwm
PRIVATE
ngltools
Qt6::Xml
PUBLIC
Qt6::Core
${Qt6_Gui}
LtsUtilsCoreHeaderOnly
LtsUtilsCore
BuildingControlCommon
svcTabCommon
)
NGL_TARGET_INCLUDE_DIRECTORIES(BuildingControlVwm
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../..
)
################################
### Test
################################
@@ -58,6 +62,7 @@ NGL_TARGET_LINK_LIBRARIES(BuildingControlTestVwm
nglcoreapplication
LtsCoordTrans
)
add_test(NAME bld_vwm_test COMMAND $<TARGET_FILE:BuildingControlTestVwm>)
NGL_ADD_EXECUTABLE(AAR SV BuildingControlTestVwmXml test_vwm_xml.cpp)
if(QT6_GUI_AVAILABLE)
NGL_TARGET_LINK_LIBRARIES(BuildingControlTestVwmXml
@@ -69,6 +74,7 @@ if(QT6_GUI_AVAILABLE)
BuildingControlCommon
nglcoreapplication
)
add_test(NAME bld_vwm_xml_test COMMAND $<TARGET_FILE:BuildingControlTestVwmXml>)
endif()
IF(BUILD_TESTING AND TARGET BuildingControlVwm)
@@ -11,11 +11,11 @@
#include "test_read_xml.h"
#include "bcu_xml_reader.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <TrainingAreaBase/logger.h>
Test::Test() : m_api(new BuildingControlUnit::VWM::Api(this))
.getNGLLogger("BCU.VWM.Test")),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
{
connect(m_api, &BuildingControlUnit::VWM::Api::hitResult,
this, &Test::hitResult);
QTimer::singleShot(0, this, &Test::test1);
@@ -28,7 +28,8 @@ Test::~Test()
void Test::hitResult(const BuildingControlUnit::HitResult &result)
{
INFO_LOG(m_logger) << "Hit Result: sensorId = " << result.sensorId
auto &logger = TrainingAreaBase::getLogger("BCU.VWM.Test");
INFO_LOG(logger) << "Hit Result: sensorId = " << result.sensorId
<< ", originatorId = " << result.originatorId
<< ", chargeTypeId = " << result.chargeTypeId
<< ", dmgPercentOld = " << result.damagePercentOld
@@ -41,10 +42,7 @@ void Test::hitResult(const BuildingControlUnit::HitResult &result)
void Test::test1()
{
auto &logger = TrainingAreaBase::getLogger("BCU.VWM.Test");
const auto bsmMap = m_api->bsmMap();
for (const BuildingControlUnit::Bsm &bsm : bsmMap)
{
@@ -53,18 +51,18 @@ void Test::test1()
const auto hitPos = BuildingControlUnit::VWM::Math::checkBsmPosition(bsm.position, bsm.direction, rooms);
if (hitPos.state != BuildingControlUnit::VWM::HitPosition::State::OuterWall)
{
WARNING_LOG(m_logger) << "Effect on bsm " << bsm.id << " does not hit building ! - position: "
WARNING_LOG(logger) << "Effect on bsm " << bsm.id << " does not hit building ! - position: "
<< bsm.position << ", direction: " << bsm.direction;
}
else if (hitPos.distance < 0)
{
WARNING_LOG(m_logger) << "Effect on bsm " << bsm.id << " results in hit pos behind a wall ("
WARNING_LOG(logger) << "Effect on bsm " << bsm.id << " results in hit pos behind a wall ("
<< hitPos.distance << "m) instead in front - BSM is not modelled in the correct place: "
<< bsm.position << ", direction: " << bsm.direction << ", roomId which was hit: " << hitPos.roomId;
}
else
{
DEBUG_LOG(m_logger) << "BSM with id " << bsm.id << " looks fine - room which will be hit: " << hitPos.roomId;
DEBUG_LOG(logger) << "BSM with id " << bsm.id << " looks fine - room which will be hit: " << hitPos.roomId;
}
}
@@ -23,6 +23,4 @@ private Q_SLOTS:
void test4();
void test5();
void test6();
private:
NGL::INGLLogger &m_logger;
};
@@ -8,7 +8,8 @@
#include "vwm_state_store.h"
#include "vwm_math.h"
#include <QtCore/QDateTime>
#include <settings.h>
#include <QtCore/QMetaType>
#include <BuildingControlUnit/settings.h>
#include <QtCore/QFile>
#include <initializer_list>
#ifdef LTS_DEBUG
@@ -27,11 +28,23 @@ namespace BuildingControlUnit
{
namespace VWM
{
namespace
{
// Ensure QPoint3D meta-type is registered for queued connections
// Qt6: Q_DECLARE_METATYPE is sufficient, no need for qRegisterMetaTypeStreamOperators
static const bool point3dRegistered = []() {
return true;
}();
}
Api::Api(QObject *parent)
: QObject(parent)
, m_lastHitResult(HitResult())
, m_logger(BuildingControlUnit::getLogger("VWM.Api"))
{}
, m_logger(TrainingAreaBase::getLogger("VWM.Api"))
{
Q_UNUSED(point3dRegistered);
}
bool Api::init(const QString &chargesConfig,
const QString &vulBuildingConfig,
@@ -7,7 +7,7 @@
#include <QtCore/QSet>
#include <QtCore/QVector>
#include <QtCore/QLineF>
#include <settings.h>
#include <BuildingControlUnit/settings.h>
#include <algorithm>
@@ -17,7 +17,7 @@ namespace VWM
{
static NGL::INGLLogger &logger()
{
return BuildingControlUnit::getLogger("VWM.Building");
return TrainingAreaBase::getLogger("VWM.Building");
}
static inline bool isEffectNegligible(double effect)
@@ -259,7 +259,6 @@ double Room::calcRemainingEffect(double SG_alt, double ZF, double WF)
Building::Building()
: m_lastHitPosition(HitPosition())
, m_logger(BuildingControlUnit::getLogger("VWM.Building"))
{}
int Building::checkPolygons()
@@ -308,12 +307,12 @@ int Building::cleanupPolygons()
cleanupDublicatePointsInPolygon(room.id(), owIdx, elemIdx, "room", candidate);
if (candidate.size() < 4)
{
NOTICE_LOG(m_logger) << "wall was made planar: Building '" << m_name << "' -> "
NOTICE_LOG(logger()) << "wall was made planar: Building '" << m_name << "' -> "
<< " in room " << room.id() << " OuterWall[" << owIdx
<< "], element[" << elemIdx << "] "
<< " makePlanar and cleanupDublicatePointsInPolygon would generate short polygon, size=" << candidate.size();
for (auto point : std::as_const(candidate))
NOTICE_LOG(m_logger) << " point= " << point;
NOTICE_LOG(logger()) << " point= " << point;
bMakePlanarDone = false;
@@ -324,7 +323,7 @@ int Building::cleanupPolygons()
if (bMakePlanarDone)
NOTICE_LOG(m_logger) << "wall was made planar: Building '" << m_name << "' -> "
NOTICE_LOG(logger()) << "wall was made planar: Building '" << m_name << "' -> "
<< " in room " << room.id() << " OuterWall[" << owIdx
<< "], element[" << elemIdx << "] "
<< " smallestDim=" << (int)makePlanar.getSmallestDim()
@@ -354,7 +353,7 @@ int Building::cleanupDublicatePointsInPolygon(int roomId, int idx, int subIdx, c
auto p2 = points.at(j);
if (qFuzzyCompare(p1, p2))
{
DEBUG_LOG(m_logger) << "Building '" << m_name << "' -> "
DEBUG_LOG(logger()) << "Building '" << m_name << "' -> "
<< "Polygon point " << i << " (" << p1 << ") and " << j << " (" << p2
<< ") in room " << roomId << ", " << type << "[" << idx
<< "], element[" << subIdx << "] are the same! -> REMOVE";
@@ -410,7 +409,7 @@ QVector<HitRoom> Building::roomStates() const
hr.fortifyFactor = room.fortifyFactor();
hr.directHit = room.isDirectHit();
ret += hr;
DEBUG_LOG(m_logger) << "HitRoom " << hr.roomId
DEBUG_LOG(logger()) << "HitRoom " << hr.roomId
<< " damage: " << hr.damagePercent
<< "%, remainEffect: " << hr.remainingEffectPercent << "%"
<< ", remainingEffectChargeTypeId: " << hr.remainingEffectChargeTypeId << "%"
@@ -448,7 +447,7 @@ void Building::setRoomState(DamageState damageState, const QVector<int> &afffect
auto it = m_rooms.find(roomId);
if (it == m_rooms.end())
{
WARNING_LOG(m_logger) << "Could not find room with id " << roomId;
WARNING_LOG(logger()) << "Could not find room with id " << roomId;
continue;
}
if (damageState == DamageState::Destroyed)
@@ -465,7 +464,7 @@ void Building::setFortifyInfo(const QVector<FortifyInfo> &foritfyInfos)
auto it = m_rooms.find(info.roomId);
if (it == m_rooms.end())
{
WARNING_LOG(m_logger) << "Could not find room with id " << info.roomId;
WARNING_LOG(logger()) << "Could not find room with id " << info.roomId;
continue;
}
Room &room = it.value();
@@ -538,14 +537,14 @@ bool Building::hit(const LtsUtils::QPoint3D &pos, const LtsUtils::QPoint3D &dir,
const bool bBelowGround = isLastHitPositionBelowGroundHack();
if (bBelowGround)
{
INFO_LOG(m_logger) << " XXXX CES belowGround, reduce charge: " << charge;
INFO_LOG(logger()) << " XXXX CES belowGround, reduce charge: " << charge;
charge.destructiveFactor *= 0.25;
charge.penetrationEffect *= 0.25;
INFO_LOG(m_logger) << " XXXX CES belowGround, reduce charge: " << charge;
INFO_LOG(logger()) << " XXXX CES belowGround, reduce charge: " << charge;
}
INFO_LOG(m_logger) << "XXXXX HitPosition: state=" << m_lastHitPosition.state
INFO_LOG(logger()) << "XXXXX HitPosition: state=" << m_lastHitPosition.state
<< ", m_name=" << m_name
<< ", m_modelId=" << m_modelId
<< ", roomId=" << m_lastHitPosition.roomId
@@ -560,7 +559,7 @@ bool Building::hit(const LtsUtils::QPoint3D &pos, const LtsUtils::QPoint3D &dir,
Room &hitRoom = m_rooms[m_lastHitPosition.roomId];
if (!hitRoom.isValid())
{
ERROR_LOG(m_logger) << "Internal error in hit calculation - could not find room with id " << m_lastHitPosition.roomId;
ERROR_LOG(logger()) << "Internal error in hit calculation - could not find room with id " << m_lastHitPosition.roomId;
return false;
}
@@ -651,7 +650,7 @@ QMap<int, Building::NeighboursToCheck> Building::checkHitNeighbours(const QMap<i
auto itRoom = m_rooms.find(neighbourRoomId);
if (itRoom == m_rooms.end())
{
WARNING_LOG(m_logger) << "Could not find room with id " << neighbourRoomId;
WARNING_LOG(logger()) << "Could not find room with id " << neighbourRoomId;
continue;
}
@@ -670,7 +669,7 @@ QMap<int, Building::NeighboursToCheck> Building::checkHitNeighbours(const QMap<i
const double oldRe = neighbour.remainingEffect();
neighbour.setRemainingEffect(neighbourRoom.remainEffect * TF);
DEBUG_LOG(m_logger) << "room " << neighbourRoomId << " remaining effect old: "
DEBUG_LOG(logger()) << "room " << neighbourRoomId << " remaining effect old: "
<< oldRe << " -> new: " << neighbour.remainingEffect();
@@ -740,7 +739,7 @@ int Building::checkDublicatePointsInPolygon(int roomId, int idx, int subIdx, con
if (qFuzzyCompare(p1, p2))
{
++numberOfDuplicates;
WARNING_LOG(m_logger) << "Building '" << m_name << "' -> "
WARNING_LOG(logger()) << "Building '" << m_name << "' -> "
<< "Polygon point " << i << " (" << p1 << ") and " << j << " (" << p2
<< ") in room " << roomId << ", " << type << "[" << idx
<< "], element[" << subIdx << "] are the same! (size=" << points.size() << ")";
@@ -750,7 +749,7 @@ int Building::checkDublicatePointsInPolygon(int roomId, int idx, int subIdx, con
if (numberOfDuplicates > 0)
for (auto point : points)
WARNING_LOG(m_logger) << "Building '" << m_name << "' -> " << "point =" << point << " (same points)";
WARNING_LOG(logger()) << "Building '" << m_name << "' -> " << "point =" << point << " (same points)";
return numberOfDuplicates;
}
@@ -28,9 +28,6 @@ public:
double transitionFactor() const { return m_transitionFactor; }
private:
NGL::INGLLogger &m_logger;
int m_id = 0;
double m_transitionFactor = 0;
};
@@ -15,7 +15,7 @@ namespace VWM
{
BuildingRoomGeometry::BuildingRoomGeometry()
: m_logger(BuildingControlUnit::getLogger("VWM.BuildingRoomGeometry"))
: m_logger(TrainingAreaBase::getLogger("VWM.BuildingRoomGeometry"))
{
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
@@ -126,7 +126,7 @@ static inline LtsUtils::QPoint3D positionFromElement(const QDomElement &elem)
bool BuildingRoomGeometry::parse(const QDomElement &domGroup)
{
NGL::INGLLogger &loggerParse = BuildingControlUnit::getLogger("VWM.BuildingRoomGeometry.parse");
NGL::INGLLogger &loggerParse = TrainingAreaBase::getLogger("VWM.BuildingRoomGeometry.parse");
QDomElement domGroup1 = getChildElement(domGroup, QStringLiteral("Group"));
for ( ; !domGroup1.isNull(); domGroup1 = domGroup1.nextSiblingElement(domGroup1.tagName()))
@@ -22,7 +22,7 @@ namespace Math
static NGL::INGLLogger &logger()
{
return BuildingControlUnit::getLogger("VWM.Math");
return TrainingAreaBase::getLogger("VWM.Math");
}
LtsUtils::QPoint3D rotateAroundYAxis(const LtsUtils::QPoint3D &in, double phi)
@@ -20,7 +20,7 @@ namespace StateStore
{
static NGL::INGLLogger &logger()
{
return BuildingControlUnit::getLogger("VWM.StateStore");
return TrainingAreaBase::getLogger("VWM.StateStore");
}
static QJsonObject writeBuilding(const Building &building)
@@ -19,7 +19,7 @@ namespace XmlReader
static NGL::INGLLogger &logger()
{
return BuildingControlUnit::getLogger("XmlReader");
return TrainingAreaBase::getLogger("XmlReader");
}
static Charge parseCharge(const QDomElement &domCharge)
@@ -11,8 +11,8 @@ else()
set(Qt6_Gui "")
endif()
# Make ${Qt6_WebSockets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::WebSockets)
# Make ${Qt6_WebSockets} optional (doesn't require GUI)
if(TARGET Qt6::WebSockets)
set(Qt6_WebSockets ${Qt6_WebSockets})
else()
set(Qt6_WebSockets "")
@@ -118,6 +118,10 @@ NGL_TARGET_INCLUDE_DIRECTORIES(svcBldServer
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
NGL_TARGET_COMPILE_DEFINITIONS(svcBldServer
PRIVATE
MAKE_SVCBLDSERVER_LIB
)
IF(BUILD_RTI)
NGL_TARGET_LINK_LIBRARIES(svcBldServer
@@ -127,6 +131,7 @@ NGL_TARGET_LINK_LIBRARIES(svcBldServer
ddsfts
PUBLIC
svcBldCommon
svcTabCommon
ngldb
)
ENDIF(BUILD_RTI)
@@ -10,7 +10,7 @@ namespace Buildings
{
using LOGGER_T = NGL::INGLLogger &;
BLD_COMMON_EXPORT LOGGER_T getLogger(const char *name);
SVCBLDCOMMON_EXPORT LOGGER_T getLogger(const char *name);
inline LOGGER_T getLogger(const QString &loggerName)
{
return getLogger(loggerName.toUtf8().constData());
@@ -26,18 +26,10 @@ SET(xml_FILE tab_service.xml)
#
# --- Library tabTelegrams --------------------------------------------------------------------------------
#
# Prefer Qt6 when available, fall back to Qt5
find_package(Qt6 COMPONENTS Core Sql Network QUIET)
if (Qt6_FOUND)
set(_QT_CORE_TARGET Qt6::Core)
set(_QT_SQL_TARGET Qt6::Sql)
set(_QT_NETWORK_TARGET Qt6::Network)
else()
find_package(Qt6 COMPONENTS Core Sql Network QUIET)
set(_QT_CORE_TARGET Qt6::Core)
set(_QT_SQL_TARGET Qt6::Sql)
set(_QT_NETWORK_TARGET Qt6::Network)
endif()
find_package(Qt6 COMPONENTS Core Sql Network REQUIRED)
set(_QT_CORE_TARGET Qt6::Core)
set(_QT_SQL_TARGET Qt6::Sql)
set(_QT_NETWORK_TARGET Qt6::Network)
SET(SRCS_telegrams
training_area_telegrams.cpp
@@ -26,7 +26,7 @@ SET(SRCS
PrtCnv.dat
)
QT5_ADD_RESOURCES(SRCS tetra.qrc)
qt6_add_resources(SRCS tetra.qrc)
NGL_ADD_LIBRARY(AAR SV tabPluginTetraJson MODULE ${SRCS})
NGL_INSTALL_TARGET(tabPluginTetraJson)
@@ -26,6 +26,7 @@ ENDMACRO()
#_BUILD_TEST(1)
#_BUILD_TEST(2)
_BUILD_TEST(3)
add_test(NAME tab_uas_test3 COMMAND $<TARGET_FILE:TabUASTest3>)
# # test4
@@ -59,6 +60,7 @@ PRIVATE
TmsIfAdapterInterface
tabPluginInterface
)
add_test(NAME tab_uas_test4_2 COMMAND $<TARGET_FILE:TabUASTest4_2>)
# # test5
@@ -81,4 +83,5 @@ if(QT6_GUI_AVAILABLE)
#TmsIfAdapter via dlopen !
TmsIfAdapterInterface
)
add_test(NAME tab_uas_test6 COMMAND $<TARGET_FILE:TabUASTest6>)
endif()
@@ -39,7 +39,7 @@ SET(SRCS
wls_handler_tx.cpp
wls_handler_tx.h
)
QT5_ADD_RESOURCES(SRCS tetra.qrc)
qt6_add_resources(SRCS tetra.qrc)
NGL_ADD_LIBRARY(AAR SV tabPluginWlsTetra MODULE ${SRCS})
NGL_INSTALL_TARGET(tabPluginWlsTetra)
NGL_TARGET_LINK_LIBRARIES(tabPluginWlsTetra
@@ -238,6 +238,7 @@ IF(BUILD_TESTING)
nglsettings
ngltools
NGLLogger)
add_test(NAME taboc_serialtest COMMAND $<TARGET_FILE:serialtest>)
IF(NOT BUILD_RPM)
NGL_INSTALL(AAR SV TARGETS serialtest DESTINATION bin)
@@ -72,6 +72,7 @@ NGL_TARGET_LINK_LIBRARIES(wlsJsonClientTest
Qt6::Core
${Qt6_WebSockets}
)
add_test(NAME wls_json_client_test COMMAND $<TARGET_FILE:wlsJsonClientTest>)
NGL_ADD_LIBRARY2(SfmConverter AAR SV SHARED
logger.cpp
@@ -151,8 +151,8 @@ NGL_ADD_LIBRARY(WS AAR SV HLA svcPdmClient SHARED ${SRCS_client})
SET_TARGET_PROPERTIES(svcPdmClient PROPERTIES AUTOMOC ON)
NGL_TARGET_INCLUDE_DIRECTORIES(svcPdmClient
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_CURRENT_SOURCE_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(svcPdmClient
@@ -180,8 +180,8 @@ ENDIF()
NGL_ADD_LIBRARY(WS AAR SV svcPdmServer SHARED ${SRCS_server})
NGL_TARGET_INCLUDE_DIRECTORIES(svcPdmServer
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_CURRENT_SOURCE_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(svcPdmServer