Browse Source

14000703 swconnect button edit wtrite

master
nasi 4 years ago
parent
commit
1c514aec46
  1. BIN
      build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/mainwindow.o
  2. 34
      build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/moc_mainwindow.cpp
  3. BIN
      build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/moc_mainwindow.o
  4. 46
      build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/moc_modbusmaster.cpp
  5. BIN
      build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/moc_modbusmaster.o
  6. BIN
      build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/modbusmaster.o
  7. BIN
      build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/serialConnectionManager
  8. 78
      build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/ui_mainwindow.h
  9. 25
      serialConnectionManager/mainwindow.cpp
  10. 1
      serialConnectionManager/mainwindow.h
  11. 104
      serialConnectionManager/mainwindow.ui
  12. 10
      serialConnectionManager/modbusmaster.cpp
  13. 2
      serialConnectionManager/modbusmaster.h

BIN
build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/mainwindow.o

Binary file not shown.

34
build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/moc_mainwindow.cpp

@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_MainWindow_t {
QByteArrayData data[7];
char stringdata0[113];
QByteArrayData data[9];
char stringdata0[135];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
@ -38,12 +38,15 @@ QT_MOC_LITERAL(2, 36, 0), // ""
QT_MOC_LITERAL(3, 37, 21), // "on_readButton_clicked"
QT_MOC_LITERAL(4, 59, 19), // "printDataFromClient"
QT_MOC_LITERAL(5, 79, 10), // "readedData"
QT_MOC_LITERAL(6, 90, 22) // "on_writeButton_clicked"
QT_MOC_LITERAL(6, 90, 15), // "connectionState"
QT_MOC_LITERAL(7, 106, 5), // "state"
QT_MOC_LITERAL(8, 112, 22) // "on_writeButton_clicked"
},
"MainWindow\0on_connectButton_clicked\0"
"\0on_readButton_clicked\0printDataFromClient\0"
"readedData\0on_writeButton_clicked"
"readedData\0connectionState\0state\0"
"on_writeButton_clicked"
};
#undef QT_MOC_LITERAL
@ -53,7 +56,7 @@ static const uint qt_meta_data_MainWindow[] = {
8, // revision
0, // classname
0, 0, // classinfo
4, 14, // methods
5, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
@ -61,15 +64,17 @@ static const uint qt_meta_data_MainWindow[] = {
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 0, 34, 2, 0x08 /* Private */,
3, 0, 35, 2, 0x08 /* Private */,
4, 1, 36, 2, 0x08 /* Private */,
6, 0, 39, 2, 0x08 /* Private */,
1, 0, 39, 2, 0x08 /* Private */,
3, 0, 40, 2, 0x08 /* Private */,
4, 1, 41, 2, 0x08 /* Private */,
6, 1, 44, 2, 0x08 /* Private */,
8, 0, 47, 2, 0x08 /* Private */,
// slots: parameters
QMetaType::Void,
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 5,
QMetaType::Void, QMetaType::Bool, 7,
QMetaType::Void,
0 // eod
@ -84,7 +89,8 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id,
case 0: _t->on_connectButton_clicked(); break;
case 1: _t->on_readButton_clicked(); break;
case 2: _t->printDataFromClient((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 3: _t->on_writeButton_clicked(); break;
case 3: _t->connectionState((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 4: _t->on_writeButton_clicked(); break;
default: ;
}
}
@ -119,13 +125,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 4)
if (_id < 5)
qt_static_metacall(this, _c, _id, _a);
_id -= 4;
_id -= 5;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 4)
if (_id < 5)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 4;
_id -= 5;
}
return _id;
}

BIN
build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/moc_mainwindow.o

Binary file not shown.

46
build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/moc_modbusmaster.cpp

