# danomagnum/gologix architecture

> Architecture diagram of the GitHub repository danomagnum/gologix, 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/danomagnum/gologix
- Repository: https://github.com/danomagnum/gologix

## Overview

gologix is a native Go Ethernet/IP and CIP driver for ControlLogix, CompactLogix, and Micro820 PLCs. Its primary workflow is to connect a client to a PLC, perform tag reads or writes (including batches and discovery), and return typed values to the Go caller. Separate capabilities include a CIP message interface, a server that accepts PLC messages and routes them to tag providers, L5X project-file parsing, and canned diagnostics. The graph follows documented relationships; some internal call details are not established by the excerpts or source index.

Main entry points: [`client.go`](https://github.com/danomagnum/gologix/blob/master/client.go) (Client), [`canned/faults.go`](https://github.com/danomagnum/gologix/blob/master/canned/faults.go) (Fault and force diagnostics), [`server.go`](https://github.com/danomagnum/gologix/blob/master/server.go) (Server), [`connect.go`](https://github.com/danomagnum/gologix/blob/master/connect.go) (Connection setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["PLC Client"]
  node_client["Client<br/>[client.go]"]
  node_connection["Connection setup<br/>[connect.go]"]
  node_tag_read["Tag reads<br/>[read.go]"]
  node_tag_write["Tag writes<br/>[write.go]"]
  node_tag_discovery["Tag and program discovery<br/>[listalltags.go]"]
  node_cip_message["Generic CIP messages<br/>[messages.go]"]
end

subgraph group_protocol["CIP Protocol"]
  node_cip_protocol["CIP definitions and services<br/>[cip_definitions.go]"]
  node_packing["CIP data packing<br/>[pack.go]"]
end

subgraph group_server["CIP Server"]
  node_server["Server<br/>[server.go]"]
  node_server_router["Path router<br/>[server_router.go]"]
  node_tag_provider[("Map tag provider<br/>[server_router.go]")]
end

subgraph group_l5x["L5X Projects"]
  node_l5x_schema["L5X schema<br/>[schema.go]"]
  node_l5x_loader["L5X tag and comment extraction<br/>[load_tags.go]"]
end

subgraph group_extras["Diagnostics And Types"]
  node_canned_faults["Fault descriptions"]
  node_canned_diagnostics["Fault and force diagnostics<br/>[faults.go]"]
  node_logix_types["Logix structured types<br/>[timer.go]"]
end

node_go_user(("Go application"))
node_plc(("Ethernet/IP PLC"))

node_go_user -->|"creates and uses"| node_client
node_client -->|"connects"| node_connection
node_connection -->|"opens Ethernet/IP"| node_plc
node_client -->|"requests reads"| node_tag_read
node_client -->|"requests writes"| node_tag_write
node_client -->|"lists tags and programs"| node_tag_discovery
node_client -->|"sends custom messages"| node_cip_message
node_tag_read -->|"reads tag data"| node_plc
node_tag_write -->|"writes tag data"| node_plc
node_tag_discovery -->|"queries controller"| node_plc
node_cip_message -->|"sends CIP request"| node_plc
node_go_user -->|"starts server"| node_server
node_plc -->|"sends MSG or IO"| node_server
node_server -->|"routes requests"| node_server_router
node_server_router -->|"dispatches tag access"| node_tag_provider
node_go_user -->|"loads project data"| node_l5x_loader
node_l5x_loader -.->|"uses project structures"| node_l5x_schema
node_go_user -->|"requests diagnostics"| node_canned_diagnostics
node_canned_diagnostics -->|"requests fault data"| node_client
node_canned_diagnostics -->|"looks up descriptions"| node_canned_faults
node_go_user -.->|"uses typed values"| node_logix_types

click node_client "https://github.com/danomagnum/gologix/blob/master/client.go"
click node_connection "https://github.com/danomagnum/gologix/blob/master/connect.go"
click node_tag_read "https://github.com/danomagnum/gologix/blob/master/read.go"
click node_tag_write "https://github.com/danomagnum/gologix/blob/master/write.go"
click node_tag_discovery "https://github.com/danomagnum/gologix/blob/master/listalltags.go"
click node_cip_message "https://github.com/danomagnum/gologix/blob/master/messages.go"
click node_cip_protocol "https://github.com/danomagnum/gologix/blob/master/cip_definitions.go"
click node_packing "https://github.com/danomagnum/gologix/blob/master/pack.go"
click node_server "https://github.com/danomagnum/gologix/blob/master/server.go"
click node_server_router "https://github.com/danomagnum/gologix/blob/master/server_router.go"
click node_tag_provider "https://github.com/danomagnum/gologix/blob/master/server_router.go"
click node_l5x_schema "https://github.com/danomagnum/gologix/blob/master/l5x/schema.go"
click node_l5x_loader "https://github.com/danomagnum/gologix/blob/master/l5x/load_tags.go"
click node_canned_faults "https://github.com/danomagnum/gologix/blob/master/canned/fault_descriptions.go"
click node_canned_diagnostics "https://github.com/danomagnum/gologix/blob/master/canned/faults.go"
click node_logix_types "https://github.com/danomagnum/gologix/blob/master/lgxtypes/timer.go"

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_client,node_connection,node_tag_read,node_tag_write,node_tag_discovery,node_cip_message toneBlue
class node_cip_protocol,node_packing toneAmber
class node_server,node_server_router,node_tag_provider toneMint
class node_l5x_schema,node_l5x_loader toneRose
class node_canned_faults,node_canned_diagnostics,node_logix_types,node_go_user,node_plc toneIndigo
```

## Components

### PLC Client

- [Client](https://github.com/danomagnum/gologix/blob/master/client.go): `client.go`
- [Connection setup](https://github.com/danomagnum/gologix/blob/master/connect.go): `connect.go`
- [Tag reads](https://github.com/danomagnum/gologix/blob/master/read.go): `read.go`
- [Tag writes](https://github.com/danomagnum/gologix/blob/master/write.go): `write.go`
- [Tag and program discovery](https://github.com/danomagnum/gologix/blob/master/listalltags.go): `listalltags.go`
- [Generic CIP messages](https://github.com/danomagnum/gologix/blob/master/messages.go): `messages.go`

### CIP Protocol

- [CIP definitions and services](https://github.com/danomagnum/gologix/blob/master/cip_definitions.go): `cip_definitions.go`
- [CIP data packing](https://github.com/danomagnum/gologix/blob/master/pack.go): `pack.go`

### CIP Server

- [Server](https://github.com/danomagnum/gologix/blob/master/server.go): `server.go`
- [Path router](https://github.com/danomagnum/gologix/blob/master/server_router.go): `server_router.go`
- [Map tag provider](https://github.com/danomagnum/gologix/blob/master/server_router.go): `server_router.go`

### L5X Projects

- [L5X schema](https://github.com/danomagnum/gologix/blob/master/l5x/schema.go): `l5x/schema.go`
- [L5X tag and comment extraction](https://github.com/danomagnum/gologix/blob/master/l5x/load_tags.go): `l5x/load_tags.go`

### Diagnostics And Types

- [Fault descriptions](https://github.com/danomagnum/gologix/blob/master/canned/fault_descriptions.go): `canned/fault_descriptions.go`
- [Fault and force diagnostics](https://github.com/danomagnum/gologix/blob/master/canned/faults.go): `canned/faults.go`
- [Logix structured types](https://github.com/danomagnum/gologix/blob/master/lgxtypes/timer.go): `lgxtypes/timer.go`

### Other components

- **Go application**
- **Ethernet/IP PLC**

## Connections

- Go application → Client: creates and uses
- Client → Connection setup: connects
- Connection setup → Ethernet/IP PLC: opens Ethernet/IP
- Client → Tag reads: requests reads
- Client → Tag writes: requests writes
- Client → Tag and program discovery: lists tags and programs
- Client → Generic CIP messages: sends custom messages
- Tag reads → Ethernet/IP PLC: reads tag data
- Tag writes → Ethernet/IP PLC: writes tag data
- Tag and program discovery → Ethernet/IP PLC: queries controller
- Generic CIP messages → Ethernet/IP PLC: sends CIP request
- Go application → Server: starts server
- Ethernet/IP PLC → Server: sends MSG or IO
- Server → Path router: routes requests (evidence: `server.go`)
- Path router → Map tag provider: dispatches tag access (evidence: `server_router.go`)
- Go application → L5X tag and comment extraction: loads project data
- L5X tag and comment extraction → L5X schema: uses project structures
- Go application → Fault and force diagnostics: requests diagnostics
- Fault and force diagnostics → Client: requests fault data (evidence: `canned/faults.go`)
- Fault and force diagnostics → Fault descriptions: looks up descriptions (evidence: `canned/faults.go`)
- Go application → Logix structured types: uses typed values
