-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev'
# Conflicts: # README.md
- Loading branch information
Showing
32 changed files
with
1,019 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "formattedspinbox.h" | ||
|
||
/// | ||
/// \brief FormattedSpinBox::FormattedSpinBox | ||
/// \param parent | ||
/// | ||
FormattedSpinBox::FormattedSpinBox(QWidget* parent) | ||
:QSpinBox(parent) | ||
{ | ||
} | ||
|
||
/// | ||
/// \brief FormattedSpinBox::textFromValue | ||
/// \param val | ||
/// \return | ||
/// | ||
QString FormattedSpinBox::textFromValue(int val) const | ||
{ | ||
const int nums = qMax(1, QString::number(maximum()).length()); | ||
return QStringLiteral("%1").arg(val, nums, 10, QLatin1Char('0')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef FORMATTEDSPINBOX_H | ||
#define FORMATTEDSPINBOX_H | ||
|
||
#include <QSpinBox> | ||
#include <QObject> | ||
|
||
class FormattedSpinBox : public QSpinBox | ||
{ | ||
Q_OBJECT | ||
public: | ||
FormattedSpinBox(QWidget* parent = nullptr); | ||
|
||
protected: | ||
QString textFromValue(int val) const override; | ||
}; | ||
|
||
#endif // FORMATTEDSPINBOX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#include "functioncodecombobox.h" | ||
|
||
/// | ||
/// \brief FunctionCodeComboBox::FunctionCodeComboBox | ||
/// \param parent | ||
/// | ||
FunctionCodeComboBox::FunctionCodeComboBox(QWidget *parent) | ||
:QComboBox(parent) | ||
{ | ||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(on_currentIndexChanged(int))); | ||
} | ||
|
||
/// | ||
/// \brief FunctionCodeComboBox::currentFunctionCode | ||
/// \return | ||
/// | ||
QModbusPdu::FunctionCode FunctionCodeComboBox::currentFunctionCode() const | ||
{ | ||
return currentData().value<QModbusPdu::FunctionCode>(); | ||
} | ||
|
||
/// | ||
/// \brief FunctionCodeComboBox::setCurrentFunctionCode | ||
/// \param pointType | ||
/// | ||
void FunctionCodeComboBox::setCurrentFunctionCode(QModbusPdu::FunctionCode funcCode) | ||
{ | ||
const auto idx = findData(funcCode); | ||
setCurrentIndex(idx); | ||
} | ||
|
||
/// | ||
/// \brief FunctionCodeComboBox::addItem | ||
/// \param funcCode | ||
/// | ||
void FunctionCodeComboBox::addItem(QModbusPdu::FunctionCode funcCode) | ||
{ | ||
switch(funcCode) | ||
{ | ||
case QModbusPdu::ReadCoils: | ||
QComboBox::addItem("01: READ COILS", QModbusPdu::ReadCoils); | ||
break; | ||
|
||
case QModbusPdu::ReadDiscreteInputs: | ||
QComboBox::addItem("02: READ INPUTS", QModbusPdu::ReadDiscreteInputs); | ||
break; | ||
|
||
case QModbusPdu::ReadHoldingRegisters: | ||
QComboBox::addItem("03: READ HOLDING REGS", QModbusPdu::ReadHoldingRegisters); | ||
break; | ||
|
||
case QModbusPdu::ReadInputRegisters: | ||
QComboBox::addItem("04: READ INPUT REGS", QModbusPdu::ReadInputRegisters); | ||
break; | ||
|
||
case QModbusPdu::WriteSingleCoil: | ||
QComboBox::addItem("05: WRITE SINGLE COIL", QModbusPdu::WriteSingleCoil); | ||
break; | ||
|
||
case QModbusPdu::WriteSingleRegister: | ||
QComboBox::addItem("06: WRITE SINGLE REG", QModbusPdu::WriteSingleRegister); | ||
break; | ||
|
||
case QModbusPdu::ReadExceptionStatus: | ||
QComboBox::addItem("07: READ EXCEPTION STAT", QModbusPdu::ReadExceptionStatus); | ||
break; | ||
|
||
case QModbusPdu::Diagnostics: | ||
QComboBox::addItem("08: DIAGNOSTICS", QModbusPdu::Diagnostics); | ||
break; | ||
|
||
case QModbusPdu::GetCommEventCounter: | ||
QComboBox::addItem("11: GET COMM EVENT CNT", QModbusPdu::GetCommEventCounter); | ||
break; | ||
|
||
case QModbusPdu::GetCommEventLog: | ||
QComboBox::addItem("12: GET COMM EVENT LOG", QModbusPdu::GetCommEventLog); | ||
break; | ||
|
||
case QModbusPdu::WriteMultipleCoils: | ||
QComboBox::addItem("15: WRITE MULT COILS", QModbusPdu::WriteMultipleCoils); | ||
break; | ||
|
||
case QModbusPdu::WriteMultipleRegisters: | ||
QComboBox::addItem("16: WRITE MULT REGS", QModbusPdu::WriteMultipleRegisters); | ||
break; | ||
|
||
case QModbusPdu::ReportServerId: | ||
QComboBox::addItem("17: REPORT SLAVE ID", QModbusPdu::ReportServerId); | ||
break; | ||
|
||
case QModbusPdu::ReadFileRecord: | ||
QComboBox::addItem("20: READ FILE RECORD", QModbusPdu::ReadFileRecord); | ||
break; | ||
|
||
case QModbusPdu::WriteFileRecord: | ||
QComboBox::addItem("21: WRITE FILE RECORD", QModbusPdu::WriteFileRecord); | ||
break; | ||
|
||
case QModbusPdu::MaskWriteRegister: | ||
QComboBox::addItem("22: MASK WRITE REG", QModbusPdu::MaskWriteRegister); | ||
break; | ||
|
||
case QModbusPdu::ReadWriteMultipleRegisters: | ||
QComboBox::addItem("23: READ WRITE MULT REGS", QModbusPdu::ReadWriteMultipleRegisters); | ||
break; | ||
|
||
case QModbusPdu::ReadFifoQueue: | ||
QComboBox::addItem("24: READ FIFO QUEUE", QModbusPdu::ReadFifoQueue); | ||
break; | ||
|
||
case QModbusPdu::EncapsulatedInterfaceTransport: | ||
QComboBox::addItem("43: ENC IFACE TRANSPORT", QModbusPdu::EncapsulatedInterfaceTransport); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
/// | ||
/// \brief FunctionCodeComboBox::on_currentIndexChanged | ||
/// \param index | ||
/// | ||
void FunctionCodeComboBox::on_currentIndexChanged(int index) | ||
{ | ||
emit functionCodeChanged(itemData(index).value<QModbusPdu::FunctionCode>()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef FUNCTIONCODECOMBOBOX_H | ||
#define FUNCTIONCODECOMBOBOX_H | ||
|
||
#include <QComboBox> | ||
#include <QModbusPdu> | ||
|
||
class FunctionCodeComboBox : public QComboBox | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
FunctionCodeComboBox(QWidget *parent = nullptr); | ||
|
||
QModbusPdu::FunctionCode currentFunctionCode() const; | ||
void setCurrentFunctionCode(QModbusPdu::FunctionCode funcCode); | ||
|
||
void addItem(QModbusPdu::FunctionCode funcCode); | ||
|
||
signals: | ||
void functionCodeChanged(QModbusPdu::FunctionCode funcCode); | ||
|
||
private slots: | ||
void on_currentIndexChanged(int); | ||
}; | ||
|
||
#endif // FUNCTIONCODECOMBOBOX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.