@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_modBusMaster_t {
QByteArrayData data[5];
char stringdata0[55];
QByteArrayData data[7];
char stringdata0[83];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
@ -36,11 +36,14 @@ QT_MOC_LITERAL(0, 0, 12), // "modBusMaster"
QT_MOC_LITERAL(1, 13, 14), // "dataFromClient"
QT_MOC_LITERAL(2, 28, 0), // ""
QT_MOC_LITERAL(3, 29, 15), // "readedParameter"
QT_MOC_LITERAL(4, 45, 9) // "readReady"
QT_MOC_LITERAL(4, 45, 21), // "modbusConnectionState"
QT_MOC_LITERAL(5, 67, 5), // "state"
QT_MOC_LITERAL(6, 73, 9) // "readReady"
},
"modBusMaster\0dataFromClient\0\0"
"readedParameter\0readReady"
"readedParameter\0modbusConnectionState\0"
"state\0readReady"
};
#undef QT_MOC_LITERAL
@ -50,21 +53,23 @@ static const uint qt_meta_data_modBusMaster[] = {
8, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
3, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signalCount
2, // signalCount
// signals: name, argc, parameters, tag, flags
1, 1, 24, 2, 0x06 /* Public */,
1, 1, 29, 2, 0x06 /* Public */,
4, 1, 32, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
4, 0, 27, 2, 0x0a /* Public */,
6, 0, 35, 2, 0x0a /* Public */,
// signals: parameters
QMetaType::Void, QMetaType::QString, 3,
QMetaType::Void, QMetaType::Bool, 5,
// slots: parameters
QMetaType::Void,
@ -79,7 +84,8 @@ void modBusMaster::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id
Q_UNUSED(_t)
switch (_id) {
case 0: _t->dataFromClient((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 1: _t->readReady(); break;
case 1: _t->modbusConnectionState((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 2: _t->readReady(); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
@ -91,6 +97,13 @@ void modBusMaster::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id
return;
}
}
{
using _t = void (modBusMaster::*)(bool );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&modBusMaster::modbusConnectionState)) {
*result = 1;
return;
}
}
}
}
@ -123,13 +136,13 @@ int modBusMaster::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
if (_id < 3)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
_id -= 3;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 2)
if (_id < 3)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 2;
_id -= 3;
}
return _id;
}
@ -140,5 +153,12 @@ void modBusMaster::dataFromClient(QString _t1)
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
// SIGNAL 1
void modBusMaster::modbusConnectionState(bool _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE

BIN
build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/moc_modbusmaster.o

Binary file not shown.

BIN
build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/modbusmaster.o

Binary file not shown.

BIN
build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/serialConnectionManager

Binary file not shown.

78
build-serialConnectionManager-Desktop_Qt_5_13_1_GCC_64bit-Debug/ui_mainwindow.h

@ -46,19 +46,19 @@ public:
QHBoxLayout *horizontalLayout_2;
QGroupBox *groupBox_2;
QGridLayout *gridLayout_3;
QLabel *label_4;
QSpinBox *readAddress;
QComboBox *readSize;
QLabel *label_5;
QLabel *label_9;
QComboBox *readSize;
QLabel *label_4;
QTextEdit *textEditRead;
QLabel *label_5;
QGroupBox *writeGroupBox;
QGridLayout *gridLayout_2;
QSpinBox *writeAddress;
QVBoxLayout *verticalLayout_2;
QCheckBox *coilData1;
QCheckBox *coilData2;
QComboBox *writeSize;
QSpinBox *writeAddress;
QLabel *label_7;
QLabel *label_8;
QVBoxLayout *verticalLayout;
@ -83,7 +83,7 @@ public:
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(588, 520);
MainWindow->resize(578, 569);
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
layoutWidget = new QWidget(centralwidget);
@ -156,17 +156,22 @@ public:
groupBox_2->setMinimumSize(QSize(250, 0));
gridLayout_3 = new QGridLayout(groupBox_2);
gridLayout_3->setObjectName(QString::fromUtf8("gridLayout_3"));
label_4 = new QLabel(groupBox_2);
label_4->setObjectName(QString::fromUtf8("label_4"));
gridLayout_3->addWidget(label_4, 0, 1, 1, 1);
readAddress = new QSpinBox(groupBox_2);
readAddress->setObjectName(QString::fromUtf8("readAddress"));
readAddress->setMaximum(15);
gridLayout_3->addWidget(readAddress, 0, 2, 1, 1);
label_5 = new QLabel(groupBox_2);
label_5->setObjectName(QString::fromUtf8("label_5"));
gridLayout_3->addWidget(label_5, 1, 1, 1, 1);
label_9 = new QLabel(groupBox_2);
label_9->setObjectName(QString::fromUtf8("label_9"));
gridLayout_3->addWidget(label_9, 2, 1, 1, 1);
readSize = new QComboBox(groupBox_2);
readSize->addItem(QString());
readSize->addItem(QString());
@ -182,21 +187,16 @@ public:
gridLayout_3->addWidget(readSize, 1, 2, 1, 1);
label_9 = new QLabel(groupBox_2);
label_9->setObjectName(QString::fromUtf8("label_9"));
label_4 = new QLabel(groupBox_2);
label_4->setObjectName(QString::fromUtf8("label_4"));
gridLayout_3->addWidget(label_9, 2, 1, 1, 1);
gridLayout_3->addWidget(label_4, 0, 1, 1, 1);
textEditRead = new QTextEdit(groupBox_2);
textEditRead->setObjectName(QString::fromUtf8("textEditRead"));
gridLayout_3->addWidget(textEditRead, 3, 1, 1, 2);
label_5 = new QLabel(groupBox_2);
label_5->setObjectName(QString::fromUtf8("label_5"));
gridLayout_3->addWidget(label_5, 1, 1, 1, 1);
horizontalLayout_2->addWidget(groupBox_2);
@ -205,12 +205,6 @@ public:
writeGroupBox->setMinimumSize(QSize(225, 0));
gridLayout_2 = new QGridLayout(writeGroupBox);
gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
writeAddress = new QSpinBox(writeGroupBox);
writeAddress->setObjectName(QString::fromUtf8("writeAddress"));
writeAddress->setMaximum(9);
gridLayout_2->addWidget(writeAddress, 0, 1, 1, 1);
verticalLayout_2 = new QVBoxLayout();
verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
coilData1 = new QCheckBox(writeGroupBox);
@ -229,18 +223,17 @@ public:
writeSize = new QComboBox(writeGroupBox);
writeSize->addItem(QString());
writeSize->addItem(QString());
writeSize->addItem(QString());
writeSize->addItem(QString());
writeSize->addItem(QString());
writeSize->addItem(QString());
writeSize->addItem(QString());
writeSize->addItem(QString());
writeSize->addItem(QString());
writeSize->addItem(QString());
writeSize->setObjectName(QString::fromUtf8("writeSize"));
writeSize->setMaxVisibleItems(2);
gridLayout_2->addWidget(writeSize, 1, 1, 1, 1);
writeAddress = new QSpinBox(writeGroupBox);
writeAddress->setObjectName(QString::fromUtf8("writeAddress"));
writeAddress->setMaximum(9);
gridLayout_2->addWidget(writeAddress, 0, 1, 1, 1);
label_7 = new QLabel(writeGroupBox);
label_7->setObjectName(QString::fromUtf8("label_7"));
@ -291,7 +284,7 @@ public:
layoutWidget_3 = new QWidget(centralwidget);
layoutWidget_3->setObjectName(QString::fromUtf8("layoutWidget_3"));
layoutWidget_3->setGeometry(QRect(10, 350, 561, 27));
layoutWidget_3->setGeometry(QRect(10, 500, 561, 27));
horizontalLayout = new QHBoxLayout(layoutWidget_3);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
horizontalLayout->setContentsMargins(0, 0, 0, 0);
@ -330,7 +323,7 @@ public:
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 588, 22));
menubar->setGeometry(QRect(0, 0, 578, 22));
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
@ -340,7 +333,7 @@ public:
connectButton->setDefault(true);
readSize->setCurrentIndex(9);
writeSize->setCurrentIndex(9);
writeSize->setCurrentIndex(0);
QMetaObject::connectSlotsByName(MainWindow);
@ -354,7 +347,8 @@ public:
label->setText(QCoreApplication::translate("MainWindow", "Connection type Is Serial:", nullptr));
label_2->setText(QCoreApplication::translate("MainWindow", "Port:", nullptr));
groupBox_2->setTitle(QCoreApplication::translate("MainWindow", "Read", nullptr));
label_4->setText(QCoreApplication::translate("MainWindow", "Start address:", nullptr));
label_5->setText(QCoreApplication::translate("MainWindow", "Number of values:", nullptr));
label_9->setText(QCoreApplication::translate("MainWindow", "Result:", nullptr));
readSize->setItemText(0, QCoreApplication::translate("MainWindow", "1", nullptr));
readSize->setItemText(1, QCoreApplication::translate("MainWindow", "2", nullptr));
readSize->setItemText(2, QCoreApplication::translate("MainWindow", "3", nullptr));
@ -366,22 +360,14 @@ public:
readSize->setItemText(8, QCoreApplication::translate("MainWindow", "9", nullptr));
readSize->setItemText(9, QCoreApplication::translate("MainWindow", "10", nullptr));
label_9->setText(QCoreApplication::translate("MainWindow", "Result:", nullptr));
label_5->setText(QCoreApplication::translate("MainWindow", "Number of values:", nullptr));
label_4->setText(QCoreApplication::translate("MainWindow", "Start address:", nullptr));
writeGroupBox->setTitle(QCoreApplication::translate("MainWindow", "Write", nullptr));
coilData1->setText(QCoreApplication::translate("MainWindow", "Coil1", nullptr));
coilData2->setText(QCoreApplication::translate("MainWindow", "Coil2", nullptr));
writeSize->setItemText(0, QCoreApplication::translate("MainWindow", "1", nullptr));
writeSize->setItemText(1, QCoreApplication::translate("MainWindow", "2", nullptr));
writeSize->setItemText(2, QCoreApplication::translate("MainWindow", "3", nullptr));
writeSize->setItemText(3, QCoreApplication::translate("MainWindow", "4", nullptr));
writeSize->setItemText(4, QCoreApplication::translate("MainWindow", "5", nullptr));
writeSize->setItemText(5, QCoreApplication::translate("MainWindow", "6", nullptr));
writeSize->setItemText(6, QCoreApplication::translate("MainWindow", "7", nullptr));
writeSize->setItemText(7, QCoreApplication::translate("MainWindow", "8", nullptr));
writeSize->setItemText(8, QCoreApplication::translate("MainWindow", "9", nullptr));
writeSize->setItemText(9, QCoreApplication::translate("MainWindow", "10", nullptr));
writeSize->setCurrentText(QCoreApplication::translate("MainWindow", "1", nullptr));
label_7->setText(QCoreApplication::translate("MainWindow", "Start address:", nullptr));
label_8->setText(QCoreApplication::translate("MainWindow", "Number of values:", nullptr));
label_3->setText(QCoreApplication::translate("MainWindow", "register1", nullptr));

