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

@@ -49,7 +49,7 @@ WhgTests::~WhgTests()
//-----------------------------------------------------------------------------
bool WhgTests::init(int domainId, int testId, int eqtTypeWhId, int injuryModelWhId, int equipNo, int boxId)
{
INFO_LOG() << "WhgTests::init() "
INFO_LOG(m_logger) << "WhgTests::init() "
<< " domainId:" << domainId
<< " testId: " << testId
<< " equipmentTypeWhId: " << eqtTypeWhId
@@ -70,24 +70,24 @@ bool WhgTests::init(int domainId, int testId, int eqtTypeWhId, int injuryModelWh
m_ddsConnector->initPublisherSubscriber();
// Access to FTC
DEBUG_LOG() << "create ftc";
DEBUG_LOG(m_logger) << "create ftc";
m_ftc = WarehouseGuez::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;
// Access to DTC
DEBUG_LOG() << "create dtc";
DEBUG_LOG(m_logger) << "create dtc";
m_dtc = WarehouseGuez::Interface::Dtc::create(m_ddsConnector);
DEBUG_LOG() << "init dtc";
DEBUG_LOG(m_logger) << "init dtc";
bRet = m_dtc->enableAll();
DEBUG_LOG() << "init end - bRet = " << bRet;
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
connect(&m_wsClient, &QWebSocket::connected, this, &WhgTests::onConnected);
connect(&m_wsClient, &QWebSocket::textMessageReceived, this, &WhgTests::onTextMessageReceived);
int port = NGL::Connections::port(NGL::Connections::eConnection::LVS);
ERROR_LOG() << "Port:_ " << port;
ERROR_LOG(m_logger) << "Port:_ " << port;
//QUrl url(QStringLiteral("ws://%1:%2").arg(QStringLiteral("localhost"), QString::number(9094)));
QUrl url(QStringLiteral("ws://%1:%2").arg(QStringLiteral("localhost"), QString::number(port)));
@@ -98,20 +98,20 @@ bool WhgTests::init(int domainId, int testId, int eqtTypeWhId, int injuryModelWh
void WhgTests::onConnected()
{
ERROR_LOG() << "wsClient connected";
ERROR_LOG(m_logger) << "wsClient connected";
startTest();
}
void WhgTests::onTextMessageReceived(const QString &msg)
{
INFO_LOG() << "new text message: " << msg;
INFO_LOG(m_logger) << "new text message: " << msg;
//QTimer::singleShot(0, qApp, &QCoreApplication::quit);
}
//-----------------------------------------------------------------------------
void WhgTests::startTest()
{
INFO_LOG() << "startTest()"
INFO_LOG(m_logger) << "startTest()"
<< " testId:" << m_testId
<< " eqtTypeWhId:" << m_equipmentTypeWhId
;
@@ -139,7 +139,7 @@ void WhgTests::startTest()
QTimer::singleShot(0, this, &WhgTests::tryGetBiteData);
else
{
ERROR_LOG() << "Unknown test id " << m_testId;
ERROR_LOG(m_logger) << "Unknown test id " << m_testId;
failExit();
}
//QTimer::singleShot(0, qApp, &QCoreApplication::quit);
@@ -153,10 +153,10 @@ void WhgTests::tryCreate()
EquipmentTypeWh data;
getEqtTypeWhCreateRequestData(data);
INFO_LOG() << "trying to send create EquipmentTypeWh Request";
INFO_LOG(m_logger) << "trying to send create EquipmentTypeWh Request";
if (!m_ftc->modifyEquipmentTypeWhRequest(data, this))
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
} // end of tryCreate()
@@ -168,10 +168,10 @@ void WhgTests::tryModify()
EquipmentTypeWh data;
getEqtTypeWhModifyRequestData(data);
INFO_LOG() << "trying to send ModifyEquipementTypeWhRequest for eqtTypeWhId:" << data.id();
INFO_LOG(m_logger) << "trying to send ModifyEquipementTypeWhRequest for eqtTypeWhId:" << data.id();
if (!m_ftc->modifyEquipmentTypeWhRequest(data, this))
{
ERROR_LOG() << "Error requesting modify data for eqtTypeWhId:" << data.id();
ERROR_LOG(m_logger) << "Error requesting modify data for eqtTypeWhId:" << data.id();
failExit();
}
} // end of tryModify()
@@ -184,10 +184,10 @@ void WhgTests::tryRemove()
data.id(m_equipmentTypeWhId);
INFO_LOG() << "trying to send remove request for eqtTypeWhId:" << data.id();
INFO_LOG(m_logger) << "trying to send remove request for eqtTypeWhId:" << data.id();
if (!m_ftc->removeEquipmentTypeWhRequest(data, this))
{
ERROR_LOG() << "Error requesting remove data for eqtTypeWhId:" << data.id();
ERROR_LOG(m_logger) << "Error requesting remove data for eqtTypeWhId:" << data.id();
failExit();
}
} // end of tryRemove()
@@ -196,22 +196,22 @@ void WhgTests::tryRemove()
void WhgTests::tryGetAllEquipmentTypesWh()
{
m_eTestStep = eGetAllEquipmentTypesWh;
DEBUG_LOG() << "trying to get all eqtTypesWh";
DEBUG_LOG(m_logger) << "trying to get all eqtTypesWh";
m_dtc->waitForHistoricalDataEquipmentTypeWh();
const QMap<qint32, WarehouseGuez::EquipmentTypeWh> map = m_dtc->equipmentTypeWhs();
if (map.isEmpty())
{
ERROR_LOG() << "Error requesting all eqtTypesWh data";
ERROR_LOG(m_logger) << "Error requesting all eqtTypesWh data";
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
return;
}
INFO_LOG() << "Amout of existing eqtTypesWh:" << map.size();
INFO_LOG(m_logger) << "Amout of existing eqtTypesWh:" << map.size();
m_equipmentTypeWhId = map.firstKey();
for (auto it = map.begin(); it != map.end(); ++it)
{
INFO_LOG() << "whg(" << it.key() << ") :"
INFO_LOG(m_logger) << "whg(" << it.key() << ") :"
<< " name:" << it.value().name()
<< " minEquipNo:" << it.value().minEquipNo()
<< " maxEquipNo:" << it.value().maxEquipNo()
@@ -225,14 +225,14 @@ void WhgTests::tryGetAllEquipmentTypesWh()
//-----------------------------------------------------------------------------
void WhgTests::tryGetEquipmentTypeWh()
{
DEBUG_LOG() << "trying to get eqtTypeWh with id:" << m_equipmentTypeWhId;
DEBUG_LOG(m_logger) << "trying to get eqtTypeWh with id:" << m_equipmentTypeWhId;
if (m_testId > 1)
m_eTestStep = eGetEquipmentTypeWh;
if (m_equipmentTypeWhId < 0)
{
ERROR_LOG() << "invalid eqtTypeWhId - test aborted.";
ERROR_LOG(m_logger) << "invalid eqtTypeWhId - test aborted.";
failExit();
}
@@ -241,12 +241,12 @@ void WhgTests::tryGetEquipmentTypeWh()
if (data.id() < 0)
{
ERROR_LOG() << "Error receiving data for equipmentTypeId " << m_equipmentTypeWhId << " returnVal:" << data.id();
ERROR_LOG(m_logger) << "Error receiving data for equipmentTypeId " << m_equipmentTypeWhId << " returnVal:" << data.id();
failExit();
}
else
{
INFO_LOG() << "whg(" << data.id() << ") :"
INFO_LOG(m_logger) << "whg(" << data.id() << ") :"
<< " name:" << data.name()
<< " minEquipNo:" << data.minEquipNo()
<< " maxEquipNo:" << data.maxEquipNo()
@@ -259,7 +259,7 @@ void WhgTests::tryGetEquipmentTypeWh()
{
if (! onCompareCreatedData(data))
{
ERROR_LOG() << "Compare created data failed!";
ERROR_LOG(m_logger) << "Compare created data failed!";
failExit();
}
else
@@ -272,7 +272,7 @@ void WhgTests::tryGetEquipmentTypeWh()
{
if (! onCompareModifiedData(data))
{
ERROR_LOG() << "Compare modified data failed!";
ERROR_LOG(m_logger) << "Compare modified data failed!";
failExit();
}
else
@@ -291,19 +291,19 @@ void WhgTests::tryGetEquipmentTypeWh()
//-----------------------------------------------------------------------------
void WhgTests::onModifyEquipmentTypeWhReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG() << "Got onModifyEquipmentTypeWhReply with id " << replyObject.id()
INFO_LOG(m_logger) << "Got onModifyEquipmentTypeWhReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
m_equipmentTypeWhId = replyObject.id();
if (replyObject.error())
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
return;
}
else
INFO_LOG() << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
INFO_LOG(m_logger) << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
if (m_testId == 0)
// QTimer::singleShot(0, this, &WhgTests::tryModify()));
@@ -317,17 +317,17 @@ void WhgTests::onModifyEquipmentTypeWhReply(const Core::FunctionReplyObject &rep
//-----------------------------------------------------------------------------
void WhgTests::onRemoveEquipmentTypeWhReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG() << "Got removeReply with id " << replyObject.id()
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
if (replyObject.error())
{
ERROR_LOG() << "Error requesting remove data for eqtTypeWhId:" << replyObject.id();
ERROR_LOG(m_logger) << "Error requesting remove data for eqtTypeWhId:" << replyObject.id();
failExit();
return;
}
else
DEBUG_LOG() << "Requesting remove data for eqtTypeWhId:" << replyObject.id() << " ... ok.";
DEBUG_LOG(m_logger) << "Requesting remove data for eqtTypeWhId:" << replyObject.id() << " ... ok.";
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
@@ -337,19 +337,19 @@ void WhgTests::onRemoveEquipmentTypeWhReply(const Core::FunctionReplyObject &rep
//-----------------------------------------------------------------------------
void WhgTests::onModifyInjuryModelAgdusWhReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG() << "Got onModifyInjuryModelAgdusWhReply with id " << replyObject.id()
INFO_LOG(m_logger) << "Got onModifyInjuryModelAgdusWhReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
m_injuryModelWhId = replyObject.id();
if (replyObject.error())
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
return;
}
else
DEBUG_LOG() << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
DEBUG_LOG(m_logger) << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
@@ -358,17 +358,17 @@ void WhgTests::onModifyInjuryModelAgdusWhReply(const Core::FunctionReplyObject &
//-----------------------------------------------------------------------------
void WhgTests::onRemoveInjuryModelAgdusWhReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG() << "Got removeReply with id " << replyObject.id()
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
if (replyObject.error())
{
ERROR_LOG() << "Error requesting remove data for injuryModelWhId:" << replyObject.id();
ERROR_LOG(m_logger) << "Error requesting remove data for injuryModelWhId:" << replyObject.id();
failExit();
return;
}
else
DEBUG_LOG() << "Requesting remove data for injuryModelWhId:" << replyObject.id() << " ... ok.";
DEBUG_LOG(m_logger) << "Requesting remove data for injuryModelWhId:" << replyObject.id() << " ... ok.";
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
@@ -378,25 +378,25 @@ void WhgTests::onRemoveInjuryModelAgdusWhReply(const Core::FunctionReplyObject &
//-----------------------------------------------------------------------------
void WhgTests::onReceiveEqtTypeChanged(const EquipmentTypeWh &data, DataModification modType)
{
INFO_LOG() << "onReceiveEqtTypeChanged() eqtTypeWhId:" << data.id()
INFO_LOG(m_logger) << "onReceiveEqtTypeChanged() eqtTypeWhId:" << data.id()
<< " modificationType: = " << (int)modType<< " received";
switch (modType)
{
case DataModification::eAdded:
INFO_LOG() << "*** EquipmentTypeWh added received. eqtTypeWhId:" << data.id();
INFO_LOG(m_logger) << "*** EquipmentTypeWh added received. eqtTypeWhId:" << data.id();
break;
case DataModification::eModified:
INFO_LOG() << "*** EquipmentTypeWh modified received. eqtTypeWhId:" << data.id();
INFO_LOG(m_logger) << "*** EquipmentTypeWh modified received. eqtTypeWhId:" << data.id();
break;
case DataModification::eRemoved:
INFO_LOG() << "*** EquipmentTypeWh removed received. eqtTypeWhId:" << data.id();
INFO_LOG(m_logger) << "*** EquipmentTypeWh removed received. eqtTypeWhId:" << data.id();
break;
default:
INFO_LOG() << "DataModification::" << modType << " not implemented";
INFO_LOG(m_logger) << "DataModification::" << modType << " not implemented";
}
} // end of onReceiveEqtTypeChanged()
@@ -448,7 +448,7 @@ void WhgTests::getInjuryModelWhModifyRequestData(InjuryModelAgdusWh &data)
//-----------------------------------------------------------------------------
bool WhgTests::onCompareCreatedData(EquipmentTypeWh &data)
{
DEBUG_LOG() << "start onCompareCreatedData() for id :" << data.id();
DEBUG_LOG(m_logger) << "start onCompareCreatedData() for id :" << data.id();
// Vergleicht die zurueckgelesen Datan mit den statischen create Daten
@@ -469,14 +469,14 @@ bool WhgTests::onCompareCreatedData(EquipmentTypeWh &data)
return false;
DEBUG_LOG() << "successfull finished onCompareCreatedData() for id :" << data.id();
DEBUG_LOG(m_logger) << "successfull finished onCompareCreatedData() for id :" << data.id();
return true;
} // end of onCompareCreatedData()
bool WhgTests::onCompareCreatedData(InjuryModelAgdusWh &data)
{
DEBUG_LOG() << "start onCompareCreatedData() for id :" << data.id();
DEBUG_LOG(m_logger) << "start onCompareCreatedData() for id :" << data.id();
// Vergleicht die zurueckgelesen Datan mit den statischen create Daten
@@ -493,7 +493,7 @@ bool WhgTests::onCompareCreatedData(InjuryModelAgdusWh &data)
if (createData.description() != data.description())
return false;
DEBUG_LOG() << "successfull finished onCompareCreatedData() for id :" << data.id();
DEBUG_LOG(m_logger) << "successfull finished onCompareCreatedData() for id :" << data.id();
return true;
} // end of onCompareCreatedData()
@@ -501,7 +501,7 @@ bool WhgTests::onCompareCreatedData(InjuryModelAgdusWh &data)
//-----------------------------------------------------------------------------
bool WhgTests::onCompareModifiedData(EquipmentTypeWh &data)
{
DEBUG_LOG() << "start onCompareModifiedData() for id :" << data.id();
DEBUG_LOG(m_logger) << "start onCompareModifiedData() for id :" << data.id();
EquipmentTypeWh modifyData;
@@ -522,7 +522,7 @@ bool WhgTests::onCompareModifiedData(EquipmentTypeWh &data)
if (modifyData.vbAgdusId() != data.vbAgdusId())
return false;
DEBUG_LOG() << "successfully finished onCompareModifiedData() for id :" << data.id();
DEBUG_LOG(m_logger) << "successfully finished onCompareModifiedData() for id :" << data.id();
return true;
} // end of onCompareModifiedData()
@@ -530,7 +530,7 @@ bool WhgTests::onCompareModifiedData(EquipmentTypeWh &data)
//-----------------------------------------------------------------------------
bool WhgTests::onCompareModifiedData(InjuryModelAgdusWh &data)
{
DEBUG_LOG() << "start onCompareModifiedData() for id :" << data.id();
DEBUG_LOG(m_logger) << "start onCompareModifiedData() for id :" << data.id();
InjuryModelAgdusWh modifyData;
@@ -548,7 +548,7 @@ bool WhgTests::onCompareModifiedData(InjuryModelAgdusWh &data)
if (modifyData.description() != data.description())
return false;
DEBUG_LOG() << "successfull finished onCompareModifiedData() for id :" << data.id();
DEBUG_LOG(m_logger) << "successfull finished onCompareModifiedData() for id :" << data.id();
return true;
} // end of onCompareModifiedData()
@@ -561,10 +561,10 @@ void WhgTests::tryCreateInjuryModel()
InjuryModelAgdusWh data;
getInjuryModelWhCreateRequestData(data);
INFO_LOG() << "trying to send modifyInjuryModelAgdusWhRequest with id = 0 (create)";
INFO_LOG(m_logger) << "trying to send modifyInjuryModelAgdusWhRequest with id = 0 (create)";
if (!m_ftc->modifyInjuryModelAgdusWhRequest(data, this))
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
} // end of tryCreateInjuryModel()
@@ -576,10 +576,10 @@ void WhgTests::tryModifyInjuryModel()
InjuryModelAgdusWh data;
getInjuryModelWhModifyRequestData(data);
ERROR_LOG() << "trying to send modifyInjuryModelAgdusWhRequest for injuryModelWhId:" << data.id();
ERROR_LOG(m_logger) << "trying to send modifyInjuryModelAgdusWhRequest for injuryModelWhId:" << data.id();
if (!m_ftc->modifyInjuryModelAgdusWhRequest(data, this))
{
ERROR_LOG() << "Error requesting modify data for injuryModelWhId:" << data.id();
ERROR_LOG(m_logger) << "Error requesting modify data for injuryModelWhId:" << data.id();
failExit();
}
} // end of tryModifyInjuryModel()
@@ -592,10 +592,10 @@ void WhgTests::tryRemoveInjuryModel()
data.id(m_injuryModelWhId);
INFO_LOG() << "trying to send remove request for injuryModelWhId:" << data.id();
INFO_LOG(m_logger) << "trying to send remove request for injuryModelWhId:" << data.id();
if (!m_ftc->removeInjuryModelAgdusWhRequest(data, this))
{
ERROR_LOG() << "Error requesting remove data for injuryModelWhId:" << data.id();
ERROR_LOG(m_logger) << "Error requesting remove data for injuryModelWhId:" << data.id();
failExit();
}
} // end of tryRemoveInjuryModel()
@@ -68,6 +68,7 @@ protected Q_SLOTS:
void onReceiveEqtTypeChanged(const WarehouseGuez::EquipmentTypeWh &data, DataModification modType);
protected:
NGL::INGLLogger &m_logger;
// Callbackfunctions for FTC
void onModifyEquipmentTypeWhReply(const Core::FunctionReplyObject &replyObject) override final;
void onRemoveEquipmentTypeWhReply(const Core::FunctionReplyObject &replyObject) override final;
@@ -90,7 +90,7 @@ LtsWebSocket::ReplyMessage *DataManager::equipmentTypes(const QString &uuid) con
QJsonObject obj = eTypes.toJsonAll();
INFO_LOG() << "equipTypeMap.size: " << etMap.size() << ", " << QJsonDocument(obj).toJson();
INFO_LOG(m_logger) << "equipTypeMap.size: " << etMap.size() << ", " << QJsonDocument(obj).toJson();
return new EquipmentTypesMessage(obj, uuid);
}
@@ -98,7 +98,7 @@ void DataManager::newExerciseInformationsFromEXCON(const EXCON::Exercises &ex)
{
const IWMS2ECC::exerciseMap exMap = ex.getExercises();
DEBUG_LOG() << "Exercises map.size: " << exMap.size();
DEBUG_LOG(m_logger) << "Exercises map.size: " << exMap.size();
QVector<Database::Exercise> dataVec;
m_mainHandler->db()->select(dataVec);
@@ -121,7 +121,7 @@ void DataManager::newExerciseInformationsFromEXCON(const EXCON::Exercises &ex)
if (!ok)
{
ERROR_LOG() << "Error while insert/update in exercise";
ERROR_LOG(m_logger) << "Error while insert/update in exercise";
break;
}
}
@@ -175,15 +175,15 @@ void DataManager::participantsFromEXCON(const PlayerInfo &pl)
if (plMap.isEmpty())
{
DEBUG_LOG() << "No valid exercise -> no participants";
DEBUG_LOG(m_logger) << "No valid exercise -> no participants";
return;
}
// first get exerciseId
int exerciseId = plMap.firstKey() / s_exerciseOffset;
DEBUG_LOG() << "ExerciseId: " << exerciseId;
DEBUG_LOG() << "plMap.size(): " << plMap.size();
DEBUG_LOG(m_logger) << "ExerciseId: " << exerciseId;
DEBUG_LOG(m_logger) << "plMap.size(): " << plMap.size();
// table is created at exercise creation
QString tlnOut = tlnTable(exerciseId);
@@ -192,28 +192,28 @@ void DataManager::participantsFromEXCON(const PlayerInfo &pl)
// If entries exist delete them
QString stmt = QStringLiteral("DELETE FROM ") + tlnOut;
DEBUG_LOG() << "Executing delete statement: " << stmt;
DEBUG_LOG(m_logger) << "Executing delete statement: " << stmt;
q.exec(stmt);
stmt = QStringLiteral("INSERT INTO ") + tlnOut + QStringLiteral("( id, hierarchie, typ_id, ausstg_typ_id, ausstg_nr, zuordnung, y_nr, info, loeschkennung, zeit ) VALUES (" )
+ QStringLiteral(":id, :hierarchie, :typ_id, :ausstg_typ_id, :ausstg_nr, :zuordnung, :y_nr, :info, :loeschkennung, :zeit )");
DEBUG_LOG() << "Preparing insert statement: " << stmt;
DEBUG_LOG(m_logger) << "Preparing insert statement: " << stmt;
q.prepare(stmt);
for (const IWMS2ECC::PlayerInfo &pl : plMap)
{
bindPlayer(q, pl);
DEBUG_LOG() << "Executing insert statement for participant: " << pl.playerId;
DEBUG_LOG(m_logger) << "Executing insert statement for participant: " << pl.playerId;
if (!q.exec())
ERROR_LOG() << "Error inserting data for participantId: " << pl.playerId;
ERROR_LOG(m_logger) << "Error inserting data for participantId: " << pl.playerId;
}
}
bool DataManager::participantFromEXCON(const IWMS2ECC::PlayerInfo &pl, int modType)
{
DEBUG_LOG() << "IN participantFromEXCON: modType: " << modType << ", participantId: " << pl.playerId;
DEBUG_LOG(m_logger) << "IN participantFromEXCON: modType: " << modType << ", participantId: " << pl.playerId;
DataModification modificationType = static_cast<DataModification>(modType);
int exerciseId = pl.playerId / s_exerciseOffset;
@@ -221,7 +221,7 @@ bool DataManager::participantFromEXCON(const IWMS2ECC::PlayerInfo &pl, int modTy
NSqlQuery q(m_mainHandler->db()->database());
DEBUG_LOG() << "Executing delete statement: " << QStringLiteral("DELETE FROM %1 WHERE id = %2").arg(tlnOut).arg(pl.playerId);
DEBUG_LOG(m_logger) << "Executing delete statement: " << QStringLiteral("DELETE FROM %1 WHERE id = %2").arg(tlnOut).arg(pl.playerId);
q.exec(QStringLiteral("DELETE FROM %1 WHERE id = %2").arg(tlnOut).arg(pl.playerId));
switch(modificationType)
@@ -234,16 +234,16 @@ bool DataManager::participantFromEXCON(const IWMS2ECC::PlayerInfo &pl, int modTy
QStringLiteral(":id, :hierarchie, :typ_id, :ausstg_typ_id, :ausstg_nr, :zuordnung, :y_nr, :info, :loeschkennung, :zeit )");
if (!q.prepare(stmt))
{
ERROR_LOG() << "Error while preparing insert stmt: " << stmt;
ERROR_LOG(m_logger) << "Error while preparing insert stmt: " << stmt;
return false;
}
bindPlayer(q, pl);
DEBUG_LOG() << "Executing insert statement: " << stmt;
DEBUG_LOG(m_logger) << "Executing insert statement: " << stmt;
if (!q.exec())
{
ERROR_LOG() << "Error inserting data for participantId: " << pl.playerId;
ERROR_LOG(m_logger) << "Error inserting data for participantId: " << pl.playerId;
return false;
}
break;
@@ -257,7 +257,7 @@ bool DataManager::participantFromEXCON(const IWMS2ECC::PlayerInfo &pl, int modTy
bool DataManager::exerciseChanged(const IWMS2ECC::Exercise &data, DataModification modType)
{
DEBUG_LOG() << "IN exerciseChanged: id = " << data.id << ", actExercise: " << data.actExercise;
DEBUG_LOG(m_logger) << "IN exerciseChanged: id = " << data.id << ", actExercise: " << data.actExercise;
Database::Exercise exData;
exData.id = data.id;
@@ -276,7 +276,7 @@ bool DataManager::exerciseChanged(const IWMS2ECC::Exercise &data, DataModificati
{
if (!m_mainHandler->db()->update(exData))
{
ERROR_LOG() << "Error while updating exerciseData for exercise: " << data.id;
ERROR_LOG(m_logger) << "Error while updating exerciseData for exercise: " << data.id;
return false;
}
}
@@ -284,7 +284,7 @@ bool DataManager::exerciseChanged(const IWMS2ECC::Exercise &data, DataModificati
{
if (!m_mainHandler->db()->insert(exData))
{
ERROR_LOG() << "Error while inserting exerciseData for exercise: " << data.id;
ERROR_LOG(m_logger) << "Error while inserting exerciseData for exercise: " << data.id;
return false;
}
createTableTlnOut(exData.id);
@@ -296,7 +296,7 @@ bool DataManager::exerciseChanged(const IWMS2ECC::Exercise &data, DataModificati
{
if (!m_mainHandler->db()->update(exData))
{
ERROR_LOG() << "Error while updating exerciseData for exercise: " << data.id;
ERROR_LOG(m_logger) << "Error while updating exerciseData for exercise: " << data.id;
return false;
}
return true;
@@ -305,20 +305,20 @@ bool DataManager::exerciseChanged(const IWMS2ECC::Exercise &data, DataModificati
{
if (!m_mainHandler->db()->removeExercise(data.id))
{
ERROR_LOG() << "Error while removing exerciseData for exercise: " << data.id;
ERROR_LOG(m_logger) << "Error while removing exerciseData for exercise: " << data.id;
return false;
}
return true;
}
}
ERROR_LOG() << "DataModification Type: " << modType << " not handled in switch";
ERROR_LOG(m_logger) << "DataModification Type: " << modType << " not handled in switch";
return false;
}
void DataManager::createTableTlnOut(int exerciseId)
{
ERROR_LOG() << "createTableTlnOut";
ERROR_LOG(m_logger) << "createTableTlnOut";
// xmlPath
const QString xmlPath = NGL::directory(NGL::FileType::ConfigFile, QLatin1String("xml"));
QString xmlFile = xmlPath + QStringLiteral("/whg.xml");
@@ -326,7 +326,7 @@ void DataManager::createTableTlnOut(int exerciseId)
CodeGen::SqlGenerator sqlGen(xmlFile);
QString tlnOut = tlnTable(exerciseId);
ERROR_LOG() << "tlnOut: " << tlnOut;
ERROR_LOG(m_logger) << "tlnOut: " << tlnOut;
sqlGen.createStatementsForTable(QStringLiteral("tln"), tlnOut);
@@ -337,18 +337,18 @@ void DataManager::createTableTlnOut(int exerciseId)
NSqlQuery q(m_mainHandler->db()->database());
for (const QString &stmt : stmts.createTables)
{
ERROR_LOG() << "stmt: " << stmt;
ERROR_LOG(m_logger) << "stmt: " << stmt;
if (record.isEmpty())
{
if (!q.exec(stmt))
ERROR_LOG() << "Error executing stmt: " << stmt;
ERROR_LOG(m_logger) << "Error executing stmt: " << stmt;
}
}
}
void DataManager::createTableTlnZuordnung(int exerciseId)
{
ERROR_LOG() << "in createTableTlnZuordnung";
ERROR_LOG(m_logger) << "in createTableTlnZuordnung";
// xmlPath
const QString xmlPath = NGL::directory(NGL::FileType::ConfigFile, QLatin1String("xml"));
QString xmlFile = xmlPath + QStringLiteral("/whg.xml");
@@ -356,7 +356,7 @@ void DataManager::createTableTlnZuordnung(int exerciseId)
CodeGen::SqlGenerator sqlGen(xmlFile);
const QString tlnZuordnung = tlnZuordnungTable(exerciseId);
ERROR_LOG() << "tlnZuordnung: " << tlnZuordnung;
ERROR_LOG(m_logger) << "tlnZuordnung: " << tlnZuordnung;
sqlGen.createStatementsForTable(QStringLiteral("tln_zuordnung"), tlnZuordnung);
const CodeGen::SqlGenerator::SqlStatements stmts = sqlGen.getStatements(CodeGen::Global);
@@ -366,20 +366,20 @@ void DataManager::createTableTlnZuordnung(int exerciseId)
NSqlQuery q(m_mainHandler->db()->database());
for (const QString &stmt : stmts.createTables)
{
DEBUG_LOG() << "stmt: " << stmt;
DEBUG_LOG(m_logger) << "stmt: " << stmt;
if (record.isEmpty())
{
if (!q.exec(stmt))
ERROR_LOG() << "Error executing stmt: " << stmt;
ERROR_LOG(m_logger) << "Error executing stmt: " << stmt;
}
}
for (const QString &stmt : stmts.createSequences)
{
DEBUG_LOG() << "stmt: " << stmt;
DEBUG_LOG(m_logger) << "stmt: " << stmt;
if (record.isEmpty())
{
if (!q.exec(stmt))
ERROR_LOG() << "Error executing stmt: " << stmt;
ERROR_LOG(m_logger) << "Error executing stmt: " << stmt;
}
}
@@ -396,7 +396,7 @@ void DataManager::createTriggerForExercise(NSqlQuery &q, int exerciseId)
stmt = QLatin1String("DROP TRIGGER IF EXISTS ") + triggerNameExercise +
QLatin1String(" ON ") + tlnZuordnungTableExercise;
if (!q.exec(stmt))
ERROR_LOG() << "Error dropping possible old trigger: " << stmt;
ERROR_LOG(m_logger) << "Error dropping possible old trigger: " << stmt;
// Create trigger
stmt = QLatin1String("CREATE OR REPLACE FUNCTION public.") + triggerNameExercise +
@@ -408,14 +408,14 @@ void DataManager::createTriggerForExercise(NSqlQuery &q, int exerciseId)
"$$ LANGUAGE plpgsql;");
if (!q.exec(stmt))
ERROR_LOG() << "Error while creating function in statement: " << stmt;
ERROR_LOG(m_logger) << "Error while creating function in statement: " << stmt;
stmt = QLatin1String("CREATE TRIGGER ") + triggerNameExercise +
QLatin1String(" AFTER INSERT ON ") + tlnZuordnungTableExercise +
QLatin1String(" FOR EACH ROW EXECUTE PROCEDURE public.") + triggerNameExercise + QLatin1String("();");
if (!q.exec(stmt))
ERROR_LOG() << "Error while creating trigger in statement: " << stmt;
ERROR_LOG(m_logger) << "Error while creating trigger in statement: " << stmt;
QSqlDriver *driver = m_mainHandler->db()->database().driver();
@@ -424,14 +424,14 @@ void DataManager::createTriggerForExercise(NSqlQuery &q, int exerciseId)
this, &DataManager::onNotification, Qt::UniqueConnection);
if (!driver->subscribeToNotification(triggerNameExercise))
WARNING_LOG() << "Error subscribing to DB notification " << triggerNameExercise;
WARNING_LOG(m_logger) << "Error subscribing to DB notification " << triggerNameExercise;
else
DEBUG_LOG() << "Sucessfully subscribed to DB notification " << triggerNameExercise;
DEBUG_LOG(m_logger) << "Sucessfully subscribed to DB notification " << triggerNameExercise;
}
void DataManager::onInsertParticipantAssignment(int participantId, int exerciseId)
{
INFO_LOG() << "Reading ParticipantAssignment from database!";
INFO_LOG(m_logger) << "Reading ParticipantAssignment from database!";
NSqlQuery q(m_mainHandler->db()->database());
@@ -445,7 +445,7 @@ void DataManager::onInsertParticipantAssignment(int participantId, int exerciseI
if (!q.exec(stmt))
{
ERROR_LOG() << "Error selecting data for participantId: " << participantId << ", exerciseId: " << exerciseId;
ERROR_LOG(m_logger) << "Error selecting data for participantId: " << participantId << ", exerciseId: " << exerciseId;
return;
}
@@ -454,7 +454,7 @@ void DataManager::onInsertParticipantAssignment(int participantId, int exerciseI
{
// use the 'correct' participant id in case participantId == 0 was given (happens during startup)
participantId = q.value(0).toInt() - (exerciseId * s_exerciseOffset);
DEBUG_LOG() << "participantId: " << participantId;
DEBUG_LOG(m_logger) << "participantId: " << participantId;
Registration reg;
reg.setPlayerId(participantId);
@@ -472,7 +472,7 @@ void DataManager::onInsertParticipantAssignment(int participantId, int exerciseI
Messages::ParticipantRegisterInExconRequest *msg = new Messages::ParticipantRegisterInExconRequest(reg.toJson(),
QLatin1String("blub"));
INFO_LOG() << "registration: " << msg->toJsonString();
INFO_LOG(m_logger) << "registration: " << msg->toJsonString();
m_webSocketServer->sendToAllClients(msg);
}
}
@@ -482,7 +482,7 @@ void DataManager::onNotification(const QString &name, QSqlDriver::NotificationSo
Q_UNUSED(source);
// search coresponding signal
INFO_LOG() << "IN onNotification name: " << name;
INFO_LOG(m_logger) << "IN onNotification name: " << name;
const QString triggerNameEx0 = triggerName(0);
if (name.contains(triggerNameEx0))
@@ -491,7 +491,7 @@ void DataManager::onNotification(const QString &name, QSqlDriver::NotificationSo
name_ = name_.mid(triggerNameEx0.size() + 1);
int exerciseId = name_.toInt();
int participantId = payload.toInt();
INFO_LOG() << "exerciseId: " << exerciseId << ", participantId: " << participantId;
INFO_LOG(m_logger) << "exerciseId: " << exerciseId << ", participantId: " << participantId;
onInsertParticipantAssignment(participantId, exerciseId);
}
}
@@ -512,7 +512,7 @@ void DataManager::reconnectSignals()
void DataManager::registerReply(int exerciseId, qint32 participantId, int returnValue)
{
DEBUG_LOG() << "registerReply for exercise id = " << exerciseId << ", participant id = " << participantId << ", return value = " << returnValue;
DEBUG_LOG(m_logger) << "registerReply for exercise id = " << exerciseId << ", participant id = " << participantId << ", return value = " << returnValue;
NSqlQuery q(m_mainHandler->db()->database());
@@ -523,15 +523,15 @@ void DataManager::registerReply(int exerciseId, qint32 participantId, int return
QLatin1String(" WHERE id = ") + QString::number(newParticipantId) +
QLatin1String(" AND gesendet = false");
DEBUG_LOG() << "registerReply: stmt = " << stmt;
DEBUG_LOG(m_logger) << "registerReply: stmt = " << stmt;
if (!q.exec(stmt))
{
ERROR_LOG() << "Cannot update reply entry for participant: " << participantId
ERROR_LOG(m_logger) << "Cannot update reply entry for participant: " << participantId
<< " in exercise: " << exerciseId << ", returnValue: " << returnValue;
}
else
{
INFO_LOG() << "Update successful for participant " << participantId << " in exercise: " << exerciseId;
INFO_LOG(m_logger) << "Update successful for participant " << participantId << " in exercise: " << exerciseId;
}
if (returnValue != 0)
@@ -541,16 +541,16 @@ void DataManager::registerReply(int exerciseId, qint32 participantId, int return
QLatin1String(" SET ausstg_nr = -1, zeit = ") + QString::number(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch()) +
QLatin1String(" WHERE id = ") + QString::number(newParticipantId);
DEBUG_LOG() << "registerReply: stmt1 = " << stmt1;
DEBUG_LOG(m_logger) << "registerReply: stmt1 = " << stmt1;
if (!q.exec(stmt1))
{
ERROR_LOG() << "Cannot update austtg_nr for participant: " << participantId
ERROR_LOG(m_logger) << "Cannot update austtg_nr for participant: " << participantId
<< " in exercise: " << exerciseId << ", returnValue: " << returnValue;
}
else
{
INFO_LOG() << "Update ausstg_nr successful for participant " << participantId << " in exercise: " << exerciseId;
INFO_LOG(m_logger) << "Update ausstg_nr successful for participant " << participantId << " in exercise: " << exerciseId;
}
}
@@ -36,34 +36,34 @@ bool WsBaseDataInterfaceHandler::init()
{
cleanup();
DEBUG_LOG() << "... ok";
DEBUG_LOG(m_logger) << "... ok";
DEBUG_LOG() << "Initialising DataManager";
DEBUG_LOG(m_logger) << "Initialising DataManager";
m_dataManager = new DataManager(m_mainHandler);
if (!m_dataManager->init())
{
ERROR_LOG() << "Failed to initialise DataManager";
ERROR_LOG(m_logger) << "Failed to initialise DataManager";
return false;
}
DEBUG_LOG() << "... ok";
DEBUG_LOG(m_logger) << "... ok";
m_messageFactory = new Messages::ClientMessageFactory(m_dataManager);
m_webSocketServer = new LtsWebSocket::LtsWebSocketServer(m_messageFactory, this);
DEBUG_LOG() << "Initialising LtsWebSocketServer";
DEBUG_LOG(m_logger) << "Initialising LtsWebSocketServer";
int port = NGL::Connections::port(NGL::Connections::eConnection::ZSLV);
ERROR_LOG() << "Port: " << port;
ERROR_LOG(m_logger) << "Port: " << port;
if (!m_webSocketServer->init(QStringLiteral("localhost"), port))
{
ERROR_LOG() << "Failed to initialise LtsWebSocketServer";
ERROR_LOG(m_logger) << "Failed to initialise LtsWebSocketServer";
return false;
}
DEBUG_LOG() << "... ok";
DEBUG_LOG(m_logger) << "... ok";
DEBUG_LOG() << "Connection signals and slots";
DEBUG_LOG(m_logger) << "Connection signals and slots";
m_dataManager->setWebSocketServer(m_webSocketServer);
@@ -36,7 +36,7 @@ bool ClientConnection::init()
{
if (m_socket == nullptr)
{
ERROR_LOG() << "Initialisation failed due to an invalid socket";
ERROR_LOG(m_logger) << "Initialisation failed due to an invalid socket";
return false;
}
@@ -57,17 +57,17 @@ void ClientConnection::addMessage(const WarehouseGuez::WsBiteInterface::Messages
if (!m_socket || m_socket->state() != QAbstractSocket::ConnectedState)
{
m_messageQueue.enqueue(message);
DEBUG_LOG() << "Adding message to queue, size: " << m_messageQueue.size();
DEBUG_LOG(m_logger) << "Adding message to queue, size: " << m_messageQueue.size();
return;
}
const QString msg(message.toJsonString());
TRACE_LOG() << "Send msg: " << msg;
TRACE_LOG(m_logger) << "Send msg: " << msg;
m_socket->sendTextMessage(msg);
}
void ClientConnection::onNewTextMessageFromSocket(const QString &message)
{
DEBUG_LOG() << "Recv msg: " << message;
DEBUG_LOG(m_logger) << "Recv msg: " << message;
emit newTextMessage(this, message);
}
@@ -79,15 +79,15 @@ void ClientConnection::sendMessagesFromQueue()
{
Messages::ReplyMessage message = m_messageQueue.dequeue();
const QString msg(message.toJsonString());
TRACE_LOG() << "Send msg: " << msg;
TRACE_LOG(m_logger) << "Send msg: " << msg;
m_socket->sendTextMessage(msg);
DEBUG_LOG() << "Sent message from queue, new size: " << m_messageQueue.size();
DEBUG_LOG(m_logger) << "Sent message from queue, new size: " << m_messageQueue.size();
}
}
void ClientConnection::onSocketDisconnect()
{
DEBUG_LOG() << "Client with ip "
DEBUG_LOG(m_logger) << "Client with ip "
<< m_ip.toString()
<< " disconnected";
emit disconnected(this);
@@ -46,6 +46,8 @@ private Q_SLOTS:
void onSocketDisconnect();
private: // methods
NGL::INGLLogger &m_logger;
void sendMessages();
private: // attributes
@@ -19,9 +19,8 @@
using namespace WarehouseGuez::WsBiteInterface::Connection;
ConnectionHandler::ConnectionHandler()
: m_server(nullptr)
{
ConnectionHandler::ConnectionHandler() : m_server(nullptr),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
}
ConnectionHandler::~ConnectionHandler()
@@ -48,13 +47,13 @@ bool ConnectionHandler::init()
// TODO: read port from config?
int port = NGL::Connections::port(NGL::Connections::eConnection::LVS);
DEBUG_LOG() << "Trying to listen to port " << port;
DEBUG_LOG(m_logger) << "Trying to listen to port " << port;
if (!m_server->listen(QHostAddress::Any, port))
{
ERROR_LOG() << "Not possible to listen to port " << port;
ERROR_LOG(m_logger) << "Not possible to listen to port " << port;
return false;
}
DEBUG_LOG() << "... ok - port: " << port;
DEBUG_LOG(m_logger) << "... ok - port: " << port;
return true;
}
@@ -66,7 +65,7 @@ void ConnectionHandler::onNewMessage(WarehouseGuez::WsBiteInterface::Messages::M
void ConnectionHandler::onServerError(QWebSocketProtocol::CloseCode closeCode)
{
ERROR_LOG() << "Got server error with close code " << closeCode;
ERROR_LOG(m_logger) << "Got server error with close code " << closeCode;
}
void ConnectionHandler::onNewConnection()
@@ -78,7 +77,7 @@ void ConnectionHandler::onNewConnection()
if (!newConnection->init())
{
ERROR_LOG() << "Failed to initialise new client";
ERROR_LOG(m_logger) << "Failed to initialise new client";
delete newConnection;
newConnection = nullptr;
continue;
@@ -88,7 +87,7 @@ void ConnectionHandler::onNewConnection()
connect(newConnection, &ClientConnection::disconnected, this, &ConnectionHandler::onDisconnected);
m_connections.append(newConnection);
DEBUG_LOG() << "New client with ip " << newConnection->ip().toString() << " connected";
DEBUG_LOG(m_logger) << "New client with ip " << newConnection->ip().toString() << " connected";
}
}
@@ -50,6 +50,8 @@ private Q_SLOTS:
void onDisconnected(ClientConnection *conn);
private: // attributes
NGL::INGLLogger &m_logger;
QWebSocketServer *m_server;
QVector<ClientConnection *> m_connections;
};
@@ -18,9 +18,8 @@ namespace WsBiteInterface
namespace Messages
{
MessageHandler::MessageHandler(DataManager *dataManager)
: m_dataManager(dataManager)
{
MessageHandler::MessageHandler(DataManager *dataManager) : m_dataManager(dataManager),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
Q_ASSERT(dataManager);
}
@@ -34,6 +34,8 @@ public Q_SLOTS:
void onNewTextMessage(MessageTransmitter *transmitter, const QString &message);
private:
NGL::INGLLogger &m_logger;
DataManager *m_dataManager;
};
} // namespace Messages
@@ -44,7 +44,7 @@ DataManager::DataManager(std::shared_ptr<DdsHandler> ddsHandler)
m_tabDtc = TrainingAreaBase::Interface::Dtc::create(m_ddsHandler->dds());
if (m_tabDtc == nullptr)
{
ERROR_LOG() << "Could not create DTC TrainingAreaBase";
ERROR_LOG(m_logger) << "Could not create DTC TrainingAreaBase";
return;
}
@@ -64,7 +64,7 @@ DataManager::~DataManager()
void DataManager::onConnected()
{
DEBUG_LOG() << "SCM websocket port connected";
DEBUG_LOG(m_logger) << "SCM websocket port connected";
connect(m_scmWebSocket, &QWebSocket::textMessageReceived, this, &DataManager::onTextMessageFromScm);
@@ -81,26 +81,26 @@ void DataManager::onTimerTimeout()
void DataManager::onTextMessageFromScm(const QString &message)
{
DEBUG_LOG() << "onTextMessageFromScm from scm: " << message;
DEBUG_LOG(m_logger) << "onTextMessageFromScm from scm: " << message;
const QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8());
const QJsonArray exercises = doc.object().value(DATA()).toArray();
for (const QJsonValue &valEx : exercises)
{
const QJsonObject &exercise = valEx.toObject();
const int exerciseId = exercise.value(EXERCISE_ID()).toInt();
DEBUG_LOG() << "textMessageFromScm from scm - exerciseId " << exerciseId;
DEBUG_LOG(m_logger) << "textMessageFromScm from scm - exerciseId " << exerciseId;
const QJsonArray services = exercise.value(SERVICES()).toArray();
for (const QJsonValue &valSvc : services)
{
const QJsonObject &service = valSvc.toObject();
const QString svcName = service.value(NAME_ABBREVATION()).toString().toUpper();
DEBUG_LOG() << "textMessageFromScm from scm - svcName " << svcName;
DEBUG_LOG(m_logger) << "textMessageFromScm from scm - svcName " << svcName;
if (svcName != QStringLiteral("TAB"))
continue;
DEBUG_LOG() << "service TAB ";
DEBUG_LOG(m_logger) << "service TAB ";
const QJsonArray ports = service.value(PORTS()).toArray();
for (const QJsonValue &valPort : ports)
@@ -110,7 +110,7 @@ void DataManager::onTextMessageFromScm(const QString &message)
if (typeId == Core::PortType::WebSocketServer)
{
int tabPort = port.value(NUMBER()).toInt();
DEBUG_LOG() << "connect to TAB - port: " << tabPort;
DEBUG_LOG(m_logger) << "connect to TAB - port: " << tabPort;
connectToTabWebSocket(tabPort, exerciseId);
}
}
@@ -120,7 +120,7 @@ void DataManager::onTextMessageFromScm(const QString &message)
void DataManager::onConnectedTab()
{
DEBUG_LOG() << "TAB connected";
DEBUG_LOG(m_logger) << "TAB connected";
}
void DataManager::connectToTabWebSocket(int port, int exerciseId)
@@ -131,7 +131,7 @@ void DataManager::connectToTabWebSocket(int port, int exerciseId)
// Websocket connection already exists?
if (tabData.port == port)
{
INFO_LOG() << "Connection to port " << port << " already exists.";
INFO_LOG(m_logger) << "Connection to port " << port << " already exists.";
return;
}
else
@@ -142,7 +142,7 @@ void DataManager::connectToTabWebSocket(int port, int exerciseId)
}
}
INFO_LOG() << "New connection: exercise: " << exerciseId << ", port: " << port;
INFO_LOG(m_logger) << "New connection: exercise: " << exerciseId << ", port: " << port;
const QUrl url(QStringLiteral("ws://%1:%2").arg(NGL::Connections::hostName(NGL::Connections::eConnection::SCM_WEBSOCKET)).arg(port));
@@ -152,7 +152,7 @@ void DataManager::connectToTabWebSocket(int port, int exerciseId)
connect(webSocketTab, &QWebSocket::disconnected, this, &DataManager::closedTab);
connect(webSocketTab, &QWebSocket::textMessageReceived, this, &DataManager::onTextMessageFromTab);
DEBUG_LOG() << "Trying to connect to TAB at " << url.toString();
DEBUG_LOG(m_logger) << "Trying to connect to TAB at " << url.toString();
webSocketTab->open(url);
TabData data;
@@ -168,7 +168,7 @@ void DataManager::onClientDisconnect(Messages::MessageTransmitter *transmitter)
{
if (ed.transmitter == transmitter)
{
DEBUG_LOG() << "removed dead transmitter";
DEBUG_LOG(m_logger) << "removed dead transmitter";
ed.transmitter = nullptr;
}
}
@@ -176,13 +176,13 @@ void DataManager::onClientDisconnect(Messages::MessageTransmitter *transmitter)
void DataManager::onTextMessageFromTab(const QString &message)
{
INFO_LOG() << "onTextMessageFromTab : " << message;
INFO_LOG(m_logger) << "onTextMessageFromTab : " << message;
const QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8());
if (doc.object().value(TYPE()) != BITE_DATA() && doc.object().value(TYPE()) != POSITION_DATA())
return;
INFO_LOG() << "TYPE: " << doc.object().value(TYPE()).toString();
INFO_LOG(m_logger) << "TYPE: " << doc.object().value(TYPE()).toString();
QJsonObject data = doc.object().value(DATA()).toObject();
@@ -190,7 +190,7 @@ void DataManager::onTextMessageFromTab(const QString &message)
int equipNo = data.value(EQUIP_NO()).toInt();
INFO_LOG() << "equipNo: " << equipNo;
INFO_LOG(m_logger) << "equipNo: " << equipNo;
if (equipNo <= 0)
return;
@@ -200,7 +200,7 @@ void DataManager::onTextMessageFromTab(const QString &message)
if (doc.object().value(TYPE()) == POSITION_DATA())
{
m_equipDataMap[equipNo].lastPositionUpdate = data.value(LAST_POSITION_UPDATE()).toDouble();
INFO_LOG() << "lastPosUpdate: " << m_equipDataMap[equipNo].lastPositionUpdate;
INFO_LOG(m_logger) << "lastPosUpdate: " << m_equipDataMap[equipNo].lastPositionUpdate;
}
if (m_equipDataMap[equipNo].boxId >= 0)
@@ -209,7 +209,7 @@ void DataManager::onTextMessageFromTab(const QString &message)
if (transmitter == nullptr)
{
ERROR_LOG() << "transmitter for eqId " << equipNo << " no longer available";
ERROR_LOG(m_logger) << "transmitter for eqId " << equipNo << " no longer available";
return;
}
@@ -218,7 +218,7 @@ void DataManager::onTextMessageFromTab(const QString &message)
biteData.insert(BOX(), boxId);
biteData.insert(LAST_POSITION_UPDATE(), m_equipDataMap[equipNo].lastPositionUpdate);
transmitter->addMessage(Messages::BiteDataMessage(biteData, m_equipDataMap[equipNo].uuid));
INFO_LOG() << "Send Message with boxId: " << boxId << ", equipNo: " << equipNo;
INFO_LOG(m_logger) << "Send Message with boxId: " << boxId << ", equipNo: " << equipNo;
if (boxId == 0)
boxId = -1; // only single request
}
@@ -226,7 +226,7 @@ void DataManager::onTextMessageFromTab(const QString &message)
void DataManager::setEquipNoBoxId(int equipNo, int boxId, Messages::MessageTransmitter *transmitter, const QString &uuid)
{
INFO_LOG() << "equipNo: " << equipNo << ", boxId = " << boxId;
INFO_LOG(m_logger) << "equipNo: " << equipNo << ", boxId = " << boxId;
// erase abonnement, no further biteData telegrams
if (equipNo == 0)
@@ -259,7 +259,7 @@ void DataManager::setEquipNoBoxId(int equipNo, int boxId, Messages::MessageTrans
data.insert(BOX(), boxId);
data.insert(LAST_POSITION_UPDATE(), equipData.lastPositionUpdate);
transmitter->addMessage(Messages::BiteDataMessage(data, equipData.uuid));
INFO_LOG() << "Send Message with boxId: " << boxId << ", equipNo: " << equipNo;
INFO_LOG(m_logger) << "Send Message with boxId: " << boxId << ", equipNo: " << equipNo;
}
}
else
@@ -273,7 +273,7 @@ void DataManager::setEquipNoBoxId(int equipNo, int boxId, Messages::MessageTrans
equipData.biteMessage = data;
transmitter->addMessage(Messages::BiteDataMessage(data, equipData.uuid));
INFO_LOG() << "Send Message with boxId: " << boxId << ", equipNo: " << equipNo << ", lastUpdate 0";
INFO_LOG(m_logger) << "Send Message with boxId: " << boxId << ", equipNo: " << equipNo << ", lastUpdate 0";
// send bite request
QJsonObject biteData;
@@ -283,7 +283,7 @@ void DataManager::setEquipNoBoxId(int equipNo, int boxId, Messages::MessageTrans
biteData.insert(UUID_(), QUuid::createUuid().toString());
QString message = QString::fromStdString(QJsonDocument(biteData).toJson(QJsonDocument::Compact).toStdString());
INFO_LOG() << "message: " << message;
INFO_LOG(m_logger) << "message: " << message;
for (TabData dataTab : m_tabWebSocketMap)
dataTab.websocket->sendTextMessage(message);
@@ -66,6 +66,8 @@ private Q_SLOTS:
private: // methods
NGL::INGLLogger &m_logger;
void connectToTabWebSocket(int port, int exerciseId);
private: // attributes
@@ -40,7 +40,7 @@ bool WsBiteInterfaceHandler::init()
m_connectionHandler = new Connection::ConnectionHandler;
if (!m_connectionHandler->init())
{
ERROR_LOG() << "Failed to initialise ConnectionHandler";
ERROR_LOG(m_logger) << "Failed to initialise ConnectionHandler";
return false;
}
@@ -15,14 +15,14 @@ namespace WarehouseGuez
DdsHandler::DdsHandler(int domainId)
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Global))
{
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
}
bool DdsHandler::init(const QStringList &qosFileList)
{
if(!m_ddsConnector->init(qosFileList))
{
ERROR_LOG() << "Error initializing dds connections - aborting";
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
return false;
}
@@ -36,10 +36,10 @@ bool DdsHandler::init(const QStringList &qosFileList)
m_ddsFts = WarehouseGuez::Interface::Fts::create(m_ddsConnector);
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";
return bRet;
}
@@ -44,6 +44,7 @@ public:
std::shared_ptr<DDSConnector::DdsConnector> dds() const { return m_ddsConnector; }
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<Core::Pacemaker> m_pacemaker;
std::shared_ptr<Core::TopicLockMaster> m_topicLockMaster;
@@ -35,7 +35,7 @@ bool HandlerEquipmentTypeWh::init()
if (ret.error())
{
delete ifs;
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
bRet = false;
return;
}
@@ -43,11 +43,11 @@ bool HandlerEquipmentTypeWh::init()
};
if (!m_mainHandler->db()->select(cb) || !bRet)
{
ERROR_LOG() << "Error reading data from database!";
ERROR_LOG(m_logger) << "Error reading data from database!";
return true;
}
DEBUG_LOG() << "m_exeObjMap.size() = " << m_equipmenttypewhObjMap.size();
DEBUG_LOG(m_logger) << "m_exeObjMap.size() = " << m_equipmenttypewhObjMap.size();
return true;
}
@@ -83,7 +83,7 @@ void convert(Database::EquipmentTypeWh &data, const EquipmentTypeWh &request)
void HandlerEquipmentTypeWh::onModifyEquipmentTypeWhRequest(const rti::core::SampleIdentity &cookie, const EquipmentTypeWh &request)
{
DEBUG_LOG() << "onModifyEquipmentTypeWhRequest() id:" << request.id();
DEBUG_LOG(m_logger) << "onModifyEquipmentTypeWhRequest() id:" << request.id();
ObjectEquipmentTypeWh *ifs = nullptr;
Core::FunctionReplyObject ret;
@@ -93,7 +93,7 @@ void HandlerEquipmentTypeWh::onModifyEquipmentTypeWhRequest(const rti::core::Sam
convert(data, request);
data.id = 0 - request.id();
DEBUG_LOG() << "Request.id = " << request.id() << ", data.id = " << data.id;
DEBUG_LOG(m_logger) << "Request.id = " << request.id() << ", data.id = " << data.id;
ifs = new ObjectEquipmentTypeWh(m_mainHandler);
ret = ifs->createObject(data, true);
@@ -102,7 +102,7 @@ void HandlerEquipmentTypeWh::onModifyEquipmentTypeWhRequest(const rti::core::Sam
{
delete ifs;
ifs = nullptr;
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
}
else
m_equipmenttypewhObjMap.insert(ifs->getId(), ifs);
@@ -125,7 +125,7 @@ void HandlerEquipmentTypeWh::onModifyEquipmentTypeWhRequest(const rti::core::Sam
}
if (ret.error() || !ifs)
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
else
sendToEXCON();
@@ -137,7 +137,7 @@ void HandlerEquipmentTypeWh::onModifyEquipmentTypeWhRequest(const rti::core::Sam
//-----------------------------------------------------------------------------
void HandlerEquipmentTypeWh::onRemoveEquipmentTypeWhRequest(const rti::core::SampleIdentity &cookie, const Core::RemoveElementRequest &request)
{
DEBUG_LOG() << "onRemoveEquipmentTypeWhRequest() id:" << request.id();
DEBUG_LOG(m_logger) << "onRemoveEquipmentTypeWhRequest() id:" << request.id();
Core::FunctionReplyObject ret;
ObjectEquipmentTypeWh *ifs = m_equipmenttypewhObjMap.value(request.id());
@@ -151,7 +151,7 @@ void HandlerEquipmentTypeWh::onRemoveEquipmentTypeWhRequest(const rti::core::Sam
ret = ifs->removeObject();
if (ret.error())
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
else
{
// delete ObjectEquipmentTypeWH
@@ -27,11 +27,13 @@ public:
bool init();
private:
NGL::INGLLogger &m_logger;
void onModifyEquipmentTypeWhRequest(const rti::core::SampleIdentity &cookie, const EquipmentTypeWh &request) override final;
void onRemoveEquipmentTypeWhRequest(const rti::core::SampleIdentity &cookie, const Core::RemoveElementRequest &request) override final;
void sendToEXCON();
private:
NGL::INGLLogger &m_logger;
QHash<int, ObjectEquipmentTypeWh*> m_equipmenttypewhObjMap;
MainHandler *m_mainHandler;
};
@@ -36,7 +36,7 @@ bool HandlerInjuryModel::init()
if(ret.error())
{
delete ifs;
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
bRet = false;
return;
}
@@ -44,18 +44,18 @@ bool HandlerInjuryModel::init()
};
if (!m_mainHandler->db()->select(cb) || !bRet)
{
ERROR_LOG() << "Error reading data from database!";
ERROR_LOG(m_logger) << "Error reading data from database!";
return true;
}
DEBUG_LOG() << "m_exeObjMap.size() = " << m_injurymodelObjMap.size();
DEBUG_LOG(m_logger) << "m_exeObjMap.size() = " << m_injurymodelObjMap.size();
return true;
}
void HandlerInjuryModel::onModifyInjuryModelAgdusWhRequest(const rti::core::SampleIdentity &cookie, const InjuryModelAgdusWh &request)
{
DEBUG_LOG() << "onModifyInjuryModelAgdusWhRequest() id:" << request.id();
DEBUG_LOG(m_logger) << "onModifyInjuryModelAgdusWhRequest() id:" << request.id();
Core::FunctionReplyObject ret;
if (request.id() <= 0)
@@ -73,7 +73,7 @@ void HandlerInjuryModel::onModifyInjuryModelAgdusWhRequest(const rti::core::Samp
{
delete ifs;
ifs = nullptr;
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
}
else
m_injurymodelObjMap.insert(ifs->getId(), ifs);
@@ -98,14 +98,14 @@ void HandlerInjuryModel::onModifyInjuryModelAgdusWhRequest(const rti::core::Samp
}
if (ret.error())
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
m_mainHandler->dds()->fts()->modifyInjuryModelAgdusWhReply(cookie, ret);
}
void HandlerInjuryModel::onRemoveInjuryModelAgdusWhRequest(const rti::core::SampleIdentity &cookie, const Core::RemoveElementRequest &request)
{
DEBUG_LOG() << "onRemoveInjuryModelAgdusWhRequest() id:" << request.id();
DEBUG_LOG(m_logger) << "onRemoveInjuryModelAgdusWhRequest() id:" << request.id();
Core::FunctionReplyObject ret;
ObjectInjuryModel *ifs = m_injurymodelObjMap.value(request.id());
@@ -119,7 +119,7 @@ void HandlerInjuryModel::onRemoveInjuryModelAgdusWhRequest(const rti::core::Samp
ret = ifs->removeObject();
if (ret.error())
ERROR_LOG() << ret();
ERROR_LOG(m_logger) << ret();
else
{
// delete ObjectInjuryModel
@@ -26,10 +26,12 @@ public:
bool init();
private:
NGL::INGLLogger &m_logger;
void onModifyInjuryModelAgdusWhRequest(const rti::core::SampleIdentity &cookie, const InjuryModelAgdusWh &request);
void onRemoveInjuryModelAgdusWhRequest(const rti::core::SampleIdentity &cookie, const Core::RemoveElementRequest &request);
private:
NGL::INGLLogger &m_logger;
QHash<int, ObjectInjuryModel*> m_injurymodelObjMap;
MainHandler* m_mainHandler;
};
@@ -13,22 +13,21 @@
namespace WarehouseGuez
{
HandlerTypes::HandlerTypes(MainHandler *mainHandler)
: m_mainHandler(mainHandler)
{}
HandlerTypes::HandlerTypes(MainHandler *mainHandler) : m_mainHandler(mainHandler),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
bool HandlerTypes::init()
{
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(m_mainHandler->dds()->dds());
if (m_ppmDtc == nullptr)
{
ERROR_LOG() << "Could not create PPM DTC";
ERROR_LOG(m_logger) << "Could not create PPM DTC";
return false;
}
if (!m_mainHandler->db()->truncateType())
{
ERROR_LOG() << "Error reading types from db";
ERROR_LOG(m_logger) << "Error reading types from db";
return false;
}
@@ -50,7 +49,7 @@ static inline Database::Type convert(const ParticipantManagement::Type &data)
void HandlerTypes::onTypeChanged(const ParticipantManagement::Type &data, DataModification modType)
{
DEBUG_LOG() << "onTypeChanged: " << data << ", " << modType;
DEBUG_LOG(m_logger) << "onTypeChanged: " << data << ", " << modType;
switch(modType)
{
@@ -28,6 +28,7 @@ private Q_SLOTS:
void onTypeChanged(const ParticipantManagement::Type &data, DataModification modType);
private:
NGL::INGLLogger &m_logger;
MainHandler* m_mainHandler;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc; ///< Pointer to DTC ParticipantManagement interface object
};
@@ -41,40 +41,40 @@ bool MainHandler::init(int domainId)
if (!m_dbHandler->init(0, Settings::settings()))
{
ERROR_LOG() << "Initialisation dbHandler failed.";
ERROR_LOG(m_logger) << "Initialisation dbHandler failed.";
return false;
}
DEBUG_LOG() << "Initialisation dbHandler succesful.";
DEBUG_LOG(m_logger) << "Initialisation dbHandler succesful.";
// initialize DDS
m_ddsHandler = std::make_shared<DdsHandler>(domainId);
if (!m_ddsHandler->init())
{
ERROR_LOG() << "Initialisation ddsHandler failed.";
ERROR_LOG(m_logger) << "Initialisation ddsHandler failed.";
return false;
}
DEBUG_LOG() << "Initialisation ddsHandler succesful.";
DEBUG_LOG(m_logger) << "Initialisation ddsHandler succesful.";
DEBUG_LOG() << "WarehouseManagement FTC initialized";
DEBUG_LOG(m_logger) << "WarehouseManagement FTC initialized";
m_handlerEquipTypeWh = std::make_shared<HandlerEquipmentTypeWh>(this);
if (!m_handlerEquipTypeWh->init())
{
ERROR_LOG() << "Initalisation HandlerEquipmentTYpeWH failed";
ERROR_LOG(m_logger) << "Initalisation HandlerEquipmentTYpeWH failed";
return false;
}
m_handlerInjuryModel = std::make_shared<HandlerInjuryModel>(this);
if (!m_handlerInjuryModel->init())
{
ERROR_LOG() << "Initialisation HandlerInjuryModel failed";
ERROR_LOG(m_logger) << "Initialisation HandlerInjuryModel failed";
return false;
}
m_handlerTypes = std::make_shared<HandlerTypes>(this);
if (!m_handlerTypes->init())
{
ERROR_LOG() << "Initialisation HandlerTypes failed";
ERROR_LOG(m_logger) << "Initialisation HandlerTypes failed";
return false;
}
@@ -82,14 +82,14 @@ bool MainHandler::init(int domainId)
m_wsBaseDataHandler = std::make_shared<WsBaseDataInterface::WsBaseDataInterfaceHandler>(this);
if (!m_wsBaseDataHandler->init())
{
ERROR_LOG() << "Initialisation WsBaseDataInterfaceHandler failed.";
ERROR_LOG(m_logger) << "Initialisation WsBaseDataInterfaceHandler failed.";
return false;
}
m_wsBiteInterfaceHandler = std::make_shared<WsBiteInterface::WsBiteInterfaceHandler>(new WsBiteInterface::DataManager(m_ddsHandler));
if (!m_wsBiteInterfaceHandler->init())
{
ERROR_LOG() << "Initialisation WsBiteInterfaceHandler failed.";
ERROR_LOG(m_logger) << "Initialisation WsBiteInterfaceHandler failed.";
return false;
}
@@ -45,6 +45,7 @@ public:
std::shared_ptr<WsBaseDataInterface::WsBaseDataInterfaceHandler> wsBaseDataHandler() { return m_wsBaseDataHandler; }
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DdsHandler> m_ddsHandler;
std::shared_ptr<DbHandler> m_dbHandler;
std::shared_ptr<HandlerEquipmentTypeWh> m_handlerEquipTypeWh;
@@ -27,7 +27,7 @@ Core::FunctionReplyObject ObjectEquipmentTypeWh::createObject(const Database::Eq
if (!m_mainHandler->db()->insert(m_data))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting EquipmentTypeWh-data into database"));
DEBUG_LOG() << "New EquipmentTypeId: " << m_data.id;
DEBUG_LOG(m_logger) << "New EquipmentTypeId: " << m_data.id;
}
// Publish Data via DTS
@@ -42,7 +42,7 @@ Core::FunctionReplyObject ObjectEquipmentTypeWh::updateObject(const Database::Eq
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating EquipmentTypeWh-data into database"));
m_data = data;
DEBUG_LOG() << "Data changed for EquipmentTypeWhId: " << m_data.id;
DEBUG_LOG(m_logger) << "Data changed for EquipmentTypeWhId: " << m_data.id;
// Publish Data via DTS
onPublishData();
@@ -90,11 +90,11 @@ void ObjectEquipmentTypeWh::onPublishData()
ddsData.vbNc(m_data.vbAcWaffen);
ddsData.canDevices(m_data.canDevices);
INFO_LOG() << "Publish WhgEquipmentTypeWh-data to dds (" << m_data.id << ") ...";
INFO_LOG(m_logger) << "Publish WhgEquipmentTypeWh-data to dds (" << m_data.id << ") ...";
if (!m_mainHandler->dds()->dts()->publish(ddsData))
{
ERROR_LOG() << "Error publishing WhgEquipmentTypeWh-data to dds";
ERROR_LOG(m_logger) << "Error publishing WhgEquipmentTypeWh-data to dds";
}
}
@@ -27,6 +27,7 @@ public:
Database::EquipmentTypeWh getData() const { return m_data; }
protected:
NGL::INGLLogger &m_logger;
void onPublishData();
private:
@@ -25,7 +25,7 @@ Core::FunctionReplyObject ObjectInjuryModel::createObject(const Database::Injury
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting InjuryModel-data into database"));
}
DEBUG_LOG() << "New InjuryModel: " << m_data.id;
DEBUG_LOG(m_logger) << "New InjuryModel: " << m_data.id;
// Publish Data via DTS
onPublishData();
@@ -39,7 +39,7 @@ Core::FunctionReplyObject ObjectInjuryModel::updateObject(const Database::Injury
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating InjuryModel-data into database"));
m_data = data;
DEBUG_LOG() << "Data changed for InjuryModelId: " << m_data.id;
DEBUG_LOG(m_logger) << "Data changed for InjuryModelId: " << m_data.id;
// Publish Data via DTS
onPublishData();
@@ -66,11 +66,11 @@ void ObjectInjuryModel::onPublishData()
ddsData.description(m_data.beschreibung.toStdString());
ddsData.version(m_data.version.toStdString());
INFO_LOG() << "Publish InjuryModelAgdusWh-data to dds (" << m_data.id << ") ...";
INFO_LOG(m_logger) << "Publish InjuryModelAgdusWh-data to dds (" << m_data.id << ") ...";
if (!m_mainHandler->dds()->dts()->publish(ddsData))
{
ERROR_LOG() << "Error publishing WhgInjuryModel-data to dds";
ERROR_LOG(m_logger) << "Error publishing WhgInjuryModel-data to dds";
}
}
@@ -27,6 +27,7 @@ public:
Database::InjuryModelAgdusWh getData() const { return m_data; }
protected:
NGL::INGLLogger &m_logger;
void onPublishData();
private: