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

@@ -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;
}