|
|
@ -41,6 +41,7 @@ void MainWindow::on_connect_clicked() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
void MainWindow::on_readButton_clicked() |
|
|
|
{ |
|
|
|
int startAddress = ui->startAddress->text().toInt(); |
|
|
@ -71,6 +72,7 @@ void MainWindow::on_readButton_clicked() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
void MainWindow::printCoilsDataFromClient(QBitArray uiCoils) |
|
|
|
{ |
|
|
|
QString readedData; |
|
|
@ -83,6 +85,7 @@ void MainWindow::printCoilsDataFromClient(QBitArray uiCoils) |
|
|
|
ui->textEditRead->setText(readedData); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
void MainWindow::printRegisterDataFromClient(QVector<quint16> uiHoldingRegisters) |
|
|
|
{ |
|
|
|
QString readedData; |
|
|
@ -95,14 +98,14 @@ void MainWindow::printRegisterDataFromClient(QVector<quint16> uiHoldingRegisters |
|
|
|
ui->textEditRead->setText(readedData); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
void MainWindow::on_writeSingleCoil_clicked() |
|
|
|
{ |
|
|
|
int startAddress = ui->writeSingleCoilAddress->text().toInt(); |
|
|
|
QBitArray uiCoils; |
|
|
|
uiCoils.resize(1); |
|
|
|
modbusWrapper.setSingleCoil(startAddress, ui->coilData->isChecked()); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
void MainWindow::on_writeMultiCoil_clicked() |
|
|
|
{ |
|
|
|
int startAddress = ui->writeMultiCoilStartAddress->text().toInt(); |
|
|
@ -121,3 +124,32 @@ void MainWindow::on_writeMultiCoil_clicked() |
|
|
|
} |
|
|
|
modbusWrapper.setMultipleCoil(startAddress, static_cast<quint16>(writeQty), uiCoils); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
void MainWindow::on_writeSingleRegister_clicked() |
|
|
|
{ |
|
|
|
int startAddress = ui->writeSingleRegisterAddress->text().toInt(); |
|
|
|
quint16 value = static_cast<quint16>(ui->writeSingleRegisterValue->text().toInt()); |
|
|
|
modbusWrapper.setSingleRegister(startAddress, value); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
void MainWindow::on_writeMultiRegister_clicked() |
|
|
|
{ |
|
|
|
int startAddress = ui->writeMultiRegisterStartAddress->text().toInt(); |
|
|
|
int writeQty = ui->writeMultiRegisterQty->text().toInt(); |
|
|
|
QString valueToWrite = ui->writeMultiRegisterValue->text(); |
|
|
|
QVector<quint16> uiHoldingRegisters; |
|
|
|
uiHoldingRegisters.resize(writeQty); |
|
|
|
|
|
|
|
QRegExp rx("(\\ |\\,|\\.|\\:|\\t)"); //RegEx for ' ' or ',' or '.' or ':' or '\t'
|
|
|
|
QStringList stringListValue = valueToWrite.split(rx); |
|
|
|
|
|
|
|
for(int i = 0; i < stringListValue.size(); i++) |
|
|
|
{ |
|
|
|
uiHoldingRegisters[i] = static_cast<quint16>(stringListValue[i].toInt()); |
|
|
|
} |
|
|
|
modbusWrapper.setMultipleRegister(startAddress, |
|
|
|
static_cast<quint16>(writeQty), |
|
|
|
uiHoldingRegisters); |
|
|
|
} |
|
|
|