25
serialConnectionManager/mainwindow.cpp

@ -11,6 +11,8 @@ MainWindow::MainWindow(QWidget *parent)
ui->writeTable->addItem(tr("Input Registers"), 2);
ui->writeTable->addItem(tr("Holding Registers"), 3);
connect(&modBusObj, &modBusMaster::dataFromClient, this, &MainWindow::printDataFromClient);
connect(&modBusObj, &modBusMaster::modbusConnectionState, this, &MainWindow::connectionState);
}
MainWindow::~MainWindow()
@ -21,8 +23,17 @@ MainWindow::~MainWindow()
void MainWindow::on_connectButton_clicked()
{
modBusObj.init();
modBusObj.open(ui->portEdit->text(),ui->serverEdit->value());
if( ui->connectButton->text()==tr("Disconnect"))
{
modBusObj.stop();
}
else
{
modBusObj.init();
modBusObj.open(ui->portEdit->text(),ui->serverEdit->value());
}
}
void MainWindow::on_readButton_clicked()
@ -48,6 +59,14 @@ void MainWindow::printDataFromClient(QString readedData)
ui->textEditRead->setText(readedData);
}
void MainWindow::connectionState(bool state)
{
if (state)
ui->connectButton->setText(tr("Disconnect"));
else
ui->connectButton->setText(tr("Connect"));
}
void MainWindow::on_writeButton_clicked()
{
uiCoils.resize(2);
@ -66,7 +85,7 @@ void MainWindow::on_writeButton_clicked()
}
else if (numberOfEntries==1)
{
qDebug() << "coil umberOfEntries==1 " << numberOfEntries ;
qDebug() << "coil numberOfEntries==1 " << numberOfEntries ;
modBusObj.setSingleCoil(startAddress, ui->coilData1->isChecked());
}
break;

