|
@@ -378,6 +378,7 @@ class ModbusNG : public QObject
|
378
|
378
|
QTimer *messageDelayTimer;
|
379
|
379
|
QTimer *commTimeout;
|
380
|
380
|
int scanPosition;
|
|
381
|
+ bool waiting;
|
381
|
382
|
QByteArray responseBuffer;
|
382
|
383
|
QList<Channel*> channels;
|
383
|
384
|
QList<ModbusScanItem> scanList;
|
|
@@ -393,7 +394,7 @@ sub-tree. In this design, child nodes establish a scan list.
|
393
|
394
|
@<ModbusNG implementation@>=
|
394
|
395
|
ModbusNG::ModbusNG(DeviceTreeModel *model, const QModelIndex &index) :
|
395
|
396
|
QObject(NULL), messageDelayTimer(new QTimer), commTimeout(new QTimer),
|
396
|
|
- scanPosition(0)
|
|
397
|
+ scanPosition(0), waiting(false)
|
397
|
398
|
{
|
398
|
399
|
QDomElement portReferenceElement =
|
399
|
400
|
model->referenceElement(model->data(index, Qt::UserRole).toString());
|
|
@@ -495,11 +496,12 @@ ModbusNG::~ModbusNG()
|
495
|
496
|
|
496
|
497
|
void ModbusNG::sendNextMessage()
|
497
|
498
|
{
|
498
|
|
- if(scanList.length() > 0)
|
|
499
|
+ if(scanList.length() > 0 && !waiting)
|
499
|
500
|
{
|
500
|
501
|
port->write(scanList.at(scanPosition).request);
|
501
|
502
|
commTimeout->start(2000);
|
502
|
503
|
messageDelayTimer->start(delayTime);
|
|
504
|
+ waiting = true;
|
503
|
505
|
}
|
504
|
506
|
}
|
505
|
507
|
|
|
@@ -579,6 +581,7 @@ void ModbusNG::dataAvailable()
|
579
|
581
|
}
|
580
|
582
|
}
|
581
|
583
|
responseBuffer.clear();
|
|
584
|
+ waiting = false;
|
582
|
585
|
messageDelayTimer->start(delayTime);
|
583
|
586
|
}
|
584
|
587
|
|