aboutsummaryrefslogtreecommitdiffstats
path: root/src/Xpl2Client.cpp
blob: 45963fab4eca6d42853fc463da22def017f399eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
/**
 * @file   Xpl2Client.cpp
 * @brief  TCP client for the Alchemie XPL2 printhead protocol.
 */
#include "Xpl2Client.h"

#include <QDebug>

bool Xpl2Client::s_wireDebug = false;

/* ------------------------------------------------------------------ */
/*  Response dispatch table                                           */
/* ------------------------------------------------------------------ */

// clang-format off
const QHash<QByteArray, Xpl2Client::ResponseEntry>
Xpl2Client::s_responseTable = {
  /* CN_ JC success shape: controllerId, successFlag */
  { "CN_JETTING_ALL_ON",       { ResponseShape::JcSuccess, 2,
    [](auto *s, const auto &p) { emit s->jettingAllOnResult (p[0].toInt (), p[1].toInt () == 1); } } },
  { "CN_JETTING_ON",           { ResponseShape::JcSuccess, 2,
    [](auto *s, const auto &p) { emit s->jettingOnResult (p[0].toInt (), p[1].toInt () == 1); } } },
  { "CN_JETTING_OFF",          { ResponseShape::JcSuccess, 2,
    [](auto *s, const auto &p) { emit s->jettingOffResult (p[0].toInt (), p[1].toInt () == 1); } } },
  { "CN_JC_ID_LED_ON",         { ResponseShape::JcSuccess, 2,
    [](auto *s, const auto &p) { emit s->jcIdLedOnResult (p[0].toInt (), p[1].toInt () == 1); } } },
  { "CN_JC_ID_LED_OFF",        { ResponseShape::JcSuccess, 2,
    [](auto *s, const auto &p) { emit s->jcIdLedOffResult (p[0].toInt (), p[1].toInt () == 1); } } },
  { "CN_JC_CALIBRATION",       { ResponseShape::JcSuccess, 2,
    [](auto *s, const auto &p) { emit s->jcCalibrationResult (p[0].toInt (), p[1].toInt () == 1); } } },
  { "CN_JC_RESET_FAULT_CODES", { ResponseShape::JcSuccess, 2,
    [](auto *s, const auto &p) { emit s->jcResetFaultCodesResult (p[0].toInt (), p[1].toInt () == 1); } } },
  { "CN_JC_STATUS_MESSAGING_STOP",  { ResponseShape::JcSuccess, 2,
    [](auto *s, const auto &p) { emit s->jcStatusMessagingStopResult (p[0].toInt (), p[1].toInt () == 1); } } },
  { "CN_PH_STATUS_MESSAGING_STOP",  { ResponseShape::JcSuccess, 2,
    [](auto *s, const auto &p) { emit s->phStatusMessagingStopResult (p[0].toInt (), p[1].toInt () == 1); } } },

  /* CN_ PH success shape: controllerId, printheadId, successFlag */
  { "CN_PH_JETTING_ON",        { ResponseShape::PhSuccess, 3,
    [](auto *s, const auto &p) { emit s->phJettingOnResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } },
  { "CN_PH_JETTING_OFF",       { ResponseShape::PhSuccess, 3,
    [](auto *s, const auto &p) { emit s->phJettingOffResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } },
  { "CN_PH_ID_LED_ON",         { ResponseShape::PhSuccess, 3,
    [](auto *s, const auto &p) { emit s->phIdLedOnResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } },
  { "CN_PH_ID_LED_OFF",        { ResponseShape::PhSuccess, 3,
    [](auto *s, const auto &p) { emit s->phIdLedOffResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } },
  { "CN_PH_CALIBRATION",       { ResponseShape::PhSuccess, 3,
    [](auto *s, const auto &p) { emit s->phCalibrationResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } },
  { "CN_PH_RESET_FAULT_CODES", { ResponseShape::PhSuccess, 3,
    [](auto *s, const auto &p) { emit s->phResetFaultCodesResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } },
  { "CN_PH_NOZZLES_DISABLED",  { ResponseShape::PhSuccess, 3,
    [](auto *s, const auto &p) { emit s->phNozzlesDisabledResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } },

  /* CN_ calibration data: controllerId, phId, 48 floats */
  { "CN_PH_CALIBRATION_DATA",     { ResponseShape::CalData, 50,
    [](auto *s, const auto &p) { emit s->phCalibrationDataReceived (p[0].toInt (), p[1].toInt (), p.mid (2, 48)); } } },
  { "CN_PH_CALIBRATION_RAW_DATA", { ResponseShape::CalData, 50,
    [](auto *s, const auto &p) { emit s->phCalibrationRawDataReceived (p[0].toInt (), p[1].toInt (), p.mid (2, 48)); } } },

  /* CN_ base frequency: controllerId, phId, baseFreq, activeBaseFreq */
  { "CN_PH_CALIBRATED_BASE_FREQUENCY", { ResponseShape::BaseFreq, 4,
    [](auto *s, const auto &p) { emit s->phCalibratedBaseFrequencyReceived (p[0].toInt (), p[1].toInt (), p[2].toDouble (), p[3].toDouble ()); } } },

  /* CN_ status messaging start: controllerId, level, interval, successFlag */
  { "CN_JC_STATUS_MESSAGING_START", { ResponseShape::StatusStart, 4,
    [](auto *s, const auto &p) { emit s->jcStatusMessagingStartResult (p[0].toInt (), p[1].toInt (), p[2].toInt (), p[3].toInt () == 1); } } },
  { "CN_PH_STATUS_MESSAGING_START", { ResponseShape::StatusStart, 4,
    [](auto *s, const auto &p) { emit s->phStatusMessagingStartResult (p[0].toInt (), p[1].toInt (), p[2].toInt (), p[3].toInt () == 1); } } },
};
// clang-format on

Xpl2Client::Xpl2Client (QObject *parent) : QObject (parent)
{
  for (auto *socket : { &m_commandSocket, &m_imagingSocket, &m_statusSocket })
    {
      connect (socket, &QTcpSocket::connected, this,
               &Xpl2Client::onSocketConnected);
      connect (socket, &QTcpSocket::disconnected, this,
               &Xpl2Client::onSocketDisconnected);
      connect (socket, &QTcpSocket::readyRead, this,
               &Xpl2Client::onSocketMessageReady);
      connect (socket, &QAbstractSocket::errorOccurred, this,
               &Xpl2Client::onSocketError);
    }
}

/* ------------------------------------------------------------------ */
/*  Properties                                                        */
/* ------------------------------------------------------------------ */

QString
Xpl2Client::host () const
{
  return m_host;
}

void
Xpl2Client::setHost (const QString &host)
{
  if (m_host == host)
    return;
  m_host = host;
  emit hostChanged ();
}

bool
Xpl2Client::isConnected () const
{
  return m_connected;
}

int
Xpl2Client::controllerId () const
{
  return m_controllerId;
}

QString
Xpl2Client::firmwareVersion () const
{
  return m_firmwareVersion;
}

QString
Xpl2Client::hardwareVersion () const
{
  return m_hardwareVersion;
}

int
Xpl2Client::printheadCount () const
{
  return m_printheadCount;
}

void
Xpl2Client::enableWireDebug ()
{
  s_wireDebug = true;
}

/* ------------------------------------------------------------------ */
/*  Connection                                                        */
/* ------------------------------------------------------------------ */

void
Xpl2Client::connectToServer ()
{
  if (m_connected)
    {
      emit statusMessage (QStringLiteral ("Already connected"));
      return;
    }
  emit statusMessage (QStringLiteral ("Connecting to %1…").arg (m_host));
  m_commandSocket.connectToHost (m_host, m_commandPort);
  m_imagingSocket.connectToHost (m_host, m_imagingPort);
  m_statusSocket.connectToHost (m_host, m_statusPort);
}

void
Xpl2Client::disconnectFromServer ()
{
  m_commandSocket.disconnectFromHost ();
  m_imagingSocket.disconnectFromHost ();
  m_statusSocket.disconnectFromHost ();
}

void
Xpl2Client::getJcVersion ()
{
  sendCommand (m_commandSocket, "GS_JC_VERSION");
}

void
Xpl2Client::getPhVersion (int printheadId)
{
  sendCommand (m_commandSocket, "GS_PH_VERSION", { printheadId });
}

/* ------------------------------------------------------------------ */
/*  CN_ Control commands                                              */
/* ------------------------------------------------------------------ */

void
Xpl2Client::jettingAllOn ()
{
  sendCommand (m_commandSocket, "CN_JETTING_ALL_ON");
}

void
Xpl2Client::jettingOn (const QString &jettingMask)
{
  sendCommand (m_commandSocket, "CN_JETTING_ON", { jettingMask });
}

void
Xpl2Client::jettingOff ()
{
  sendCommand (m_commandSocket, "CN_JETTING_OFF");
}

void
Xpl2Client::phJettingOn (int printheadId, const QString &jettingMask)
{
  sendCommand (m_commandSocket, "CN_PH_JETTING_ON",
               { printheadId, jettingMask });
}

void
Xpl2Client::phJettingOff (int printheadId)
{
  sendCommand (m_commandSocket, "CN_PH_JETTING_OFF", { printheadId });
}

void
Xpl2Client::jcIdLedOn ()
{
  sendCommand (m_commandSocket, "CN_JC_ID_LED_ON");
}

void
Xpl2Client::jcIdLedOff ()
{
  sendCommand (m_commandSocket, "CN_JC_ID_LED_OFF");
}

void
Xpl2Client::phIdLedOn (int printheadId)
{
  sendCommand (m_commandSocket, "CN_PH_ID_LED_ON", { printheadId });
}

void
Xpl2Client::phIdLedOff (int printheadId)
{
  sendCommand (m_commandSocket, "CN_PH_ID_LED_OFF", { printheadId });
}

void
Xpl2Client::jcCalibration ()
{
  sendCommand (m_commandSocket, "CN_JC_CALIBRATION");
}

void
Xpl2Client::phCalibration (int printheadId)
{
  sendCommand (m_commandSocket, "CN_PH_CALIBRATION", { printheadId });
}

void
Xpl2Client::phCalibrationData (int printheadId)
{
  sendCommand (m_commandSocket, "CN_PH_CALIBRATION_DATA", { printheadId });
}

void
Xpl2Client::phCalibrationRawData (int printheadId)
{
  sendCommand (m_commandSocket, "CN_PH_CALIBRATION_RAW_DATA", { printheadId });
}

void
Xpl2Client::phCalibratedBaseFrequency (int printheadId)
{
  sendCommand (m_commandSocket, "CN_PH_CALIBRATED_BASE_FREQUENCY",
               { printheadId });
}

void
Xpl2Client::jcStatusMessagingStart (int statusLevel, int sendIntervalMs)
{
  sendCommand (m_statusSocket, "CN_JC_STATUS_MESSAGING_START",
               { statusLevel, sendIntervalMs });
}

void
Xpl2Client::jcStatusMessagingStop ()
{
  sendCommand (m_statusSocket, "CN_JC_STATUS_MESSAGING_STOP");
}

void
Xpl2Client::phStatusMessagingStart (int statusLevel, int sendIntervalMs)
{
  sendCommand (m_statusSocket, "CN_PH_STATUS_MESSAGING_START",
               { statusLevel, sendIntervalMs });
}

void
Xpl2Client::phStatusMessagingStop ()
{
  sendCommand (m_statusSocket, "CN_PH_STATUS_MESSAGING_STOP");
}

void
Xpl2Client::jcResetFaultCodes ()
{
  sendCommand (m_commandSocket, "CN_JC_RESET_FAULT_CODES");
}

void
Xpl2Client::phResetFaultCodes (int printheadId)
{
  sendCommand (m_commandSocket, "CN_PH_RESET_FAULT_CODES", { printheadId });
}

void
Xpl2Client::phNozzlesDisabled (int printheadId, const QString &mask)
{
  sendCommand (m_commandSocket, "CN_PH_NOZZLES_DISABLED",
               { printheadId, mask });
}

/* ------------------------------------------------------------------ */
/*  Send / dispatch                                                   */
/* ------------------------------------------------------------------ */

void
Xpl2Client::sendCommand (QTcpSocket &socket, const QByteArray &command,
                         const QVariantList &params)
{
  if (socket.state () != QAbstractSocket::ConnectedState)
    {
      emit errorOccurred (QStringLiteral ("Not connected for %1")
                              .arg (QString::fromUtf8 (command)));
      return;
    }
  QByteArray data = Xpl2Protocol::buildMessage (command, params);
  socket.write (data);

  QByteArray wire;
  if (s_wireDebug)
    wire = " >> " + data.trimmed ();
  qDebug ("%s TX %s%s", qPrintable (logTag (&socket)), command.constData (),
          wire.constData ());
}

void
Xpl2Client::dispatchCommandMessage (const Xpl2Protocol::ParsedMessage &msg)
{
  if (msg.command == "KA_PING")
    handleKaPing (m_commandSocket);
  else if (msg.command == "GS_JC_VERSION")
    handleGsJcVersion (msg.params);
  else if (msg.command == "GS_PH_VERSION")
    handleGsPhVersion (msg.params);
  else if (!dispatchResponse (msg.command, msg.params, &m_commandSocket))
    qWarning ("%s Unknown command: %s", qPrintable (logTag (&m_commandSocket)),
              msg.command.constData ());
}

void
Xpl2Client::dispatchImagingMessage (const Xpl2Protocol::ParsedMessage &msg)
{
  if (msg.command == "KA_PING")
    handleKaPing (m_imagingSocket);
  else
    qWarning ("%s Unknown command: %s", qPrintable (logTag (&m_imagingSocket)),
              msg.command.constData ());
}

void
Xpl2Client::dispatchStatusMessage (const Xpl2Protocol::ParsedMessage &msg)
{
  if (msg.command == "KA_PING")
    handleKaPing (m_statusSocket);
  else if (!dispatchResponse (msg.command, msg.params, &m_statusSocket))
    qWarning ("%s Unknown command: %s", qPrintable (logTag (&m_statusSocket)),
              msg.command.constData ());
}

void
Xpl2Client::handleKaPing (QTcpSocket &socket)
{
  sendCommand (socket, "KA_PING", { 1 });
}

void
Xpl2Client::handleGsJcVersion (const QVariantList &params)
{
  if (params.size () < 4)
    {
      qWarning () << "GS_JC_VERSION: expected 4 params, got" << params.size ();
      return;
    }
  m_controllerId = params[0].toInt ();
  m_firmwareVersion = params[1].toString ();
  m_hardwareVersion = params[2].toString ();
  m_printheadCount = params[3].toInt ();
  qDebug ("%s    controller=%d fw=%s hw=%s phCount=%d",
          qPrintable (logTag (&m_commandSocket)), m_controllerId,
          qPrintable (m_firmwareVersion), qPrintable (m_hardwareVersion),
          m_printheadCount);
  emit statusMessage (
      QStringLiteral ("RX JC Version: controller=%1 fw=%2 hw=%3 phCount=%4")
          .arg (m_controllerId)
          .arg (m_firmwareVersion)
          .arg (m_hardwareVersion)
          .arg (m_printheadCount));
  emit jcVersionReceived ();
}

void
Xpl2Client::handleGsPhVersion (const QVariantList &params)
{
  if (params.size () < 8)
    {
      qWarning () << "GS_PH_VERSION: expected 8 params, got" << params.size ();
      return;
    }
  int cid = params[0].toInt ();
  int phId = params[1].toInt ();
  QString mcuFw = params[2].toString ();
  QString mcuHw = params[3].toString ();
  QString mcuFwVar = params[4].toString ();
  QString fpgaFw = params[5].toString ();
  QString fpgaHw = params[6].toString ();
  QString bootVer = params[7].toString ();
  qDebug ("%s    PH[%d] mcuFw=%s mcuHw=%s mcuFwVar=%s fpgaFw=%s fpgaHw=%s "
          "boot=%s",
          qPrintable (logTag (&m_commandSocket)), phId, qPrintable (mcuFw),
          qPrintable (mcuHw), qPrintable (mcuFwVar), qPrintable (fpgaFw),
          qPrintable (fpgaHw), qPrintable (bootVer));
  emit statusMessage (
      QStringLiteral (
          "RX PH[%1] Version: mcuFw=%2 mcuHw=%3 fpgaFw=%4 fpgaHw=%5 boot=%6")
          .arg (phId)
          .arg (mcuFw)
          .arg (mcuHw)
          .arg (fpgaFw)
          .arg (fpgaHw)
          .arg (bootVer));
  emit phVersionReceived (cid, phId, mcuFw, mcuHw, mcuFwVar, fpgaFw, fpgaHw,
                          bootVer);
}

bool
Xpl2Client::dispatchResponse (const QByteArray &command,
                              const QVariantList &params,
                              const QTcpSocket *socket)
{
  auto it = s_responseTable.find (command);
  if (it == s_responseTable.end ())
    return false;

  const ResponseEntry &entry = *it;
  if (params.size () < entry.minParams)
    {
      qWarning ("%s %s: expected %d params, got %lld",
                qPrintable (logTag (socket)), command.constData (),
                entry.minParams, static_cast<long long> (params.size ()));
      return true;
    }

  int cid = params[0].toInt ();
  QString cmd = QString::fromUtf8 (command);
  QString logStr;

  switch (entry.shape)
    {
    case ResponseShape::JcSuccess:
      logStr = QStringLiteral ("RX %1: controller=%2 success=%3")
                   .arg (cmd)
                   .arg (cid)
                   .arg (params[1].toInt () == 1);
      break;
    case ResponseShape::PhSuccess:
      logStr = QStringLiteral ("RX %1: controller=%2 ph=%3 success=%4")
                   .arg (cmd)
                   .arg (cid)
                   .arg (params[1].toInt ())
                   .arg (params[2].toInt () == 1);
      break;
    case ResponseShape::CalData:
      logStr = QStringLiteral ("RX %1: controller=%2 ph=%3")
                   .arg (cmd)
                   .arg (cid)
                   .arg (params[1].toInt ());
      break;
    case ResponseShape::BaseFreq:
      logStr = QStringLiteral ("RX %1: controller=%2 ph=%3 base=%4 active=%5")
                   .arg (cmd)
                   .arg (cid)
                   .arg (params[1].toInt ())
                   .arg (params[2].toDouble ())
                   .arg (params[3].toDouble ());
      break;
    case ResponseShape::StatusStart:
      logStr = QStringLiteral ("RX %1: controller=%2 level=%3 interval=%4 "
                               "success=%5")
                   .arg (cmd)
                   .arg (cid)
                   .arg (params[1].toInt ())
                   .arg (params[2].toInt ())
                   .arg (params[3].toInt () == 1);
      break;
    }

  qDebug ("%s    %s", qPrintable (logTag (socket)), qPrintable (logStr));
  emit statusMessage (logStr);
  entry.emitter (this, params);
  return true;
}

/* ------------------------------------------------------------------ */
/*  Internal                                                          */
/* ------------------------------------------------------------------ */

void
Xpl2Client::updateConnectedState ()
{
  bool allConnected
      = m_commandSocket.state () == QAbstractSocket::ConnectedState
        && m_imagingSocket.state () == QAbstractSocket::ConnectedState
        && m_statusSocket.state () == QAbstractSocket::ConnectedState;
  if (m_connected == allConnected)
    return;
  m_connected = allConnected;
  emit connectedChanged ();
}

QString
Xpl2Client::logTag (const QTcpSocket *socket) const
{
  const char *name = "Unknown";
  quint16 port = 0;
  if (socket == &m_commandSocket)
    {
      name = "Command";
      port = m_commandPort;
    }
  else if (socket == &m_imagingSocket)
    {
      name = "Imaging";
      port = m_imagingPort;
    }
  else if (socket == &m_statusSocket)
    {
      name = "Status";
      port = m_statusPort;
    }

  return QStringLiteral ("[%1:%2]").arg (name).arg (port).leftJustified (15);
}

/* ------------------------------------------------------------------ */
/*  Socket slots                                                      */
/* ------------------------------------------------------------------ */

void
Xpl2Client::onSocketConnected ()
{
  auto *socket = qobject_cast<QTcpSocket *> (sender ());
  qInfo ("%s Connected", qPrintable (logTag (socket)));
  updateConnectedState ();
}

void
Xpl2Client::onSocketDisconnected ()
{
  auto *socket = qobject_cast<QTcpSocket *> (sender ());
  if (!socket)
    {
      /* Identify by elimination — which socket just left ConnectedState? */
      for (auto *s : { &m_commandSocket, &m_imagingSocket, &m_statusSocket })
        if (s->state () != QAbstractSocket::ConnectedState)
          qInfo ("%s Disconnected", qPrintable (logTag (s)));
    }
  else
    qInfo ("%s Disconnected", qPrintable (logTag (socket)));
  updateConnectedState ();
}

void
Xpl2Client::onSocketMessageReady ()
{
  auto *socket = qobject_cast<QTcpSocket *> (sender ());
  while (socket->canReadLine ())
    {
      QByteArray raw = socket->readLine ();
      auto msg = Xpl2Protocol::parseMessage (raw);
      if (msg.valid)
        {
          QByteArray wire;
          if (s_wireDebug)
            wire = " << " + raw.trimmed ();
          qDebug ("%s RX %s%s", qPrintable (logTag (socket)),
                  msg.command.constData (), wire.constData ());

          if (socket == &m_commandSocket)
            dispatchCommandMessage (msg);
          else if (socket == &m_imagingSocket)
            dispatchImagingMessage (msg);
          else
            dispatchStatusMessage (msg);
        }
    }
}

void
Xpl2Client::onSocketError (QAbstractSocket::SocketError error)
{
  Q_UNUSED (error)
  auto *socket = qobject_cast<QTcpSocket *> (sender ());
  emit errorOccurred (QStringLiteral ("%1 %2")
                          .arg (logTag (socket))
                          .arg (socket->errorString ()));
}