# sanny32/openmodscan architecture

> Architecture diagram of the GitHub repository sanny32/openmodscan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sanny32/openmodscan
- Repository: https://github.com/sanny32/openmodscan

## Overview

OpenModScan is a Qt Modbus master/client for TCP, RTU, and RTU-over-TCP. The principal workflow is to launch the desktop UI, configure a connection, issue Modbus reads or writes, and inspect returned data and message logs; the README also documents address scanning, protocol scanning, raw-message parsing, and user messages. The graph preserves those product branches, but several UI-to-feature links are dashed because the relevant wiring was not sampled. The sampled sources and index support the client/transport and message-format relationships shown.

Main entry points: [`src/mainwindow.cpp`](https://github.com/sanny32/openmodscan/blob/main/src/mainwindow.cpp) (Main window), [`src/modbusclient.cpp`](https://github.com/sanny32/openmodscan/blob/main/src/modbusclient.cpp) (Read/write requests), [`src/qmodbusadutcp.h`](https://github.com/sanny32/openmodscan/blob/main/src/qmodbusadutcp.h) (ADU framing), [`src/controls/outputwidget.cpp`](https://github.com/sanny32/openmodscan/blob/main/src/controls/outputwidget.cpp) (Data output)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop application"]
  node_entry["Application entry<br/>[main.cpp]"]
  node_main_window["Main window<br/>[mainwindow.cpp]"]
  node_connection_details["Connection settings"]
end

subgraph group_operations["Modbus operations"]
  node_read_write["Read/write requests<br/>[modbusclient.cpp]"]
  node_address_scan["Address scan"]
  node_protocol_scan["Protocol scanner"]
  node_raw_parser["Message parser"]
  node_user_message["User messages<br/>[dialogusermsg.cpp]"]
end

subgraph group_protocol["Protocol runtime"]
  node_client_private["Client engine"]
  node_tcp_transport["TCP transport"]
  node_rtu_transport["RTU transport"]
  node_rtu_tcp_transport["RTU over TCP"]
  node_adu["ADU framing<br/>[qmodbusadutcp.h]"]
  node_messages["Modbus messages<br/>[modbusmessage.cpp]"]
end

subgraph group_inspection["Data and inspection"]
  node_output["Data output<br/>[outputwidget.cpp]"]
  node_message_view["Message viewer"]
  node_logging["Modbus logging"]
end

subgraph group_utilities["Shared utilities"]
  node_data_formats["Display definitions"]
  node_numeric_utils["Numeric conversion<br/>[numericutils.h]"]
  node_format_utils["Value formatting<br/>[formatutils.h]"]
  node_ansi_utils["ANSI utilities<br/>[ansiutils.h]"]
end

node_operator(("Operator"))

node_operator -->|"launches"| node_entry
node_entry -->|"opens"| node_main_window
node_main_window -.->|"configures"| node_connection_details
node_main_window -.->|"initiates"| node_read_write
node_main_window -.->|"offers"| node_address_scan
node_main_window -.->|"offers"| node_protocol_scan
node_main_window -.->|"offers"| node_raw_parser
node_main_window -.->|"offers"| node_user_message
node_read_write -.->|"delegates to"| node_client_private
node_read_write -->|"selects transport"| node_tcp_transport
node_read_write -->|"selects transport"| node_rtu_transport
node_read_write -->|"selects transport"| node_rtu_tcp_transport
node_tcp_transport -->|"frames TCP"| node_adu
node_rtu_transport -->|"uses serial framing"| node_adu
node_rtu_tcp_transport -->|"uses serial framing"| node_adu
node_messages -->|"wraps protocol data"| node_adu
node_read_write -.->|"updates results"| node_output
node_read_write -.->|"reports traffic"| node_logging
node_output -->|"displays messages"| node_message_view
node_output -->|"uses definitions"| node_data_formats
node_message_view -->|"interprets"| node_messages
node_message_view -->|"formats values"| node_format_utils
node_format_utils -->|"converts values"| node_numeric_utils
node_ansi_utils -->|"uses conversions"| node_numeric_utils

click node_entry "https://github.com/sanny32/openmodscan/blob/main/src/main.cpp"
click node_main_window "https://github.com/sanny32/openmodscan/blob/main/src/mainwindow.cpp"
click node_connection_details "https://github.com/sanny32/openmodscan/blob/main/src/connectiondetails.h"
click node_read_write "https://github.com/sanny32/openmodscan/blob/main/src/modbusclient.cpp"
click node_address_scan "https://github.com/sanny32/openmodscan/blob/main/src/dialogs/dialogaddressscan.cpp"
click node_protocol_scan "https://github.com/sanny32/openmodscan/blob/main/src/dialogs/dialogmodbusscanner.cpp"
click node_raw_parser "https://github.com/sanny32/openmodscan/blob/main/src/dialogs/dialogmsgparser.cpp"
click node_user_message "https://github.com/sanny32/openmodscan/blob/main/src/dialogs/dialogusermsg.cpp"
click node_client_private "https://github.com/sanny32/openmodscan/blob/main/src/modbusclientprivate.cpp"
click node_tcp_transport "https://github.com/sanny32/openmodscan/blob/main/src/modbustcpclient.cpp"
click node_rtu_transport "https://github.com/sanny32/openmodscan/blob/main/src/modbusrtuclient.cpp"
click node_rtu_tcp_transport "https://github.com/sanny32/openmodscan/blob/main/src/modbusrtutcpclient.cpp"
click node_adu "https://github.com/sanny32/openmodscan/blob/main/src/qmodbusadutcp.h"
click node_messages "https://github.com/sanny32/openmodscan/blob/main/src/modbusmessages/modbusmessage.cpp"
click node_output "https://github.com/sanny32/openmodscan/blob/main/src/controls/outputwidget.cpp"
click node_message_view "https://github.com/sanny32/openmodscan/blob/main/src/controls/modbusmessagewidget.cpp"
click node_logging "https://github.com/sanny32/openmodscan/blob/main/src/controls/modbuslogwidget.cpp"
click node_data_formats "https://github.com/sanny32/openmodscan/blob/main/src/displaydefinition.h"
click node_numeric_utils "https://github.com/sanny32/openmodscan/blob/main/src/numericutils.h"
click node_format_utils "https://github.com/sanny32/openmodscan/blob/main/src/formatutils.h"
click node_ansi_utils "https://github.com/sanny32/openmodscan/blob/main/src/ansiutils.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_main_window,node_connection_details toneBlue
class node_read_write,node_address_scan,node_protocol_scan,node_raw_parser,node_user_message toneAmber
class node_client_private,node_tcp_transport,node_rtu_transport,node_rtu_tcp_transport,node_adu,node_messages toneMint
class node_output,node_message_view,node_logging toneRose
class node_data_formats,node_numeric_utils,node_format_utils,node_ansi_utils,node_operator toneIndigo
```

## Components

### Desktop application

- [Application entry](https://github.com/sanny32/openmodscan/blob/main/src/main.cpp): `src/main.cpp`
- [Main window](https://github.com/sanny32/openmodscan/blob/main/src/mainwindow.cpp): `src/mainwindow.cpp`
- [Connection settings](https://github.com/sanny32/openmodscan/blob/main/src/connectiondetails.h): `src/connectiondetails.h`

### Modbus operations

- [Read/write requests](https://github.com/sanny32/openmodscan/blob/main/src/modbusclient.cpp): `src/modbusclient.cpp`
- [Address scan](https://github.com/sanny32/openmodscan/blob/main/src/dialogs/dialogaddressscan.cpp): `src/dialogs/dialogaddressscan.cpp`
- [Protocol scanner](https://github.com/sanny32/openmodscan/blob/main/src/dialogs/dialogmodbusscanner.cpp): `src/dialogs/dialogmodbusscanner.cpp`
- [Message parser](https://github.com/sanny32/openmodscan/blob/main/src/dialogs/dialogmsgparser.cpp): `src/dialogs/dialogmsgparser.cpp`
- [User messages](https://github.com/sanny32/openmodscan/blob/main/src/dialogs/dialogusermsg.cpp): `src/dialogs/dialogusermsg.cpp`

### Protocol runtime

- [Client engine](https://github.com/sanny32/openmodscan/blob/main/src/modbusclientprivate.cpp): `src/modbusclientprivate.cpp`
- [TCP transport](https://github.com/sanny32/openmodscan/blob/main/src/modbustcpclient.cpp): `src/modbustcpclient.cpp`
- [RTU transport](https://github.com/sanny32/openmodscan/blob/main/src/modbusrtuclient.cpp): `src/modbusrtuclient.cpp`
- [RTU over TCP](https://github.com/sanny32/openmodscan/blob/main/src/modbusrtutcpclient.cpp): `src/modbusrtutcpclient.cpp`
- [ADU framing](https://github.com/sanny32/openmodscan/blob/main/src/qmodbusadutcp.h): `src/qmodbusadutcp.h`
- [Modbus messages](https://github.com/sanny32/openmodscan/blob/main/src/modbusmessages/modbusmessage.cpp): `src/modbusmessages/modbusmessage.cpp`

### Data and inspection

- [Data output](https://github.com/sanny32/openmodscan/blob/main/src/controls/outputwidget.cpp): `src/controls/outputwidget.cpp`
- [Message viewer](https://github.com/sanny32/openmodscan/blob/main/src/controls/modbusmessagewidget.cpp): `src/controls/modbusmessagewidget.cpp`
- [Modbus logging](https://github.com/sanny32/openmodscan/blob/main/src/controls/modbuslogwidget.cpp): `src/controls/modbuslogwidget.cpp`

### Shared utilities

- [Display definitions](https://github.com/sanny32/openmodscan/blob/main/src/displaydefinition.h): `src/displaydefinition.h`
- [Numeric conversion](https://github.com/sanny32/openmodscan/blob/main/src/numericutils.h): `src/numericutils.h`
- [Value formatting](https://github.com/sanny32/openmodscan/blob/main/src/formatutils.h): `src/formatutils.h`
- [ANSI utilities](https://github.com/sanny32/openmodscan/blob/main/src/ansiutils.h): `src/ansiutils.h`

### Other components

- **Operator**

## Connections

- Operator → Application entry: launches (evidence: `src/main.cpp`)
- Application entry → Main window: opens (evidence: `src/main.cpp`)
- Main window → Connection settings: configures
- Main window → Read/write requests: initiates
- Main window → Address scan: offers
- Main window → Protocol scanner: offers
- Main window → Message parser: offers
- Main window → User messages: offers
- Read/write requests → Client engine: delegates to
- Read/write requests → TCP transport: selects transport (evidence: `src/modbusclient.cpp`)
- Read/write requests → RTU transport: selects transport (evidence: `src/modbusclient.cpp`)
- Read/write requests → RTU over TCP: selects transport (evidence: `src/modbusclient.cpp`)
- TCP transport → ADU framing: frames TCP (evidence: `src/modbustcpclient.cpp`)
- RTU transport → ADU framing: uses serial framing (evidence: `src/modbusrtuclient.cpp`)
- RTU over TCP → ADU framing: uses serial framing (evidence: `src/modbusrtutcpclient.cpp`)
- Modbus messages → ADU framing: wraps protocol data
- Read/write requests → Data output: updates results
- Read/write requests → Modbus logging: reports traffic
- Data output → Message viewer: displays messages (evidence: `src/controls/outputwidget.cpp`)
- Data output → Display definitions: uses definitions
- Message viewer → Modbus messages: interprets (evidence: `src/controls/modbusmessagewidget.cpp`)
- Message viewer → Value formatting: formats values (evidence: `src/controls/modbusmessagewidget.cpp`)
- Value formatting → Numeric conversion: converts values (evidence: `src/formatutils.h`)
- ANSI utilities → Numeric conversion: uses conversions (evidence: `src/ansiutils.h`)
