Adds immediate migration results in progress

This commit is contained in:
torsten committed 2026-08-19 11:18:24 +02:00
1 parent 8453e104c5
commit 3bb6e89496
2102 files changed
+17482 -15071

No files matched your search

@@ -19,12 +19,11 @@
//---------------------------------------------------------------------------------
namespace SituationReplay
{
SrpDtTests::SrpDtTests(QObject *parent)
: QObject(parent)
SrpDtTests::SrpDtTests(QObject *parent) : QObject(parent)
, m_replayPartitionId(0)
, m_situationReplayId(0)
, m_bTestsSuccessful(true)
{
, m_bTestsSuccessful(true),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
}
@@ -35,7 +34,7 @@ SrpDtTests::~SrpDtTests()
//---------------------------------------------------------------------------------
bool SrpDtTests::init(int domainId, int replayPartitionId)
{
DEBUG_LOG() << "init begin";
DEBUG_LOG(m_logger) << "init begin";
m_replayPartitionId = replayPartitionId;
// initialize DDS
@@ -51,11 +50,11 @@ bool SrpDtTests::init(int domainId, int replayPartitionId)
// DdsInterface Publisher
//m_ddsConnector->setPublisher(new Publisher(domainId, m_ddsConnector->getPartition(), m_ddsConnector->getDomainParticipant()));
DEBUG_LOG() << "Create dtc";
DEBUG_LOG(m_logger) << "Create dtc";
m_dtc = SituationReplay::Interface::Dtc::create(m_ddsConnector);
DEBUG_LOG() << "Init dtc";
DEBUG_LOG(m_logger) << "Init dtc";
bool bRet = m_dtc->enableAll();
DEBUG_LOG() << "init end - bRet = " << bRet;
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
connect(m_dtc.get(), &SituationReplay::Interface::Dtc::sitReplayChanged,
this, &SrpDtTests::onReceiveSituationReplayData);
@@ -66,26 +65,26 @@ bool SrpDtTests::init(int domainId, int replayPartitionId)
//---------------------------------------------------------------------------------
void SrpDtTests::startTest()
{
INFO_LOG() << "startTest";
INFO_LOG(m_logger) << "startTest";
QTimer::singleShot(1000, this, &SrpDtTests::tryGetAllSituationReplays);
}
//---------------------------------------------------------------------------------
void SrpDtTests::tryGetAllSituationReplays()
{
INFO_LOG() << "trying to get all situationReplays";
INFO_LOG(m_logger) << "trying to get all situationReplays";
const QMap<qint32, SituationReplay::SitReplay> map = m_dtc->sitReplays();
if (map.isEmpty())
{
ERROR_LOG() << "Error requesting all situation replay data";
ERROR_LOG(m_logger) << "Error requesting all situation replay data";
failExit();
}
else
{
INFO_LOG() << "Amout of existing situation replays = " << map.size();
INFO_LOG(m_logger) << "Amout of existing situation replays = " << map.size();
m_situationReplayId = map.firstKey();
for(auto it = map.begin(); it != map.end(); ++it)
INFO_LOG() << "situationReplay(" << it.key() << ") : " << it.value().replayPartitionId() ;
INFO_LOG(m_logger) << "situationReplay(" << it.key() << ") : " << it.value().replayPartitionId() ;
}
QTimer::singleShot(10, this, &SrpDtTests::tryGetSituationReplay);
@@ -94,17 +93,17 @@ void SrpDtTests::tryGetAllSituationReplays()
//---------------------------------------------------------------------------------
void SrpDtTests::tryGetSituationReplay()
{
INFO_LOG() << "trying get itemData for situationReplay " << m_situationReplayId;
INFO_LOG(m_logger) << "trying get itemData for situationReplay " << m_situationReplayId;
SituationReplay::SitReplay data = m_dtc->sitReplay(m_situationReplayId);
if (data.id() <= 0)
{
ERROR_LOG() << "Error receiving data for situation replay " << m_situationReplayId;
ERROR_LOG(m_logger) << "Error receiving data for situation replay " << m_situationReplayId;
failExit();
}
else
{
INFO_LOG() << "## SitReplay(" << data.id() << "), replayPartition: " << data.replayPartitionId()
INFO_LOG(m_logger) << "## SitReplay(" << data.id() << "), replayPartition: " << data.replayPartitionId()
<< ", on exercise " << data.exerciseId();
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
}
@@ -114,7 +113,7 @@ void SrpDtTests::tryGetSituationReplay()
void SrpDtTests::onReceiveSituationReplayData(const SituationReplay::SitReplay &data)
{
if (m_situationReplayId == data.id())
INFO_LOG() << "##################### Data for id = " << data.id() << " received";
INFO_LOG(m_logger) << "##################### Data for id = " << data.id() << " received";
}
// ------------------------------------------------------------------------------
@@ -36,7 +36,7 @@ SrpFtTests::~SrpFtTests()
//--------------------------------------------------------------------------------------------------------
bool SrpFtTests::init(int domainId, TestId testId, int replayPartitionId, int srpId)
{
INFO_LOG() << "init begin";
INFO_LOG(m_logger) << "init begin";
m_testId = testId;
m_replayPartitionId = replayPartitionId;
@@ -53,11 +53,11 @@ bool SrpFtTests::init(int domainId, TestId testId, int replayPartitionId, int sr
// Publish/Subscribe on replayPartition
m_ddsConnector->initPublisherSubscriber();
DEBUG_LOG() << "create ftc";
DEBUG_LOG(m_logger) << "create ftc";
m_ftc = SituationReplay::Interface::Ftc::create(m_ddsConnector);
DEBUG_LOG() << "init ftc";
DEBUG_LOG(m_logger) << "init ftc";
bool bRet = m_ftc->enableAll();
DEBUG_LOG() << "init end - bRet = " << bRet;
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
return bRet;
}
@@ -65,7 +65,7 @@ bool SrpFtTests::init(int domainId, TestId testId, int replayPartitionId, int sr
//--------------------------------------------------------------------------------------------------------
void SrpFtTests::startTest()
{
INFO_LOG() << "startTest";
INFO_LOG(m_logger) << "startTest";
if (m_testId <= TryStart)
QTimer::singleShot(0, this, &SrpFtTests::tryStart);
@@ -82,7 +82,7 @@ void SrpFtTests::startTest()
//--------------------------------------------------------------------------------------------------------
void SrpFtTests::tryStart()
{
INFO_LOG() << "trying to send startReplay";
INFO_LOG(m_logger) << "trying to send startReplay";
m_currentTestId = TryStart;
qint64 beginTime = 1468401389668;
@@ -99,7 +99,7 @@ void SrpFtTests::tryStart()
if (!m_ftc->changeReplayStateRequest(req, this))
{
ERROR_LOG() << "Error starting replay for srp " << m_replayPartitionId;
ERROR_LOG(m_logger) << "Error starting replay for srp " << m_replayPartitionId;
failExit();
}
}
@@ -107,7 +107,7 @@ void SrpFtTests::tryStart()
//--------------------------------------------------------------------------------------------------------
void SrpFtTests::tryNotAllowedChange()
{
INFO_LOG() << "trying to send changeReplayState (start) => should fail (not possible with this method)";
INFO_LOG(m_logger) << "trying to send changeReplayState (start) => should fail (not possible with this method)";
m_currentTestId = TryNotAllowedChange;
switchToState(SituationReplay::SrpState::Started);
}
@@ -115,7 +115,7 @@ void SrpFtTests::tryNotAllowedChange()
//--------------------------------------------------------------------------------------------------------
void SrpFtTests::tryChangePaused()
{
INFO_LOG() << "trying to send changeReplayState (Paused)";
INFO_LOG(m_logger) << "trying to send changeReplayState (Paused)";
m_currentTestId = TryChangePaused;
switchToState(SituationReplay::SrpState::Paused);
}
@@ -123,7 +123,7 @@ void SrpFtTests::tryChangePaused()
//--------------------------------------------------------------------------------------------------------
void SrpFtTests::tryChangeResumed()
{
INFO_LOG() << "trying to send changeReplayState (Resumed)";
INFO_LOG(m_logger) << "trying to send changeReplayState (Resumed)";
m_currentTestId = TryChangeResumed;
switchToState(SituationReplay::SrpState::Resumed);
}
@@ -131,7 +131,7 @@ void SrpFtTests::tryChangeResumed()
//--------------------------------------------------------------------------------------------------------
void SrpFtTests::tryStop()
{
INFO_LOG() << "trying to send stopReplay";
INFO_LOG(m_logger) << "trying to send stopReplay";
m_currentTestId = TryStop;
switchToState(SituationReplay::SrpState::Stopped);
}
@@ -139,7 +139,7 @@ void SrpFtTests::tryStop()
//--------------------------------------------------------------------------------------------------------
void SrpFtTests::startReplayReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG() << "Got startReplayReply with id " << replyObject.id();
INFO_LOG(m_logger) << "Got startReplayReply with id " << replyObject.id();
m_situationReplayId = replyObject.id();
if (m_testId == 0 && !replyObject.error())
QTimer::singleShot(0, this, &SrpFtTests::tryNotAllowedChange);
@@ -150,9 +150,9 @@ void SrpFtTests::startReplayReply(const Core::FunctionReplyObject &replyObject)
//--------------------------------------------------------------------------------------------------------
void SrpFtTests::changeReplayStateReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG() << "Got changeReplayStateReply with id " << replyObject.id();
INFO_LOG(m_logger) << "Got changeReplayStateReply with id " << replyObject.id();
if (replyObject.error())
INFO_LOG() << ", string: " << replyObject.translated();
INFO_LOG(m_logger) << ", string: " << replyObject.translated();
if (m_testId == 0 && !replyObject.error())
{
if (m_currentTestId == TryNotAllowedChange)
@@ -169,7 +169,7 @@ void SrpFtTests::changeReplayStateReply(const Core::FunctionReplyObject &replyOb
//--------------------------------------------------------------------------------------------------------
void SrpFtTests::stopReplayReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG() << "Got stopReplayReply with id " << replyObject.id() ;
INFO_LOG(m_logger) << "Got stopReplayReply with id " << replyObject.id() ;
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
}
@@ -213,7 +213,7 @@ void SrpFtTests::switchToState(SrpState state)
if (!m_ftc->changeReplayStateRequest(req, this))
{
ERROR_LOG() << "Error changing replay state for srp " << m_situationReplayId << "(" << m_replayPartitionId << ")";
ERROR_LOG(m_logger) << "Error changing replay state for srp " << m_situationReplayId << "(" << m_replayPartitionId << ")";
failExit();
}
}
@@ -36,17 +36,17 @@ bool DbReader::loadPlugin(const LtsPluginManager::PluginInstance &pi)
RecordReplay::RecordReplayPlugin *recPlugin = qobject_cast<RecordReplay::RecordReplayPlugin*>(pi.plugin);
if (!recPlugin)
{
ERROR_LOG() << "Cannot load RecordReplayPlugin " << pi.fileName;
ERROR_LOG(m_logger) << "Cannot load RecordReplayPlugin " << pi.fileName;
return false;
}
if (!recPlugin->initDts(m_ddsConnector, m_exerciseId, m_bCanHandleSchemas, *m_query))
{
ERROR_LOG() << "Initialisation for RecordReplayPlugin " << pi.fileName << " failed ";
ERROR_LOG(m_logger) << "Initialisation for RecordReplayPlugin " << pi.fileName << " failed ";
return false;
}
INFO_LOG() << "Loaded record replay plugin " << recPlugin->pluginName();
INFO_LOG(m_logger) << "Loaded record replay plugin " << recPlugin->pluginName();
m_plugins.push_back(recPlugin);
return true;
@@ -67,67 +67,67 @@ bool DbReader::init(const QSqlDatabase &db)
bool DbReader::setReplayStartTime(qint64 startTime)
{
INFO_LOG() << "IN setReplayStartTime " << startTime;
INFO_LOG(m_logger) << "IN setReplayStartTime " << startTime;
if (!m_query)
{
WARNING_LOG() << "Internal error - no query!";
WARNING_LOG(m_logger) << "Internal error - no query!";
return false;
}
for (RecordReplay::RecordReplayPlugin *recPlugin : m_plugins)
{
INFO_LOG() << "IN setReplayStartTime, current Plugin: " << recPlugin->pluginName()
INFO_LOG(m_logger) << "IN setReplayStartTime, current Plugin: " << recPlugin->pluginName()
<< " typename=" << typeid(*recPlugin).name();
if (!recPlugin->setReplayStartTime(*m_query, startTime))
{
WARNING_LOG() << "setReplayStartTime for plugin " << recPlugin->svcShortName() << " failed!";
WARNING_LOG(m_logger) << "setReplayStartTime for plugin " << recPlugin->svcShortName() << " failed!";
return false;
}
}
INFO_LOG() << "IN setReplayStartTime " << startTime << " DONE";
INFO_LOG(m_logger) << "IN setReplayStartTime " << startTime << " DONE";
return true;
}
bool DbReader::readData(qint64 fromTime, qint64 toTime)
{
INFO_LOG() << "IN readData " << fromTime << " to " << toTime;
INFO_LOG(m_logger) << "IN readData " << fromTime << " to " << toTime;
if (!m_query)
{
WARNING_LOG() << "Internal error - no query!";
WARNING_LOG(m_logger) << "Internal error - no query!";
return false;
}
for (RecordReplay::RecordReplayPlugin *recPlugin : m_plugins)
{
if (!recPlugin->ddsTopicsFromDatabase(*m_query, fromTime, toTime))
{
WARNING_LOG() << "ddsTopicsFromDatabase for plugin " << recPlugin->svcShortName() << " failed!";
WARNING_LOG(m_logger) << "ddsTopicsFromDatabase for plugin " << recPlugin->svcShortName() << " failed!";
return false;
}
}
INFO_LOG() << "IN readData " << fromTime << " to " << toTime << " DONE";
INFO_LOG(m_logger) << "IN readData " << fromTime << " to " << toTime << " DONE";
return true;
}
void DbReader::publish(qint64 desiredTime)
{
INFO_LOG() << "IN publish " << desiredTime;
INFO_LOG(m_logger) << "IN publish " << desiredTime;
for (RecordReplay::RecordReplayPlugin *recPlugin : m_plugins)
if (!recPlugin->publishData(desiredTime))
WARNING_LOG() << "publishData for plugin " << recPlugin->svcShortName() << " failed!";
INFO_LOG() << "IN publish " << desiredTime << " DONE";
WARNING_LOG(m_logger) << "publishData for plugin " << recPlugin->svcShortName() << " failed!";
INFO_LOG(m_logger) << "IN publish " << desiredTime << " DONE";
}
void DbReader::waitForAsyncOperations(qint64 desiredTime)
{
INFO_LOG() << "IN waitForAsyncOperations " << desiredTime;
INFO_LOG(m_logger) << "IN waitForAsyncOperations " << desiredTime;
for (RecordReplay::RecordReplayPlugin *recPlugin : m_plugins)
if (!recPlugin->waitForAsyncOperations(desiredTime))
WARNING_LOG() << "waitForAsyncOperations for plugin " << recPlugin->svcShortName() << " failed!";
WARNING_LOG(m_logger) << "waitForAsyncOperations for plugin " << recPlugin->svcShortName() << " failed!";
}
void DbReader::clearData()
{
INFO_LOG() << "IN clearData";
INFO_LOG(m_logger) << "IN clearData";
for (RecordReplay::RecordReplayPlugin *recPlugin : m_plugins)
recPlugin->clearData();
}
@@ -35,8 +35,10 @@ public:
void waitForAsyncOperations(qint64 desiredTime);
void clearData();
private:
NGL::INGLLogger &m_logger;
bool loadPlugin(const LtsPluginManager::PluginInstance &pi);
private:
NGL::INGLLogger &m_logger;
int m_exerciseId;
NSqlQuery *m_query;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
@@ -35,15 +35,15 @@ static std::shared_ptr<DDSConnector::DdsConnector> makeConnector(const Connectio
DdsHandler::DdsHandler(const ConnectionParams &output)
: m_ddsConnectorReplay(makeConnector(output, IDL::PartitionType::Replay, DDS::QosProfile::ConnectionType::ShmUdpLocalhost))
{
DEBUG_LOG() << "DdsHandler Replay(" << output.partitionId << ") for partition: " << m_ddsConnectorReplay->getDefaultPartition();
DEBUG_LOG(m_logger) << "DdsHandler Replay(" << output.partitionId << ") for partition: " << m_ddsConnectorReplay->getDefaultPartition();
}
DdsHandler::DdsHandler(const ConnectionParams &input, const ConnectionParams &output)
: m_ddsConnectorExercise(makeConnector(input, IDL::PartitionType::Exercise, DDS::QosProfile::ConnectionType::Client))
, m_ddsConnectorReplay(makeConnector(output, IDL::PartitionType::Replay, DDS::QosProfile::ConnectionType::Shm))
{
DEBUG_LOG() << "DdsHandler Exercise(" << input.partitionId << ") for partition: " << m_ddsConnectorExercise->getDefaultPartition();
DEBUG_LOG() << "DdsHandler Replay(" << output.partitionId << ") for partition: " << m_ddsConnectorReplay->getDefaultPartition();
DEBUG_LOG(m_logger) << "DdsHandler Exercise(" << input.partitionId << ") for partition: " << m_ddsConnectorExercise->getDefaultPartition();
DEBUG_LOG(m_logger) << "DdsHandler Replay(" << output.partitionId << ") for partition: " << m_ddsConnectorReplay->getDefaultPartition();
}
DdsHandler::~DdsHandler()
@@ -61,7 +61,7 @@ bool DdsHandler::init(const QStringList &qosFileList)
if ((m_ddsConnectorExercise && !m_ddsConnectorExercise->init(qosFileList)) ||
!m_ddsConnectorReplay->init(qosFileList))
{
ERROR_LOG() << "Error initializing dds connections - aborting";
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
return false;
}
@@ -80,10 +80,10 @@ bool DdsHandler::init(const QStringList &qosFileList)
m_ddsDts = SituationReplay::Interface::Dts::create(m_ddsConnectorReplay);
m_ddsFts = SituationReplay::Interface::Fts::create(m_ddsConnectorReplay);
bool bRet = m_ddsDts->enableAll();
INFO_LOG() << "Dts initialised";
INFO_LOG(m_logger) << "Dts initialised";
bRet &= m_ddsFts->enableAll();
INFO_LOG() << "Fts initialised";
INFO_LOG(m_logger) << "Fts initialised";
initReplayRouting();
@@ -92,7 +92,7 @@ bool DdsHandler::init(const QStringList &qosFileList)
void DdsHandler::publishPartitionTime(const Core::PartitionTime &partitionTime)
{
INFO_LOG() << "publish partitionTime: " << partitionTime.timeStamp();
INFO_LOG(m_logger) << "publish partitionTime: " << partitionTime.timeStamp();
m_dtsPartitionTime->write(partitionTime);
}
@@ -46,8 +46,10 @@ public:
static bool parseOptions(const QString &opts, ConnectionParams &params);
private:
NGL::INGLLogger &m_logger;
void initReplayRouting();
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnectorExercise;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnectorReplay;
std::shared_ptr<SituationReplay::Interface::Dts> m_ddsDts;
@@ -46,7 +46,7 @@ bool HandlerSituationReplay::init(int exerciseId, int partitionId)
NSqlQuery q(m_db->database());
const qint64 exerciseStartTime = (q.execAndFetch(stmt) ? q.value(0).toLongLong() : 0);
DEBUG_LOG() << "stmt: " << stmt << ", res " << exerciseStartTime;
DEBUG_LOG(m_logger) << "stmt: " << stmt << ", res " << exerciseStartTime;
Database::SrpSituationReplay newData;
newData.srpStateId = SrpState::Stopped;
@@ -67,14 +67,14 @@ bool HandlerSituationReplay::createObject(const Database::SrpSituationReplay &ne
{
delete m_objSrp;
m_objSrp = nullptr;
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
}
return m_objSrp != nullptr;
}
Core::FunctionReplyObject HandlerSituationReplay::startReplayRequest(const SituationReplay::ChangeReplayStateRequest &request)
{
DEBUG_LOG() << "onStartReplayRequest: " << request;
DEBUG_LOG(m_logger) << "onStartReplayRequest: " << request;
// Start only own replay
if (request.replayPartitionId() != m_partitionId)
return Core::FunctionReplyObject(request.replayPartitionId(),tr_lts("dds", "Wrong replay partition"));
@@ -102,7 +102,7 @@ Core::FunctionReplyObject HandlerSituationReplay::startReplayRequest(const Situa
Core::FunctionReplyObject HandlerSituationReplay::stopReplayRequest(const SituationReplay::ChangeReplayStateRequest &request)
{
DEBUG_LOG() << "onStopReplayRequest: " << request;
DEBUG_LOG(m_logger) << "onStopReplayRequest: " << request;
if (m_objSrp == nullptr)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "SituationReplay for replayPartitionId %1 not found")).arg(request.replayPartitionId());
@@ -144,7 +144,7 @@ Core::FunctionReplyObject HandlerSituationReplay::changeReplayStateRequest(const
return startReplayRequest(request);
case SrpState_def::Resumed:
{
DEBUG_LOG() << "Resume request: " << request.beginTime() << ", cur playback time: " << m_objSrp->currentReplayTime();
DEBUG_LOG(m_logger) << "Resume request: " << request.beginTime() << ", cur playback time: " << m_objSrp->currentReplayTime();
if (request.beginTime() != 0 && request.beginTime() != m_objSrp->currentReplayTime())
{
stopReplayRequest(request);
@@ -163,10 +163,10 @@ Core::FunctionReplyObject HandlerSituationReplay::changeReplayStateRequest(const
void HandlerSituationReplay::onChangeReplayStateRequest(const rti::core::SampleIdentity &cookie,
const ChangeReplayStateRequest &request)
{
DEBUG_LOG() << "onChangeReplayStateRequest: " << request;
DEBUG_LOG(m_logger) << "onChangeReplayStateRequest: " << request;
auto ret = changeReplayStateRequest(request);
if (ret.error())
WARNING_LOG() << ret();
WARNING_LOG(m_logger) << ret();
m_ddsHandler->fts()->changeReplayStateReply(cookie, ret);
}
@@ -37,6 +37,7 @@ public:
bool init(int exerciseId, int partitionId);
private:
NGL::INGLLogger &m_logger;
bool createObject(const Database::SrpSituationReplay &newData);
Core::FunctionReplyObject startReplayRequest(const ChangeReplayStateRequest &request);
Core::FunctionReplyObject stopReplayRequest(const ChangeReplayStateRequest &request);
@@ -46,6 +47,7 @@ private:
const ChangeReplayStateRequest &request) override;
private:
NGL::INGLLogger &m_logger;
ObjectSituationReplay *m_objSrp; // only one (!) replay per partition possible
const std::shared_ptr<DdsHandler> m_ddsHandler;
const std::shared_ptr<DatabaseInterface> m_db;
@@ -57,7 +57,7 @@ bool HandlerSituationReplaySqlite::createObject(const Database::SrpSituationRepl
{
delete m_objSrp;
m_objSrp = nullptr;
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
return false;
}
connect(m_objSrp, &ObjectSituationReplay::replayTimeChanged, this, &HandlerSituationReplaySqlite::replayTimeChanged);
@@ -70,7 +70,7 @@ bool HandlerSituationReplaySqlite::createObject(const Database::SrpSituationRepl
bool HandlerSituationReplaySqlite::onStartReplayRequest(qint64 begin, qint64 end, double pace)
{
DEBUG_LOG() << "onStartReplayRequest: " << begin << ", " << end << ", " << pace;
DEBUG_LOG(m_logger) << "onStartReplayRequest: " << begin << ", " << end << ", " << pace;
Database::SrpSituationReplay newData;
newData.srpStateId = SrpState::Started;
@@ -86,11 +86,11 @@ bool HandlerSituationReplaySqlite::onStartReplayRequest(qint64 begin, qint64 end
bool HandlerSituationReplaySqlite::onStopReplayRequest()
{
DEBUG_LOG() << "onStopReplayRequest";
DEBUG_LOG(m_logger) << "onStopReplayRequest";
if (m_objSrp == nullptr)
{
ERROR_LOG() << "onStopReplayRequest - internal error";
ERROR_LOG(m_logger) << "onStopReplayRequest - internal error";
return false;
}
@@ -99,7 +99,7 @@ bool HandlerSituationReplaySqlite::onStopReplayRequest()
ret = m_objSrp->removeObject();
if (ret.error())
WARNING_LOG() << ret();
WARNING_LOG(m_logger) << ret();
// remove all old data from DDS-Bus & clear maps
m_dbReader->clearData();
@@ -111,7 +111,7 @@ bool HandlerSituationReplaySqlite::onPauseReplayRequest()
{
if (m_objSrp == nullptr)
{
ERROR_LOG() << "onChangeReplayStateRequest - internal error";
ERROR_LOG(m_logger) << "onChangeReplayStateRequest - internal error";
return false;
}
return onChangeReplayStateRequest(SrpState::Paused, m_objSrp->pace());
@@ -121,7 +121,7 @@ bool HandlerSituationReplaySqlite::onResumeReplayRequest()
{
if (m_objSrp == nullptr)
{
ERROR_LOG() << "onChangeReplayStateRequest - internal error";
ERROR_LOG(m_logger) << "onChangeReplayStateRequest - internal error";
return false;
}
return onChangeReplayStateRequest(SrpState::Resumed, m_objSrp->pace());
@@ -130,17 +130,17 @@ bool HandlerSituationReplaySqlite::onResumeReplayRequest()
bool HandlerSituationReplaySqlite::onChangeReplayStateRequest(const SituationReplay::SrpState &newState, double newPace)
{
DEBUG_LOG() << "onChangeReplayStateRequest: " << newState << ", " << newPace;
DEBUG_LOG(m_logger) << "onChangeReplayStateRequest: " << newState << ", " << newPace;
if (m_objSrp == nullptr)
{
ERROR_LOG() << "onChangeReplayStateRequest - internal error";
ERROR_LOG(m_logger) << "onChangeReplayStateRequest - internal error";
return false;
}
if (newState != SrpState::Resumed && newState != SrpState::Paused)
{
ERROR_LOG() << "onChangeReplayStateRequest: SrpStateChange not possible, only resumed & paused allowed";
ERROR_LOG(m_logger) << "onChangeReplayStateRequest: SrpStateChange not possible, only resumed & paused allowed";
return false;
}
@@ -148,7 +148,7 @@ bool HandlerSituationReplaySqlite::onChangeReplayStateRequest(const SituationRep
const Core::FunctionReplyObject ret = m_objSrp->switchToState(newState);
if (ret.error())
WARNING_LOG() << ret();
WARNING_LOG(m_logger) << ret();
return !ret.error();
}
@@ -157,7 +157,7 @@ bool HandlerSituationReplaySqlite::onPaceChangeRequest(double newPace)
{
if (m_objSrp == nullptr)
{
ERROR_LOG() << "onChangeReplayStateRequest - internal error";
ERROR_LOG(m_logger) << "onChangeReplayStateRequest - internal error";
return false;
}
@@ -52,8 +52,10 @@ public:
bool onChangeReplayStateRequest(const SrpState &newState, double newPace);
bool onPaceChangeRequest(double newPace);
private:
NGL::INGLLogger &m_logger;
bool createObject(const Database::SrpSituationReplay &newData);
private:
NGL::INGLLogger &m_logger;
ObjectSituationReplay *m_objSrp; // only one (!) replay per partition possible
const std::shared_ptr<DdsHandler> m_ddsHandler;
const std::shared_ptr<DbReader> m_dbReader;
@@ -38,7 +38,7 @@ bool MainHandler::init(const SituationReplay::ConnectionParams &input,
m_dbHandler = std::make_shared<DbHandler>();
if (!m_dbHandler->init(input.partitionId, Settings::settings()))
{
ERROR_LOG() << "Initialisation dbHandler failed.";
ERROR_LOG(m_logger) << "Initialisation dbHandler failed.";
return false;
}
@@ -34,9 +34,11 @@ public:
const ConnectionParams &output);
private:
NGL::INGLLogger &m_logger;
bool initSrpHandler(int partitionIdIn, int partitionIdOut);
private:
NGL::INGLLogger &m_logger;
std::unique_ptr<HandlerSituationReplay> m_handlerSrp;
std::shared_ptr<DdsHandler> m_ddsInterface;
std::shared_ptr<DbHandler> m_dbHandler;
@@ -53,7 +53,7 @@ bool MainHandlerSqlite::initDb(const ReplayInformation &replayInformation,
{
if (!m_ddsInterface)
{
WARNING_LOG() << "dds must be initialized first!";
WARNING_LOG(m_logger) << "dds must be initialized first!";
return false;
}
@@ -102,15 +102,15 @@ bool MainHandlerSqlite::initDb(const ReplayInformation &replayInformation,
m_dbHandler = std::make_shared<DbHandler>();
if (!m_dbHandler->init(partitionIdIn, m_dbSqlite))
{
ERROR_LOG() << "Initialisation dbHandler failed.";
ERROR_LOG(m_logger) << "Initialisation dbHandler failed.";
return false;
}
DEBUG_LOG() << "opening sqlite db successful";
DEBUG_LOG(m_logger) << "opening sqlite db successful";
m_dbReader = std::make_shared<DbReader>(m_ddsInterface->ddsReplay(), partitionIdIn, false);
if (!m_dbReader->init(m_dbHandler->db()->database()))
{
ERROR_LOG() << "Could not initialize database reader";
ERROR_LOG(m_logger) << "Could not initialize database reader";
return false;
}
@@ -120,7 +120,7 @@ bool MainHandlerSqlite::initDb(const ReplayInformation &replayInformation,
if (!initSrpHandler(partitionIdIn, m_ddsInterface->ddsReplay()->getPartitionId(),
replayInformation.timeSpan.begin, replayInformation.timeSpan.end))
{
ERROR_LOG() << "Could not initialize situation replay handler";
ERROR_LOG(m_logger) << "Could not initialize situation replay handler";
return false;
}
@@ -178,14 +178,14 @@ bool MainHandlerSqlite::loadReplayConfig(const QString &replayConfigPath)
QFile f(replayConfigPath);
if (!f.open(QIODevice::ReadOnly))
{
WARNING_LOG() << "Could not open '" << replayConfigPath << "' for reading - no replay config loaded";
WARNING_LOG(m_logger) << "Could not open '" << replayConfigPath << "' for reading - no replay config loaded";
return false;
}
QJsonParseError error;
const QJsonDocument doc(QJsonDocument::fromJson(f.readAll(), &error));
if (error.error != QJsonParseError::NoError)
{
WARNING_LOG() << "Could not parse replay config loaded json file: " << error.errorString();
WARNING_LOG(m_logger) << "Could not parse replay config loaded json file: " << error.errorString();
return false;
}
const QJsonObject obj = doc.object();
@@ -246,7 +246,7 @@ void MainHandlerSqlite::maybeAddNewOverlay(qint64 curTime)
return;
m_curOverlayArrayIdx = nextIdx;
m_currentVisibleOverlays += m_overlays.at(nextIdx);
DEBUG_LOG() << "Showing new overlay with id " << m_overlays.at(m_curOverlayArrayIdx).overlayId
DEBUG_LOG(m_logger) << "Showing new overlay with id " << m_overlays.at(m_curOverlayArrayIdx).overlayId
<< " at time " << curTime;
emit applyNewOverlay(m_overlays.at(m_curOverlayArrayIdx).overlayId);
}
@@ -254,7 +254,7 @@ void MainHandlerSqlite::maybeAddNewOverlay(qint64 curTime)
void MainHandlerSqlite::removeOutdatedOverlays(qint64 curTime)
{
DEBUG_LOG() << Q_FUNC_INFO << " curTime = "<< curTime
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " curTime = "<< curTime
<< " m_currentVisibleOverlays.size()= "<< m_currentVisibleOverlays.size();
const qint64 curTimeRelative = curTime - m_replay.timeSpan.begin + m_replay.relativeTimeSpan.begin; // + m_replay.relativeTimeSpan.begin
@@ -262,7 +262,7 @@ void MainHandlerSqlite::removeOutdatedOverlays(qint64 curTime)
{
const qint64 endTime = m_currentVisibleOverlays.at(i).relativeTimeSpan.end;
DEBUG_LOG() << Q_FUNC_INFO << " curTimeRelative = " << curTimeRelative << " endTime = " << endTime;
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " curTimeRelative = " << curTimeRelative << " endTime = " << endTime;
if (curTimeRelative > endTime)
{
@@ -308,7 +308,7 @@ int MainHandlerSqlite::findNextIndex(qint64 curTime, int curIdx, const QVector<F
// startTime: msec, rel. to begin of SCRIPT
const qint64 startTime = data.at(nextIdx).relativeTimeSpan.begin;
DEBUG_LOG() << Q_FUNC_INFO << " curTimeRelative = " << curTimeRelative << " startTime = " << startTime;
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " curTimeRelative = " << curTimeRelative << " startTime = " << startTime;
if (curTimeRelative < startTime)
return -1;
@@ -103,6 +103,7 @@ Q_SIGNALS:
void removeOverlay(int overlayId);
void fileContentAvailable(const FileManagement::Database::FlmFileContent &data);
private:
NGL::INGLLogger &m_logger;
bool initSrpHandler(int partitionIdIn, int partitionIdOut, qint64 beginTime, qint64 endTime);
bool initStaticPublisher();
bool loadReplayConfig(const QString &replayConfigPath);
@@ -117,6 +118,7 @@ private Q_SLOTS:
void onReplayTimeMaybeJumped(qint64 curTime);
private:
NGL::INGLLogger &m_logger;
QVector<FilterInformation> m_filter;
QVector<FilterInformation> m_overlays;
QVector<FilterInformation> m_currentVisibleOverlays;
@@ -20,14 +20,13 @@ namespace SituationReplay
ObjectSituationReplay::ObjectSituationReplay(const std::shared_ptr<DdsHandler> &ddsHandler,
const std::shared_ptr<DatabaseInterface> &db,
const std::shared_ptr<DbReader> &dbReader,
int exerciseId)
: m_ddsInterface(ddsHandler)
int exerciseId) : m_ddsInterface(ddsHandler)
, m_db(db)
, m_dbReader(dbReader)
, m_exerciseId(exerciseId)
, m_replayTimer(new QTimer(this))
, m_currentReplayTime(0)
{
, m_currentReplayTime(0),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
connect(m_replayTimer, &QTimer::timeout, this, &ObjectSituationReplay::onReplayTimerTimeout);
}
@@ -67,7 +66,7 @@ Core::FunctionReplyObject ObjectSituationReplay::createObject(const Database::Sr
}
// Id is serial -> will be generated by db => inside m_data after db-insert
DEBUG_LOG() << "New srpId: " << m_data.id;
DEBUG_LOG(m_logger) << "New srpId: " << m_data.id;
switchToState(SituationReplay::SrpState_def::Stopped);
@@ -90,7 +89,7 @@ bool ObjectSituationReplay::setPace(double newPace)
{
if (newPace < 0)
{
WARNING_LOG() << "Trying to set a pace < 0";
WARNING_LOG(m_logger) << "Trying to set a pace < 0";
return false;
}
m_data.pace = newPace;
@@ -113,7 +112,7 @@ bool ObjectSituationReplay::setSrpData(const Database::SrpSituationReplay &newDa
{
if (!m_db->update(m_data))
{
ERROR_LOG() << "Error updating SitReplay data in database (exerciseState)";
ERROR_LOG(m_logger) << "Error updating SitReplay data in database (exerciseState)";
return false;
}
@@ -129,7 +128,7 @@ bool ObjectSituationReplay::setSrpData(const Database::SrpSituationReplay &newDa
// record SrpStateChange
if (!m_db->insert(stateChange))
WARNING_LOG() << "Recording change of srpState failed";
WARNING_LOG(m_logger) << "Recording change of srpState failed";
}
// Publish Data via DTS
@@ -140,7 +139,7 @@ bool ObjectSituationReplay::setSrpData(const Database::SrpSituationReplay &newDa
bool ObjectSituationReplay::start()
{
INFO_LOG() << "start: " << m_currentReplayTime;
INFO_LOG(m_logger) << "start: " << m_currentReplayTime;
m_currentReplayTime = m_data.beginTime;
emit started(m_currentReplayTime);
@@ -156,7 +155,7 @@ bool ObjectSituationReplay::start()
bool ObjectSituationReplay::pause()
{
INFO_LOG() << "paused: " << m_currentReplayTime;
INFO_LOG(m_logger) << "paused: " << m_currentReplayTime;
m_replayTimer->stop();
emit paused();
return true;
@@ -164,7 +163,7 @@ bool ObjectSituationReplay::pause()
bool ObjectSituationReplay::resume()
{
INFO_LOG() << "resumed" << m_currentReplayTime;
INFO_LOG(m_logger) << "resumed" << m_currentReplayTime;
m_replayTimer->start(1000);
emit resumed(m_currentReplayTime);
return true;
@@ -172,7 +171,7 @@ bool ObjectSituationReplay::resume()
bool ObjectSituationReplay::stop()
{
INFO_LOG() << "stopped: " << m_currentReplayTime;
INFO_LOG(m_logger) << "stopped: " << m_currentReplayTime;
m_replayTimer->stop();
emit stopped();
return true;
@@ -188,10 +187,10 @@ void ObjectSituationReplay::onPublishReplayInformation()
m_data.endTime,
m_data.pace);
INFO_LOG() << "Publish SitReplay data: " << ddsData;
INFO_LOG(m_logger) << "Publish SitReplay data: " << ddsData;
if (!m_ddsInterface->dts()->publish(ddsData))
ERROR_LOG() << "Error publishing SitReplay data to dds";
ERROR_LOG(m_logger) << "Error publishing SitReplay data to dds";
}
void ObjectSituationReplay::onPublishReplayTime()
@@ -204,13 +203,13 @@ void ObjectSituationReplay::onPublishReplayTime()
void ObjectSituationReplay::onReplayTimerTimeout()
{
m_currentReplayTime += qRound64(m_data.pace * 1000);
DEBUG_LOG() << "onReplayTimerTimeout, endTime: " << m_data.endTime << " - " << m_currentReplayTime;
DEBUG_LOG(m_logger) << "onReplayTimerTimeout, endTime: " << m_data.endTime << " - " << m_currentReplayTime;
checkPublishData();
}
bool ObjectSituationReplay::checkPublishData()
{
INFO_LOG() << " checkPublishData...";
INFO_LOG(m_logger) << " checkPublishData...";
onPublishReplayTime();
if (m_data.endTime != 0 && m_data.endTime < m_currentReplayTime)
@@ -225,7 +224,7 @@ bool ObjectSituationReplay::checkPublishData()
// publish data for current time
m_dbReader->publish(m_currentReplayTime);
if (m_logger.isInfoEnabled()) INFO_LOG() << "m_dbReader->publish took " << timer.elapsed() << " [ms]";
if (m_logger.isInfoEnabled()) INFO_LOG(m_logger) << "m_dbReader->publish took " << timer.elapsed() << " [ms]";
if (qFuzzyIsNull(m_data.pace)) // pace == 0 -> snapshot
@@ -236,7 +235,7 @@ bool ObjectSituationReplay::checkPublishData()
if (switchToState(SrpState_def::Stopped).error())
return false;
if (m_logger.isInfoEnabled()) INFO_LOG() << "m_dbReader->waitForAsyncOperations took " << timerReadData.elapsed() << " [ms]";
if (m_logger.isInfoEnabled()) INFO_LOG(m_logger) << "m_dbReader->waitForAsyncOperations took " << timerReadData.elapsed() << " [ms]";
}
else
@@ -247,17 +246,17 @@ bool ObjectSituationReplay::checkPublishData()
if (!m_dbReader->readData(m_currentReplayTime, m_currentReplayTime + qRound64(m_data.pace * 1000)))
return false;
if (m_logger.isInfoEnabled()) INFO_LOG() << "m_dbReader->readData took " << timerReadData.elapsed() << " [ms]";
if (m_logger.isInfoEnabled()) INFO_LOG(m_logger) << "m_dbReader->readData took " << timerReadData.elapsed() << " [ms]";
}
}
INFO_LOG() << " checkPublishData... DONE";
INFO_LOG(m_logger) << " checkPublishData... DONE";
return true;
}
Core::FunctionReplyObject ObjectSituationReplay::switchToState(SrpState newSrpState)
{
Core::FunctionReplyObject ret(m_data.id);
INFO_LOG() << "-------------- switchTo: " << newSrpState
INFO_LOG(m_logger) << "-------------- switchTo: " << newSrpState
<< ", current: " << m_data.srpStateId;
if (m_data.srpStateId != newSrpState)
{
@@ -63,6 +63,7 @@ protected Q_SLOTS:
void onReplayTimerTimeout();
private:
NGL::INGLLogger &m_logger;
bool checkPublishData();
Q_SIGNALS:
@@ -74,6 +75,7 @@ Q_SIGNALS:
void stopped();
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DdsHandler> m_ddsInterface;
std::shared_ptr<DatabaseInterface> m_db;
std::shared_ptr<DbReader> m_dbReader;