@@ -90,6 +90,9 @@ void mbClientScannerThread::setSettings(const Modbus::Settings &settings)
9090 default :
9191 break ;
9292 }
93+ m_combinationCountAll = m_combinationCount * (m_unitEnd - m_unitStart + 1 );
94+ m_statTx = 0 ;
95+ m_statRx = 0 ;
9396}
9497
9598void mbClientScannerThread::run ()
@@ -102,6 +105,8 @@ void mbClientScannerThread::run()
102105 Modbus::Settings settings = m_settings;
103106 uint8_t dummy[MB_MAX_BYTES];
104107 memset (dummy, 0 , sizeof (dummy));
108+
109+ quint32 deviceCount = 0 ;
105110 for (int c = 0 ; m_ctrlRun && (c < m_combinationCount); c++)
106111 {
107112 // Get comibation number for each setting
@@ -218,6 +223,7 @@ void mbClientScannerThread::run()
218223 if (!m_ctrlRun)
219224 break ;
220225 }
226+ m_scanner->setStatPercent (++deviceCount*100 /m_combinationCountAll);
221227 }
222228 clientPort->close ();
223229 mbClient::LogInfo (s.name , QString (" End scanning '%1'" ).arg (sName ));
@@ -229,19 +235,35 @@ void mbClientScannerThread::run()
229235void mbClientScannerThread::slotBytesTx (const Modbus::Char *source, const uint8_t *buff, uint16_t size)
230236{
231237 mbClient::LogTxRx (mbClientScanner::Strings::instance ().name + QString (" " ) + source, QStringLiteral (" Tx: " ) + Modbus::bytesToString (buff, size).data ());
238+ incStatTx ();
232239}
233240
234241void mbClientScannerThread::slotBytesRx (const Modbus::Char *source, const uint8_t *buff, uint16_t size)
235242{
236243 mbClient::LogTxRx (mbClientScanner::Strings::instance ().name + QString (" " ) + source, QStringLiteral (" Rx: " ) + Modbus::bytesToString (buff, size).data ());
244+ incStatRx ();
237245}
238246
239247void mbClientScannerThread::slotAsciiTx (const Modbus::Char *source, const uint8_t *buff, uint16_t size)
240248{
241249 mbClient::LogTxRx (mbClientScanner::Strings::instance ().name + QString (" " ) + source, QStringLiteral (" Tx: " ) + Modbus::asciiToString (buff, size).data ());
250+ incStatTx ();
242251}
243252
244253void mbClientScannerThread::slotAsciiRx (const Modbus::Char *source, const uint8_t *buff, uint16_t size)
245254{
246255 mbClient::LogTxRx (mbClientScanner::Strings::instance ().name + QString (" " ) + source, QStringLiteral (" Rx: " ) + Modbus::asciiToString (buff, size).data ());
256+ incStatRx ();
257+ }
258+
259+ void mbClientScannerThread::incStatTx ()
260+ {
261+ m_statTx++;
262+ m_scanner->setStatCountTx (m_statTx);
263+ }
264+
265+ void mbClientScannerThread::incStatRx ()
266+ {
267+ m_statRx++;
268+ m_scanner->setStatCountRx (m_statRx);
247269}
0 commit comments