Skip to content

Commit 3d8a31e

Browse files
committed
Merge remote-tracking branch 'origin/dev'
2 parents b9fa162 + 52f9b73 commit 3d8a31e

26 files changed

+2437
-137
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Script.onInit(init);
108108
Now building is available via cmake (with installed Qt version 5.15 and above) or Qt Creator. Supports both OS Microsoft Windows and Linux.
109109

110110
## MIT License
111-
Copyright 2024 Alexandr Ananev [[email protected]]
111+
Copyright 2025 Alexandr Ananev [[email protected]]
112112

113113
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:
114114

omodsim/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.25)
22

3-
project(OpenModSim
4-
VERSION 1.8.0
3+
project(omodsim
4+
VERSION 1.8.1
55
LANGUAGES CXX)
66

77
set(CMAKE_AUTOUIC ON)
@@ -234,6 +234,7 @@ set(UI_FILES
234234

235235
set(TS_FILES
236236
translations/omodsim_ru.ts
237+
translations/omodsim_zh.ts
237238
)
238239

239240
set(JSHELP_INPUT "${CMAKE_SOURCE_DIR}/docs/jshelp.qhcp")

omodsim/dialogs/dialogdisplaydefinition.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ DialogDisplayDefinition::DialogDisplayDefinition(DisplayDefinition dd, QWidget*
2626
ui->lineEditLogLimit->setValue(dd.LogViewLimit);
2727
ui->comboBoxPointType->setCurrentPointType(dd.PointType);
2828

29+
ui->checkBoxGlobalMap->setChecked(dd.UseGlobalUnitMap);
30+
2931
ui->buttonBox->setFocus();
3032
}
3133

@@ -48,11 +50,11 @@ void DialogDisplayDefinition::accept()
4850
_displayDefinition.Length = ui->lineEditLength->value<int>();
4951
_displayDefinition.LogViewLimit = ui->lineEditLogLimit->value<int>();
5052
_displayDefinition.ZeroBasedAddress = (ui->comboBoxAddressBase->currentAddressBase() == AddressBase::Base0);
53+
_displayDefinition.UseGlobalUnitMap = ui->checkBoxGlobalMap->isChecked();
5154

5255
QFixedSizeDialog::accept();
5356
}
5457

55-
5658
///
5759
/// \brief DialogDisplayDefinition::on_comboBoxAddressBase_currentIndexChanged
5860
/// \param index

omodsim/dialogs/dialogdisplaydefinition.ui

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>350</width>
10-
<height>285</height>
9+
<width>352</width>
10+
<height>387</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -23,7 +23,7 @@
2323
<set>Qt::AlignmentFlag::AlignHCenter|Qt::AlignmentFlag::AlignTop</set>
2424
</property>
2525
<property name="leftMargin">
26-
<number>40</number>
26+
<number>50</number>
2727
</property>
2828
<property name="topMargin">
2929
<number>9</number>
@@ -152,22 +152,15 @@
152152
</property>
153153
</widget>
154154
</item>
155-
<item row="2" column="0">
156-
<widget class="QLabel" name="labelPointAddress">
157-
<property name="text">
158-
<string>Point Address:</string>
159-
</property>
160-
</widget>
161-
</item>
162-
<item row="4" column="0">
163-
<widget class="QLabel" name="labelLength">
155+
<item row="3" column="0">
156+
<widget class="QLabel" name="labelAddressBase">
164157
<property name="text">
165-
<string>Length:</string>
158+
<string>Address Base:</string>
166159
</property>
167160
</widget>
168161
</item>
169-
<item row="4" column="1">
170-
<widget class="NumericLineEdit" name="lineEditLength">
162+
<item row="3" column="1">
163+
<widget class="AddressBaseComboBox" name="comboBoxAddressBase">
171164
<property name="sizePolicy">
172165
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
173166
<horstretch>0</horstretch>
@@ -176,19 +169,20 @@
176169
</property>
177170
<property name="minimumSize">
178171
<size>
179-
<width>0</width>
172+
<width>100</width>
180173
<height>25</height>
181174
</size>
182175
</property>
183-
<property name="maximumSize">
184-
<size>
185-
<width>60</width>
186-
<height>16777215</height>
187-
</size>
176+
</widget>
177+
</item>
178+
<item row="4" column="0">
179+
<widget class="QLabel" name="labelPointAddress">
180+
<property name="text">
181+
<string>Point Address:</string>
188182
</property>
189183
</widget>
190184
</item>
191-
<item row="2" column="1">
185+
<item row="4" column="1">
192186
<widget class="NumericLineEdit" name="lineEditPointAddress">
193187
<property name="sizePolicy">
194188
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@@ -210,15 +204,15 @@
210204
</property>
211205
</widget>
212206
</item>
213-
<item row="3" column="0">
214-
<widget class="QLabel" name="labelAddressBase">
207+
<item row="7" column="0">
208+
<widget class="QLabel" name="labelLength">
215209
<property name="text">
216-
<string>Address Base:</string>
210+
<string>Length:</string>
217211
</property>
218212
</widget>
219213
</item>
220-
<item row="3" column="1">
221-
<widget class="AddressBaseComboBox" name="comboBoxAddressBase">
214+
<item row="7" column="1">
215+
<widget class="NumericLineEdit" name="lineEditLength">
222216
<property name="sizePolicy">
223217
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
224218
<horstretch>0</horstretch>
@@ -227,15 +221,44 @@
227221
</property>
228222
<property name="minimumSize">
229223
<size>
230-
<width>100</width>
224+
<width>0</width>
231225
<height>25</height>
232226
</size>
233227
</property>
228+
<property name="maximumSize">
229+
<size>
230+
<width>60</width>
231+
<height>16777215</height>
232+
</size>
233+
</property>
234234
</widget>
235235
</item>
236236
</layout>
237237
</widget>
238238
</item>
239+
<item>
240+
<widget class="QCheckBox" name="checkBoxGlobalMap">
241+
<property name="text">
242+
<string>Use Global Address Map (Unallocated registers will be zero)</string>
243+
</property>
244+
</widget>
245+
</item>
246+
<item>
247+
<spacer name="verticalSpacer">
248+
<property name="orientation">
249+
<enum>Qt::Orientation::Vertical</enum>
250+
</property>
251+
<property name="sizeType">
252+
<enum>QSizePolicy::Policy::Fixed</enum>
253+
</property>
254+
<property name="sizeHint" stdset="0">
255+
<size>
256+
<width>5</width>
257+
<height>9</height>
258+
</size>
259+
</property>
260+
</spacer>
261+
</item>
239262
<item>
240263
<widget class="QDialogButtonBox" name="buttonBox">
241264
<property name="orientation">
@@ -271,7 +294,6 @@
271294
<tabstops>
272295
<tabstop>lineEditSlaveAddress</tabstop>
273296
<tabstop>comboBoxPointType</tabstop>
274-
<tabstop>lineEditLength</tabstop>
275297
</tabstops>
276298
<resources/>
277299
<connections>

omodsim/displaydefinition.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct DisplayDefinition
1616
quint16 Length = 100;
1717
quint16 LogViewLimit = 30;
1818
bool ZeroBasedAddress = false;
19+
bool UseGlobalUnitMap = false;
1920

2021
void normalize()
2122
{
@@ -42,6 +43,7 @@ inline QSettings& operator <<(QSettings& out, const DisplayDefinition& dd)
4243
out.setValue("DisplayDefinition/Length", dd.Length);
4344
out.setValue("DisplayDefinition/LogViewLimit", dd.LogViewLimit);
4445
out.setValue("DisplayDefinition/ZeroBasedAddress", dd.ZeroBasedAddress);
46+
out.setValue("DisplayDefinition/UseGlobalUnitMap", dd.UseGlobalUnitMap);
4547

4648
return out;
4749
}
@@ -60,6 +62,7 @@ inline QSettings& operator >>(QSettings& in, DisplayDefinition& dd)
6062
dd.Length = in.value("DisplayDefinition/Length", 100).toUInt();
6163
dd.LogViewLimit = in.value("DisplayDefinition/LogViewLimit", 30).toUInt();
6264
dd.ZeroBasedAddress = in.value("DisplayDefinition/ZeroBasedAddress").toBool();
65+
dd.UseGlobalUnitMap = in.value("DisplayDefinition/UseGlobalUnitMap").toBool();
6366

6467
dd.normalize();
6568
return in;

omodsim/docs/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ <h1 class="title">JavaScript Help</h1>
134134
</li>
135135
<li class="object"><a href="#server"><strong>Server</strong></a>
136136
<ul class="level2">
137+
<li><a href="#server.addressbase">Server.addressBase</a></li>
137138
<li><a href="#server.onchange">Server.onChange</a></li>
138139
<li><a href="#server.readcoil">Server.readCoil</a></li>
139140
<li><a href="#server.readdiscrete">Server.readDiscrete</a></li>
@@ -157,6 +158,7 @@ <h1 class="title">JavaScript Help</h1>
157158
<li><a href="#server.writeunint64">Server.writeUInt64</a></li>
158159
<li><a href="#server.writedouble">Server.writeDouble</a></li>
159160
<li><a href="#server.writefloat">Server.writeFloat</a></li>
161+
<li><a href="#server.useglobalunitmap">Server.useGlobalUnitMap</a></li>
160162
</ul>
161163
</li>
162164
<li class="object"><a href="#storage"><strong>Storage</strong></a>
@@ -633,6 +635,16 @@ <h1 id="script">Script</h1>
633635
<h1 id="server">Server</h1>
634636
</div>
635637
<div class="section-content"><p>The <strong><code>Server</code></strong> object provides access to the MODBUS server functionality.</p></div>
638+
<section aria-labelledby="static_properties"><h2 id="script.static_properties">Static properties</h2><div class="section-content"><dl>
639+
<dt id="server.addressbase"><code>Server.addressBase</code></dt>
640+
<dd>
641+
<p>Returns or sets <a href="#addressbase">addressbase</a> of the Server object.</p>
642+
</dd>
643+
<dt id="server.useglobalunitmap"><code>Server.useGlobalUnitMap</code></dt>
644+
<dd>
645+
<p>Returns or sets global address map usage. Unallocated registers will be zero.</p>
646+
</dd>
647+
</dl>
636648
<section aria-labelledby="static_methods"><h2 id="server.static_methods">Static methods</h2><div class="section-content"><dl>
637649
<dt id="server.onchange"><code>Server.onChange(Register, address, functionRef)</code></dt>
638650
<dd>

omodsim/docs/index_ru.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ <h1 class="title">Справка по JavaScript</h1>
134134
</li>
135135
<li class="object"><a href="#server"><strong>Server</strong></a>
136136
<ul class="level2">
137+
<li><a href="#server.addressbase">Server.addressBase</a></li>
137138
<li><a href="#server.onchange">Server.onChange</a></li>
138139
<li><a href="#server.readcoil">Server.readCoil</a></li>
139140
<li><a href="#server.readdiscrete">Server.readDiscrete</a></li>
@@ -157,6 +158,7 @@ <h1 class="title">Справка по JavaScript</h1>
157158
<li><a href="#server.writeunint64">Server.writeUInt64</a></li>
158159
<li><a href="#server.writedouble">Server.writeDouble</a></li>
159160
<li><a href="#server.writefloat">Server.writeFloat</a></li>
161+
<li><a href="#server.useglobalunitmap">Server.useGlobalUnitMap</a></li>
160162
</ul>
161163
</li>
162164
<li class="object"><a href="#storage"><strong>Storage</strong></a>
@@ -633,6 +635,16 @@ <h1 id="script">Script</h1>
633635
<h1 id="server">Server</h1>
634636
</div>
635637
<div class="section-content"><p>Объект <strong><code>Server</code></strong> обеспечивает доступ к функциям сервера MODBUS.</p></div>
638+
<section aria-labelledby="static_properties"><h2 id="script.static_properties">Статические свойства</h2><div class="section-content"><dl>
639+
<dt id="server.addressbase"><code>Server.addressBase</code></dt>
640+
<dd>
641+
<p>Возвращает или устанавливает нумерацию <a href="#addressbase">адресного пространства</a> сервера.</p>
642+
</dd>
643+
<dt id="server.useglobalunitmap"><code>Server.useGlobalUnitMap</code></dt>
644+
<dd>
645+
<p>Возвращает или устанавливает использование глобальной карты адресов. Неразмеченные регистры будут занулены.</p>
646+
</dd>
647+
</dl>
636648
<section aria-labelledby="static_methods"><h2 id="server.static_methods">Статические методы</h2><div class="section-content"><dl>
637649
<dt id="server.onchange"><code>Server.onChange(Register, address, functionRef)</code></dt>
638650
<dd>

omodsim/formmodsim.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ DisplayDefinition FormModSim::displayDefinition() const
138138
dd.PointType = ui->comboBoxModbusPointType->currentPointType();
139139
dd.Length = ui->lineEditLength->value<int>();
140140
dd.ZeroBasedAddress = ui->lineEditAddress->range<int>().from() == 0;
141+
dd.UseGlobalUnitMap = _mbMultiServer.useGlobalUnitMap();
141142

142143
return dd;
143144
}
@@ -167,6 +168,8 @@ void FormModSim::setDisplayDefinition(const DisplayDefinition& dd)
167168
ui->comboBoxModbusPointType->setCurrentPointType(dd.PointType);
168169
ui->comboBoxModbusPointType->blockSignals(false);
169170

