- Auto-scroll standard aktiv

- Tag-Filter wird gespeichert
- Tag Monitor kann bei einem Tag jetzt pro Key mehrere Werte in einer Tabelle anzeigen
- Bug für Clear behoben
This commit is contained in:
2026-06-23 23:19:06 +02:00
parent 92168ee5dc
commit d3229c7b64
29 changed files with 342 additions and 380 deletions

View File

@@ -10,9 +10,9 @@
// SerialWorker lives in its own QThread and owns the QSerialPort.
// It emits newLine() for every complete line received,
// tagDetected() when a line contains a recognised tag like [WDG],
// and clearScreen() when the ANSI clear-screen sequence \033[2J is received.
// Auto-reconnect: if the port drops unexpectedly (e.g. USB cable pulled),
// the worker retries every reconnectIntervalMs until success or closePort().
// and clearScreen() when an ANSI clear-screen sequence is received.
// Auto-reconnect: if the port drops unexpectedly, the worker retries
// every reconnectIntervalMs until success or closePort().
class SerialWorker : public QObject
{
Q_OBJECT
@@ -21,9 +21,8 @@ public:
explicit SerialWorker(QObject *parent = nullptr);
~SerialWorker();
// Auto-reconnect configuration (call before openPort, or any time)
void setAutoReconnect(bool enabled) { m_autoReconnect = enabled; }
void setReconnectInterval(int ms) { m_reconnectIntervalMs = ms; }
void setAutoReconnect(bool enabled) { m_autoReconnect = enabled; }
void setReconnectInterval(int ms) { m_reconnectIntervalMs = ms; }
public slots:
void openPort(const QString &portName, qint32 baudRate,
@@ -31,17 +30,17 @@ public slots:
QSerialPort::Parity parity,
QSerialPort::StopBits stopBits,
QSerialPort::FlowControl flowControl);
void closePort(); // explicit user disconnect stops reconnect
void closePort();
void setLogFile(const QString &path);
void stopLogging();
signals:
void newLine(const QString &line);
void tagDetected(const QString &tag, const QString &value);
void clearScreen(); // emitted when \033[2J\033[H (or \033[2J alone) is received
void clearScreen();
void portOpened();
void portClosed();
void reconnecting(int attempt); // fired each retry attempt
void reconnecting(int attempt);
void errorOccurred(const QString &message);
private slots:
@@ -54,23 +53,22 @@ private:
void processLine(const QString &line);
void scheduleReconnect();
QSerialPort *m_port = nullptr;
QFile *m_logFile = nullptr;
QSerialPort *m_port = nullptr;
QFile *m_logFile = nullptr;
QTextStream *m_logStream = nullptr;
QString m_buffer;
QByteArray m_scanTail; // carries partial ANSI sequences across reads
// Reconnect state
QTimer *m_reconnectTimer = nullptr;
bool m_autoReconnect = true;
bool m_userDisconnected = false; // true only after explicit closePort()
int m_reconnectIntervalMs = 2000;
int m_reconnectAttempt = 0;
QTimer *m_reconnectTimer = nullptr;
bool m_autoReconnect = true;
bool m_userDisconnected = false;
int m_reconnectIntervalMs = 2000;
int m_reconnectAttempt = 0;
// Saved config for reconnect
QString m_portName;
qint32 m_baudRate = 115200;
QSerialPort::DataBits m_dataBits = QSerialPort::Data8;
QSerialPort::Parity m_parity = QSerialPort::NoParity;
QSerialPort::StopBits m_stopBits = QSerialPort::OneStop;
QSerialPort::FlowControl m_flowControl= QSerialPort::NoFlowControl;
qint32 m_baudRate = 115200;
QSerialPort::DataBits m_dataBits = QSerialPort::Data8;
QSerialPort::Parity m_parity = QSerialPort::NoParity;
QSerialPort::StopBits m_stopBits = QSerialPort::OneStop;
QSerialPort::FlowControl m_flowControl = QSerialPort::NoFlowControl;
};