@@ -36,12 +36,27 @@ MainWindow::MainWindow(QWidget *parent) :
3636 _exceptionGroup.addButton (_pUi->chkTargetNoResponse , QModbusPdu::GatewayTargetDeviceFailedToRespond);
3737 _exceptionGroup.addButton (_pUi->chkGatewayPathUnavailable , QModbusPdu::GatewayPathUnavailable);
3838
39- connect (&_exceptionGroup, QOverload<int >::of (&QButtonGroup::buttonClicked),
39+ connect (&_exceptionGroup, QOverload<int , bool >::of (&QButtonGroup::buttonToggled),
40+ [=](int id, bool checked){
41+ if (checked)
42+ {
43+ _pSlaveModbus->setException (static_cast <QModbusPdu::ExceptionCode>(id));
44+ }
45+ });
46+
47+ /* * Handle error recurrence group **/
48+ _bErrorOnce = true ;
49+ _errorRecurrenceGroup.addButton (_pUi->optErrorOnce , true );
50+ _errorRecurrenceGroup.addButton (_pUi->optErrorPersistent , false );
51+
52+ connect (&_errorRecurrenceGroup, QOverload<int >::of (&QButtonGroup::buttonClicked),
4053 [=](int id){
41- _pSlaveModbus-> setException ( static_cast <QModbusPdu::ExceptionCode >(id) );
54+ _bErrorOnce = static_cast <bool >(id);
4255 });
4356
44- /* ** Auto increment ***/
57+ connect (_pSlaveModbus, &TestSlaveModbus::requestProcessed, this , &MainWindow::handleRequestProcessed);
58+
59+ /* * Auto increment **/
4560 connect (&_autoIncTimer, &QTimer::timeout, this , &MainWindow::handleAutoIncTick);
4661 _autoIncTimer.start (1000 );
4762 _bAutoInc = false ;
@@ -50,7 +65,7 @@ MainWindow::MainWindow(QWidget *parent) :
5065 _bAutoInc = (state == Qt::Checked);
5166 });
5267
53- /* ** Setup registerView **/
68+ /* * Setup registerView **/
5469 _pUi->tblRegData ->setModel (_pRegisterDataModel);
5570 _pUi->tblRegData ->verticalHeader ()->show ();
5671 _pUi->tblRegData ->horizontalHeader ()->show (); // Not sure yet (show or not to show?)
@@ -126,3 +141,11 @@ void MainWindow::handleAutoIncTick()
126141 _pSlaveData->incrementAllEnabledRegisters ();
127142 }
128143}
144+
145+ void MainWindow::handleRequestProcessed ()
146+ {
147+ if (_bErrorOnce)
148+ {
149+ _pUi->chkNone ->animateClick (Qt::Checked);
150+ }
151+ }
0 commit comments