1
serialConnectionManager/mainwindow.h

@ -20,6 +20,7 @@ private slots:
void on_connectButton_clicked();
void on_readButton_clicked();
void printDataFromClient(QString readedData);
void connectionState(bool state);
void on_writeButton_clicked();

104
serialConnectionManager/mainwindow.ui

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>588</width>
<height>520</height>
<width>578</width>
<height>569</height>
</rect>
</property>
<property name="windowTitle">
@ -129,13 +129,6 @@
<string>Read</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Start address:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="readAddress">
<property name="maximum">
@ -143,6 +136,20 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Number of values:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Result:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="readSize">
<property name="currentIndex">
@ -200,23 +207,16 @@
</item>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_9">
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Result:</string>
<string>Start address:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QTextEdit" name="textEditRead"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Number of values:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -232,13 +232,6 @@
<string>Write</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QSpinBox" name="writeAddress">
<property name="maximum">
<number>9</number>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@ -259,8 +252,14 @@
</item>
<item row="1" column="1">
<widget class="QComboBox" name="writeSize">
<property name="currentText">
<string>1</string>
</property>
<property name="currentIndex">
<number>9</number>
<number>0</number>
</property>
<property name="maxVisibleItems">
<number>2</number>
</property>
<item>
<property name="text">
@ -272,46 +271,13 @@
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>3</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>5</string>
</property>
</item>
<item>
<property name="text">
<string>6</string>
</property>
</item>
<item>
<property name="text">
<string>7</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>9</string>
</property>
</item>
<item>
<property name="text">
<string>10</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="writeAddress">
<property name="maximum">
<number>9</number>
</property>
</widget>
</item>
<item row="0" column="0">
@ -367,7 +333,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>350</y>
<y>500</y>
<width>561</width>
<height>27</height>
</rect>
@ -434,7 +400,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>588</width>
<width>578</width>
<height>22</height>
</rect>
</property>

