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

@@ -10,15 +10,14 @@
namespace TrainingAreaBaseOC
{
Device::Device(QObject *parent, bool tcpMode)
: QObject(parent)
Device::Device(QObject *parent, bool tcpMode) : QObject(parent)
, m_spQuerry(new LtsSerialPortQuerry::LtsSerialPortQuerry(this))
, m_socket(new QTcpSocket(this))
, m_restartTimer(new QTimer(this))
, m_receiveTimeoutTimer(new QTimer(this))
, m_tcpMode(tcpMode)
.getNGLLogger("TTCI.Device"))
{
.getNGLLogger("TTCI.Device")),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
connect(m_spQuerry, &LtsSerialPortQuerry::LtsSerialPortQuerry::connectionEstablished, this, &Device::open);
m_spQuerry->restartQuerry();
@@ -36,7 +35,7 @@ Device::~Device()
void Device::reOpen()
{
DEBUG_LOG() << "ConnectionHandlerSerial::reOpen";
DEBUG_LOG(m_logger) << "ConnectionHandlerSerial::reOpen";
close();
QTimer::singleShot(2000, this, &Device::open);
}
@@ -52,19 +51,19 @@ bool Device::open()
m_socket->connectToHost(Settings::hostName(), Settings::portTtci());
if (!m_socket->waitForConnected())
{
ERROR_LOG() << "Could not (re)open tcp destination " << m_socket->peerName() << ":" << m_socket->peerPort() << ", error: " << m_socket->errorString();
ERROR_LOG(m_logger) << "Could not (re)open tcp destination " << m_socket->peerName() << ":" << m_socket->peerPort() << ", error: " << m_socket->errorString();
return false;
}
connect(m_socket, &QTcpSocket::readyRead, this, &Device::onDataAvailable);
connect(m_socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &Device::handleError);
connect(m_socket, &QTcpSocket::disconnected, this, &Device::open);
DEBUG_LOG() << "(Re)openend tcp destination " << m_socket->peerName() << ":" << Settings::portTtci();
DEBUG_LOG(m_logger) << "(Re)openend tcp destination " << m_socket->peerName() << ":" << Settings::portTtci();
}
else
{
m_serialPort = m_spQuerry->currentSerialPort();
DEBUG_LOG() << "(Re)openend serial destination " << m_serialPort->portName() << ":";
DEBUG_LOG(m_logger) << "(Re)openend serial destination " << m_serialPort->portName() << ":";
connect(m_serialPort, &QSerialPort::readyRead, this, &Device::onDataAvailable);
@@ -79,7 +78,7 @@ bool Device::close()
{
if (m_socket->isOpen())
m_socket->close();
DEBUG_LOG() << "Closing TCP Port";
DEBUG_LOG(m_logger) << "Closing TCP Port";
delete m_socket;
m_socket = nullptr;
m_receiveTimeoutTimer->stop();
@@ -110,7 +109,7 @@ void Device::onDataAvailable()
void Device::parseBuffer()
{
DEBUG_LOG() << "Buffer - size: " << m_buffer.size()
DEBUG_LOG(m_logger) << "Buffer - size: " << m_buffer.size()
<< ", data: " << m_buffer.toHex() ;
@@ -118,21 +117,21 @@ void Device::parseBuffer()
int idxStart = -1;
while ((idxStart = m_buffer.indexOf(0x02)) >= 0)
{
TRACE_LOG() << "idxStart: " << idxStart ;
TRACE_LOG(m_logger) << "idxStart: " << idxStart ;
int idxLen = idxStart + 1;
if (idxLen >= m_buffer.size())
return;
unsigned char len = static_cast<unsigned char>(m_buffer.at(idxLen));
TRACE_LOG() << "idxLen: " << idxLen
TRACE_LOG(m_logger) << "idxLen: " << idxLen
<< ", len: " << len
<< " = 0x" << QByteArray::number(len, 16);
int idxCrc = idxLen + len + 1;
int idxEnd = idxCrc + 1;
if (idxEnd >= m_buffer.size())
return;
TRACE_LOG() << "idxCrc: " << idxCrc
TRACE_LOG(m_logger) << "idxCrc: " << idxCrc
<< ", idxEnd: " << idxEnd ;
if (idxEnd >= m_buffer.size())
return;
@@ -141,7 +140,7 @@ void Device::parseBuffer()
if (m_buffer.at(idxEnd) != 0x03)
{
WARNING_LOG() << "Could not find valid end marker - searching new start marker"
WARNING_LOG(m_logger) << "Could not find valid end marker - searching new start marker"
;
m_buffer = m_buffer.mid(1);
continue;
@@ -149,12 +148,12 @@ void Device::parseBuffer()
unsigned char crc = static_cast<unsigned char>(m_buffer.at(idxCrc));
unsigned char crcCalc = calcChecksum(m_buffer.mid(idxStart, idxCrc - idxStart));
TRACE_LOG() << "crc: " << crc
TRACE_LOG(m_logger) << "crc: " << crc
<< ", calculated: " << crcCalc
;
if (crc != crcCalc)
{
WARNING_LOG() << "Invalid checksum - is: " << crcCalc
WARNING_LOG(m_logger) << "Invalid checksum - is: " << crcCalc
<< " - should be: " << crc ;
}
@@ -163,15 +162,15 @@ void Device::parseBuffer()
if (len == 255 || !m_payload.isEmpty())
{
DEBUG_LOG() << "telegram with more than 254 bytes ..." ;
DEBUG_LOG(m_logger) << "telegram with more than 254 bytes ..." ;
if (len == 255 && m_payload.isEmpty())
DEBUG_LOG() << "Remember the payload destination: " << destination ;
DEBUG_LOG(m_logger) << "Remember the payload destination: " << destination ;
m_payload += payload;
if (len != 255)
{
DEBUG_LOG() << "destination: " << destination
DEBUG_LOG(m_logger) << "destination: " << destination
<< ", data: " << m_payload.toHex() ;
emit dataAvailable(m_payload);
m_payload.clear();
@@ -180,7 +179,7 @@ void Device::parseBuffer()
else
{
DEBUG_LOG() << "destination: " << destination
DEBUG_LOG(m_logger) << "destination: " << destination
<< ", data: " << payload.toHex() ;
emit dataAvailable(payload);
}
@@ -197,7 +196,7 @@ bool Device::writeData(const QChar destination, const QByteArray &payload)
if ((m_tcpMode && !m_socket->isOpen()) || (!m_tcpMode && !m_serialPort->isOpen()))
return false;
DEBUG_LOG() << "Writing " << payload.size()
DEBUG_LOG(m_logger) << "Writing " << payload.size()
<< " Bytes to channel " << destination ;
QByteArray data = payload;
@@ -215,7 +214,7 @@ bool Device::writeData(const QChar destination, const QByteArray &payload)
buf.append(calcChecksum(buf));
buf.append(0x03);
DEBUG_LOG() << "Writing: " << buf.toHex() ;
DEBUG_LOG(m_logger) << "Writing: " << buf.toHex() ;
if (m_tcpMode)
m_socket->write(buf);
else
@@ -245,7 +244,7 @@ unsigned char Device::calcChecksum(const QByteArray &checksumData)
void Device::handleError(QAbstractSocket::SocketError error)
{
DEBUG_LOG() << "Spontaneous error " << error << " doesn't have to be an error ...";
DEBUG_LOG(m_logger) << "Spontaneous error " << error << " doesn't have to be an error ...";
const QString errStr(QStringLiteral("QTcpSocket::SocketError ") + QString::number(error) +
QStringLiteral(" from tcp port ") + QString::number(m_socket->peerPort()) +
@@ -257,20 +256,20 @@ void Device::handleError(QAbstractSocket::SocketError error)
case QTcpSocket::SocketError::SocketAccessError:
case QTcpSocket::SocketError::SocketResourceError:
{
ERROR_LOG() << "Closing port trying to reopen it.";
ERROR_LOG(m_logger) << "Closing port trying to reopen it.";
close();
m_restartTimer->start();
Q_FALLTHROUGH();
}
case QTcpSocket::SocketError::RemoteHostClosedError:
{
ERROR_LOG() << "Host closed trying to reopen.";
ERROR_LOG(m_logger) << "Host closed trying to reopen.";
m_restartTimer->start();
break;
}
default:
{
ERROR_LOG() << errStr;
ERROR_LOG(m_logger) << errStr;
close();
m_restartTimer->start();
break;
@@ -280,7 +279,7 @@ void Device::handleError(QAbstractSocket::SocketError error)
void Device::handleSerialError(QSerialPort::SerialPortError error)
{
DEBUG_LOG() << "Spontaneous error " << error << " doesn't have to be an error ...";
DEBUG_LOG(m_logger) << "Spontaneous error " << error << " doesn't have to be an error ...";
const QString errStr(QStringLiteral("QSerialPort::SerialPortError ") + QString::number(error) +
QStringLiteral(" error: ") + m_serialPort->errorString());
@@ -293,13 +292,13 @@ void Device::handleSerialError(QSerialPort::SerialPortError error)
case QSerialPort::SerialPortError::PermissionError:
case QSerialPort::SerialPortError::WriteError:
{
WARNING_LOG() << "Closing port trying to reopen it.";
WARNING_LOG(m_logger) << "Closing port trying to reopen it.";
m_restartTimer->start();
Q_FALLTHROUGH();
}
default:
{
WARNING_LOG() << errStr;
WARNING_LOG(m_logger) << errStr;
m_restartTimer->start();
break;
}