Compare commits
3 Commits
Pre-releas
...
main
Author | SHA1 | Date | |
---|---|---|---|
568ec9b5d3 | |||
009ac176f9 | |||
1b7388821e |
@ -26,6 +26,7 @@ SOURCES += \
|
|||||||
main.cpp \
|
main.cpp \
|
||||||
m3kte.cpp \
|
m3kte.cpp \
|
||||||
multiplesettings.cpp \
|
multiplesettings.cpp \
|
||||||
|
scanboard.cpp \
|
||||||
settingsdialog.cpp \
|
settingsdialog.cpp \
|
||||||
writeregistermodel.cpp
|
writeregistermodel.cpp
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ HEADERS += \
|
|||||||
devicesettingsdialog.h \
|
devicesettingsdialog.h \
|
||||||
m3kte.h \
|
m3kte.h \
|
||||||
multiplesettings.h \
|
multiplesettings.h \
|
||||||
|
scanboard.h \
|
||||||
settingsdialog.h \
|
settingsdialog.h \
|
||||||
writeregistermodel.h
|
writeregistermodel.h
|
||||||
|
|
||||||
@ -40,6 +42,7 @@ FORMS += \
|
|||||||
devicesettingsdialog.ui \
|
devicesettingsdialog.ui \
|
||||||
m3kte.ui \
|
m3kte.ui \
|
||||||
multiplesettings.ui \
|
multiplesettings.ui \
|
||||||
|
scanboard.ui \
|
||||||
settingsdialog.ui
|
settingsdialog.ui
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@
|
|||||||
#include "writeregistermodel.h"
|
#include "writeregistermodel.h"
|
||||||
#include "devicesettingsdialog.h"
|
#include "devicesettingsdialog.h"
|
||||||
#include "multiplesettings.h"
|
#include "multiplesettings.h"
|
||||||
|
#include "scanboard.h"
|
||||||
|
|
||||||
#include <QModbusTcpClient>
|
#include <QModbusTcpClient>
|
||||||
#include <QModbusRtuSerialMaster>
|
#include <QModbusRtuSerialMaster>
|
||||||
@ -18,6 +19,7 @@
|
|||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QGroupBox>
|
||||||
|
|
||||||
#include <QtSerialBus/qtserialbusglobal.h>
|
#include <QtSerialBus/qtserialbusglobal.h>
|
||||||
|
|
||||||
@ -25,6 +27,8 @@
|
|||||||
#include <QSerialPort>
|
#include <QSerialPort>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MODBUS_REQUEST_PROTOCOL_INFO_LENGTH 8
|
||||||
|
|
||||||
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 +44,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();
|
void errorAdrChange();
|
||||||
bool event(QEvent* event);
|
bool event(QEvent* event);
|
||||||
bool pingNetworkDevices();
|
bool pingNetworkDevices();
|
||||||
void beginScanBoards();
|
void beginScanBoards();
|
||||||
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 +67,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 +76,14 @@ 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;
|
|
||||||
int CurrentConnectedDevice = 0;
|
int CurrentConnectedDevice = 0;
|
||||||
//int DeviceOnNetwork[4];
|
//int DeviceOnNetwork[4];
|
||||||
QProgressBar *m_ProgressBar[320];
|
QProgressBar *m_ProgressBar[320];
|
||||||
@ -98,6 +93,8 @@ 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;
|
||||||
|
QGroupBox *Boards_Fields[4];
|
||||||
//WriteRegisterModel *writeModel = nullptr;
|
//WriteRegisterModel *writeModel = nullptr;
|
||||||
|
|
||||||
struct StatusM3KTE{
|
struct StatusM3KTE{
|
||||||
@ -107,6 +104,8 @@ private:
|
|||||||
|
|
||||||
struct BoardModbusRegisters
|
struct BoardModbusRegisters
|
||||||
{
|
{
|
||||||
|
bool isActive = false;
|
||||||
|
|
||||||
int adr;
|
int adr;
|
||||||
int _tmp_adr;
|
int _tmp_adr;
|
||||||
|
|
||||||
|
@ -3914,7 +3914,7 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="2" column="4" rowspan="2" colspan="2">
|
<item row="2" column="4" rowspan="2" colspan="2">
|
||||||
<layout class="QGridLayout" name="TxRxLayout">
|
<layout class="QGridLayout" name="TxRxLayout">
|
||||||
<item row="4" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QPushButton" name="writeButton">
|
<widget class="QPushButton" name="writeButton">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -3927,6 +3927,9 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QTreeView" name="writeValueTable"/>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QComboBox" name="boardSelectBox">
|
<widget class="QComboBox" name="boardSelectBox">
|
||||||
<item>
|
<item>
|
||||||
@ -3954,7 +3957,7 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QComboBox" name="writeTable"/>
|
<widget class="QComboBox" name="writeTable"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QPushButton" name="readButton">
|
<widget class="QPushButton" name="readButton">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -3967,9 +3970,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QTreeView" name="writeValueTable"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="3" rowspan="3">
|
<item row="1" column="3" rowspan="3">
|
||||||
|
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>
|
@ -23,7 +23,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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
@ -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