@@ -15,11 +15,11 @@ MainWindow::MainWindow(QWidget *parent) :
1515 _pSlaveData = new TestSlaveData ();
1616 _pSlaveModbus = new TestSlaveModbus (_pSlaveData);
1717
18- QList<uint> registerList = QList<uint>() << 0 << 1 << 2 << 3 << 4 ;
19- _pSlaveData->setRegisterState (registerList, true );
20-
2118 _pRegisterDataModel = new RegisterDataModel (_pSlaveData);
2219
20+ _pIncGraph = new IncGraph (_pSlaveData);
21+ _pSineGraph = new SineGraph (_pSlaveData);
22+
2323 connect (_pSlaveData, &TestSlaveData::dataChanged, _pRegisterDataModel, &RegisterDataModel::handleDataChange);
2424
2525 connect (_pUi->btnListen , &QPushButton::clicked, this , &MainWindow::onConnectClicked);
@@ -57,12 +57,11 @@ MainWindow::MainWindow(QWidget *parent) :
5757 connect (_pSlaveModbus, &TestSlaveModbus::requestProcessed, this , &MainWindow::handleRequestProcessed);
5858
5959 /* * Auto increment **/
60- connect (&_autoIncTimer, &QTimer::timeout, this , &MainWindow::handleAutoIncTick);
61- _autoIncTimer.start (1000 );
6260 _bAutoInc = false ;
6361 connect (_pUi->checkAutoIncrement , &QCheckBox::stateChanged, this ,
6462 [=](int state){
6563 _bAutoInc = (state == Qt::Checked);
64+ _pIncGraph->setState (_bAutoInc);
6665 });
6766
6867 /* * Setup registerView **/
@@ -73,16 +72,23 @@ MainWindow::MainWindow(QWidget *parent) :
7372 /* Don't stretch columns, resize to contents */
7473 _pUi->tblRegData ->horizontalHeader ()->setSectionResizeMode (QHeaderView::ResizeToContents);
7574
75+ QList<uint> registerList = QList<uint>() << 0 << 1 << 2 << 3 << 4 ;
76+ _pSlaveData->setRegisterState (registerList, true );
77+
78+ _pIncGraph->setRegisters (0 , 10 );
79+
80+ _pSlaveData->setRegisterState (10 , true );
81+ _pSineGraph->setRegister (10 );
82+ _pSineGraph->setPeriod (10000 );
83+
7684 QString windowCaption;
77- windowCaption = QString (" ModbusTestSlave " );
85+ windowCaption = QString (" ModbusTestSim " );
7886
7987 setWindowTitle (windowCaption);
8088}
8189
8290MainWindow::~MainWindow ()
8391{
84- _autoIncTimer.stop ();
85-
8692 if (_pSlaveModbus)
8793 {
8894 _pSlaveModbus->disconnectDevice ();
@@ -139,14 +145,6 @@ void MainWindow::onStateChanged(QModbusDevice::State state)
139145 _pUi->btnDisconnect ->setEnabled (connected);
140146}
141147
142- void MainWindow::handleAutoIncTick ()
143- {
144- if (_bAutoInc)
145- {
146- _pSlaveData->incrementAllEnabledRegisters ();
147- }
148- }
149-
150148void MainWindow::handleRequestProcessed ()
151149{
152150 if (_bErrorOnce)
0 commit comments