How serhmarch/modbustools works
1. This repository is a Qt/C++ monorepo for two desktop applications: a Modbus client simulator and a Modbus server/simulator. The src/core tree holds the shared platform code, while src/client and src/server add app-specific behavior, UI, project types, and runtime logic.
2. The architecture is split into three main layers:
- shared core libraries and GUI widgets in src/core
- client-specific UI/runtime/project code in src/client
- server-specific UI/runtime/project/script code in src/server
This separation is important for diagramming because most screens, models, and runtime objects are app-local, but they reuse common project and UI abstractions from core.
3. The shared core subsystem provides common infrastructure: application shell, file/project management, plugin manager, runtime threading, SDK helpers, and reusable GUI components like project trees, dataview widgets, log view, help browser, settings dialogs, and address widgets. It is the foundation both apps build on.
4. Both applications use a common domain model centered on projects. The shared project layer defines the core entities Project, Port, Device, DataView, and Builder/DOM parsing. The client extends this with client-specific dataview behavior, while the server extends it with device references, simulation actions, and script modules.
5. The client app is organized around communication with remote Modbus devices. Its GUI includes project editing, dataview browsing, message sending, byte sending, scanning, and statistics. These features are backed by client runtime classes that turn project definitions into active port/device/message execution.
6. The client runtime boundary is fairly clear: project configuration is translated into runnable ports and devices, then executed through runtime threads. The send message, send bytes, and scanner tools act as side channels that inject requests into the same communication layer while sharing logging and statistics with normal traffic.
7. The server app is organized around emulating Modbus devices and their memory. Its GUI includes project editing, device management, dataview editing, script editors, script module management, simulation actions, and statistics. The server runtime converts the project into runnable ports, devices, scripts, and simulation tasks.
8. The server has an additional execution plane for Python scripting. Each device can have Init, Loop, and Final scripts, plus script modules embedded in the project. The src/server/python code and resource files provide the Python integration layer, while runtime classes isolate script execution from the main UI and Modbus I/O loop.
9. Data flow in both apps follows the same general pattern: project files are loaded into the DOM/project model, edited through GUI models/delegates, then compiled into runtime objects by builder classes. At runtime, port-level transports handle Modbus communication, device-level logic applies memory/dataview rules, and UI widgets observe logs, stats, and data state.
10. The protocol scope is broad and materially shapes the architecture: the tools support Modbus TCP, UDP, RTU, ASCII, and RTU/ASCII over TCP/UDP, with many function codes including read/write register/coil operations, diagnostics, file record access, device ID, FIFO queue, and more. This is why the UI has specialized send/scanner dialogs and why the server includes simulation and scripting hooks.
11. External dependencies and packaging are also part of the architecture. The project targets Qt 5.8+ and is based on the external ModbusLib library, included as a submodule. Build definitions exist for CMake and Qt .pro/.pri files, with Docker and GitHub Actions used for containerized image publishing.
12. The repository also includes examples and documentation as first-class artifacts: sample client projects, server scripts, Doxygen docs, screenshots, and troubleshooting notes. These are not runtime subsystems, but they reinforce the intended usage model and are useful for understanding how project, device, port, and script objects are expected to interact.
Main entry points: server/project Server project · core/project Project model · gui Server UI · client/project Client project
Components 23
Core
Shared libraries, project model, runtime, SDK, and reusable GUI
- Core shell · Application shell, file manager, plugin manager, and shared core entrypoints
src/core/core - Project model · Shared Project, Port, Device, DataView, DOM, and builder layer
src/core/project - Runtime core · Shared runtime task threads and execution support
src/core/runtime - Project UI · Shared project tree, models, delegates, and project dialogs
src/core/gui/project - Dataview UI · Shared dataview widgets, models, delegates, and editors
src/core/gui/dataview - Core widgets · Shared log view, statistics, help browser, settings, address widget, and dialogs
src/core/gui - SDK · Binary readers/writers, task interfaces, and shared helpers
src/core/sdk
Client
Modbus client simulator application
- Client UI · Main window, client-specific UI wiring, and window management
src/client/gui - Client project · Client-specific project, port, device, dataview, DOM, and builder extensions
src/client/project - Client runtime · Runnable ports, devices, messages, threads, and request execution
src/client/runtime - Client dataview · Client dataview browser, model, delegate, and manager
src/client/gui/dataview - Client tools · Send message, send bytes, scanner, and statistics dialogs
src/client/gui/sendmessage - Client project UI · Client project tree, models, delegates, and dialogs
src/client/gui/project
Server
Modbus server and device simulation application
- Server UI · Main window, output view, and server-specific UI wiring
src/server/gui - Server project · Server-specific project, device refs, dataview, sim actions, script modules, DOM, and builder
src/server/project - Server runtime · Runnable ports, devices, simulation actions, scripts, threads, and runtime coordination
src/server/runtime - Server dataview · Server dataview browser, model, delegate, and manager
src/server/gui/dataview - Device UI · Device management, device editor, and device UI model/delegate
src/server/gui/device - Script UI · Script editor, script manager, script module editor, and device script editors
src/server/gui/script - Sim actions · Simulation action browser, model, delegate, and editor dialogs
src/server/gui/simactions
Repo
Build, docs, examples, and packaging
- Build & packaging · CMake, Qt project files, Dockerfile, and GitHub Actions publishing
CMakeLists.txt - Docs & examples · Doxygen docs, README content, samples, screenshots, and troubleshooting notes
doc - ModbusLib · External Modbus protocol library used by both applications
modbus
Connections 35
- Core shell → Project model: manages · Core shell owns shared project lifecycle
- Core shell → Runtime core: orchestrates · Core shell coordinates runtime startup and shutdown
- Project model → SDK: uses · Shared project layer relies on SDK helpers and task types
- Project UI → Project model: edits · Project UI presents the shared project model
- Dataview UI → Project model: edits · Dataview UI binds to shared dataview entities
- Core widgets → Project model: observes · Shared dialogs and widgets reflect project state
- Core widgets → Runtime core: monitors · Log, statistics, and help views observe runtime behavior
- Client project → Project model: extends · Client domain specializes the shared project model
- Client UI → Client project UI: hosts · Client application shell hosts project editing screens
- Client UI → Client dataview: hosts · Client shell also hosts dataview browsing
- Client UI → Client tools: hosts · Client shell exposes message sending and scanner tools
- Client project UI → Client project: edits · Client project UI edits client-specific project data
- Client dataview → Client project: binds · Client dataview UI binds to client dataview objects
- Client tools → Client runtime: injects · Send message, bytes, and scanner tools drive the same communication layer
- Client runtime → Runtime core: builds on · Client runtime uses shared runtime threads and execution support
- Client runtime → Client project: compiles · Client runtime turns project definitions into runnable objects
- Server project → Project model: extends · Server domain specializes the shared project model
- Server UI → Server project: hosts · Server shell hosts project, device, script, and action screens
- Server UI → Server dataview: hosts · Server shell exposes dataview editing and browsing
- Server UI → Device UI: hosts · Server shell manages device editing and selection
- Server UI → Script UI: hosts · Server shell provides script editor workflows
- Server UI → Sim actions: hosts · Server shell exposes simulation action editing
- Server dataview → Server project: binds · Server dataview UI binds to server dataview objects
- Device UI → Server project: edits · Device UI edits server device definitions
- Script UI → Server project: edits · Script tools edit script modules and device scripts
- Sim actions → Server project: edits · Simulation action tools edit server actions
- Server runtime → Runtime core: builds on · Server runtime uses shared runtime threads and execution support
- Server runtime → Server project: compiles · Server runtime turns project definitions into runnable ports, devices, and scripts
- Server runtime → ModbusLib: uses · Server runtime depends on the external Modbus library
- Client runtime → ModbusLib: uses · Client runtime depends on the external Modbus library
- Build & packaging → Core shell: builds · Repo build config includes the shared core targets
- Build & packaging → Client UI: builds · Repo build config includes the client application
- Build & packaging → Server UI: builds · Repo build config includes the server application
- Docs & examples → Client project: documents · Examples and docs show client project usage
- Docs & examples → Server project: documents · Examples and docs show server project and scripting usage