-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathREADME.md.in
More file actions
354 lines (278 loc) · 13 KB
/
Copy pathREADME.md.in
File metadata and controls
354 lines (278 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# Open ModSim
[](https://github.com/sanny32/OpenModSim/releases)
[](https://github.com/sanny32/OpenModSim/releases/latest)
[](LICENSE.md)
Open ModSim is a free implimentation of modbus slave (server) utility for modbus-tcp and modbus-rtu protocols.
<img width="1292" height="759" alt="image" src=".github/assets/omodsim-dataview.png" />
<img width="1292" height="759" alt="image" src=".github/assets/omodsim-mapview.png" />
# Features
The following Modbus functions are available:
- Discrete Coils/Flags
```
0x01 - Read Coils
0x02 - Read Discrete Inputs
0x05 - Write Single Coil
0x0F - Write Multiple Coils
```
- Registers
```
0x03 - Read Holding Registers
0x04 - Read Input Registers
0x06 - Write Single Register
0x10 - Write Multiple Registers
0x16 - Mask Write Register
```
The following simulations are available:
- Discrete Coils/Flags
```
Random - simulate flag randomly
Toggle - simulate flag on/off periodicaly
```
- Registers
```
Random - simulate register randomly
Increment - simulate register from Low Limit to High Limit with a given Step
Decrement - simulate register from High Limit to Low Limit with a given Step
```
# Modbus Logging
<img width="1292" height="759" alt="image" src=".github/assets/omodsim-trafficview.png" />
# Extended Featues
- Modbus Message Parser
<img width="674" height="463" alt="image" src=".github/assets/omodsim-msg-parser.png" />
- Modbus Definitions
<img width="416" height="346" alt="image" src=".github/assets/omodsim-modbus-defs.png" />
- Error Simualtions
<img width="416" height="346" alt="image" src=".github/assets/omodsim-modbus-errsim.png" />
# Scripting
From version 1.2.0 Open ModSim supports scripting. Qt runtime implements the [ECMAScript Language Specification](http://www.ecma-international.org/publications/standards/Ecma-262.htm) standard, so Javascript is used to write code.
<img width="1288" height="749" alt="image" src=".github/assets/omodsim-script.png" />
Scripts can be launched in two modes: Once or Periodically. If you run script in Once mode the script will stop after it finishes executing. In Periodically mode, the script will start after a certain period of time until the user stops it or the method is called
```javascript
Script.stop();
```
> [!NOTE]
> In Periodically mode the whole script is re-executed on every period, so top-level variables are reset on each run. Only the code passed to `Script.onInit()` runs once, and only values kept in `Storage` persist between runs. Use `Storage.setItem()` / `Storage.getItem()` to keep state (counters, flags, etc.) across periods.
Here is an example of using the script in the Periodically mode
```javascript
/**************************************************************************/
/*
/* Example script that store value after 3 seconds
/*
***************************************************************************/
/* Set the server address base starts from one (1-based) */
Server.addressBase = AddressBase.Base1;
let deviceId = 1;
let address1 = 1;
let address10 = 10;
function reset()
{
/* Write to a Holding register at address1 zero value */
Server.writeHolding(address1, 0, deviceId);
}
/* init function */
function init()
{
reset();
/* Print server error if occured and stop script execution */
Server.onError(deviceId, (error)=> {
console.error(error);
Script.stop();
});
/* Runs when Hodling register value at address1 was changed */
Server.onChange(deviceId, Register.Holding, address1, (value)=>
{
if(value === 1)
{
/* Runs after 3 seconds and increase Holding register value at address10
* Then reset register value at address1 and stop script execution
*/
Script.setTimeout(function()
{
Server.writeHolding(address10, Server.readHolding(address10, deviceId) + 1, deviceId);
reset();
Script.stop();
}, 3000);
}
});
}
/* Runs once when script started */
Script.onInit(init);
```
# About supported operating systems
The following minimum operating system versions are supported for OpenModSim:
- <img src="docs/icons/logo_windows7.svg" width="16" height="16" /> **Microsoft Windows 7**
- <img src="docs/icons/logo_apple.svg" width="16" height="16" /> **macOS 15 (Sequoia)**
- <img src="docs/icons/logo_debian.svg" width="16" height="16" /> **Debian Linux 11**
- <img src="docs/icons/logo_ubuntu.svg" width="16" height="16" /> **Ubuntu Linux 22.04**
- <img src="docs/icons/logo_mint.png" width="16" height="16" /> **Mint Linux 22**
- <img src="docs/icons/logo_zorin.png" width="16" height="16" /> **Zorin OS 18**
- <img src="docs/icons/logo_fedora.svg" width="16" height="16" /> **Fedora Linux 43**
- <img src="docs/icons/logo_rocky.png" width="16" height="16" /> **Rocky Linux 9.7**
- <img src="docs/icons/logo_opensuse.svg" width="16" height="16" /> **OpenSuse Linux 15.6**
- <img src="docs/icons/logo_alt.png" width="16" height="16" /> **Alt Linux 11**
- <img src="docs/icons/logo_astra.png" width="18" height="18" /> **Astra Linux 1.7**
- <img src="docs/icons/logo_redos.png" width="16" height="16" /> **RedOS 8**
- <img src="docs/icons/logo_arch.svg" width="16" height="16" /> **Arch** (manual building only)
# Building
Building is available via cmake (with installed Qt version 5.15 and above) or Qt Creator. Supports both OS Microsoft Windows and Linux.
> [!NOTE]
> Building from source requires CMake version @CMAKE_MIN_REQ_VERSION@ or newer.
## Microsoft Windows Building
The minimum supported version of Microsoft Windows for building OpenModSim from sources is Windows 10.
1. Install latest [git](https://git-scm.com/downloads/win) version
2. Run Windows PowerShell terminal as an Administrator
3. Clone OpenModSim sources from github repository
```powershell
git clone https://github.com/sanny32/OpenModSim.git
```
4. Go to OpenModSim folder
```powershell
cd OpenModSim
```
5. Allow script execution in PowerShell terminal
```powershell
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
```
6. Run the build script
```powershell
.\build.ps1
```
If you need to specify Qt framework major version (5 or 6), you can do it in the parameters
- `.\build.ps1 -qt5` or `.\build.ps1 -qt6`
To enable the experimental [Qlementine](https://github.com/oclero/qlementine) application style (requires Qt6 >= 6.8):
- `.\build.ps1 -qlementine`
The build script supports building the application only for 64-bit architecture.
## Linux Building
1. Install [git](https://git-scm.com/downloads/linux) for your Linux distribution
2. Run the following commands from the console:
```bash
git clone https://github.com/sanny32/OpenModSim.git
```
```bash
cd OpenModSim
```
```bash
./build.sh
```
If you need to specify Qt framework major version (5 or 6), you can do it in the parameters
- `./build.sh -qt5` or `./build.sh -qt6`
To enable the experimental [Qlementine](https://github.com/oclero/qlementine) application style (requires Qt6 >= 6.8):
- `./build.sh -qlementine`
## macOS Building
The minimum supported version of macOS for building OpenModSim from sources is macOS 15 (Sequoia).
1. Install [Homebrew](https://brew.sh) if not already installed
2. Install required dependencies:
```bash
brew install qt@6 cmake ninja
```
3. Clone OpenModSim sources from github repository:
```bash
git clone https://github.com/sanny32/OpenModSim.git
```
4. Go to OpenModSim folder:
```bash
cd OpenModSim
```
5. Run the build script:
```bash
./build-macos.sh
```
> [!NOTE]
> On macOS, OpenModSim uses [**Qlementine**](https://github.com/oclero/qlementine) style and [**Qlementine Icons**](https://github.com/oclero/qlementine-icons) by default when building with **Qt6 >= 6.8**.
> These dependencies are fetched automatically during CMake configure and improve icon/theme consistency on macOS.
> If you build with Qt5 or Qt6 < 6.8, OpenModSim falls back to the standard built-in style.
The build script generates a macOS application bundle (`omodsim.app`). To run the application:
```bash
open build-omodsim-Qt_*/omodsim.app
```
# Install from [binary distributions](https://github.com/sanny32/OpenModSim/releases/latest)
Below are the methods for installing the OpenModSim for different OS
## <img src="docs/icons/logo_windows.svg" width="16" height="16"> Microsoft Windows
Run the installer:
- For 32-bit Windows: `qt5-omodsim@VERSION_MAJOR@-@PROJECT_VERSION@_x86.exe`
- For 64-bit Windows: `qt5-omodsim@VERSION_MAJOR@-@PROJECT_VERSION@_x64.exe` or `qt6-omodsim@VERSION_MAJOR@-@PROJECT_VERSION@_x64.exe`
## <img src="docs/icons/logo_apple.svg" width="16" height="16"> macOS
### Install
Open the DMG package:
```bash
open qt6-omodsim@VERSION_MAJOR@-@PROJECT_VERSION@_arm64.dmg
```
Then drag `Open ModSim @VERSION_MAJOR@.app` to the `Applications` folder.
Before the first launch, allow the application to run in `System Settings` > `Privacy & Security`, or remove the quarantine attribute from the command line:
```bash
xattr -dr com.apple.quarantine "/Applications/Open ModSim @VERSION_MAJOR@.app"
```
Run the application:
```bash
open "/Applications/Open ModSim @VERSION_MAJOR@.app"
```
### Remove
To remove the application, move it to Trash or run:
```bash
rm -rf "/Applications/Open ModSim @VERSION_MAJOR@.app"
```
## <img src="docs/icons/logo_debian.svg" width="20" height="20"> Debian • <img src="docs/icons/logo_ubuntu.svg" width="20" height="20"> Ubuntu • <img width="20" height="20" src="docs/icons/logo_mint.png" /> Mint • <img src="docs/icons/logo_zorin.png" width="20" height="20"> Zorin • <img width="22" height="22" src="docs/icons/logo_astra.png" /> Astra Linux
### Install
Install the DEB package from the command line:
```bash
sudo apt install ./qt6-omodsim@VERSION_MAJOR@_@PROJECT_VERSION@-1_amd64.deb
```
or if you want to use Qt5 libraries:
```bash
sudo apt install ./qt5-omodsim@VERSION_MAJOR@_@PROJECT_VERSION@-1_amd64.deb
```
### Remove
To remove the DEB package run:
```bash
sudo apt remove qt6-omodsim@VERSION_MAJOR@
```
or for Qt5 package:
```bash
sudo apt remove qt5-omodsim@VERSION_MAJOR@
```
## <img src="docs/icons/logo_redhat.svg" width="24" height="24"> RedHat • <img src="docs/icons/logo_fedora.svg" width="20" height="20"> Fedora • <img src="docs/icons/logo_rocky.png" width="20" height="20"> Rocky • <img width="20" height="20" src="docs/icons/logo_redos.png" /> RedOS Linux
### Install
Install the RPM package from the command line:
```bash
sudo dnf install ./qt6-omodsim@VERSION_MAJOR@-@PROJECT_VERSION@-1.x86_64.rpm
```
### Remove
To remove the RPM package run:
```bash
sudo dnf remove qt6-omodsim@VERSION_MAJOR@
```
## <img src="docs/icons/logo_alt.png" width="24" height="24"> Alt Linux
### Install
Install the RPM package from the command line as root user:
```bash
apt-get install ./qt6-omodsim@VERSION_MAJOR@-@PROJECT_VERSION@-1.x86_64.rpm
```
### Remove
To remove the RPM package run as root user:
```bash
apt-get remove qt6-omodsim@VERSION_MAJOR@
```
## <img width="20" height="20" src="docs/icons/logo_suse.png" /> SUSE • <img src="docs/icons/logo_opensuse.svg" width="24" height="24" /> OpenSUSE Linux
### Install
Import qt6-omodsim@VERSION_MAJOR@.rpm.pubkey to rpm repository:
```bash
sudo rpm --import qt6-omodsim@VERSION_MAJOR@.rpm.pubkey
```
Install the RPM package using Zypper:
```bash
sudo zypper install ./qt6-omodsim@VERSION_MAJOR@-@PROJECT_VERSION@-1.x86_64.rpm
```
### Remove
To remove the RPM package run:
```bash
sudo zypper remove qt6-omodsim@VERSION_MAJOR@
```
# Code Signing Sponsor
Windows binaries for this project are signed thanks to **SignPath Foundation**.
* 🔐 **Free code signing service:** [SignPath.io](https://signpath.io)
* 📜 **Certificate provider:** [SignPath Foundation](https://signpath.org)
# MIT License
Copyright 2023-2026 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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.