Pre-release.
Added: 1) Added check for transition to new speed and parity. 2) Added the ability to stop scanning before polling all addresses. 3) A window has been added that allows you to set the value of multiple registers at once. Supports both simple saving on the device and the saved-sent mode. 4) Added check for parity and speed changes. 5) Added output of current voltage to the table. 6) Now, when you click on an indicator in the table, the corresponding element will be highlighted. Minor updates: 1) Now the device settings take into account the number of boards found during scanning. 2) When you close the main window, the device turns off.
This commit is contained in:
parent
49083ca06d
commit
fc01a6c06d
@ -25,18 +25,21 @@ SOURCES += \
|
||||
devicesettingsdialog.cpp \
|
||||
main.cpp \
|
||||
m3kte.cpp \
|
||||
multiplesettings.cpp \
|
||||
settingsdialog.cpp \
|
||||
writeregistermodel.cpp
|
||||
|
||||
HEADERS += \
|
||||
devicesettingsdialog.h \
|
||||
m3kte.h \
|
||||
multiplesettings.h \
|
||||
settingsdialog.h \
|
||||
writeregistermodel.h
|
||||
|
||||
FORMS += \
|
||||
devicesettingsdialog.ui \
|
||||
m3kte.ui \
|
||||
multiplesettings.ui \
|
||||
settingsdialog.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
|
@ -12,6 +12,11 @@ DeviceSettingsDialog::DeviceSettingsDialog(QWidget *parent) :
|
||||
_currentBoardTimers[2] = ui->spinTimerBoard_3->value();
|
||||
_currentBoardTimers[3] = ui->spinTimerBoard_4->value();
|
||||
|
||||
_m_timer[0] = ui->spinTimerBoard_1;
|
||||
_m_timer[1] = ui->spinTimerBoard_2;
|
||||
_m_timer[2] = ui->spinTimerBoard_3;
|
||||
_m_timer[3] = ui->spinTimerBoard_4;
|
||||
|
||||
_currentSpeed = ui->speedBox->currentText().toUInt();
|
||||
|
||||
_currentParity = ui->parityBox->currentIndex();
|
||||
@ -38,13 +43,13 @@ void DeviceSettingsDialog::on_buttonApplyChangeTimer_clicked()
|
||||
void DeviceSettingsDialog::on_buttonApplyChangeSpeed_clicked()
|
||||
{
|
||||
|
||||
_currentSpeed = ui->speedBox->currentText().toUInt();
|
||||
_currentSpeed = ui->speedBox->currentIndex();
|
||||
emit speedChanged();
|
||||
}
|
||||
|
||||
void DeviceSettingsDialog::on_buttonApplyChangeParity_clicked()
|
||||
{
|
||||
_currentParity = ui->parityBox->currentData().toUInt();
|
||||
_currentParity = ui->parityBox->currentIndex();
|
||||
emit parityChanged();
|
||||
}
|
||||
|
||||
@ -52,6 +57,7 @@ void DeviceSettingsDialog::on_buttonApplyChangeAdr_clicked()
|
||||
{
|
||||
BoardIdHasBeenChanged* _boardIdHasBeenChanged = new BoardIdHasBeenChanged(ui->idComboBox->currentIndex(), ui->adrSpinBox->value());
|
||||
QCoreApplication::postEvent(parent(), _boardIdHasBeenChanged);
|
||||
close();
|
||||
}
|
||||
|
||||
unsigned DeviceSettingsDialog::currentBoardTimer(unsigned short _ID)
|
||||
@ -69,16 +75,22 @@ unsigned short DeviceSettingsDialog::currentParity()
|
||||
return _currentParity;
|
||||
}
|
||||
|
||||
void DeviceSettingsDialog::updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr)
|
||||
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++)
|
||||
{
|
||||
_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());
|
||||
}
|
||||
|
||||
@ -86,3 +98,34 @@ void DeviceSettingsDialog::on_idComboBox_currentIndexChanged(int index)
|
||||
{
|
||||
ui->adrSpinBox->setValue(_currentAdrs[index]);
|
||||
}
|
||||
|
||||
void DeviceSettingsDialog::on_buttonBox_clicked(QAbstractButton *button)
|
||||
{
|
||||
switch (ui->buttonBox->buttonRole(button)) {
|
||||
case QDialogButtonBox::ResetRole:
|
||||
ui->spinTimerBoard_1->setValue(1000);
|
||||
ui->spinTimerBoard_2->setValue(1000);
|
||||
ui->spinTimerBoard_3->setValue(1000);
|
||||
ui->spinTimerBoard_4->setValue(1000);
|
||||
_currentBoardTimers[0] = ui->spinTimerBoard_1->value();
|
||||
_currentBoardTimers[1] = ui->spinTimerBoard_2->value();
|
||||
_currentBoardTimers[2] = ui->spinTimerBoard_3->value();
|
||||
_currentBoardTimers[3] = ui->spinTimerBoard_4->value();
|
||||
|
||||
ui->speedBox->setCurrentText("31250");
|
||||
_currentSpeed = ui->speedBox->currentText().toUInt();
|
||||
|
||||
ui->parityBox->setCurrentIndex(0);
|
||||
_currentParity = ui->parityBox->currentIndex();
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
_currentAdrs[i] = i+1;
|
||||
}
|
||||
ui->adrSpinBox->setValue(_currentAdrs[ui->idComboBox->currentIndex()]);
|
||||
break;
|
||||
case QDialogButtonBox::AcceptRole:
|
||||
close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QEvent>
|
||||
#include <QAbstractButton>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QSpinBox>
|
||||
|
||||
class BoardIdHasBeenChanged : public QEvent
|
||||
{
|
||||
@ -33,7 +36,7 @@ public:
|
||||
unsigned currentBoardTimer(unsigned short _ID);
|
||||
unsigned currentSpeed();
|
||||
unsigned short currentParity();
|
||||
void updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr);
|
||||
void updateSettingsAfterConnection(unsigned tmp_speed, unsigned tmp_parity, unsigned *tmp_adr, int CurrentConnectedDevice);
|
||||
signals:
|
||||
void parityChanged();
|
||||
void speedChanged();
|
||||
@ -54,7 +57,10 @@ private slots:
|
||||
|
||||
void on_idComboBox_currentIndexChanged(int index);
|
||||
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
QSpinBox *_m_timer[4];
|
||||
unsigned _currentBoardTimers[4];
|
||||
unsigned _currentSpeed;
|
||||
unsigned short _currentParity;
|
||||
|
@ -30,28 +30,18 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="speedBox">
|
||||
<property name="currentIndex">
|
||||
<number>5</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1200</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2400</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4800</string>
|
||||
</property>
|
||||
</item>
|
||||
<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>
|
||||
@ -67,6 +57,11 @@
|
||||
<string>38400</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>56000</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>57600</string>
|
||||
@ -204,30 +199,17 @@
|
||||
<property name="whatsThis">
|
||||
<string>Номер платы</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="adrSpinBox"/>
|
||||
<widget class="QSpinBox" name="adrSpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>247</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="buttonApplyChangeAdr">
|
||||
|
1176
M3KTE_TERM/m3kte.cpp
1176
M3KTE_TERM/m3kte.cpp
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@
|
||||
#include <QtSerialBus/QModbusDataUnit>
|
||||
#include "writeregistermodel.h"
|
||||
#include "devicesettingsdialog.h"
|
||||
#include "multiplesettings.h"
|
||||
|
||||
#include <QModbusTcpClient>
|
||||
#include <QModbusRtuSerialMaster>
|
||||
@ -16,6 +17,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QProgressDialog>
|
||||
#include <QErrorMessage>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <QtSerialBus/qtserialbusglobal.h>
|
||||
|
||||
@ -45,7 +47,16 @@ private:
|
||||
void beginScanBoards();
|
||||
void displayResultOfScan(QModbusReply *reply, int boardID);
|
||||
void stepForScanCurrentSettings(QModbusReply *reply);
|
||||
|
||||
void multipleRegWrite();
|
||||
void multipleRegSend();
|
||||
|
||||
void selectPositionOnTree(unsigned index);
|
||||
private slots:
|
||||
|
||||
void slotmultipleRegWrite();
|
||||
void slotmultipleRegWriteAndSend();
|
||||
|
||||
void onConnectClicked();
|
||||
|
||||
void onReadButtonClicked();
|
||||
@ -62,7 +73,6 @@ private slots:
|
||||
void onSpeedUpdate();
|
||||
void onParityUpdate();
|
||||
|
||||
|
||||
void firstBoardScan();
|
||||
void secondBoardScan();
|
||||
void thirdBoardScan();
|
||||
@ -77,17 +87,17 @@ public:
|
||||
~M3KTE();
|
||||
|
||||
private:
|
||||
bool timerForPingSignal = false;
|
||||
|
||||
|
||||
|
||||
Ui::M3KTE *ui;
|
||||
bool timerForPingSignal = false;
|
||||
int CurrentConnectedDevice = 0;
|
||||
//int DeviceOnNetwork[4];
|
||||
QProgressBar *m[320];
|
||||
QProgressBar *m_ProgressBar[320];
|
||||
QPushButton *ThePhantomMenace[320];
|
||||
QModbusReply *lastRequest = nullptr;
|
||||
QModbusClient *modbusDevice = nullptr;
|
||||
DeviceSettingsDialog *m_deviceSettingsDialog = nullptr;
|
||||
SettingsDialog *m_settingsDialog = nullptr;
|
||||
MultipleSettings *m_regMultipleSettings = nullptr;
|
||||
//WriteRegisterModel *writeModel = nullptr;
|
||||
|
||||
struct StatusM3KTE{
|
||||
@ -99,6 +109,10 @@ private:
|
||||
{
|
||||
int adr;
|
||||
int _tmp_adr;
|
||||
|
||||
bool coil[85];
|
||||
unsigned HR[170];
|
||||
|
||||
WriteRegisterModel *ModbusModelCoil;
|
||||
WriteRegisterModel *ModbusModelHoldingReg;
|
||||
QTimer *boardScanners;
|
||||
|
14766
M3KTE_TERM/m3kte.ui
14766
M3KTE_TERM/m3kte.ui
File diff suppressed because it is too large
Load Diff
75
M3KTE_TERM/multiplesettings.cpp
Normal file
75
M3KTE_TERM/multiplesettings.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include "multiplesettings.h"
|
||||
#include "ui_multiplesettings.h"
|
||||
|
||||
MultipleSettings::MultipleSettings(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::MultipleSettings)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Записать");
|
||||
ui->buttonBox->button(QDialogButtonBox::SaveAll)->setText("Записать и установить");
|
||||
}
|
||||
|
||||
MultipleSettings::~MultipleSettings()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MultipleSettings::on_buttonBox_clicked(QAbstractButton *button)
|
||||
{
|
||||
if(button == ui->buttonBox->button(QDialogButtonBox::Ok))
|
||||
{
|
||||
newValue = ui->regValueLine->text().toInt(nullptr, 16);
|
||||
typeReg = ui->regTypeBox->currentIndex();
|
||||
startAdr = ui->adrBox->value();
|
||||
countReg = ui->countBox->value();
|
||||
boardId = ui->boardBox->currentIndex();
|
||||
emit write();
|
||||
}
|
||||
else if (button == ui->buttonBox->button(QDialogButtonBox::SaveAll))
|
||||
{
|
||||
newValue = ui->regValueLine->text().toInt(nullptr, 16);
|
||||
typeReg = ui->regTypeBox->currentIndex();
|
||||
startAdr = ui->adrBox->value();
|
||||
countReg = ui->countBox->value();
|
||||
boardId = ui->boardBox->currentIndex();
|
||||
emit writeAndSend();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleSettings::on_regTypeBox_currentIndexChanged(int index)
|
||||
{
|
||||
switch (index) {
|
||||
case 0:
|
||||
case 1:
|
||||
ui->adrBox->setRange(0, 84);
|
||||
ui->adrBox->setValue(0);
|
||||
break;
|
||||
case 2:
|
||||
ui->adrBox->setRange(85, 170);
|
||||
ui->adrBox->setValue(85);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleSettings::on_boardBox_currentIndexChanged(int index)
|
||||
{
|
||||
switch (index) {
|
||||
case 3:
|
||||
ui->countBox->setRange(1, 65-ui->adrBox->value()+85*ui->regTypeBox->currentIndex()/2);
|
||||
break;
|
||||
default:
|
||||
ui->countBox->setRange(1, 85-ui->adrBox->value()+85*ui->regTypeBox->currentIndex()/2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleSettings::on_adrBox_valueChanged(int arg1)
|
||||
{
|
||||
ui->countBox->setRange(1, ((85-(20*(ui->boardBox->currentIndex()/3)))*(1+(ui->regTypeBox->currentIndex()/2))-arg1));
|
||||
}
|
45
M3KTE_TERM/multiplesettings.h
Normal file
45
M3KTE_TERM/multiplesettings.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef MULTIPLESETTINGS_H
|
||||
#define MULTIPLESETTINGS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace Ui {
|
||||
class MultipleSettings;
|
||||
}
|
||||
|
||||
class MultipleSettings : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MultipleSettings(QWidget *parent = nullptr);
|
||||
~MultipleSettings();
|
||||
quint16 getNewValue() {return newValue;}
|
||||
unsigned getStartAdr() {return startAdr;}
|
||||
unsigned getCountReg() {return countReg;}
|
||||
short getTypeReg() {return typeReg;}
|
||||
short getBoardId() {return boardId;}
|
||||
signals:
|
||||
void write();
|
||||
void writeAndSend();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
|
||||
void on_regTypeBox_currentIndexChanged(int index);
|
||||
|
||||
void on_boardBox_currentIndexChanged(int index);
|
||||
|
||||
void on_adrBox_valueChanged(int arg1);
|
||||
|
||||
private:
|
||||
Ui::MultipleSettings *ui;
|
||||
quint16 newValue = 0;
|
||||
unsigned startAdr;
|
||||
unsigned countReg;
|
||||
short typeReg;
|
||||
short boardId;
|
||||
};
|
||||
|
||||
#endif // MULTIPLESETTINGS_H
|
198
M3KTE_TERM/multiplesettings.ui
Normal file
198
M3KTE_TERM/multiplesettings.ui
Normal file
@ -0,0 +1,198 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MultipleSettings</class>
|
||||
<widget class="QDialog" name="MultipleSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>381</width>
|
||||
<height>128</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Уставка</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="countLabel">
|
||||
<property name="text">
|
||||
<string>Кол-во</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QLabel" name="adrLabel">
|
||||
<property name="text">
|
||||
<string>Стартовый</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="boardLabel">
|
||||
<property name="text">
|
||||
<string>Плата</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="adrBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>84</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QComboBox" name="boardBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QSpinBox" name="countBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>85</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="QLineEdit" name="regValueLine"/>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QLabel" name="regValueLabel">
|
||||
<property name="text">
|
||||
<string>Значение (HEX)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="regTypeBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Coil</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Warning</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Accident</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="regTypeLabel">
|
||||
<property name="text">
|
||||
<string>Тип Регистра</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::SaveAll</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>MultipleSettings</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>MultipleSettings</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>
|
@ -45,8 +45,8 @@ SettingsDialog::Settings SettingsDialog::settings() const
|
||||
|
||||
int SettingsDialog::UpdateBaud(int baud)
|
||||
{
|
||||
ui->baudCombo->setCurrentText(QString::number(baud, 10));
|
||||
return (m_settings.baud = baud);
|
||||
ui->baudCombo->setCurrentIndex(baud);
|
||||
return (m_settings.baud = ui->baudCombo->currentText().toInt());
|
||||
}
|
||||
|
||||
int SettingsDialog::UpdateParity(int parity)
|
||||
@ -60,3 +60,13 @@ int SettingsDialog::UpdateParity(int parity)
|
||||
return (m_settings.parity = parity);
|
||||
}
|
||||
}
|
||||
|
||||
int SettingsDialog::curBaud()
|
||||
{
|
||||
return ui->baudCombo->currentIndex();
|
||||
}
|
||||
|
||||
int SettingsDialog::curParity()
|
||||
{
|
||||
return ui->parityCombo->currentIndex();
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ public:
|
||||
int baud = 115200;
|
||||
int dataBits = QSerialPort::Data8;
|
||||
int stopBits = QSerialPort::OneStop;
|
||||
int responseTime = 1000;
|
||||
int numberOfRetries = 3;
|
||||
int responseTime = 500;
|
||||
int numberOfRetries = 0;
|
||||
};
|
||||
|
||||
explicit SettingsDialog(QWidget *parent = nullptr);
|
||||
@ -35,7 +35,8 @@ public:
|
||||
int UpdateBaud(int baud);
|
||||
int UpdateParity(int parity);
|
||||
|
||||
|
||||
int curBaud();
|
||||
int curParity();
|
||||
private:
|
||||
Settings m_settings;
|
||||
Ui::SettingsDialog *ui;
|
||||
|
@ -35,8 +35,11 @@
|
||||
</item>
|
||||
<item row="2" column="1" rowspan="2" colspan="2">
|
||||
<widget class="QSpinBox" name="retriesSpinner">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -112,28 +115,18 @@
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="baudCombo">
|
||||
<property name="currentIndex">
|
||||
<number>8</number>
|
||||
<number>7</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1200</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2400</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4800</string>
|
||||
</property>
|
||||
</item>
|
||||
<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>
|
||||
@ -149,6 +142,11 @@
|
||||
<string>38400</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>56000</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>57600</string>
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
#include "writeregistermodel.h"
|
||||
|
||||
enum { NumColumn = 0, NameColumn = 1, CoilsColumn = 2, HoldingColumn = 3, ColumnCount = 4};
|
||||
enum { NumColumn = 0, NameColumn = 1, CoilsColumn = 2, HoldingColumn = 3, ColumnCount = 5, CurrentUColumn = 4};
|
||||
|
||||
WriteRegisterModel::WriteRegisterModel(QObject *parent, int _tmpRC, bool _isHR)
|
||||
: QAbstractTableModel(parent),
|
||||
m_coils(RowCount=_tmpRC, false), m_holdingRegisters(RowCount=_tmpRC, 0u)
|
||||
m_coils(RowCount=_tmpRC, false), m_holdingRegisters(RowCount=_tmpRC, 0u), m_currentU(RowCount=_tmpRC)
|
||||
{
|
||||
isHR=_isHR;
|
||||
}
|
||||
@ -41,6 +41,9 @@ QVariant WriteRegisterModel::data(const QModelIndex &index, int role) const
|
||||
if (index.column() == HoldingColumn && role == Qt::DisplayRole) // holding registers
|
||||
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 QVariant();
|
||||
|
||||
}
|
||||
@ -60,6 +63,8 @@ QVariant WriteRegisterModel::headerData(int section, Qt::Orientation orientation
|
||||
return QStringLiteral("Coils");
|
||||
case HoldingColumn:
|
||||
return QStringLiteral("Holding Registers");
|
||||
case CurrentUColumn:
|
||||
return QStringLiteral("Current U");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -133,3 +138,11 @@ uint WriteRegisterModel::get_holreg(const QModelIndex &index)
|
||||
{
|
||||
return m_holdingRegisters.at(index.row());
|
||||
}
|
||||
|
||||
bool WriteRegisterModel::set_currentU(unsigned _tmpU, unsigned index)
|
||||
{
|
||||
m_currentU[index] = _tmpU;
|
||||
if(isHR)
|
||||
m_currentU[index + m_number] = _tmpU;
|
||||
return true;
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ public:
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
bool set_currentU(unsigned _tmpU, unsigned index);
|
||||
|
||||
public slots:
|
||||
void setStartAddress(int address);
|
||||
void setNumberOfValues(const QString &number);
|
||||
@ -36,5 +38,6 @@ public:
|
||||
int m_address = 0;
|
||||
QBitArray m_coils;
|
||||
QVector<quint16> m_holdingRegisters;
|
||||
QVector<quint16> m_currentU;
|
||||
};
|
||||
#endif // WRITEREGISTERMODEL_H
|
||||
|
Loading…
Reference in New Issue
Block a user