Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
sanny32 committed Mar 13, 2024
2 parents 3ddff51 + 20fd6dd commit a92d341
Show file tree
Hide file tree
Showing 77 changed files with 1,349 additions and 577 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## MIT License
Copyright 2023 Alexandr Ananev [mail@ananev.org]
Copyright 2024 Alexandr Ananev [mail@ananev.org]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Open ModScan
Open ModScan is a free implimentation of modbus master (client) utility for modbus-tcp and modbus-rtu protocols.

![image](https://github.com/sanny32/OpenModScan/assets/13627951/aa912ece-4b76-44b4-9523-5b0b0156a64b)
![image](https://github.com/sanny32/OpenModScan/assets/13627951/c2df0ea1-0f27-4d4b-8cc0-b6268caf8f11)


![image](https://github.com/sanny32/OpenModScan/assets/13627951/77bee5d8-09a8-4845-8d64-02b7bf3cf592)

![image](https://github.com/sanny32/OpenModScan/assets/13627951/2e24982e-3b32-4434-928e-6518505e48ae)



## Features
Expand All @@ -28,7 +30,8 @@ Registers

Modbus Logging

![image](https://github.com/sanny32/OpenModScan/assets/13627951/b3e43b25-ea7b-4beb-96c9-c7b9d6a65a03)
![image](https://github.com/sanny32/OpenModScan/assets/13627951/69de27f0-b09b-4587-8493-6d1908610735)



## Extended Featues
Expand All @@ -52,7 +55,7 @@ Modbus Logging
Now building is available with Qt/qmake (version 5.15 and above) or Qt Creator. Supports both OS Microsoft Windows and Linux.

## MIT License
Copyright 2023 Alexandr Ananev [mail@ananev.org]
Copyright 2024 Alexandr Ananev [mail@ananev.org]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
8 changes: 4 additions & 4 deletions omodscan/controls/bytelisttextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ void ByteListTextEdit::setValue(const QByteArray& value)
{
case DecMode:
{
const auto text = formatByteArray(DataDisplayMode::Decimal, value);
const auto text = formatUInt8Array(DataDisplayMode::UInt16, value);
if(text != toPlainText())
setPlainText(formatByteArray(DataDisplayMode::Decimal, value));
setPlainText(formatUInt8Array(DataDisplayMode::UInt16, value));
}
break;

case HexMode:
{
const auto text = formatByteArray(DataDisplayMode::Hex, value);
const auto text = formatUInt8Array(DataDisplayMode::Hex, value);
if(text != toPlainText())
setPlainText(formatByteArray(DataDisplayMode::Hex, value));
setPlainText(formatUInt8Array(DataDisplayMode::Hex, value));
}
break;
}
Expand Down
176 changes: 88 additions & 88 deletions omodscan/controls/modbusmessagewidget.cpp

Large diffs are not rendered by default.

127 changes: 113 additions & 14 deletions omodscan/controls/numericlineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QIntValidator>
#include "qhexvalidator.h"
#include "quintvalidator.h"
#include "qint64validator.h"
#include "numericlineedit.h"

///
Expand All @@ -14,7 +15,7 @@ NumericLineEdit::NumericLineEdit(QWidget* parent)
,_paddingZeroes(false)
,_paddingZeroWidth(0)
{
setInputMode(DecMode);
setInputMode(Int32Mode);
setValue(0);

connect(this, &QLineEdit::editingFinished, this, &NumericLineEdit::on_editingFinished);
Expand Down Expand Up @@ -78,14 +79,14 @@ void NumericLineEdit::setInputMode(InputMode mode)
{
switch(mode)
{
case DecMode:
case Int32Mode:
case HexMode:
_minValue = INT_MIN;
_maxValue = INT_MAX;
break;

case UnsignedMode:
_minValue = 0U;
case UInt32Mode:
_minValue = 0;
_maxValue = UINT_MAX;
break;

Expand All @@ -98,6 +99,16 @@ void NumericLineEdit::setInputMode(InputMode mode)
_minValue = -DBL_MAX;
_maxValue = DBL_MAX;
break;

case Int64Mode:
_minValue = QVariant::fromValue(INT64_MIN);
_maxValue = QVariant::fromValue(INT64_MAX);
break;

case UInt64Mode:
_minValue = 0;
_maxValue = QVariant::fromValue(UINT64_MAX);
break;
}
}
emit rangeChanged(_minValue, _maxValue);
Expand All @@ -121,7 +132,7 @@ void NumericLineEdit::internalSetValue(QVariant value)
{
switch(_inputMode)
{
case DecMode:
case Int32Mode:
value = qBound(_minValue.toInt(), value.toInt(), _maxValue.toInt());
if(_paddingZeroes)
{
Expand All @@ -137,7 +148,7 @@ void NumericLineEdit::internalSetValue(QVariant value)
}
break;

case UnsignedMode:
case UInt32Mode:
value = qBound(_minValue.toUInt(), value.toUInt(), _maxValue.toUInt());
if(_paddingZeroes)
{
Expand Down Expand Up @@ -189,6 +200,42 @@ void NumericLineEdit::internalSetValue(QVariant value)
QLineEdit::setText(text);
}
break;

case Int64Mode:
{
value = qBound(_minValue.toLongLong(), value.toLongLong(), _maxValue.toLongLong());
if(_paddingZeroes)
{
const auto text = QStringLiteral("%1").arg(value.toLongLong(), _paddingZeroWidth, 10, QLatin1Char('0'));
if(text != QLineEdit::text())
QLineEdit::setText(text);
}
else
{
const auto text = QString::number(value.toLongLong());
if(text != QLineEdit::text())
QLineEdit::setText(text);
}
}
break;

case UInt64Mode:
{
value = qBound(_minValue.toULongLong(), value.toULongLong(), _maxValue.toULongLong());
if(_paddingZeroes)
{
const auto text = QStringLiteral("%1").arg(value.toULongLong(), _paddingZeroWidth, 10, QLatin1Char('0'));
if(text != QLineEdit::text())
QLineEdit::setText(text);
}
else
{
const auto text = QString::number(value.toULongLong());
if(text != QLineEdit::text())
QLineEdit::setText(text);
}
}
break;
}

if(value != _value)
Expand All @@ -205,7 +252,7 @@ void NumericLineEdit::updateValue()
{
switch(_inputMode)
{
case DecMode:
case Int32Mode:
{
bool ok;
const auto value = text().toInt(&ok);
Expand All @@ -214,7 +261,7 @@ void NumericLineEdit::updateValue()
}
break;

case UnsignedMode:
case UInt32Mode:
{
bool ok;
const auto value = text().toUInt(&ok);
Expand Down Expand Up @@ -249,6 +296,24 @@ void NumericLineEdit::updateValue()
else internalSetValue(_value);
}
break;

case Int64Mode:
{
bool ok;
const auto value = text().toLongLong(&ok);
if(ok) internalSetValue(value);
else internalSetValue(_value);
}
break;

case UInt64Mode:
{
bool ok;
const auto value = text().toULongLong(&ok);
if(ok) internalSetValue(value);
else internalSetValue(_value);
}
break;
}
}

Expand Down Expand Up @@ -297,19 +362,19 @@ void NumericLineEdit::on_textChanged(const QString& text)
QVariant value;
switch(_inputMode)
{
case DecMode:
case Int32Mode:
{
bool ok;
const auto valueInt = text.toInt(&ok);
if(ok) value = qBound(_minValue.toInt(), valueInt, _maxValue.toInt());
}
break;

case UnsignedMode:
case UInt32Mode:
{
bool ok;
const auto valueInt = text.toUInt(&ok);
if(ok) value = qBound(_minValue.toUInt(), valueInt, _maxValue.toUInt());
const auto valueUInt = text.toUInt(&ok);
if(ok) value = qBound(_minValue.toUInt(), valueUInt, _maxValue.toUInt());
}
break;

Expand All @@ -336,6 +401,22 @@ void NumericLineEdit::on_textChanged(const QString& text)
if(ok) value = qBound(_minValue.toDouble(), valueDouble, _maxValue.toDouble());
}
break;

case Int64Mode:
{
bool ok;
const auto valueLongLong = text.toLongLong(&ok);
if(ok) value = qBound(_minValue.toLongLong(), valueLongLong, _maxValue.toLongLong());
}
break;

case UInt64Mode:
{
bool ok;
const auto valueULongLong = text.toULongLong(&ok);
if(ok) value = qBound(_minValue.toULongLong(), valueULongLong, _maxValue.toULongLong());
}
break;
}

if(value.isValid() && value != _value)
Expand All @@ -356,7 +437,7 @@ void NumericLineEdit::on_rangeChanged(const QVariant& bottom, const QVariant& to
setValidator(nullptr);
switch(_inputMode)
{
case DecMode:
case Int32Mode:
{
const int nums = QString::number(top.toInt()).length();
_paddingZeroWidth = qMax(1, nums);
Expand All @@ -366,7 +447,7 @@ void NumericLineEdit::on_rangeChanged(const QVariant& bottom, const QVariant& to
}
break;

case UnsignedMode:
case UInt32Mode:
{
const int nums = QString::number(top.toUInt()).length();
_paddingZeroWidth = qMax(1, nums);
Expand All @@ -389,6 +470,24 @@ void NumericLineEdit::on_rangeChanged(const QVariant& bottom, const QVariant& to
setMaxLength(INT16_MAX);
setValidator(new QDoubleValidator(bottom.toDouble(), top.toDouble(), 6, this));
break;

case Int64Mode:
{
const int nums = QString::number(top.toLongLong()).length();
_paddingZeroWidth = qMax(1, nums);
setMaxLength(qMax(1, nums));
setValidator(new QInt64Validator(bottom.toLongLong(), top.toLongLong(), this));
}
break;

case UInt64Mode:
{
const int nums = QString::number(top.toULongLong()).length();
_paddingZeroWidth = qMax(1, nums);
setMaxLength(qMax(1, nums));
setValidator(new QUIntValidator(bottom.toULongLong(), top.toULongLong(), this));
}
break;
}
internalSetValue(_value);
blockSignals(false);
Expand Down
8 changes: 5 additions & 3 deletions omodscan/controls/numericlineedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ class NumericLineEdit : public QLineEdit
public:
enum InputMode
{
DecMode = 0,
UnsignedMode,
Int32Mode = 0,
UInt32Mode,
HexMode,
FloatMode,
DoubleMode
DoubleMode,
Int64Mode,
UInt64Mode
};

explicit NumericLineEdit(QWidget* parent = nullptr);
Expand Down
Loading

0 comments on commit a92d341

Please sign in to comment.