Checkpoint to git test
This commit is contained in:
parent
fc01a6c06d
commit
1b7388821e
@ -26,6 +26,7 @@ SOURCES += \
|
||||
main.cpp \
|
||||
m3kte.cpp \
|
||||
multiplesettings.cpp \
|
||||
scanboard.cpp \
|
||||
settingsdialog.cpp \
|
||||
writeregistermodel.cpp
|
||||
|
||||
@ -33,6 +34,7 @@ HEADERS += \
|
||||
devicesettingsdialog.h \
|
||||
m3kte.h \
|
||||
multiplesettings.h \
|
||||
scanboard.h \
|
||||
settingsdialog.h \
|
||||
writeregistermodel.h
|
||||
|
||||
@ -40,6 +42,7 @@ FORMS += \
|
||||
devicesettingsdialog.ui \
|
||||
m3kte.ui \
|
||||
multiplesettings.ui \
|
||||
scanboard.ui \
|
||||
settingsdialog.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@
|
||||
#include "writeregistermodel.h"
|
||||
#include "devicesettingsdialog.h"
|
||||
#include "multiplesettings.h"
|
||||
#include "scanboard.h"
|
||||
|
||||
#include <QModbusTcpClient>
|
||||
#include <QModbusRtuSerialMaster>
|
||||
@ -18,6 +19,7 @@
|
||||
#include <QProgressDialog>
|
||||
#include <QErrorMessage>
|
||||
#include <QPushButton>
|
||||
#include <QGroupBox>
|
||||
|
||||
#include <QtSerialBus/qtserialbusglobal.h>
|
||||
|
||||
@ -25,6 +27,8 @@
|
||||
#include <QSerialPort>
|
||||
#endif
|
||||
|
||||
#define MODBUS_REQUEST_PROTOCOL_INFO_LENGTH 8
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class M3KTE; class SettingsDialog;}
|
||||
QT_END_NAMESPACE
|
||||
@ -40,17 +44,18 @@ 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 displayResultOfScan(QModbusReply *reply, int boardID);
|
||||
void stepForScanCurrentSettings(QModbusReply *reply);
|
||||
void applySettingsFromScan(QModbusReply *reply);
|
||||
|
||||
void multipleRegWrite();
|
||||
void multipleRegSend();
|
||||
|
||||
bool autoBaudRateScan();
|
||||
|
||||
void selectPositionOnTree(unsigned index);
|
||||
private slots:
|
||||
|
||||
@ -62,9 +67,7 @@ private slots:
|
||||
void onReadButtonClicked();
|
||||
void onReadReady();
|
||||
|
||||
void timeForPingIsGone();
|
||||
|
||||
void checkAdrChange();
|
||||
void checkAdrChange(QModbusReply *reply, unsigned boardNum);
|
||||
|
||||
void onWriteButtonClicked();
|
||||
void onSelectedBoardChanged(int index);
|
||||
@ -73,22 +76,14 @@ private slots:
|
||||
void onSpeedUpdate();
|
||||
void onParityUpdate();
|
||||
|
||||
void firstBoardScan();
|
||||
void secondBoardScan();
|
||||
void thirdBoardScan();
|
||||
void fourthBoardScan();
|
||||
void boardScan(unsigned boardID);
|
||||
|
||||
void firstBoardReady();
|
||||
void secondBoardReady();
|
||||
void thirdBoardReady();
|
||||
void fourthBoardReady();
|
||||
public:
|
||||
M3KTE(QWidget *parent = nullptr);
|
||||
~M3KTE();
|
||||
|
||||
private:
|
||||
Ui::M3KTE *ui;
|
||||
bool timerForPingSignal = false;
|
||||
int CurrentConnectedDevice = 0;
|
||||
//int DeviceOnNetwork[4];
|
||||
QProgressBar *m_ProgressBar[320];
|
||||
@ -98,6 +93,8 @@ private:
|
||||
DeviceSettingsDialog *m_deviceSettingsDialog = nullptr;
|
||||
SettingsDialog *m_settingsDialog = nullptr;
|
||||
MultipleSettings *m_regMultipleSettings = nullptr;
|
||||
ScanBoard *m_scanBoard = nullptr;
|
||||
QGroupBox *Boards_Fields[4];
|
||||
//WriteRegisterModel *writeModel = nullptr;
|
||||
|
||||
struct StatusM3KTE{
|
||||
@ -107,6 +104,8 @@ private:
|
||||
|
||||
struct BoardModbusRegisters
|
||||
{
|
||||
bool isActive = false;
|
||||
|
||||
int adr;
|
||||
int _tmp_adr;
|
||||
|
||||
|
@ -3914,7 +3914,7 @@
|
||||
</item>
|
||||
<item row="2" column="4" rowspan="2" colspan="2">
|
||||
<layout class="QGridLayout" name="TxRxLayout">
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="writeButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -3927,6 +3927,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QTreeView" name="writeValueTable"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="boardSelectBox">
|
||||
<item>
|
||||
@ -3954,7 +3957,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QComboBox" name="writeTable"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="readButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -3967,9 +3970,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QTreeView" name="writeValueTable"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="3" rowspan="3">
|
||||
|
29
M3KTE_TERM/scanboard.cpp
Normal file
29
M3KTE_TERM/scanboard.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#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);
|
||||
}
|
29
M3KTE_TERM/scanboard.h
Normal file
29
M3KTE_TERM/scanboard.h
Normal file
@ -0,0 +1,29 @@
|
||||
#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);
|
||||
private slots:
|
||||
void on_applyToAllBox_stateChanged(int arg1);
|
||||
|
||||
private:
|
||||
Qt::CheckState checkState;
|
||||
|
||||
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 dataBits = QSerialPort::Data8;
|
||||
int stopBits = QSerialPort::OneStop;
|
||||
int responseTime = 500;
|
||||
int responseTime = 50;
|
||||
int numberOfRetries = 0;
|
||||
};
|
||||
|
||||
|
@ -20,13 +20,13 @@
|
||||
<string> мс</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>20</number>
|
||||
<number>1</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>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="value">
|
||||
<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)
|
||||
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());
|
||||
|
||||
@ -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));
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
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:
|
||||
@ -76,7 +71,6 @@ 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);
|
||||
|
||||
@ -86,7 +80,6 @@ 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);
|
||||
@ -96,7 +89,6 @@ 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