Compare commits
No commits in common. "main" and "Pre-release" have entirely different histories.
main
...
Pre-releas
@ -1,21 +0,0 @@
|
||||
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
|
Binary file not shown.
@ -16,9 +16,6 @@ CONFIG += c++11
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
TEMPLATE = lib
|
||||
DEFINES += M3KTE_LIBRARY
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
# 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.
|
||||
@ -26,37 +23,26 @@ DEFINES += M3KTE_LIBRARY
|
||||
|
||||
SOURCES += \
|
||||
devicesettingsdialog.cpp \
|
||||
lineringer.cpp \
|
||||
main.cpp \
|
||||
m3kte.cpp \
|
||||
multiplesettings.cpp \
|
||||
scanboard.cpp \
|
||||
settingsdialog.cpp \
|
||||
writeregistermodel.cpp
|
||||
|
||||
HEADERS += \
|
||||
devicesettingsdialog.h \
|
||||
lineringer.h \
|
||||
m3kte.h \
|
||||
multiplesettings.h \
|
||||
scanboard.h \
|
||||
settingsdialog.h \
|
||||
writeregistermodel.h
|
||||
|
||||
FORMS += \
|
||||
devicesettingsdialog.ui \
|
||||
lineringer.ui \
|
||||
m3kte.ui \
|
||||
multiplesettings.ui \
|
||||
scanboard.ui \
|
||||
settingsdialog.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
#qnx: target.path = /tmp/$${TARGET}/bin
|
||||
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
#!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
}
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
@ -55,7 +55,7 @@ void DeviceSettingsDialog::on_buttonApplyChangeParity_clicked()
|
||||
|
||||
void DeviceSettingsDialog::on_buttonApplyChangeAdr_clicked()
|
||||
{
|
||||
BoardIdHasBeenChanged* _boardIdHasBeenChanged = new BoardIdHasBeenChanged(ui->idComboBox->currentText().toUInt(), ui->adrSpinBox->value());
|
||||
BoardIdHasBeenChanged* _boardIdHasBeenChanged = new BoardIdHasBeenChanged(ui->idComboBox->currentIndex(), ui->adrSpinBox->value());
|
||||
QCoreApplication::postEvent(parent(), _boardIdHasBeenChanged);
|
||||
close();
|
||||
}
|
||||
@ -75,24 +75,21 @@ unsigned short DeviceSettingsDialog::currentParity()
|
||||
return _currentParity;
|
||||
}
|
||||
|
||||
void DeviceSettingsDialog::updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr, bool *ActiveDevices)
|
||||
void DeviceSettingsDialog::updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr, int CurrentConnectedDevice)
|
||||
{
|
||||
ui->speedBox->setCurrentText(QString::number(_currentSpeed=tmp_speed, 10));
|
||||
if(tmp_parity>0)
|
||||
tmp_parity--;
|
||||
ui->parityBox->setCurrentIndex(_currentParity = tmp_parity);
|
||||
for(int i = 0; i < 4; i++)
|
||||
for(int i = 0; i < CurrentConnectedDevice; i++)
|
||||
{
|
||||
if(ActiveDevices[i])
|
||||
{
|
||||
_m_timer[i]->setEnabled(true);
|
||||
ui->idComboBox->addItem(QString::number(i));
|
||||
_currentAdrs[i] = tmp_adr[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
_m_timer[i]->setEnabled(false);
|
||||
}
|
||||
_m_timer[i]->setEnabled(true);
|
||||
ui->idComboBox->addItem(QString::number(i));
|
||||
_currentAdrs[i] = tmp_adr[i];
|
||||
}
|
||||
for(int i = CurrentConnectedDevice; i < 4; i++)
|
||||
{
|
||||
_m_timer[i]->setEnabled(false);
|
||||
}
|
||||
on_idComboBox_currentIndexChanged(ui->idComboBox->currentIndex());
|
||||
}
|
||||
@ -132,25 +129,3 @@ void DeviceSettingsDialog::on_buttonBox_clicked(QAbstractButton *button)
|
||||
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,20 +21,6 @@ private:
|
||||
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 {
|
||||
class DeviceSettingsDialog;
|
||||
}
|
||||
@ -50,9 +36,7 @@ public:
|
||||
unsigned currentBoardTimer(unsigned short _ID);
|
||||
unsigned currentSpeed();
|
||||
unsigned short currentParity();
|
||||
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);
|
||||
void updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr, int CurrentConnectedDevice);
|
||||
signals:
|
||||
void parityChanged();
|
||||
void speedChanged();
|
||||
@ -75,17 +59,12 @@ private slots:
|
||||
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
|
||||
void on_buttonApplyChangePoll_clicked();
|
||||
|
||||
void on_idPollComboBox_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
QSpinBox *_m_timer[4];
|
||||
unsigned _currentBoardTimers[4];
|
||||
unsigned _currentSpeed;
|
||||
unsigned short _currentParity;
|
||||
unsigned _currentAdrs[4];
|
||||
bool _currentPollStatus[4];
|
||||
|
||||
Ui::DeviceSettingsDialog *ui;
|
||||
};
|
||||
|
@ -6,14 +6,77 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>278</width>
|
||||
<height>500</height>
|
||||
<width>243</width>
|
||||
<height>431</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<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">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
@ -125,41 +188,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
@ -193,70 +221,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<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">
|
||||
<item row="4" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -266,36 +231,38 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Опрос ТЭ</string>
|
||||
<string>Контроль четности</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="idPollComboBox"/>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="1">
|
||||
<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">
|
||||
<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>
|
||||
|
@ -1,315 +0,0 @@
|
||||
#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;
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
#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
|
@ -1,303 +0,0 @@
|
||||
<?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>
|
1555
M3KTE_TERM/m3kte.cpp
1555
M3KTE_TERM/m3kte.cpp
File diff suppressed because it is too large
Load Diff
@ -9,8 +9,6 @@
|
||||
#include "writeregistermodel.h"
|
||||
#include "devicesettingsdialog.h"
|
||||
#include "multiplesettings.h"
|
||||
#include "scanboard.h"
|
||||
#include "lineringer.h"
|
||||
|
||||
#include <QModbusTcpClient>
|
||||
#include <QModbusRtuSerialMaster>
|
||||
@ -20,10 +18,6 @@
|
||||
#include <QProgressDialog>
|
||||
#include <QErrorMessage>
|
||||
#include <QPushButton>
|
||||
#include <QGroupBox>
|
||||
#include <QTableWidget>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include <QtSerialBus/qtserialbusglobal.h>
|
||||
|
||||
@ -31,10 +25,6 @@
|
||||
#include <QSerialPort>
|
||||
#endif
|
||||
|
||||
#define MODBUS_REQUEST_PROTOCOL_INFO_LENGTH 8
|
||||
|
||||
extern "C" __declspec(dllexport) QWidget* init(QWidget *parent);
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class M3KTE; class SettingsDialog;}
|
||||
QT_END_NAMESPACE
|
||||
@ -50,18 +40,17 @@ private:
|
||||
QModbusDataUnit readRequest() const;
|
||||
QModbusDataUnit writeRequest() const;
|
||||
void changeTable(int board, int tabletype);
|
||||
void debug();
|
||||
void errorAdrChange();
|
||||
bool event(QEvent* event);
|
||||
bool pingNetworkDevices();
|
||||
void beginScanBoards();
|
||||
void stopScanBoard();
|
||||
void displayResultOfScan(QModbusReply *reply, int boardID);
|
||||
void applySettingsFromScan(QModbusReply *reply);
|
||||
void stepForScanCurrentSettings(QModbusReply *reply);
|
||||
|
||||
void multipleRegWrite();
|
||||
void multipleRegSend();
|
||||
|
||||
bool autoBaudRateScan();
|
||||
|
||||
void selectPositionOnTree(unsigned index);
|
||||
private slots:
|
||||
|
||||
@ -73,7 +62,9 @@ private slots:
|
||||
void onReadButtonClicked();
|
||||
void onReadReady();
|
||||
|
||||
void checkAdrChange(QModbusReply *reply, unsigned boardNum);
|
||||
void timeForPingIsGone();
|
||||
|
||||
void checkAdrChange();
|
||||
|
||||
void onWriteButtonClicked();
|
||||
void onSelectedBoardChanged(int index);
|
||||
@ -82,15 +73,22 @@ private slots:
|
||||
void onSpeedUpdate();
|
||||
void onParityUpdate();
|
||||
|
||||
void boardScan(unsigned boardID);
|
||||
void firstBoardScan();
|
||||
void secondBoardScan();
|
||||
void thirdBoardScan();
|
||||
void fourthBoardScan();
|
||||
|
||||
void firstBoardReady();
|
||||
void secondBoardReady();
|
||||
void thirdBoardReady();
|
||||
void fourthBoardReady();
|
||||
public:
|
||||
M3KTE(QWidget *parent = nullptr);
|
||||
~M3KTE();
|
||||
|
||||
private:
|
||||
Ui::M3KTE *ui;
|
||||
QTableWidget *loggerTable = nullptr;
|
||||
bool timerForPingSignal = false;
|
||||
int CurrentConnectedDevice = 0;
|
||||
//int DeviceOnNetwork[4];
|
||||
QProgressBar *m_ProgressBar[320];
|
||||
@ -100,10 +98,6 @@ private:
|
||||
DeviceSettingsDialog *m_deviceSettingsDialog = nullptr;
|
||||
SettingsDialog *m_settingsDialog = nullptr;
|
||||
MultipleSettings *m_regMultipleSettings = nullptr;
|
||||
ScanBoard *m_scanBoard = nullptr;
|
||||
|
||||
LineRinger *m_lineRinger = nullptr;
|
||||
QGroupBox *Boards_Fields[4];
|
||||
//WriteRegisterModel *writeModel = nullptr;
|
||||
|
||||
struct StatusM3KTE{
|
||||
@ -111,52 +105,17 @@ private:
|
||||
bool Accidents[4];
|
||||
}statusM3KTE;
|
||||
|
||||
unsigned error_terminal;
|
||||
|
||||
struct BoardModbusRegisters
|
||||
{
|
||||
bool isActive = false;
|
||||
bool pollIsActive = true;
|
||||
|
||||
int adr;
|
||||
int _tmp_adr;
|
||||
|
||||
bool coil[85];
|
||||
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 *ModbusModelHoldingReg;
|
||||
QTimer *boardScanners;
|
||||
|
||||
QElapsedTimer timerToStatusResponse;
|
||||
QElapsedTimer timerToDataResponse;
|
||||
}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
|
||||
|
21168
M3KTE_TERM/m3kte.ui
21168
M3KTE_TERM/m3kte.ui
File diff suppressed because it is too large
Load Diff
@ -1,39 +0,0 @@
|
||||
#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);
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
#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
|
@ -1,81 +0,0 @@
|
||||
<?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,15 +12,13 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
||||
ui->baudCombo->setCurrentText(QString::number(m_settings.baud));
|
||||
ui->dataBitsCombo->setCurrentText(QString::number(m_settings.dataBits));
|
||||
ui->stopBitsCombo->setCurrentText(QString::number(m_settings.stopBits));
|
||||
on_updateComBox_clicked();
|
||||
#endif
|
||||
ui->timeoutSpinner->setValue(m_settings.responseTime);
|
||||
ui->retriesSpinner->setValue(m_settings.numberOfRetries);
|
||||
|
||||
|
||||
connect(ui->AcceptOrRejectButtonBox, &QDialogButtonBox::accepted, [this]() {
|
||||
#if QT_CONFIG(modbus_serialport)
|
||||
m_settings.portName = ui->comBox->currentData().toString();
|
||||
m_settings.portName = ui->portEdit->text();
|
||||
m_settings.parity = ui->parityCombo->currentIndex();
|
||||
if (m_settings.parity > 0)
|
||||
m_settings.parity++;
|
||||
@ -72,13 +70,3 @@ int SettingsDialog::curParity()
|
||||
{
|
||||
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,7 +6,6 @@
|
||||
#include <QtSerialBus/qtserialbusglobal.h>
|
||||
#if QT_CONFIG(modbus_serialport)
|
||||
#include <QSerialPort>
|
||||
#include <QSerialPortInfo>
|
||||
#endif
|
||||
|
||||
namespace Ui {
|
||||
@ -24,7 +23,7 @@ public:
|
||||
int baud = 115200;
|
||||
int dataBits = QSerialPort::Data8;
|
||||
int stopBits = QSerialPort::OneStop;
|
||||
int responseTime = 50;
|
||||
int responseTime = 500;
|
||||
int numberOfRetries = 0;
|
||||
};
|
||||
|
||||
@ -38,9 +37,6 @@ public:
|
||||
|
||||
int curBaud();
|
||||
int curParity();
|
||||
private slots:
|
||||
void on_updateComBox_clicked();
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
Ui::SettingsDialog *ui;
|
||||
|
@ -20,13 +20,13 @@
|
||||
<string> мс</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>200</number>
|
||||
@ -36,7 +36,7 @@
|
||||
<item row="2" column="1" rowspan="2" colspan="2">
|
||||
<widget class="QSpinBox" name="retriesSpinner">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
@ -69,6 +69,16 @@
|
||||
<string>Serial Parameters</string>
|
||||
</property>
|
||||
<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">
|
||||
<widget class="QLabel" name="parityLabel">
|
||||
<property name="text">
|
||||
@ -76,6 +86,32 @@
|
||||
</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="2" column="0">
|
||||
<widget class="QLabel" name="baudLabel">
|
||||
<property name="text">
|
||||
<string>Скорость</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="baudCombo">
|
||||
<property name="currentIndex">
|
||||
@ -130,51 +166,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QComboBox" name="dataBitsCombo">
|
||||
<property name="currentIndex">
|
||||
@ -202,13 +193,6 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="portLabel">
|
||||
<property name="text">
|
||||
<string>Порт</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="stopBitsLabel">
|
||||
<property name="text">
|
||||
@ -216,38 +200,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="stopBitsCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="updateComBox">
|
||||
<property name="sizePolicy">
|
||||
<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>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
</layout>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -25,8 +25,10 @@ QVariant WriteRegisterModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() >= RowCount || index.column() >= ColumnCount)
|
||||
return QVariant();
|
||||
|
||||
Q_ASSERT(m_coils.count() == RowCount);
|
||||
Q_ASSERT(m_holdingRegisters.count() == RowCount);
|
||||
|
||||
if (index.column() == NumColumn && role == Qt::DisplayRole)
|
||||
return QString::number(index.row());
|
||||
|
||||
@ -40,14 +42,17 @@ QVariant WriteRegisterModel::data(const QModelIndex &index, int role) const
|
||||
return QString("0x%1").arg(QString::number(m_holdingRegisters.at(index.row()), 16));
|
||||
|
||||
if(index.column() == CurrentUColumn && role == Qt::DisplayRole)
|
||||
return QString("%1 В").arg(QString::number((double)((double)m_currentU.at(index.row())/(double)1000), 'f', 3));
|
||||
return QString("%1 В").arg(QString::number((double)((double)m_currentU.at(index.row())/(double)1000)));
|
||||
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
|
||||
QVariant WriteRegisterModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
if (orientation == Qt::Horizontal) {
|
||||
switch (section) {
|
||||
case NumColumn:
|
||||
@ -71,6 +76,7 @@ bool WriteRegisterModel::setData(const QModelIndex &index, const QVariant &value
|
||||
{
|
||||
if (!index.isValid() || index.row() >= RowCount || index.column() >= ColumnCount)
|
||||
return false;
|
||||
|
||||
Q_ASSERT(m_coils.count() == RowCount);
|
||||
Q_ASSERT(m_holdingRegisters.count() == RowCount);
|
||||
|
||||
@ -80,6 +86,7 @@ bool WriteRegisterModel::setData(const QModelIndex &index, const QVariant &value
|
||||
emit dataChanged(index, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (index.column() == HoldingColumn && role == Qt::EditRole) { // holding registers
|
||||
bool result = false;
|
||||
quint16 newValue = value.toString().toUShort(&result, 16);
|
||||
@ -89,6 +96,7 @@ bool WriteRegisterModel::setData(const QModelIndex &index, const QVariant &value
|
||||
emit dataChanged(index, index);
|
||||
return result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user