Compare commits
4 Commits
Pre-releas
...
main
Author | SHA1 | Date | |
---|---|---|---|
7dc314d266 | |||
568ec9b5d3 | |||
009ac176f9 | |||
1b7388821e |
21
Debug/.qmake.stash
Normal file
21
Debug/.qmake.stash
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
|
||||||
|
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7
|
||||||
|
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3
|
||||||
|
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
|
||||||
|
QMAKE_CXX.COMPILER_MACROS = \
|
||||||
|
QT_COMPILER_STDCXX \
|
||||||
|
QMAKE_GCC_MAJOR_VERSION \
|
||||||
|
QMAKE_GCC_MINOR_VERSION \
|
||||||
|
QMAKE_GCC_PATCH_VERSION
|
||||||
|
QMAKE_CXX.INCDIRS = \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++ \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/i686-w64-mingw32 \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/backward \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include-fixed \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/i686-w64-mingw32/include
|
||||||
|
QMAKE_CXX.LIBDIRS = \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0 \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/lib/gcc \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/i686-w64-mingw32/lib \
|
||||||
|
C:/Qt/Qt5.14.2/Tools/mingw730_32/lib
|
BIN
Debug/debug/M3KTE_TERM.exe
Normal file
BIN
Debug/debug/M3KTE_TERM.exe
Normal file
Binary file not shown.
@ -16,6 +16,9 @@ CONFIG += c++11
|
|||||||
# deprecated API in order to know how to port your code away from it.
|
# deprecated API in order to know how to port your code away from it.
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
DEFINES += M3KTE_LIBRARY
|
||||||
|
|
||||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||||
# In order to do so, uncomment the following line.
|
# In order to do so, uncomment the following line.
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
@ -23,26 +26,37 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
devicesettingsdialog.cpp \
|
devicesettingsdialog.cpp \
|
||||||
|
lineringer.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
m3kte.cpp \
|
m3kte.cpp \
|
||||||
multiplesettings.cpp \
|
multiplesettings.cpp \
|
||||||
|
scanboard.cpp \
|
||||||
settingsdialog.cpp \
|
settingsdialog.cpp \
|
||||||
writeregistermodel.cpp
|
writeregistermodel.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
devicesettingsdialog.h \
|
devicesettingsdialog.h \
|
||||||
|
lineringer.h \
|
||||||
m3kte.h \
|
m3kte.h \
|
||||||
multiplesettings.h \
|
multiplesettings.h \
|
||||||
|
scanboard.h \
|
||||||
settingsdialog.h \
|
settingsdialog.h \
|
||||||
writeregistermodel.h
|
writeregistermodel.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
devicesettingsdialog.ui \
|
devicesettingsdialog.ui \
|
||||||
|
lineringer.ui \
|
||||||
m3kte.ui \
|
m3kte.ui \
|
||||||
multiplesettings.ui \
|
multiplesettings.ui \
|
||||||
|
scanboard.ui \
|
||||||
settingsdialog.ui
|
settingsdialog.ui
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
#qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
|
#!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
|
unix {
|
||||||
|
target.path = /usr/lib
|
||||||
|
}
|
||||||
!isEmpty(target.path): INSTALLS += target
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
@ -55,7 +55,7 @@ void DeviceSettingsDialog::on_buttonApplyChangeParity_clicked()
|
|||||||
|
|
||||||
void DeviceSettingsDialog::on_buttonApplyChangeAdr_clicked()
|
void DeviceSettingsDialog::on_buttonApplyChangeAdr_clicked()
|
||||||
{
|
{
|
||||||
BoardIdHasBeenChanged* _boardIdHasBeenChanged = new BoardIdHasBeenChanged(ui->idComboBox->currentIndex(), ui->adrSpinBox->value());
|
BoardIdHasBeenChanged* _boardIdHasBeenChanged = new BoardIdHasBeenChanged(ui->idComboBox->currentText().toUInt(), ui->adrSpinBox->value());
|
||||||
QCoreApplication::postEvent(parent(), _boardIdHasBeenChanged);
|
QCoreApplication::postEvent(parent(), _boardIdHasBeenChanged);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@ -75,21 +75,24 @@ unsigned short DeviceSettingsDialog::currentParity()
|
|||||||
return _currentParity;
|
return _currentParity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSettingsDialog::updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr, int CurrentConnectedDevice)
|
void DeviceSettingsDialog::updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr, bool *ActiveDevices)
|
||||||
{
|
{
|
||||||
ui->speedBox->setCurrentText(QString::number(_currentSpeed=tmp_speed, 10));
|
ui->speedBox->setCurrentText(QString::number(_currentSpeed=tmp_speed, 10));
|
||||||
if(tmp_parity>0)
|
if(tmp_parity>0)
|
||||||
tmp_parity--;
|
tmp_parity--;
|
||||||
ui->parityBox->setCurrentIndex(_currentParity = tmp_parity);
|
ui->parityBox->setCurrentIndex(_currentParity = tmp_parity);
|
||||||
for(int i = 0; i < CurrentConnectedDevice; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
_m_timer[i]->setEnabled(true);
|
if(ActiveDevices[i])
|
||||||
ui->idComboBox->addItem(QString::number(i));
|
{
|
||||||
_currentAdrs[i] = tmp_adr[i];
|
_m_timer[i]->setEnabled(true);
|
||||||
}
|
ui->idComboBox->addItem(QString::number(i));
|
||||||
for(int i = CurrentConnectedDevice; i < 4; i++)
|
_currentAdrs[i] = tmp_adr[i];
|
||||||
{
|
}
|
||||||
_m_timer[i]->setEnabled(false);
|
else
|
||||||
|
{
|
||||||
|
_m_timer[i]->setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
on_idComboBox_currentIndexChanged(ui->idComboBox->currentIndex());
|
on_idComboBox_currentIndexChanged(ui->idComboBox->currentIndex());
|
||||||
}
|
}
|
||||||
@ -129,3 +132,25 @@ void DeviceSettingsDialog::on_buttonBox_clicked(QAbstractButton *button)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceSettingsDialog::initPollForBoard(unsigned boardID, unsigned boardAdr)
|
||||||
|
{
|
||||||
|
ui->idPollComboBox->addItem(QString("Плата №%1 (ID %2)").arg(boardID).arg(boardAdr), QVariant(boardID));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSettingsDialog::updatePollStatus(unsigned boardID, bool status)
|
||||||
|
{
|
||||||
|
_currentPollStatus[boardID] = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSettingsDialog::on_buttonApplyChangePoll_clicked()
|
||||||
|
{
|
||||||
|
updatePollStatus(ui->idPollComboBox->currentData().toUInt(), (bool)ui->pollStatusBox->currentIndex());
|
||||||
|
pollStatusChange* _pollStatusChanged = new pollStatusChange(ui->idPollComboBox->currentData().toUInt(), _currentPollStatus[ui->idPollComboBox->currentData().toUInt()]);
|
||||||
|
QCoreApplication::postEvent(parent(), _pollStatusChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSettingsDialog::on_idPollComboBox_currentIndexChanged(int index)
|
||||||
|
{
|
||||||
|
ui->pollStatusBox->setCurrentIndex(_currentPollStatus[ui->idPollComboBox->currentData().toUInt()]);
|
||||||
|
}
|
||||||
|
@ -21,6 +21,20 @@ private:
|
|||||||
short _BoardNewID;
|
short _BoardNewID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class pollStatusChange : public QEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
pollStatusChange(unsigned BoardID, bool Stat) : QEvent((QEvent::Type)1001) {_BoardID = BoardID; _Status = Stat;}
|
||||||
|
~pollStatusChange() {}
|
||||||
|
|
||||||
|
unsigned BoardID() const {return _BoardID;}
|
||||||
|
bool Status() const {return _Status;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned _BoardID;
|
||||||
|
bool _Status;
|
||||||
|
};
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DeviceSettingsDialog;
|
class DeviceSettingsDialog;
|
||||||
}
|
}
|
||||||
@ -36,7 +50,9 @@ public:
|
|||||||
unsigned currentBoardTimer(unsigned short _ID);
|
unsigned currentBoardTimer(unsigned short _ID);
|
||||||
unsigned currentSpeed();
|
unsigned currentSpeed();
|
||||||
unsigned short currentParity();
|
unsigned short currentParity();
|
||||||
void updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr, int CurrentConnectedDevice);
|
void updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr, bool *ActiveDevices);
|
||||||
|
void updatePollStatus(unsigned boardID, bool status);
|
||||||
|
void initPollForBoard(unsigned boardID, unsigned boardAdr);
|
||||||
signals:
|
signals:
|
||||||
void parityChanged();
|
void parityChanged();
|
||||||
void speedChanged();
|
void speedChanged();
|
||||||
@ -59,12 +75,17 @@ private slots:
|
|||||||
|
|
||||||
void on_buttonBox_clicked(QAbstractButton *button);
|
void on_buttonBox_clicked(QAbstractButton *button);
|
||||||
|
|
||||||
|
void on_buttonApplyChangePoll_clicked();
|
||||||
|
|
||||||
|
void on_idPollComboBox_currentIndexChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSpinBox *_m_timer[4];
|
QSpinBox *_m_timer[4];
|
||||||
unsigned _currentBoardTimers[4];
|
unsigned _currentBoardTimers[4];
|
||||||
unsigned _currentSpeed;
|
unsigned _currentSpeed;
|
||||||
unsigned short _currentParity;
|
unsigned short _currentParity;
|
||||||
unsigned _currentAdrs[4];
|
unsigned _currentAdrs[4];
|
||||||
|
bool _currentPollStatus[4];
|
||||||
|
|
||||||
Ui::DeviceSettingsDialog *ui;
|
Ui::DeviceSettingsDialog *ui;
|
||||||
};
|
};
|
||||||
|
@ -6,77 +6,14 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>243</width>
|
<width>278</width>
|
||||||
<height>431</height>
|
<height>500</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="title">
|
|
||||||
<string>Скорость обмена</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QPushButton" name="buttonApplyChangeSpeed">
|
|
||||||
<property name="text">
|
|
||||||
<string>Применить</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QComboBox" name="speedBox">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>3</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>9600</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>14400</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>19200</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>31250</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>38400</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>56000</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>57600</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>115200</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -188,6 +125,41 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
|
<property name="title">
|
||||||
|
<string>Контроль четности</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonApplyChangeParity">
|
||||||
|
<property name="text">
|
||||||
|
<string>Применить</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QComboBox" name="parityBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>No</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Even</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Odd</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -221,7 +193,70 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="1" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Скорость обмена</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonApplyChangeSpeed">
|
||||||
|
<property name="text">
|
||||||
|
<string>Применить</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QComboBox" name="speedBox">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>9600</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>14400</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>19200</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>31250</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>38400</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>56000</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>57600</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>115200</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -231,38 +266,36 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox_4">
|
<widget class="QGroupBox" name="groupBox_5">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Контроль четности</string>
|
<string>Опрос ТЭ</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_5">
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QComboBox" name="idPollComboBox"/>
|
||||||
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="buttonApplyChangeParity">
|
<widget class="QComboBox" name="pollStatusBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Вкл</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Выкл</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="buttonApplyChangePoll">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Применить</string>
|
<string>Применить</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QComboBox" name="parityBox">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>No</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Even</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Odd</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
315
M3KTE_TERM/lineringer.cpp
Normal file
315
M3KTE_TERM/lineringer.cpp
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
#include "lineringer.h"
|
||||||
|
#include "ui_lineringer.h"
|
||||||
|
|
||||||
|
LineRinger::LineRinger(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::LineRinger)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
const auto listPorts = QSerialPortInfo::availablePorts();
|
||||||
|
for (const auto& port: listPorts)
|
||||||
|
{
|
||||||
|
ui->comBox->addItem(QString(port.portName() + ": " + port.manufacturer()), QVariant(port.portName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->parityControlBox->addItem("No", QVariant(QSerialPort::NoParity));
|
||||||
|
ui->parityControlBox->addItem("Even", QVariant(QSerialPort::EvenParity));
|
||||||
|
ui->parityControlBox->addItem("Odd", QVariant(QSerialPort::OddParity));
|
||||||
|
ui->parityControlBox->addItem("Space", QVariant(QSerialPort::SpaceParity));
|
||||||
|
ui->parityControlBox->addItem("Mark", QVariant(QSerialPort::MarkParity));
|
||||||
|
|
||||||
|
ui->dataBox->addItem("Data5", QVariant(QSerialPort::Data5));
|
||||||
|
ui->dataBox->addItem("Data6", QVariant(QSerialPort::Data6));
|
||||||
|
ui->dataBox->addItem("Data7", QVariant(QSerialPort::Data7));
|
||||||
|
ui->dataBox->addItem("Data8", QVariant(QSerialPort::Data8));
|
||||||
|
ui->dataBox->setCurrentIndex(3);
|
||||||
|
|
||||||
|
ui->stopBox->addItem("One", QVariant(QSerialPort::OneStop));
|
||||||
|
ui->stopBox->addItem("OneAndHalf", QVariant(QSerialPort::OneAndHalfStop));
|
||||||
|
ui->stopBox->addItem("Two", QVariant(QSerialPort::TwoStop));
|
||||||
|
|
||||||
|
ui->deviceOnlineView->horizontalHeader()->setVisible(true);
|
||||||
|
syncColumnHeaders();
|
||||||
|
ui->deviceOnlineView->setColumnHidden(1, true);
|
||||||
|
|
||||||
|
ui->ringButton->setEnabled(false);
|
||||||
|
|
||||||
|
modbusDevice = new QModbusRtuSerialMaster(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LineRinger::~LineRinger()
|
||||||
|
{
|
||||||
|
if (modbusDevice->state() == QModbusDevice::ConnectedState)
|
||||||
|
on_connectButton_clicked();
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineRinger::syncColumnHeaders()
|
||||||
|
{
|
||||||
|
QStringList headers;
|
||||||
|
headers << "ID" << "BaudRate" << "Vendor Name" << "Product Code" << "Major Minor Revision" << "Vendor Url" << "Product Name" << "Model Name" << "User Application Name" << "Примечание";
|
||||||
|
ui->deviceOnlineView->setHorizontalHeaderLabels(headers);
|
||||||
|
ui->deviceOnlineView->resizeColumnsToContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineRinger::on_connectButton_clicked()
|
||||||
|
{
|
||||||
|
if (!modbusDevice)
|
||||||
|
return;
|
||||||
|
if (modbusDevice->state() != QModbusDevice::ConnectedState) {
|
||||||
|
modbusDevice->setConnectionParameter(QModbusDevice::SerialPortNameParameter,
|
||||||
|
ui->comBox->currentData().toString());
|
||||||
|
#if QT_CONFIG(modbus_serialport)
|
||||||
|
modbusDevice->setConnectionParameter(QModbusDevice::SerialParityParameter,
|
||||||
|
ui->parityControlBox->currentData().toInt());
|
||||||
|
modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter,
|
||||||
|
ui->baudRateBox->currentText().toInt(nullptr, 10));
|
||||||
|
modbusDevice->setConnectionParameter(QModbusDevice::SerialDataBitsParameter,
|
||||||
|
ui->dataBox->currentData().toInt());
|
||||||
|
modbusDevice->setConnectionParameter(QModbusDevice::SerialStopBitsParameter,
|
||||||
|
ui->stopBox->currentData().toInt());
|
||||||
|
#endif
|
||||||
|
modbusDevice->setTimeout(50);
|
||||||
|
modbusDevice->setNumberOfRetries(0);
|
||||||
|
if (!modbusDevice->connectDevice()) {
|
||||||
|
QMessageBox::warning(this, "Ошибка", "Произошла ошибка при попытке подключения.");
|
||||||
|
} else {
|
||||||
|
ui->connectButton->setText(tr("Отключить"));
|
||||||
|
ui->ringButton->setEnabled(true);
|
||||||
|
currentBaudRate = ui->baudRateBox->currentText().toUInt(nullptr, 10);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
modbusDevice->disconnectDevice();
|
||||||
|
ui->connectButton->setText(tr("Подключить"));
|
||||||
|
ui->ringButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LineRinger::callStatus LineRinger::lineCall()
|
||||||
|
{
|
||||||
|
QModbusRequest readDeviceBasicIdentification(QModbusRequest::EncapsulatedInterfaceTransport, QByteArray::fromHex("0E0100"));
|
||||||
|
QModbusRequest readDeviceRegularIdentification(QModbusRequest::EncapsulatedInterfaceTransport, QByteArray::fromHex("0E0200"));
|
||||||
|
bool isRun = false;
|
||||||
|
bool *tmp_isRun = &isRun;
|
||||||
|
uint tmp_adr = 1;
|
||||||
|
auto bar = new QProgressDialog(this);
|
||||||
|
connect(bar, &QProgressDialog::canceled, this, [this, tmp_isRun]()
|
||||||
|
{
|
||||||
|
*tmp_isRun = true;
|
||||||
|
});
|
||||||
|
connect(this, &LineRinger::stopLineCall, this, [this, tmp_isRun]()
|
||||||
|
{
|
||||||
|
*tmp_isRun = true;
|
||||||
|
});
|
||||||
|
bar->setLabelText(tr("Поиск устройств... Текущий адрес: %1").arg(tmp_adr));
|
||||||
|
bar->setCancelButton(nullptr);
|
||||||
|
bar->setRange(1, 247);
|
||||||
|
bar->setMinimumDuration(100);
|
||||||
|
for(tmp_adr = 1; tmp_adr<248; tmp_adr++)
|
||||||
|
{
|
||||||
|
bar->setValue(tmp_adr);
|
||||||
|
bar->setLabelText(tr("Поиск устройств... Текущий адрес: %1/247").arg(tmp_adr));
|
||||||
|
auto *reply = modbusDevice->sendRawRequest(readDeviceBasicIdentification, tmp_adr);
|
||||||
|
//auto *reply = modbusDevice->sendReadRequest(*_unit, tmp_adr);
|
||||||
|
//Запрос типа устройства.
|
||||||
|
if(reply == nullptr)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "Ошибка при сканировании.", QString("%1").arg(modbusDevice->errorString()));
|
||||||
|
bar->close();
|
||||||
|
bar->deleteLater();
|
||||||
|
return callStatus::ERROR;
|
||||||
|
}
|
||||||
|
while(!reply->isFinished())
|
||||||
|
{
|
||||||
|
if(isRun)
|
||||||
|
{
|
||||||
|
bar->close();
|
||||||
|
bar->deleteLater();
|
||||||
|
return callStatus::INTERRUPT;
|
||||||
|
}
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
|
if(isRun)
|
||||||
|
{
|
||||||
|
bar->close();
|
||||||
|
bar->deleteLater();
|
||||||
|
return callStatus::INTERRUPT;
|
||||||
|
}
|
||||||
|
else if (!isRun)
|
||||||
|
{
|
||||||
|
//Нужна проверка типа устройства
|
||||||
|
if(reply->error()!=QModbusDevice::TimeoutError)
|
||||||
|
{
|
||||||
|
deviceOnLine currentDevice;
|
||||||
|
currentDevice.adr = tmp_adr;
|
||||||
|
currentDevice.baudRate = currentBaudRate;
|
||||||
|
bool regularReplyError = false;
|
||||||
|
QString regularReplyErrorString;
|
||||||
|
if(reply->error()==QModbusDevice::NoError)
|
||||||
|
{
|
||||||
|
QModbusResponse resp = reply->rawResult();
|
||||||
|
uint8_t numOfObject = resp.data().at(5);
|
||||||
|
QByteArray result = resp.data().remove(0, 6);
|
||||||
|
for(int tmp_obj = 0; tmp_obj < numOfObject; tmp_obj++)
|
||||||
|
{
|
||||||
|
uint8_t objectID = result.at(0);
|
||||||
|
uint8_t lengthOfObject = result.at(1);
|
||||||
|
if(lengthOfObject>0)
|
||||||
|
{
|
||||||
|
currentDevice.fields[objectID].clear();
|
||||||
|
}
|
||||||
|
for(int i = 0; i < lengthOfObject; i++)
|
||||||
|
{
|
||||||
|
currentDevice.fields[objectID] += QString(result.at(2+i));
|
||||||
|
}
|
||||||
|
result.remove(0, lengthOfObject+2);
|
||||||
|
}
|
||||||
|
auto *regularReply = modbusDevice->sendRawRequest(readDeviceRegularIdentification, tmp_adr);
|
||||||
|
if(regularReply == nullptr)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "Ошибка при сканировании.", QString("%1: %2").arg(modbusDevice->error()).arg(modbusDevice->errorString()));
|
||||||
|
bar->close();
|
||||||
|
bar->deleteLater();
|
||||||
|
return callStatus::ERROR;
|
||||||
|
}
|
||||||
|
while(!regularReply->isFinished())
|
||||||
|
{
|
||||||
|
if(isRun)
|
||||||
|
{
|
||||||
|
bar->close();
|
||||||
|
bar->deleteLater();
|
||||||
|
return callStatus::INTERRUPT;
|
||||||
|
}
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
|
if(isRun)
|
||||||
|
{
|
||||||
|
bar->close();
|
||||||
|
bar->deleteLater();
|
||||||
|
return callStatus::INTERRUPT;
|
||||||
|
}
|
||||||
|
else if(!isRun)
|
||||||
|
{
|
||||||
|
if(regularReply->error()!=QModbusDevice::NoError)
|
||||||
|
{
|
||||||
|
// QMessageBox::warning(this, "Ошибка при сканировании.", QString("%1: %2").arg(regularReply->error()).arg(regularReply->errorString()));
|
||||||
|
// bar->close();
|
||||||
|
// bar->deleteLater();
|
||||||
|
// return callStatus::ERROR;
|
||||||
|
regularReplyError = true;
|
||||||
|
regularReplyErrorString = QString("%1: %2").arg(regularReply->error()).arg(regularReply->errorString());
|
||||||
|
}
|
||||||
|
QModbusResponse regularResp = regularReply->rawResult();
|
||||||
|
uint8_t numOfRegularObject = regularResp.data().at(5);
|
||||||
|
QByteArray regularResult = regularResp.data().remove(0, 6);
|
||||||
|
for(int tmp_obj = 0; tmp_obj < numOfRegularObject; tmp_obj++)
|
||||||
|
{
|
||||||
|
uint8_t objectID = regularResult.at(0);
|
||||||
|
if(objectID > 0x06)
|
||||||
|
continue;
|
||||||
|
uint8_t lengthOfObject = regularResult.at(1);
|
||||||
|
if(lengthOfObject>0)
|
||||||
|
{
|
||||||
|
currentDevice.fields[objectID].clear();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < lengthOfObject; i++) {
|
||||||
|
currentDevice.fields[objectID] += QString(regularResult.at(2+i));
|
||||||
|
}
|
||||||
|
regularResult.remove(0, lengthOfObject+2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isRun)
|
||||||
|
{
|
||||||
|
devicesList.append(currentDevice);
|
||||||
|
unsigned newRow = ui->deviceOnlineView->rowCount();
|
||||||
|
ui->deviceOnlineView->insertRow(newRow);
|
||||||
|
ui->deviceOnlineView->setItem(newRow, 0, new QTableWidgetItem(QString::number(currentDevice.adr)));
|
||||||
|
ui->deviceOnlineView->setItem(newRow, 1, new QTableWidgetItem(QString::number(currentDevice.baudRate)));
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
ui->deviceOnlineView->setItem(newRow, i+2, new QTableWidgetItem(currentDevice.fields[i]));
|
||||||
|
}
|
||||||
|
if(reply->error()!=QModbusDevice::NoError)
|
||||||
|
{
|
||||||
|
ui->deviceOnlineView->setItem(newRow, 9, new QTableWidgetItem(QString("%1: %2").arg(reply->error()).arg(reply->errorString())));
|
||||||
|
}
|
||||||
|
else if(regularReplyError)
|
||||||
|
{
|
||||||
|
ui->deviceOnlineView->setItem(newRow, 9, new QTableWidgetItem(regularReplyErrorString));
|
||||||
|
}
|
||||||
|
ui->deviceOnlineView->resizeColumnsToContents();
|
||||||
|
syncColumnHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return callStatus::NOERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineRinger::on_ringButton_clicked()
|
||||||
|
{
|
||||||
|
ui->deviceOnlineView->clear();
|
||||||
|
devicesList.clear();
|
||||||
|
syncColumnHeaders();
|
||||||
|
while(ui->deviceOnlineView->rowCount()!=0)
|
||||||
|
ui->deviceOnlineView->removeRow(ui->deviceOnlineView->rowCount()-1);
|
||||||
|
if(isAutoBaud)
|
||||||
|
{
|
||||||
|
auto bar = new QProgressDialog(this);
|
||||||
|
bar->setLabelText(tr("Поиск устройств... Текущая скорость: %1").arg(currentBaudRate));
|
||||||
|
bar->setRange(0, ui->baudRateBox->count());
|
||||||
|
bar->setAutoClose(true);
|
||||||
|
bar->setMinimumDuration(0);
|
||||||
|
bar->setCancelButton(nullptr);
|
||||||
|
connect(bar, &QProgressDialog::canceled, this, [this]()
|
||||||
|
{
|
||||||
|
emit stopLineCall();
|
||||||
|
});
|
||||||
|
bar->setValue(0);
|
||||||
|
|
||||||
|
ui->deviceOnlineView->setColumnHidden(1, false);
|
||||||
|
modbusDevice->disconnectDevice();
|
||||||
|
for (int i = 0; i < ui->baudRateBox->count(); i++) {
|
||||||
|
|
||||||
|
bar->setValue(i+1);
|
||||||
|
|
||||||
|
modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter,
|
||||||
|
ui->baudRateBox->itemText(i).toInt(nullptr, 10));
|
||||||
|
if (!modbusDevice->connectDevice()) {
|
||||||
|
QMessageBox::warning(this, "Ошибка", "Произошла ошибка при попытке подключения.");
|
||||||
|
on_connectButton_clicked();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
currentBaudRate = ui->baudRateBox->itemText(i).toUInt(nullptr, 10);
|
||||||
|
if(lineCall() == callStatus::INTERRUPT)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "Уведомление", QString("Досрочное завершение опроса. Найдено %1 устройств.").arg(devicesList.count()));
|
||||||
|
modbusDevice->disconnectDevice();
|
||||||
|
on_connectButton_clicked();
|
||||||
|
bar->close();
|
||||||
|
bar->deleteLater();
|
||||||
|
ui->timer->setTime(QTime::currentTime());
|
||||||
|
ui->timer->setDate(QDate::currentDate());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modbusDevice->disconnectDevice();
|
||||||
|
}
|
||||||
|
on_connectButton_clicked();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->deviceOnlineView->setColumnHidden(1, true);
|
||||||
|
if(lineCall() == callStatus::INTERRUPT)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "Уведомление", QString("Досрочное завершение опроса. Найдено %1 устройств.").arg(devicesList.count()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->timer->setTime(QTime::currentTime());
|
||||||
|
ui->timer->setDate(QDate::currentDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineRinger::on_checkAutoBaud_stateChanged(int arg1)
|
||||||
|
{
|
||||||
|
isAutoBaud = (bool)arg1;
|
||||||
|
}
|
59
M3KTE_TERM/lineringer.h
Normal file
59
M3KTE_TERM/lineringer.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#ifndef LINERINGER_H
|
||||||
|
#define LINERINGER_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QModbusTcpClient>
|
||||||
|
#include <QModbusRtuSerialMaster>
|
||||||
|
#include <QSerialPortInfo>
|
||||||
|
#include <QSerialPort>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class LineRinger;
|
||||||
|
}
|
||||||
|
|
||||||
|
class LineRinger : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum callStatus{
|
||||||
|
NOERROR = 0,
|
||||||
|
ERROR = 1,
|
||||||
|
INTERRUPT = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit LineRinger(QWidget *parent = nullptr);
|
||||||
|
~LineRinger();
|
||||||
|
callStatus lineCall();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void stopLineCall();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_connectButton_clicked();
|
||||||
|
|
||||||
|
void on_ringButton_clicked();
|
||||||
|
|
||||||
|
void on_checkAutoBaud_stateChanged(int arg1);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::LineRinger *ui;
|
||||||
|
|
||||||
|
void syncColumnHeaders();
|
||||||
|
|
||||||
|
struct deviceOnLine
|
||||||
|
{
|
||||||
|
uint8_t adr;
|
||||||
|
unsigned baudRate;
|
||||||
|
QString fields[7] = {"Undefined", "Undefined", "Undefined", "Undefined", "Undefined", "Undefined", "Undefined"};
|
||||||
|
};
|
||||||
|
QVector<deviceOnLine>devicesList;
|
||||||
|
bool isAutoBaud = false;
|
||||||
|
unsigned currentBaudRate;
|
||||||
|
|
||||||
|
QModbusClient *modbusDevice = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LINERINGER_H
|
303
M3KTE_TERM/lineringer.ui
Normal file
303
M3KTE_TERM/lineringer.ui
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>LineRinger</class>
|
||||||
|
<widget class="QWidget" name="LineRinger">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>939</width>
|
||||||
|
<height>522</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QGroupBox" name="gridGroupBox_2">
|
||||||
|
<layout class="QGridLayout" name="cmdLayout">
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLabel" name="labelTimer">
|
||||||
|
<property name="text">
|
||||||
|
<string>Последний опрос:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPushButton" name="ringButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Опросить</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="checkAutoBaud">
|
||||||
|
<property name="layoutDirection">
|
||||||
|
<enum>Qt::LeftToRight</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Любая скорость</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2">
|
||||||
|
<widget class="QDateTimeEdit" name="timer">
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="buttonSymbols">
|
||||||
|
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||||
|
</property>
|
||||||
|
<property name="keyboardTracking">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="currentSection">
|
||||||
|
<enum>QDateTimeEdit::DaySection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="displayFormat">
|
||||||
|
<string>dd.MM.yyyy HH:mm:ss</string>
|
||||||
|
</property>
|
||||||
|
<property name="calendarPopup">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="currentSectionIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="controlGroup">
|
||||||
|
<layout class="QGridLayout" name="controlLaylout">
|
||||||
|
<item row="0" column="5">
|
||||||
|
<widget class="QLabel" name="labelStopBit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Стоп-биты</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="8">
|
||||||
|
<widget class="QPushButton" name="connectButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Подключить</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="6">
|
||||||
|
<widget class="QLabel" name="labelEvenControl">
|
||||||
|
<property name="text">
|
||||||
|
<string>Чётность</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="5">
|
||||||
|
<widget class="QComboBox" name="stopBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QComboBox" name="comBox">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>21</width>
|
||||||
|
<height>21</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Поиск</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="6">
|
||||||
|
<widget class="QComboBox" name="parityControlBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QComboBox" name="baudRateBox">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>9600</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>14400</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>19200</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>31250</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>38400</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>56000</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>57600</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>115200</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="4">
|
||||||
|
<widget class="QComboBox" name="dataBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QLabel" name="labelBaud">
|
||||||
|
<property name="text">
|
||||||
|
<string>Скорость</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="labelCom">
|
||||||
|
<property name="text">
|
||||||
|
<string>Порт</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QLabel" name="labelDataBit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Биты данных</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="3">
|
||||||
|
<widget class="QTableWidget" name="deviceOnlineView">
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
|
<property name="textElideMode">
|
||||||
|
<enum>Qt::ElideMiddle</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<attribute name="horizontalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderCascadingSectionResizes">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderShowSortIndicator" stdset="0">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderStretchLastSection">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>ID</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>BaudRate</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Vendor Name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Product Code</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Major Minor Revision</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Vendor Url</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Product Name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Model Name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>User Application Name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Примечание</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
1563
M3KTE_TERM/m3kte.cpp
1563
M3KTE_TERM/m3kte.cpp
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,8 @@
|
|||||||
#include "writeregistermodel.h"
|
#include "writeregistermodel.h"
|
||||||
#include "devicesettingsdialog.h"
|
#include "devicesettingsdialog.h"
|
||||||
#include "multiplesettings.h"
|
#include "multiplesettings.h"
|
||||||
|
#include "scanboard.h"
|
||||||
|
#include "lineringer.h"
|
||||||
|
|
||||||
#include <QModbusTcpClient>
|
#include <QModbusTcpClient>
|
||||||
#include <QModbusRtuSerialMaster>
|
#include <QModbusRtuSerialMaster>
|
||||||
@ -18,6 +20,10 @@
|
|||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
#include <QtSerialBus/qtserialbusglobal.h>
|
#include <QtSerialBus/qtserialbusglobal.h>
|
||||||
|
|
||||||
@ -25,6 +31,10 @@
|
|||||||
#include <QSerialPort>
|
#include <QSerialPort>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MODBUS_REQUEST_PROTOCOL_INFO_LENGTH 8
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) QWidget* init(QWidget *parent);
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class M3KTE; class SettingsDialog;}
|
namespace Ui { class M3KTE; class SettingsDialog;}
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@ -40,17 +50,18 @@ private:
|
|||||||
QModbusDataUnit readRequest() const;
|
QModbusDataUnit readRequest() const;
|
||||||
QModbusDataUnit writeRequest() const;
|
QModbusDataUnit writeRequest() const;
|
||||||
void changeTable(int board, int tabletype);
|
void changeTable(int board, int tabletype);
|
||||||
void debug();
|
|
||||||
void errorAdrChange();
|
|
||||||
bool event(QEvent* event);
|
bool event(QEvent* event);
|
||||||
bool pingNetworkDevices();
|
bool pingNetworkDevices();
|
||||||
void beginScanBoards();
|
void beginScanBoards();
|
||||||
|
void stopScanBoard();
|
||||||
void displayResultOfScan(QModbusReply *reply, int boardID);
|
void displayResultOfScan(QModbusReply *reply, int boardID);
|
||||||
void stepForScanCurrentSettings(QModbusReply *reply);
|
void applySettingsFromScan(QModbusReply *reply);
|
||||||
|
|
||||||
void multipleRegWrite();
|
void multipleRegWrite();
|
||||||
void multipleRegSend();
|
void multipleRegSend();
|
||||||
|
|
||||||
|
bool autoBaudRateScan();
|
||||||
|
|
||||||
void selectPositionOnTree(unsigned index);
|
void selectPositionOnTree(unsigned index);
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
@ -62,9 +73,7 @@ private slots:
|
|||||||
void onReadButtonClicked();
|
void onReadButtonClicked();
|
||||||
void onReadReady();
|
void onReadReady();
|
||||||
|
|
||||||
void timeForPingIsGone();
|
void checkAdrChange(QModbusReply *reply, unsigned boardNum);
|
||||||
|
|
||||||
void checkAdrChange();
|
|
||||||
|
|
||||||
void onWriteButtonClicked();
|
void onWriteButtonClicked();
|
||||||
void onSelectedBoardChanged(int index);
|
void onSelectedBoardChanged(int index);
|
||||||
@ -73,22 +82,15 @@ private slots:
|
|||||||
void onSpeedUpdate();
|
void onSpeedUpdate();
|
||||||
void onParityUpdate();
|
void onParityUpdate();
|
||||||
|
|
||||||
void firstBoardScan();
|
void boardScan(unsigned boardID);
|
||||||
void secondBoardScan();
|
|
||||||
void thirdBoardScan();
|
|
||||||
void fourthBoardScan();
|
|
||||||
|
|
||||||
void firstBoardReady();
|
|
||||||
void secondBoardReady();
|
|
||||||
void thirdBoardReady();
|
|
||||||
void fourthBoardReady();
|
|
||||||
public:
|
public:
|
||||||
M3KTE(QWidget *parent = nullptr);
|
M3KTE(QWidget *parent = nullptr);
|
||||||
~M3KTE();
|
~M3KTE();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::M3KTE *ui;
|
Ui::M3KTE *ui;
|
||||||
bool timerForPingSignal = false;
|
QTableWidget *loggerTable = nullptr;
|
||||||
int CurrentConnectedDevice = 0;
|
int CurrentConnectedDevice = 0;
|
||||||
//int DeviceOnNetwork[4];
|
//int DeviceOnNetwork[4];
|
||||||
QProgressBar *m_ProgressBar[320];
|
QProgressBar *m_ProgressBar[320];
|
||||||
@ -98,6 +100,10 @@ private:
|
|||||||
DeviceSettingsDialog *m_deviceSettingsDialog = nullptr;
|
DeviceSettingsDialog *m_deviceSettingsDialog = nullptr;
|
||||||
SettingsDialog *m_settingsDialog = nullptr;
|
SettingsDialog *m_settingsDialog = nullptr;
|
||||||
MultipleSettings *m_regMultipleSettings = nullptr;
|
MultipleSettings *m_regMultipleSettings = nullptr;
|
||||||
|
ScanBoard *m_scanBoard = nullptr;
|
||||||
|
|
||||||
|
LineRinger *m_lineRinger = nullptr;
|
||||||
|
QGroupBox *Boards_Fields[4];
|
||||||
//WriteRegisterModel *writeModel = nullptr;
|
//WriteRegisterModel *writeModel = nullptr;
|
||||||
|
|
||||||
struct StatusM3KTE{
|
struct StatusM3KTE{
|
||||||
@ -105,17 +111,52 @@ private:
|
|||||||
bool Accidents[4];
|
bool Accidents[4];
|
||||||
}statusM3KTE;
|
}statusM3KTE;
|
||||||
|
|
||||||
|
unsigned error_terminal;
|
||||||
|
|
||||||
struct BoardModbusRegisters
|
struct BoardModbusRegisters
|
||||||
{
|
{
|
||||||
|
bool isActive = false;
|
||||||
|
bool pollIsActive = true;
|
||||||
|
|
||||||
int adr;
|
int adr;
|
||||||
int _tmp_adr;
|
int _tmp_adr;
|
||||||
|
|
||||||
bool coil[85];
|
bool coil[85];
|
||||||
unsigned HR[170];
|
unsigned HR[170];
|
||||||
|
|
||||||
|
unsigned error_W = 0;
|
||||||
|
unsigned error_A = 0;
|
||||||
|
unsigned error_modbus = 0;
|
||||||
|
unsigned error_baud_change = 0;
|
||||||
|
unsigned error_parity_change = 0;
|
||||||
|
unsigned error_RX = 0;
|
||||||
|
unsigned error_TX = 0;
|
||||||
|
unsigned error_adr_change = 0;
|
||||||
|
unsigned error_cmd_change = 0;
|
||||||
|
|
||||||
|
QLabel *timerData = nullptr;
|
||||||
|
QLabel *timerStatus = nullptr;
|
||||||
|
|
||||||
WriteRegisterModel *ModbusModelCoil;
|
WriteRegisterModel *ModbusModelCoil;
|
||||||
WriteRegisterModel *ModbusModelHoldingReg;
|
WriteRegisterModel *ModbusModelHoldingReg;
|
||||||
QTimer *boardScanners;
|
QTimer *boardScanners;
|
||||||
|
|
||||||
|
QElapsedTimer timerToStatusResponse;
|
||||||
|
QElapsedTimer timerToDataResponse;
|
||||||
}Boards[4];
|
}Boards[4];
|
||||||
|
|
||||||
|
union statusreg
|
||||||
|
{
|
||||||
|
struct parsingFields
|
||||||
|
{
|
||||||
|
unsigned accident:1;
|
||||||
|
unsigned warning:1;
|
||||||
|
unsigned poll_allowed:1;
|
||||||
|
unsigned mzkte_status:2;
|
||||||
|
unsigned reserv:3;
|
||||||
|
unsigned mzkte_error:8;
|
||||||
|
}ParsingReg;
|
||||||
|
unsigned AllReg:16;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
#endif // M3KTE_H
|
#endif // M3KTE_H
|
||||||
|
21688
M3KTE_TERM/m3kte.ui
21688
M3KTE_TERM/m3kte.ui
File diff suppressed because it is too large
Load Diff
39
M3KTE_TERM/scanboard.cpp
Normal file
39
M3KTE_TERM/scanboard.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include "scanboard.h"
|
||||||
|
#include "ui_scanboard.h"
|
||||||
|
|
||||||
|
ScanBoard::ScanBoard(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::ScanBoard)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScanBoard::~ScanBoard()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::CheckState ScanBoard::getCheckState()
|
||||||
|
{
|
||||||
|
return checkState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScanBoard::on_applyToAllBox_stateChanged(int arg1)
|
||||||
|
{
|
||||||
|
checkState = (Qt::CheckState)arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScanBoard::showMeTheTruth(QString resultOfScan)
|
||||||
|
{
|
||||||
|
ui->logger->append(resultOfScan);
|
||||||
|
}
|
||||||
|
|
||||||
|
quint16 ScanBoard::getBaud()
|
||||||
|
{
|
||||||
|
return baud;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScanBoard::on_baudRateBox_currentTextChanged(const QString &arg1)
|
||||||
|
{
|
||||||
|
baud = arg1.toInt(nullptr, 10);
|
||||||
|
}
|
33
M3KTE_TERM/scanboard.h
Normal file
33
M3KTE_TERM/scanboard.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef SCANBOARD_H
|
||||||
|
#define SCANBOARD_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class ScanBoard;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ScanBoard : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ScanBoard(QWidget *parent = nullptr);
|
||||||
|
~ScanBoard();
|
||||||
|
|
||||||
|
Qt::CheckState getCheckState();
|
||||||
|
void showMeTheTruth(QString resultOfScan);
|
||||||
|
quint16 getBaud();
|
||||||
|
private slots:
|
||||||
|
void on_applyToAllBox_stateChanged(int arg1);
|
||||||
|
|
||||||
|
void on_baudRateBox_currentTextChanged(const QString &arg1);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Qt::CheckState checkState;
|
||||||
|
quint16 baud;
|
||||||
|
|
||||||
|
Ui::ScanBoard *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCANBOARD_H
|
81
M3KTE_TERM/scanboard.ui
Normal file
81
M3KTE_TERM/scanboard.ui
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ScanBoard</class>
|
||||||
|
<widget class="QDialog" name="ScanBoard">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>337</width>
|
||||||
|
<height>145</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTextEdit" name="logger"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QComboBox" name="baudRateBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QCheckBox" name="applyToAllBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Применить ко всем обнаруженным платам</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>ScanBoard</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>ScanBoard</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -12,13 +12,15 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
|||||||
ui->baudCombo->setCurrentText(QString::number(m_settings.baud));
|
ui->baudCombo->setCurrentText(QString::number(m_settings.baud));
|
||||||
ui->dataBitsCombo->setCurrentText(QString::number(m_settings.dataBits));
|
ui->dataBitsCombo->setCurrentText(QString::number(m_settings.dataBits));
|
||||||
ui->stopBitsCombo->setCurrentText(QString::number(m_settings.stopBits));
|
ui->stopBitsCombo->setCurrentText(QString::number(m_settings.stopBits));
|
||||||
|
on_updateComBox_clicked();
|
||||||
#endif
|
#endif
|
||||||
ui->timeoutSpinner->setValue(m_settings.responseTime);
|
ui->timeoutSpinner->setValue(m_settings.responseTime);
|
||||||
ui->retriesSpinner->setValue(m_settings.numberOfRetries);
|
ui->retriesSpinner->setValue(m_settings.numberOfRetries);
|
||||||
|
|
||||||
|
|
||||||
connect(ui->AcceptOrRejectButtonBox, &QDialogButtonBox::accepted, [this]() {
|
connect(ui->AcceptOrRejectButtonBox, &QDialogButtonBox::accepted, [this]() {
|
||||||
#if QT_CONFIG(modbus_serialport)
|
#if QT_CONFIG(modbus_serialport)
|
||||||
m_settings.portName = ui->portEdit->text();
|
m_settings.portName = ui->comBox->currentData().toString();
|
||||||
m_settings.parity = ui->parityCombo->currentIndex();
|
m_settings.parity = ui->parityCombo->currentIndex();
|
||||||
if (m_settings.parity > 0)
|
if (m_settings.parity > 0)
|
||||||
m_settings.parity++;
|
m_settings.parity++;
|
||||||
@ -70,3 +72,13 @@ int SettingsDialog::curParity()
|
|||||||
{
|
{
|
||||||
return ui->parityCombo->currentIndex();
|
return ui->parityCombo->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::on_updateComBox_clicked()
|
||||||
|
{
|
||||||
|
ui->comBox->clear();
|
||||||
|
const auto listPorts = QSerialPortInfo::availablePorts();
|
||||||
|
for (const auto& port: listPorts)
|
||||||
|
{
|
||||||
|
ui->comBox->addItem(QString(port.portName() + ": " + port.manufacturer()), QVariant(port.portName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QtSerialBus/qtserialbusglobal.h>
|
#include <QtSerialBus/qtserialbusglobal.h>
|
||||||
#if QT_CONFIG(modbus_serialport)
|
#if QT_CONFIG(modbus_serialport)
|
||||||
#include <QSerialPort>
|
#include <QSerialPort>
|
||||||
|
#include <QSerialPortInfo>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@ -23,7 +24,7 @@ public:
|
|||||||
int baud = 115200;
|
int baud = 115200;
|
||||||
int dataBits = QSerialPort::Data8;
|
int dataBits = QSerialPort::Data8;
|
||||||
int stopBits = QSerialPort::OneStop;
|
int stopBits = QSerialPort::OneStop;
|
||||||
int responseTime = 500;
|
int responseTime = 50;
|
||||||
int numberOfRetries = 0;
|
int numberOfRetries = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -37,6 +38,9 @@ public:
|
|||||||
|
|
||||||
int curBaud();
|
int curBaud();
|
||||||
int curParity();
|
int curParity();
|
||||||
|
private slots:
|
||||||
|
void on_updateComBox_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
Settings m_settings;
|
||||||
Ui::SettingsDialog *ui;
|
Ui::SettingsDialog *ui;
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
<string> мс</string>
|
<string> мс</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>-1</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>5000</number>
|
<number>5000</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="singleStep">
|
<property name="singleStep">
|
||||||
<number>20</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>200</number>
|
<number>200</number>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<item row="2" column="1" rowspan="2" colspan="2">
|
<item row="2" column="1" rowspan="2" colspan="2">
|
||||||
<widget class="QSpinBox" name="retriesSpinner">
|
<widget class="QSpinBox" name="retriesSpinner">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@ -69,16 +69,6 @@
|
|||||||
<string>Serial Parameters</string>
|
<string>Serial Parameters</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="portLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Порт</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="portEdit"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="parityLabel">
|
<widget class="QLabel" name="parityLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -86,32 +76,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QComboBox" name="parityCombo">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>No</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Even</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Odd</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="baudLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Скорость</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="baudCombo">
|
<widget class="QComboBox" name="baudCombo">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
@ -166,6 +130,51 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QComboBox" name="stopBitsCombo">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>1</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>3</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>2</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="baudLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Скорость</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="parityCombo">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>No</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Even</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Odd</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QComboBox" name="dataBitsCombo">
|
<widget class="QComboBox" name="dataBitsCombo">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
@ -193,6 +202,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="portLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Порт</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="stopBitsLabel">
|
<widget class="QLabel" name="stopBitsLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -200,24 +216,38 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QComboBox" name="stopBitsCombo">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<property name="text">
|
<widget class="QComboBox" name="comBox">
|
||||||
<string>1</string>
|
<property name="minimumSize">
|
||||||
</property>
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="2">
|
||||||
<property name="text">
|
<widget class="QPushButton" name="updateComBox">
|
||||||
<string>3</string>
|
<property name="sizePolicy">
|
||||||
</property>
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>45</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Поиск</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<property name="text">
|
|
||||||
<string>2</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -25,10 +25,8 @@ QVariant WriteRegisterModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid() || index.row() >= RowCount || index.column() >= ColumnCount)
|
if (!index.isValid() || index.row() >= RowCount || index.column() >= ColumnCount)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
Q_ASSERT(m_coils.count() == RowCount);
|
Q_ASSERT(m_coils.count() == RowCount);
|
||||||
Q_ASSERT(m_holdingRegisters.count() == RowCount);
|
Q_ASSERT(m_holdingRegisters.count() == RowCount);
|
||||||
|
|
||||||
if (index.column() == NumColumn && role == Qt::DisplayRole)
|
if (index.column() == NumColumn && role == Qt::DisplayRole)
|
||||||
return QString::number(index.row());
|
return QString::number(index.row());
|
||||||
|
|
||||||
@ -42,17 +40,14 @@ QVariant WriteRegisterModel::data(const QModelIndex &index, int role) const
|
|||||||
return QString("0x%1").arg(QString::number(m_holdingRegisters.at(index.row()), 16));
|
return QString("0x%1").arg(QString::number(m_holdingRegisters.at(index.row()), 16));
|
||||||
|
|
||||||
if(index.column() == CurrentUColumn && role == Qt::DisplayRole)
|
if(index.column() == CurrentUColumn && role == Qt::DisplayRole)
|
||||||
return QString("%1 В").arg(QString::number((double)((double)m_currentU.at(index.row())/(double)1000)));
|
return QString("%1 В").arg(QString::number((double)((double)m_currentU.at(index.row())/(double)1000), 'f', 3));
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant WriteRegisterModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant WriteRegisterModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (role != Qt::DisplayRole)
|
if (role != Qt::DisplayRole)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (orientation == Qt::Horizontal) {
|
if (orientation == Qt::Horizontal) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case NumColumn:
|
case NumColumn:
|
||||||
@ -76,7 +71,6 @@ bool WriteRegisterModel::setData(const QModelIndex &index, const QVariant &value
|
|||||||
{
|
{
|
||||||
if (!index.isValid() || index.row() >= RowCount || index.column() >= ColumnCount)
|
if (!index.isValid() || index.row() >= RowCount || index.column() >= ColumnCount)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Q_ASSERT(m_coils.count() == RowCount);
|
Q_ASSERT(m_coils.count() == RowCount);
|
||||||
Q_ASSERT(m_holdingRegisters.count() == RowCount);
|
Q_ASSERT(m_holdingRegisters.count() == RowCount);
|
||||||
|
|
||||||
@ -86,7 +80,6 @@ bool WriteRegisterModel::setData(const QModelIndex &index, const QVariant &value
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index.column() == HoldingColumn && role == Qt::EditRole) { // holding registers
|
if (index.column() == HoldingColumn && role == Qt::EditRole) { // holding registers
|
||||||
bool result = false;
|
bool result = false;
|
||||||
quint16 newValue = value.toString().toUShort(&result, 16);
|
quint16 newValue = value.toString().toUShort(&result, 16);
|
||||||
@ -96,7 +89,6 @@ bool WriteRegisterModel::setData(const QModelIndex &index, const QVariant &value
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user