10
serialConnectionManager/modbusmaster.cpp

@ -51,6 +51,7 @@ void modBusMaster::open(QString _serialPort , int _serverId)
#endif
modbusDevice->setTimeout(modbusSettings.responseTime);
modbusDevice->setNumberOfRetries(modbusSettings.numberOfRetries);
emit modbusConnectionState(true);
}
if (!modbusDevice->connectDevice())
{
@ -66,17 +67,16 @@ void modBusMaster::close()
void modBusMaster::stop()
{
if (modbusDevice)
modbusDevice->disconnectDevice();
emit modbusConnectionState(false);
}
void modBusMaster::setSingleCoil(int startAddress,bool coilFlag)
{
if (!modbusDevice)
return;
qDebug() << " ---- setSingleCoil " ;
m_coils.clearBit(2);
m_coils.setBit(0,coilFlag);
qDebug() << " ---- setSingleCoil coilFlag " <<coilFlag;
writeRequest(QModbusDataUnit::RegisterType::Coils, startAddress, 1);
}
@ -85,7 +85,6 @@ void modBusMaster::setMultipleCoil(int startAddress, quint16 writeSize, QBitArra
{
if (!modbusDevice)
return;
m_holdingRegisters.clear();
m_coils = someCoilFlags;
writeRequest(QModbusDataUnit::RegisterType::Coils, startAddress, writeSize);
}
@ -94,7 +93,6 @@ void modBusMaster::setSingleRgister(int startAddress, quint16 RegisterValue)
{
if (!modbusDevice)
return;
m_holdingRegisters.clear();
m_holdingRegisters[0]=RegisterValue;
writeRequest(QModbusDataUnit::RegisterType::HoldingRegisters, startAddress, 1);
}

2
serialConnectionManager/modbusmaster.h

@ -39,6 +39,8 @@ public:
signals:
void dataFromClient(QString readedParameter);
void modbusConnectionState(bool state);
public slots:
void readReady();
private:

Loading…
Cancel
Save