171+
_mbMultiServer.setUseGlobalUnitMap(dd.UseGlobalUnitMap);
172+
170173
onDefinitionChanged();
171174
}
172175

omodsim/jsobjects/server.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ void Server::setAddressBase(Address::Base base)
4545
_addressBase = base;
4646
}
4747

48+
///
49+
/// \brief Server::useGlobalUnitMap
50+
/// \return
51+
///
52+
bool Server::useGlobalUnitMap() const
53+
{
54+
return _mbMultiServer->useGlobalUnitMap();
55+
}
56+
57+
///
58+
/// \brief Server::setUseGlobalUnitMap
59+
/// \param value
60+
///
61+
void Server::setUseGlobalUnitMap(bool value)
62+
{
63+
_mbMultiServer->setUseGlobalUnitMap(value);
64+
}
65+
4866
///
4967
/// \brief Server::readHolding
5068
/// \param address

omodsim/jsobjects/server.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ class Server : public QObject
4141
~Server() override;
4242

4343
Q_PROPERTY(Address::Base addressBase READ addressBase WRITE setAddressBase);
44+
Q_PROPERTY(bool useGlobalUnitMap READ useGlobalUnitMap WRITE setUseGlobalUnitMap);
4445

4546
Address::Base addressBase() const;
47+
bool useGlobalUnitMap() const;
4648

4749
Q_INVOKABLE quint16 readHolding(quint16 address) const;
4850
Q_INVOKABLE void writeHolding(quint16 address, quint16 value);
@@ -81,6 +83,7 @@ class Server : public QObject
8183

8284
public slots:
8385
void setAddressBase(Address::Base base);
86+
void setUseGlobalUnitMap(bool value);
8487

8588
private slots:
8689
void on_dataChanged(const QModbusDataUnit& data);

0 commit comments

Comments
 (0)