# zzjimo/visa-tool architecture

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

- Interactive diagram: https://gitdiagram.com/zzjimo/visa-tool
- Repository: https://github.com/zzjimo/visa-tool

## Overview

VisaTool is an MFC Windows application for controlling a VISA-connected instrument, with a TCP server that accepts newline-separated commands and returns query results or errors. The demonstrated path is a TCP client request through TcpServer to the instrument operations exposed by myThread. The README identifies the main dialog but gives only MFC template documentation; the dialog and myThread implementation were not sampled, so their internal workflow and UI wiring remain uncertain.

Main entry points: [`TcpServer.cpp`](https://github.com/zzjimo/visa-tool/blob/main/TcpServer.cpp) (TCP server), [`VisaToolDlg.cpp`](https://github.com/zzjimo/visa-tool/blob/main/VisaToolDlg.cpp) (Main dialog), [`myThread.cpp`](https://github.com/zzjimo/visa-tool/blob/main/myThread.cpp) (Instrument operations), [`visa/visa.h`](https://github.com/zzjimo/visa-tool/blob/main/visa/visa.h) (VISA API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application UI"]
  node_dialog["Main dialog<br/>[VisaToolDlg.cpp]"]
end

subgraph group_control["Instrument control"]
  node_tcp["TCP server<br/>[TcpServer.cpp]"]
  node_thread["Instrument operations<br/>[myThread.cpp]"]
end

subgraph group_support["VISA support"]
  node_helpers["Shared helpers<br/>[stdafx.cpp]"]
  node_visa_api["VISA API<br/>[visa.h]"]
  node_visa_types["VISA types<br/>[visatype.h]"]
end

node_operator(("Operator"))
node_tcp_client(("TCP client"))
node_instrument{{"Instrument"}}

node_operator -.->|"uses"| node_dialog
node_dialog -.->|"starts"| node_tcp
node_tcp_client -->|"sends commands"| node_tcp
node_tcp -->|"dispatches commands"| node_thread
node_thread -.->|"controls via VISA"| node_instrument
node_tcp -->|"checks status codes"| node_visa_api
node_visa_api -->|"uses types"| node_visa_types
node_helpers -.->|"provides utilities"| node_dialog

click node_dialog "https://github.com/zzjimo/visa-tool/blob/main/VisaToolDlg.cpp"
click node_tcp "https://github.com/zzjimo/visa-tool/blob/main/TcpServer.cpp"
click node_thread "https://github.com/zzjimo/visa-tool/blob/main/myThread.cpp"
click node_helpers "https://github.com/zzjimo/visa-tool/blob/main/stdafx.cpp"
click node_visa_api "https://github.com/zzjimo/visa-tool/blob/main/visa/visa.h"
click node_visa_types "https://github.com/zzjimo/visa-tool/blob/main/visa/visatype.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_dialog,node_tcp_client toneBlue
class node_tcp,node_thread toneAmber
class node_helpers,node_visa_api,node_visa_types toneMint
class node_operator,node_instrument toneIndigo
```

## Components

### Application UI

- [Main dialog](https://github.com/zzjimo/visa-tool/blob/main/VisaToolDlg.cpp): `VisaToolDlg.cpp`

### Instrument control

- [TCP server](https://github.com/zzjimo/visa-tool/blob/main/TcpServer.cpp): `TcpServer.cpp`
- [Instrument operations](https://github.com/zzjimo/visa-tool/blob/main/myThread.cpp): `myThread.cpp`

### VISA support

- [Shared helpers](https://github.com/zzjimo/visa-tool/blob/main/stdafx.cpp): `stdafx.cpp`
- [VISA API](https://github.com/zzjimo/visa-tool/blob/main/visa/visa.h): `visa/visa.h`
- [VISA types](https://github.com/zzjimo/visa-tool/blob/main/visa/visatype.h): `visa/visatype.h`

### Other components

- **Operator**
- **TCP client**
- **Instrument**

## Connections

- Operator → Main dialog: uses (evidence: `ReadMe.txt`)
- Main dialog → TCP server: starts
- TCP client → TCP server: sends commands (evidence: `TcpServer.cpp`)
- TCP server → Instrument operations: dispatches commands (evidence: `TcpServer.cpp`)
- Instrument operations → Instrument: controls via VISA
- TCP server → VISA API: checks status codes (evidence: `TcpServer.cpp`)
- VISA API → VISA types: uses types (evidence: `visa/visa.h`)
- Shared helpers → Main dialog: provides utilities
