From 08c958f91da8ac9fe2bfc04368641d97f72cd82e Mon Sep 17 00:00:00 2001 From: nasicurious Date: Wed, 3 Nov 2021 21:04:56 +0330 Subject: [PATCH] update Exception --- Servo/include/ModbusMaster.h | 28 +- Servo/include/ModbusWrapper.h | 24 +- Servo/include/ServoException.h | 5 + Servo/src/ModbusMaster.cpp | 157 +++-- Servo/src/ModbusWrapper.cpp | 71 ++- Test/MainWindow.cpp | 91 ++- Test/MainWindow.ui | 1000 ++++++++++++++++---------------- Test/main.cpp | 1 + 8 files changed, 766 insertions(+), 611 deletions(-) diff --git a/Servo/include/ModbusMaster.h b/Servo/include/ModbusMaster.h index e2437d9..fc38e01 100644 --- a/Servo/include/ModbusMaster.h +++ b/Servo/include/ModbusMaster.h @@ -36,24 +36,30 @@ public: void writeRequest(QModbusDataUnit::RegisterType registerType, int startAddress, quint16 writeSize); + void close(); //uncrustify off public slots: //uncrustify on - void init(); - - void connectToDevice(ModbusConfig modbusConfig); + void init(ExpConfig& expConfig); + void connectToDevice(ModbusConfig modbusConfig, ExpConfig& expConfig); void connectionStateChanged(QModbusDevice::State state); QBitArray getCoil(int startAddress, quint16 readSize, ExpConfig& expConfig); - QBitArray getInputCoil(int startAddress, quint16 readSize); - QVector getHoldingRegister(int startAddress, quint16 readSize); - QVector getInputRegister(int startAddress, quint16 readSize); - - void setSingleCoil(int startAddress, bool coilFlag); - void setMultipleCoil(int startAddress, quint16 writeSize, QBitArray coilFlags); - void setSingleRegister(int startAddress, quint16 registerValue); - void setMultipleRegister(int startAddress, quint16 writeSize, QVector registerValues); + QBitArray getInputCoil(int startAddress, quint16 readSize, ExpConfig& expConfig); + QVector getHoldingRegister(int startAddress, quint16 readSize, ExpConfig& expConfig); + QVector getInputRegister(int startAddress, quint16 readSize, ExpConfig& expConfig); + + void setSingleCoil(int startAddress, bool coilFlag, ExpConfig& expConfig); + void setMultipleCoil(int startAddress, + quint16 writeSize, + QBitArray coilFlags, + ExpConfig& expConfig); + void setSingleRegister(int startAddress, quint16 registerValue, ExpConfig& expConfig); + void setMultipleRegister(int startAddress, + quint16 writeSize, + QVector registerValues, + ExpConfig& expConfig); }; #endif //MODBUSMASTER_H diff --git a/Servo/include/ModbusWrapper.h b/Servo/include/ModbusWrapper.h index 3f56b3e..d772090 100644 --- a/Servo/include/ModbusWrapper.h +++ b/Servo/include/ModbusWrapper.h @@ -33,21 +33,25 @@ public: void setMultipleRegister(int startAddress, quint16 writeSize, QVector registerValues); signals: - void connectOrder(ModbusConfig modbusConfig); - void initOrder(); + void connectOrder(ModbusConfig modbusConfig, ExpConfig& expConfig); + void initOrder(ExpConfig& expConfig); QBitArray getCoilOrder(int startAddress, quint16 readSize, ExpConfig& expConfig); - QBitArray getInputCoilOrder(int startAddress, quint16 readSize); + QBitArray getInputCoilOrder(int startAddress, quint16 readSize, ExpConfig& expConfig); QVector getHoldingRegisterOrder(int startAddress, - quint16 readSize); - QVector getInputRegisterOrder(int startAddress, quint16 readSize); - - void setSingleCoilOrder(int startAddress, bool coilFlag); - void setMultipleCoilOrder(int startAddress, quint16 writeSize, QBitArray coilFlags); - void setSingleRegisterOrder(int startAddress, quint16 registerValue); + quint16 readSize, ExpConfig& expConfig); + QVector getInputRegisterOrder(int startAddress, quint16 readSize, + ExpConfig& expConfig); + + void setSingleCoilOrder(int startAddress, bool coilFlag, ExpConfig& expConfig); + void setMultipleCoilOrder(int startAddress, + quint16 writeSize, + QBitArray coilFlags, + ExpConfig& expConfig); + void setSingleRegisterOrder(int startAddress, quint16 registerValue, ExpConfig& expConfig); void setMultipleRegisterOrder(int startAddress, quint16 writeSize, - QVector registerValues); + QVector registerValues, ExpConfig& expConfig); }; #endif //MODBUSWRAPPER_H diff --git a/Servo/include/ServoException.h b/Servo/include/ServoException.h index d6e9382..47093ca 100644 --- a/Servo/include/ServoException.h +++ b/Servo/include/ServoException.h @@ -19,6 +19,11 @@ public: { return _str.toStdString().c_str(); } + + QString getMessage() const + { + return _str; + } }; #endif //SERVOEXCEPTION_H diff --git a/Servo/src/ModbusMaster.cpp b/Servo/src/ModbusMaster.cpp index 31671a6..0e07747 100644 --- a/Servo/src/ModbusMaster.cpp +++ b/Servo/src/ModbusMaster.cpp @@ -8,61 +8,79 @@ ModbusMaster::ModbusMaster(QObject* parent) : QObject(parent) } /*************************************************************************************************/ -void ModbusMaster::init() +void ModbusMaster::init(ExpConfig& expConfig) { - if(!_initialized) - { - _modbusDevice = nullptr; - _modbusDevice = new QModbusRtuSerialMaster(this); - - connect(_modbusDevice, &QModbusClient::errorOccurred, [this](QModbusDevice::Error) + try { + if(!_initialized) { - throw ServoException(_modbusDevice->errorString()); - }); + _modbusDevice = nullptr; + _modbusDevice = new QModbusRtuSerialMaster(this); + + connect(_modbusDevice, &QModbusClient::errorOccurred, [this](QModbusDevice::Error) + { + throw ServoException(_modbusDevice->errorString()); + }); - connect(_modbusDevice, &QModbusDevice::stateChanged, this, - &ModbusMaster::connectionStateChanged); + connect(_modbusDevice, + &QModbusClient::stateChanged, + this, + &ModbusMaster::connectionStateChanged); - _initialized = true; + _initialized = true; + } + else + { + throw ServoException( + "Modbus Device Object Created Before First Delete it Then Make New One"); + } } - else + catch(const ServoException& ex) { - throw ServoException("Modbus Device Created Before Handle it"); + expConfig.valid = true; + expConfig.message = ex.getMessage(); } } /*************************************************************************************************/ -void ModbusMaster::connectToDevice(ModbusConfig modbusConfig) +void ModbusMaster::connectionStateChanged(QModbusDevice::State state) { - if(_modbusDevice->state() != QModbusDevice::ConnectedState) + if(state == QModbusDevice::UnconnectedState) { - _clientAddress = modbusConfig.clientAddress; - _modbusDevice->setConnectionParameter(QModbusDevice::SerialPortNameParameter, - modbusConfig.serialPort); - _modbusDevice->setConnectionParameter(QModbusDevice::SerialParityParameter, - modbusConfig.parity); - _modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, - modbusConfig.baud); - _modbusDevice->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, - modbusConfig.dataBits); - _modbusDevice->setConnectionParameter(QModbusDevice::SerialStopBitsParameter, - modbusConfig.stopBits); - _modbusDevice->setTimeout(modbusConfig.responseTime); - _modbusDevice->setNumberOfRetries(modbusConfig.numberOfRetries); - - if(!_modbusDevice->connectDevice()) - { - throw ServoException(_modbusDevice->errorString()); - } + throw ServoException("Connection wasnt prepared"); } } /*************************************************************************************************/ -void ModbusMaster::connectionStateChanged(QModbusDevice::State state) +void ModbusMaster::connectToDevice(ModbusConfig modbusConfig, ExpConfig& expConfig) { - if(state == QModbusDevice::UnconnectedState) + try { + if(_modbusDevice->state() != QModbusDevice::ConnectedState) + { + _clientAddress = modbusConfig.clientAddress; + _modbusDevice->setConnectionParameter(QModbusDevice::SerialPortNameParameter, + modbusConfig.serialPort); + _modbusDevice->setConnectionParameter(QModbusDevice::SerialParityParameter, + modbusConfig.parity); + _modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, + modbusConfig.baud); + _modbusDevice->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, + modbusConfig.dataBits); + _modbusDevice->setConnectionParameter(QModbusDevice::SerialStopBitsParameter, + modbusConfig.stopBits); + _modbusDevice->setTimeout(modbusConfig.responseTime); + + _modbusDevice->setNumberOfRetries(modbusConfig.numberOfRetries); + + if(!_modbusDevice->connectDevice()) + { + throw ServoException(_modbusDevice->errorString()); + } + } + } + catch(const ServoException& ex) { - throw ServoException("Connection wasnt prepared"); + expConfig.valid = true; + expConfig.message = ex.getMessage(); } } @@ -90,12 +108,12 @@ QBitArray ModbusMaster::getCoil(int startAddress, quint16 readSize, ExpConfig& e catch(const ServoException& ex) { expConfig.valid = true; - expConfig.message = ex.what(); + expConfig.message = ex.getMessage(); } } /*************************************************************************************************/ -QBitArray ModbusMaster::getInputCoil(int startAddress, quint16 readSize) +QBitArray ModbusMaster::getInputCoil(int startAddress, quint16 readSize, ExpConfig& expConfig) { try { @@ -117,12 +135,15 @@ QBitArray ModbusMaster::getInputCoil(int startAddress, quint16 readSize) } catch(const ServoException& ex) { - qDebug() << ex.what(); + expConfig.valid = true; + expConfig.message = ex.getMessage(); } } /*************************************************************************************************/ -QVector ModbusMaster::getHoldingRegister(int startAddress, quint16 readSize) +QVector ModbusMaster::getHoldingRegister(int startAddress, + quint16 readSize, + ExpConfig& expConfig) { try { @@ -142,12 +163,15 @@ QVector ModbusMaster::getHoldingRegister(int startAddress, quint16 read } catch(const ServoException& ex) { - qDebug() << ex.what(); + expConfig.valid = true; + expConfig.message = ex.getMessage(); } } /*************************************************************************************************/ -QVector ModbusMaster::getInputRegister(int startAddress, quint16 readSize) +QVector ModbusMaster::getInputRegister(int startAddress, + quint16 readSize, + ExpConfig& expConfig) { try { @@ -167,12 +191,13 @@ QVector ModbusMaster::getInputRegister(int startAddress, quint16 readSi } catch(const ServoException& ex) { - qDebug() << ex.what(); + expConfig.valid = true; + expConfig.message = ex.getMessage(); } } /*************************************************************************************************/ -void ModbusMaster::setSingleCoil(int startAddress, bool coilFlag) +void ModbusMaster::setSingleCoil(int startAddress, bool coilFlag, ExpConfig& expConfig) { try { @@ -187,11 +212,16 @@ void ModbusMaster::setSingleCoil(int startAddress, bool coilFlag) } catch(const ServoException& ex) { - qDebug() << ex.what(); + expConfig.valid = true; + expConfig.message = ex.getMessage(); } } -void ModbusMaster::setMultipleCoil(int startAddress, quint16 writeSize, QBitArray coilFlags) +/*************************************************************************************************/ +void ModbusMaster::setMultipleCoil(int startAddress, + quint16 writeSize, + QBitArray coilFlags, + ExpConfig& expConfig) { try { @@ -200,11 +230,13 @@ void ModbusMaster::setMultipleCoil(int startAddress, quint16 writeSize, QBitArra } catch(const ServoException& ex) { - qDebug() << ex.what(); + expConfig.valid = true; + expConfig.message = ex.getMessage(); } } -void ModbusMaster::setSingleRegister(int startAddress, quint16 registerValue) +/*************************************************************************************************/ +void ModbusMaster::setSingleRegister(int startAddress, quint16 registerValue, ExpConfig& expConfig) { try { @@ -214,14 +246,15 @@ void ModbusMaster::setSingleRegister(int startAddress, quint16 registerValue) } catch(const ServoException& ex) { - qDebug() << ex.what(); + expConfig.valid = true; + expConfig.message = ex.getMessage(); } } /*************************************************************************************************/ void ModbusMaster::setMultipleRegister(int startAddress, quint16 writeSize, - QVector registerValues) + QVector registerValues, ExpConfig& expConfig) { try { @@ -230,7 +263,8 @@ void ModbusMaster::setMultipleRegister(int startAddress, } catch(const ServoException& ex) { - qDebug() << ex.what(); + expConfig.valid = true; + expConfig.message = ex.getMessage(); } } @@ -277,15 +311,15 @@ void ModbusMaster::checkForError(QModbusReply* _reply) if(_reply->error() == QModbusDevice::ProtocolError) { - throw ServoException(tr("Read response error: %1 (Mobus exception: 0x%2)"). - arg(_reply->errorString()). - arg(_reply->rawResult().exceptionCode(), -1, 16)); + throw ServoException(QString("Read response error: %1 (Mobus exception: %2)") + .arg(_reply->errorString()) + .arg(_reply->rawResult().exceptionCode())); } else { - throw ServoException(tr("Read response error: %1 (code: 0x%2)"). - arg(_reply->errorString()). - arg(_reply->error(), -1, 16)); + throw ServoException(QString("Read response error: %1 (code: %2)") + .arg(_reply->errorString()) + .arg(_reply->error())); } } @@ -327,3 +361,10 @@ void ModbusMaster::writeRequest(QModbusDataUnit::RegisterType registerType, throw ServoException(_modbusDevice->errorString()); } } + +void ModbusMaster::close() +{ + if(_modbusDevice) + _modbusDevice->disconnectDevice(); + delete _modbusDevice; +} diff --git a/Servo/src/ModbusWrapper.cpp b/Servo/src/ModbusWrapper.cpp index 756fb3e..64ee357 100644 --- a/Servo/src/ModbusWrapper.cpp +++ b/Servo/src/ModbusWrapper.cpp @@ -75,9 +75,12 @@ void ModbusWrapper::init() &ModbusMaster::setMultipleRegister, Qt::BlockingQueuedConnection); - emit initOrder(); - - qDebug() << "init done"; + ExpConfig exp; + emit initOrder(exp); + if(exp.valid) + { + throw ServoException(exp.message); + } } /*************************************************************************************************/ @@ -97,37 +100,73 @@ QBitArray ModbusWrapper::getCoil(int startAddress, quint16 readSize) /*************************************************************************************************/ QBitArray ModbusWrapper::getInputCoil(int startAddress, quint16 readSize) { - return emit getInputCoilOrder(startAddress, readSize); + ExpConfig exp; + auto ret = emit getInputCoilOrder(startAddress, readSize, exp); + if(exp.valid) + { + throw ServoException(exp.message); + } + + return ret; } /*************************************************************************************************/ QVector ModbusWrapper::getHoldingRegister(int startAddress, quint16 readSize) { - return emit getHoldingRegisterOrder(startAddress, readSize); + ExpConfig exp; + auto ret = emit getHoldingRegisterOrder(startAddress, readSize, exp); + if(exp.valid) + { + throw ServoException(exp.message); + } + + return ret; } /*************************************************************************************************/ QVector ModbusWrapper::getInputRegister(int startAddress, quint16 readSize) { - return emit getInputRegisterOrder(startAddress, readSize); + ExpConfig exp; + auto ret = emit getInputRegisterOrder(startAddress, readSize, exp); + if(exp.valid) + { + throw ServoException(exp.message); + } + + return ret; } /*************************************************************************************************/ void ModbusWrapper::setSingleCoil(int startAddress, bool coilFlag) { - emit setSingleCoilOrder(startAddress, coilFlag); + ExpConfig exp; + emit setSingleCoilOrder(startAddress, coilFlag, exp); + if(exp.valid) + { + throw ServoException(exp.message); + } } /*************************************************************************************************/ void ModbusWrapper::setMultipleCoil(int startAddress, quint16 writeSize, QBitArray coilFlags) { - emit setMultipleCoilOrder(startAddress, writeSize, coilFlags); + ExpConfig exp; + emit setMultipleCoilOrder(startAddress, writeSize, coilFlags, exp); + if(exp.valid) + { + throw ServoException(exp.message); + } } /*************************************************************************************************/ void ModbusWrapper::setSingleRegister(int startAddress, quint16 registerValue) { - emit setSingleRegisterOrder(startAddress, registerValue); + ExpConfig exp; + emit setSingleRegisterOrder(startAddress, registerValue, exp); + if(exp.valid) + { + throw ServoException(exp.message); + } } /*************************************************************************************************/ @@ -135,11 +174,21 @@ void ModbusWrapper::setMultipleRegister(int startAddress, quint16 writeSize, QVector registerValues) { - emit setMultipleRegisterOrder(startAddress, writeSize, registerValues); + ExpConfig exp; + emit setMultipleRegisterOrder(startAddress, writeSize, registerValues, exp); + if(exp.valid) + { + throw ServoException(exp.message); + } } /*************************************************************************************************/ void ModbusWrapper::connectToDevice(ModbusConfig modbusConfig) { - emit connectOrder(modbusConfig); + ExpConfig exp; + emit connectOrder(modbusConfig, exp); + if(exp.valid) + { + throw ServoException(exp.message); + } } diff --git a/Test/MainWindow.cpp b/Test/MainWindow.cpp index 1133474..627b4bc 100644 --- a/Test/MainWindow.cpp +++ b/Test/MainWindow.cpp @@ -34,10 +34,11 @@ void MainWindow::on_connect_clicked() qDebug() << "before connect"; modbusWrapper.connectToDevice(configDevice); qDebug() << "after connect"; + ui->errorMonitoring->setText("No Error"); } catch(ServoException ex) { - qDebug() << ex.what(); + ui->errorMonitoring->setText(ex.getMessage()); } } @@ -73,11 +74,11 @@ void MainWindow::on_readButton_clicked() numberOfEntries))); break; } + ui->errorMonitoring->setText("No Error"); } catch(const ServoException& exp) { - qDebug() << "aaaa"; - qDebug() << exp.what(); + ui->errorMonitoring->setText(exp.getMessage()); } } @@ -110,55 +111,83 @@ void MainWindow::printRegisterDataFromClient(QVector uiHoldingRegisters /*************************************************************************************************/ void MainWindow::on_writeSingleCoil_clicked() { - int startAddress = ui->writeSingleCoilAddress->text().toInt(); - modbusWrapper.setSingleCoil(startAddress, ui->coilData->isChecked()); + try { + int startAddress = ui->writeSingleCoilAddress->text().toInt(); + modbusWrapper.setSingleCoil(startAddress, ui->coilData->isChecked()); + ui->errorMonitoring->setText("No Error"); + } + catch(const ServoException& exp) + { + ui->errorMonitoring->setText(exp.getMessage()); + } } /*************************************************************************************************/ void MainWindow::on_writeMultiCoil_clicked() { - int startAddress = ui->writeMultiCoilStartAddress->text().toInt(); - int writeQty = ui->writeMultiCoilQty->text().toInt(); - QString valueToWrite = ui->writeMultiCoilValue->text(); + try { + int startAddress = ui->writeMultiCoilStartAddress->text().toInt(); + int writeQty = ui->writeMultiCoilQty->text().toInt(); + QString valueToWrite = ui->writeMultiCoilValue->text(); - QBitArray uiCoils; - uiCoils.resize(writeQty); + QBitArray uiCoils; + uiCoils.resize(writeQty); - for(int i = 0; i < valueToWrite.size(); i++) + for(int i = 0; i < valueToWrite.size(); i++) + { + if(valueToWrite.at(i) == '0') + uiCoils[i] = false; + else + uiCoils[i] = true; + } + modbusWrapper.setMultipleCoil(startAddress, static_cast(writeQty), uiCoils); + ui->errorMonitoring->setText("No Error"); + } + catch(const ServoException& exp) { - if(valueToWrite.at(i) == '0') - uiCoils[i] = false; - else - uiCoils[i] = true; + ui->errorMonitoring->setText(exp.getMessage()); } - modbusWrapper.setMultipleCoil(startAddress, static_cast(writeQty), uiCoils); } /*************************************************************************************************/ void MainWindow::on_writeSingleRegister_clicked() { - int startAddress = ui->writeSingleRegisterAddress->text().toInt(); - quint16 value = static_cast(ui->writeSingleRegisterValue->text().toInt()); - modbusWrapper.setSingleRegister(startAddress, value); + try { + int startAddress = ui->writeSingleRegisterAddress->text().toInt(); + quint16 value = static_cast(ui->writeSingleRegisterValue->text().toInt()); + modbusWrapper.setSingleRegister(startAddress, value); + ui->errorMonitoring->setText("No Error"); + } + catch(const ServoException& exp) + { + ui->errorMonitoring->setText(exp.getMessage()); + } } /*************************************************************************************************/ void MainWindow::on_writeMultiRegister_clicked() { - int startAddress = ui->writeMultiRegisterStartAddress->text().toInt(); - int writeQty = ui->writeMultiRegisterQty->text().toInt(); - QString valueToWrite = ui->writeMultiRegisterValue->text(); - QVector uiHoldingRegisters; - uiHoldingRegisters.resize(writeQty); + try { + int startAddress = ui->writeMultiRegisterStartAddress->text().toInt(); + int writeQty = ui->writeMultiRegisterQty->text().toInt(); + QString valueToWrite = ui->writeMultiRegisterValue->text(); + QVector uiHoldingRegisters; + uiHoldingRegisters.resize(writeQty); - QRegExp rx("(\\ |\\,|\\.|\\:|\\t)"); //RegEx for ' ' or ',' or '.' or ':' or '\t' - QStringList stringListValue = valueToWrite.split(rx); + QRegExp rx("(\\ |\\,|\\.|\\:|\\t)"); //RegEx for ' ' or ',' or '.' or ':' or '\t' + QStringList stringListValue = valueToWrite.split(rx); - for(int i = 0; i < stringListValue.size(); i++) + for(int i = 0; i < stringListValue.size(); i++) + { + uiHoldingRegisters[i] = static_cast(stringListValue[i].toInt()); + } + modbusWrapper.setMultipleRegister(startAddress, + static_cast(writeQty), + uiHoldingRegisters); + ui->errorMonitoring->setText("No Error"); + } + catch(const ServoException& exp) { - uiHoldingRegisters[i] = static_cast(stringListValue[i].toInt()); + ui->errorMonitoring->setText(exp.getMessage()); } - modbusWrapper.setMultipleRegister(startAddress, - static_cast(writeQty), - uiHoldingRegisters); } diff --git a/Test/MainWindow.ui b/Test/MainWindow.ui index 34ac62c..b7704f4 100644 --- a/Test/MainWindow.ui +++ b/Test/MainWindow.ui @@ -6,516 +6,536 @@ 0 0 - 800 - 507 + 879 + 725 MainWindow - - - - 40 - 10 - 89 - 25 - - - - Connect - - - - - - 40 - 142 - 126 - 25 - - - - Number of values: - - - - - - 40 - 110 - 126 - 26 - - - - Start address: - - - - - - 170 - 110 - 113 - 25 - - - - - - - 170 - 140 - 113 - 25 - - - - - - - 160 - 10 - 41 - 25 - - - - Table: - - - - - - 207 - 10 - 86 - 25 - - - - - - - 40 - 167 - 126 - 17 - - - - Result: - - - + 10 - 70 - 311 - 381 - - - - Read Data From Device - - - - - 20 - 120 - 257 - 221 - - - - - - - 100 - 350 - 80 - 25 - - - - - 0 - 0 - - - - Read - - - - - - - 340 - 70 - 191 - 161 - - - - Write Single Coil - - - - - 10 - 30 - 61 - 23 - - - - Coil - - - - - - 70 - 60 - 113 - 25 - - - - - - - 10 - 60 - 71 - 26 - - - - address: - - - - - - 20 - 120 - 141 - 25 - - - - Write Single Coil - - - - - - - 540 - 70 - 241 - 161 + 20 + 811 + 621 - - Write Multiple Coil - - - - - 10 - 60 - 126 - 25 - - - - Number of values: - - - - - - 110 - 30 - 121 - 25 - - - - - - - 10 - 30 - 126 - 26 - - - - Start address: - - - - - - 140 - 60 - 91 - 25 - - - - - - - 60 - 90 - 171 - 25 - - - - - - - 10 - 90 - 51 - 25 - - - - Values - - - - - - 50 - 130 - 141 - 25 - - - - Write Multi Coil - - - - - - - 340 - 250 - 181 - 201 - - - - Write Single Register - - - - - 70 - 30 - 101 - 25 - - - - - - - 10 - 30 - 71 - 26 - - - - address: - - - - - - 60 - 70 - 111 - 25 - - - - - - - 10 - 70 - 51 - 25 - - - - Value - - - - - - 10 - 110 - 161 - 25 - - - - Write Single Register - - - - - - - 530 - 250 - 261 - 201 - - - - Write Multiple Register - - - - - 50 - 170 - 141 - 25 - - - - Write Multi Register - - - - - - 10 - 110 - 51 - 25 - - - - Values - - - - - - 10 - 60 - 126 - 25 - - - - Number of values: - - - - - - 110 - 30 - 121 - 25 - - - - - - - 140 - 60 - 91 - 25 - - - - - - - 60 - 110 - 171 - 51 - - - - - - - 10 - 30 - 126 - 26 - - - - Start address: - + + + Tab 1 + + + + + 10 + 10 + 89 + 25 + + + + Connect + + + + + + 20 + 420 + 761 + 91 + + + + Error Monitoring + + + + + + 370 + 180 + 181 + 201 + + + + Write Single Register + + + + + 70 + 30 + 101 + 25 + + + + + + + 10 + 30 + 71 + 26 + + + + address: + + + + + + 60 + 70 + 111 + 25 + + + + + + + 10 + 70 + 51 + 25 + + + + Value + + + + + + 10 + 110 + 161 + 25 + + + + Write Single Register + + + + + + + 560 + 10 + 241 + 161 + + + + Write Multiple Coil + + + + + 10 + 60 + 126 + 25 + + + + Number of values: + + + + + + 110 + 30 + 121 + 25 + + + + + + + 10 + 30 + 91 + 26 + + + + Start address: + + + + + + 140 + 60 + 91 + 25 + + + + + + + 60 + 90 + 171 + 25 + + + + + + + 10 + 90 + 51 + 25 + + + + Values + + + + + + 50 + 130 + 141 + 25 + + + + Write Multi Coil + + + + + + + 250 + 10 + 86 + 25 + + + + + + + 360 + 10 + 191 + 161 + + + + Write Single Coil + + + + + 10 + 30 + 61 + 23 + + + + Coil + + + + + + 70 + 60 + 113 + 25 + + + + + + + 10 + 60 + 71 + 26 + + + + address: + + + + + + 20 + 120 + 141 + 25 + + + + Write Single Coil + + + + + + + 560 + 180 + 261 + 201 + + + + Write Multiple Register + + + + + 50 + 170 + 141 + 25 + + + + Write Multi Register + + + + + + 10 + 110 + 51 + 25 + + + + Values + + + + + + 10 + 60 + 126 + 25 + + + + Number of values: + + + + + + 110 + 30 + 121 + 25 + + + + + + + 140 + 60 + 91 + 25 + + + + + + + 60 + 110 + 171 + 51 + + + + + + + 10 + 30 + 126 + 26 + + + + Start address: + + + + + + 90 + 90 + 91 + 21 + + + + + Ubuntu Condensed + 8 + 75 + true + + + + Comma Delimiter + + + + + + + 40 + 50 + 301 + 341 + + + + Read Data From Device + + + + + 16 + 120 + 281 + 181 + + + + + + + 110 + 310 + 80 + 25 + + + + + 0 + 0 + + + + Read + + + + + + 180 + 30 + 113 + 25 + + + + + + + 180 + 60 + 113 + 25 + + + + + + + 50 + 30 + 126 + 26 + + + + Start address: + + + + + + 40 + 60 + 126 + 25 + + + + Number of values: + + + + + + 20 + 100 + 126 + 17 + + + + Result: + + + + + + + 200 + 10 + 41 + 25 + + + + Table: + + - - - - 90 - 90 - 91 - 21 - - - - - Ubuntu Condensed - 8 - 75 - true - - - - Comma Delimiter - + + + Tab 2 + - groupBox - connect - label_5 - label_4 - startAddress - readSize - label_6 - writeTable - label_9 - groupBox_2 - groupBox_3 - groupBox_4 - groupBox_5 0 0 - 800 + 879 22 diff --git a/Test/main.cpp b/Test/main.cpp index 730adc0..4fd31bf 100644 --- a/Test/main.cpp +++ b/Test/main.cpp @@ -21,6 +21,7 @@ public: } catch(std::exception& e) { + qDebug() << "e exception " << e.what(); ; }