diff --git a/README.md b/README.md index 2f0b09639..af26c5fe0 100644 --- a/README.md +++ b/README.md @@ -1,115 +1,182 @@ # OtOpcUa -OPC UA server (.NET 10 AnyCPU) that exposes a fleet of industrial drivers as a single OPC UA address space. Drivers ship in-process for AVEVA System Platform Galaxy (via the sibling `mxaccessgw` repo), Modbus TCP, Siemens S7, Allen-Bradley CIP (ControlLogix / CompactLogix), Allen-Bradley Legacy (SLC 500 / MicroLogix), Beckhoff TwinCAT (ADS), FANUC FOCAS, OPC UA Client (gateway), and MQTT (broker subscribe; Sparkplug B in progress). +OPC UA server (.NET 10, AnyCPU) that exposes a fleet of industrial data sources under one OPC UA +address space, with two namespaces: a **Raw** device tree and a **UNS** (Area → Line → Equipment) +tree that references it. Configuration is authored and deployed from a Blazor **AdminUI**; nodes +run as Akka.NET clusters (redundant pairs) and the same `OtOpcUa.Host` binary serves the admin and +driver roles. -A cross-platform client stack (.NET 10) — shared library, CLI, and Avalonia desktop app — connects to any OPC UA server. +**Drivers (in-process):** AVEVA System Platform **Galaxy** (via the sibling `mxaccessgw` gateway), +**Modbus** TCP / RTU-over-TCP, **Siemens S7**, **Allen-Bradley CIP** (ControlLogix / CompactLogix), +**Allen-Bradley Legacy** (SLC 500 / MicroLogix), **Beckhoff TwinCAT** (ADS), **FANUC FOCAS**, +**Heidenhain** LSV2 (read-only), **OPC UA Client** (gateway), **MQTT** (plain JSON + Sparkplug B), +**MTConnect** Agent, **SQL** poll (SQL Server / Postgres / Oracle / MySQL / ODBC), plus the +**Calculation** pseudo-driver (script-computed tags). + +A cross-platform client stack (.NET 10) — shared library, CLI, and Avalonia desktop app — connects +to any OPC UA server. ## Architecture ``` - OPC UA Clients (CLI, Desktop UI, 3rd-party) - | - v - +-------------------------------------+ - | OtOpcUa.Server (.NET 10 AnyCPU) | - | address space + capability fan-out| - +-------------------------------------+ - | | | | | | | | - Galaxy Modbus S7 AbCip AbLeg TwinCAT FOCAS OpcUaClient MQTT - | - v - mxaccessgw (sibling repo, gRPC) - | - v - MXAccess COM (x86 worker, on AVEVA box) + OPC UA clients (Client CLI / UI, ScadaBridge, 3rd-party) AdminUI (Blazor) + | | + v v + +--------------------------------------------------------------------------------------+ + | OtOpcUa.Host (.NET 10) — role-gated: admin (AdminUI + control plane), driver (OPC UA) | + | OPC UA server: Raw ns (https://zb.com/otopcua/raw) + UNS ns (.../otopcua/uns) | + | virtual tags · scripted alarms · historian · redundancy (Akka.NET pair) | + +--------------------------------------------------------------------------------------+ + | | | | | | | | | | | | + Galaxy Modbus S7 AbCip AbLegacy TwinCAT FOCAS Heidenhain OpcUa MQTT MTConnect Sql + | Client + v Historian backend: HistorianGateway (default) + mxaccessgw (sibling repo, gRPC) | SQL Server | QuestDB + | + v + MXAccess COM (x86 worker, on the AVEVA box) ``` -Galaxy is the only driver with an external runtime: it speaks gRPC to a separately installed `mxaccessgw` server (sibling repo at `c:\Users\dohertj2\Desktop\mxaccessgw\`) which owns the MXAccess COM apartment and the x86/STA bitness constraint server-side. Everything in this repo is platform-agnostic .NET 10. +- **Two namespaces, one source.** Each device value comes from its Raw tag; UNS equipment + variables reference Raw tags and mirror the same value/quality/timestamp. Reads, writes, + alarms and history work through either NodeId. See [docs/Raw.md](docs/Raw.md) and + [docs/Uns.md](docs/Uns.md). +- **Clusters and meshes.** Central (admin) and site (driver) clusters talk over gRPC with + per-cluster PSKs; each 2-node cluster elects a Primary. See [docs/Redundancy.md](docs/Redundancy.md). +- **gRPC data connections.** Nodes and clusters can map each other's Raw/UNS branches for + browse, read, write and subscribe. See [docs/DataConnections.md](docs/DataConnections.md). +- **Galaxy** is the only driver with an external runtime: it speaks gRPC to a separately + installed `mxaccessgw` (sibling repo `~/Desktop/MxAccessGateway`), which owns the MXAccess COM + apartment and the x86/STA constraint. Everything in this repo is platform-agnostic .NET 10. ## Prerequisites -- .NET 10 SDK (server, drivers, clients all target .NET 10) -- SQL Server reachable for the central config DB -- For Galaxy specifically: a running `mxaccessgw` deployment — see [docs/v2/Galaxy.ParityRig.md](docs/v2/Galaxy.ParityRig.md) -- For historian read-back / alarm history / continuous historization: a running [`ZB.MOM.WW.HistorianGateway`](docs/Historian.md) deployment (the sole historian backend; consumed as the `ZB.MOM.WW.HistorianGateway.Client` gRPC package). It must run `RuntimeDb:Enabled=true` + `RuntimeDb:EventReadsEnabled=true`, and the API key must carry `historian:read` + `historian:write` + `historian:tags:write` scopes. +- .NET 10 SDK. +- SQL Server for the central configuration database (`ConfigDb`). Driver-only nodes can run + without it, fed by their cluster's config mesh. +- Galaxy only: a running `mxaccessgw` — see [docs/v2/Galaxy.ParityRig.md](docs/v2/Galaxy.ParityRig.md). +- History (HistoryRead, alarm history, continuous historization): one backend, chosen with + `ServerHistorian:Backend` — `Gateway` (default; a separately deployed `ZB.MOM.WW.HistorianGateway` + in front of AVEVA Historian), `SqlServer`, or `QuestDb`. See [docs/Historian.md](docs/Historian.md). ## Quick Start ```bash -dotnet restore ZB.MOM.WW.OtOpcUa.slnx dotnet build ZB.MOM.WW.OtOpcUa.slnx -dotnet test ZB.MOM.WW.OtOpcUa.slnx - -# Run the server in dev (foreground) -dotnet run --project src/Server/ZB.MOM.WW.OtOpcUa.Host +dotnet test ZB.MOM.WW.OtOpcUa.slnx --filter "Category!=E2E&Category!=LiveIntegration" ``` -The server starts on `opc.tcp://localhost:4840` with the `None` security profile. Configure `Security.Profiles` in `src/Server/ZB.MOM.WW.OtOpcUa.Host/appsettings.json` to enable `Basic256Sha256-Sign` or `Basic256Sha256-SignAndEncrypt`. See [docs/security.md](docs/security.md). +Unit suites are `tests/**/*.Tests`; `*.IntegrationTests` need their Docker fixtures, and +DB-backed tests need the central SQL Server — see [infra/README.md](infra/README.md). -## Install as Windows Services +**Local rig (recommended).** The `docker-dev/` stack runs a central admin+driver pair, SQL +Server, migrations and seed data, behind Traefik: -Production deployment is driven by `scripts/install/Install-Services.ps1`, which registers the `OtOpcUa` server service under a chosen service account. Historian support requires a separately deployed `ZB.MOM.WW.HistorianGateway` and Galaxy support a separately installed `mxaccessgw` — neither this repo nor the install script provisions them. +```bash +docker-dev/compose.sh up -d --build +``` + +AdminUI at `http://localhost:9200` (login disabled on the rig); OPC UA at +`opc.tcp://localhost:4840` (central-1) and `:4841` (central-2). Deploy from `/deployments` before +drivers start. See [docker-dev/README.md](docker-dev/README.md). + +**Bare host.** `dotnet run --project src/Server/ZB.MOM.WW.OtOpcUa.Host` with +`OTOPCUA_ROLES=admin,driver` (or `Cluster:Roles`) and a reachable `ConfigDb`. + +Transport security is set by `OpcUa:EnabledSecurityProfiles` (`None`, `Basic256Sha256Sign`, +`Basic256Sha256SignAndEncrypt`; all three when the key is absent). See [docs/security.md](docs/security.md). + +## Install as a Windows Service + +`scripts/install/Install-Services.ps1` installs the single `OtOpcUaHost` service; `-Roles` sets its +roles. `mxaccessgw` and the HistorianGateway are installed separately. ```powershell .\scripts\install\Install-Services.ps1 ` -InstallRoot 'C:\Program Files\OtOpcUa' ` - -ServiceAccount 'DOMAIN\svc-otopcua' + -ServiceAccount 'DOMAIN\svc-otopcua' ` + -Roles admin,driver ``` -The historian backend is the external `ZB.MOM.WW.HistorianGateway` (not installed by this script). See the script header and [docs/ServiceHosting.md](docs/ServiceHosting.md) for full options. +See the script header and [docs/ServiceHosting.md](docs/ServiceHosting.md) for all options, +including Traefik and the out-of-process script worker isolation. ## Client CLI ```bash -dotnet run --project src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI -- connect -u opc.tcp://localhost:4840 -dotnet run --project src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI -- browse -u opc.tcp://localhost:4840 -r -d 3 -dotnet run --project src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI -- read -u opc.tcp://localhost:4840 -n "ns=2;s=SomeNode" -dotnet run --project src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI -- write -u opc.tcp://localhost:4840 -n "ns=2;s=SomeNode" -v 42 -dotnet run --project src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI -- subscribe -u opc.tcp://localhost:4840 -n "ns=2;s=SomeNode" -i 500 +CLI="dotnet run --project src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI --" +$CLI connect -u opc.tcp://localhost:4840 +$CLI browse -u opc.tcp://localhost:4840 -r -d 3 +$CLI read -u opc.tcp://localhost:4840 -n "ns=;s=Plant/Modbus/dev1/Speed" +$CLI write -u opc.tcp://localhost:4840 -n "ns=;s=Plant/Modbus/dev1/Speed" -v 42 +$CLI subscribe -u opc.tcp://localhost:4840 -n "ns=;s=Plant/Modbus/dev1/Speed" -i 500 ``` -See [docs/Client.CLI.md](docs/Client.CLI.md) and [docs/Client.UI.md](docs/Client.UI.md). +Raw NodeIds are `s=`; UNS NodeIds are `s=///`. Browse first +to find the namespace indexes. The CLI also covers history reads, alarms and redundancy — see +[docs/Client.CLI.md](docs/Client.CLI.md), [docs/Client.UI.md](docs/Client.UI.md), and the +per-protocol driver CLIs in [docs/DriverClis.md](docs/DriverClis.md). ## Documentation -### Architecture deep-dives +[docs/README.md](docs/README.md) is the full documentation index. + +### Architecture and data path | Topic | Doc | |---|---| -| OPC UA server composition, namespace fan-out, Polly invoker | [docs/OpcUaServer.md](docs/OpcUaServer.md) | +| OPC UA server composition, driver dispatch | [docs/OpcUaServer.md](docs/OpcUaServer.md) | | Address space layout | [docs/AddressSpace.md](docs/AddressSpace.md) | -| Read / Write dispatch (driver vs virtual vs scripted-alarm) | [docs/ReadWriteOperations.md](docs/ReadWriteOperations.md) | -| Incremental sync (driver-backend rediscovery + config publishes) | [docs/IncrementalSync.md](docs/IncrementalSync.md) | -| Service hosting (Server + Admin; external HistorianGateway backend) | [docs/ServiceHosting.md](docs/ServiceHosting.md) | -| Security (transport, LDAP, certificates) | [docs/security.md](docs/security.md) | -| Redundancy | [docs/Redundancy.md](docs/Redundancy.md) | -| Status dashboard | [docs/StatusDashboard.md](docs/StatusDashboard.md) | +| Raw device tree (`/raw`) | [docs/Raw.md](docs/Raw.md) | +| Unified namespace (`/uns`) | [docs/Uns.md](docs/Uns.md) | +| Read / write dispatch | [docs/ReadWriteOperations.md](docs/ReadWriteOperations.md) | +| Incremental sync and surgical deploys | [docs/IncrementalSync.md](docs/IncrementalSync.md) | +| Driver lifecycle and infrastructure contracts | [docs/DriverLifecycle.md](docs/DriverLifecycle.md) | +| gRPC data connections between nodes and clusters | [docs/DataConnections.md](docs/DataConnections.md) | +| Redundancy, clusters and meshes | [docs/Redundancy.md](docs/Redundancy.md) | +| Telemetry | [docs/Telemetry.md](docs/Telemetry.md) | + +### Scripting, alarms and history + +| Topic | Doc | +|---|---| +| Virtual tags (incl. out-of-process script runner) | [docs/VirtualTags.md](docs/VirtualTags.md) | +| Script editor (Monaco + Roslyn) | [docs/ScriptEditor.md](docs/ScriptEditor.md) | +| Scripted alarms | [docs/ScriptedAlarms.md](docs/ScriptedAlarms.md) | +| Native alarms and OPC UA conditions | [docs/AlarmTracking.md](docs/AlarmTracking.md) | +| Alarm historian store-and-forward | [docs/AlarmHistorian.md](docs/AlarmHistorian.md) | +| Historian backends (Gateway / SQL Server / QuestDB) | [docs/Historian.md](docs/Historian.md) | + +### Operations + +| Topic | Doc | +|---|---| +| Configuration (appsettings + env vars) | [docs/Configuration.md](docs/Configuration.md) | +| Service hosting and role gating | [docs/ServiceHosting.md](docs/ServiceHosting.md) | +| Security (transport, LDAP, API keys, ACLs) | [docs/security.md](docs/security.md) | +| ZTag / SAPID reservations | [docs/Reservations.md](docs/Reservations.md) | +| AdminUI | [docs/v2/admin-ui.md](docs/v2/admin-ui.md) | +| Test and deployment infrastructure | [infra/README.md](infra/README.md) | +| Dev environment | [docs/v2/dev-environment.md](docs/v2/dev-environment.md) | ### Drivers | Topic | Doc | |---|---| -| Driver specs (per-driver capability surface, config, addressing) | [docs/v2/driver-specs.md](docs/v2/driver-specs.md) | -| Galaxy driver | [docs/drivers/Galaxy.md](docs/drivers/Galaxy.md) | -| Modbus / S7 / AbCip / AbLegacy / TwinCAT / FOCAS / OpcUaClient / MQTT | [docs/drivers/](docs/drivers/) | -| Galaxy parity rig (mxaccessgw setup) | [docs/v2/Galaxy.ParityRig.md](docs/v2/Galaxy.ParityRig.md) | -| Galaxy performance + tracing | [docs/v2/Galaxy.Performance.md](docs/v2/Galaxy.Performance.md) | +| Driver index and capability matrix | [docs/drivers/README.md](docs/drivers/README.md) | +| Galaxy | [docs/drivers/Galaxy.md](docs/drivers/Galaxy.md) | +| Modbus · S7 · AbCip · AbLegacy · TwinCAT · FOCAS | [Modbus](docs/drivers/Modbus.md) · [S7](docs/drivers/S7.md) · [AbCip](docs/drivers/AbCip.md) · [AbLegacy](docs/drivers/AbLegacy.md) · [TwinCAT](docs/drivers/TwinCAT.md) · [FOCAS](docs/drivers/FOCAS.md) | +| Heidenhain · OPC UA Client · MQTT · MTConnect · Sql · Calculation | [Heidenhain](docs/drivers/Heidenhain.md) · [OpcUaClient](docs/drivers/OpcUaClient.md) · [Mqtt](docs/drivers/Mqtt.md) · [MTConnect](docs/drivers/MTConnect.md) · [Sql](docs/drivers/Sql.md) · [Calculation](docs/drivers/Calculation.md) | +| Test Connect probes | [docs/drivers/TestConnectProbes.md](docs/drivers/TestConnectProbes.md) | +| Driver specs (design reference) | [docs/v2/driver-specs.md](docs/v2/driver-specs.md) | +| Galaxy parity rig and performance | [ParityRig](docs/v2/Galaxy.ParityRig.md) · [Performance](docs/v2/Galaxy.Performance.md) | -### Clients +### Design history -| Topic | Doc | -|---|---| -| Client CLI | [docs/Client.CLI.md](docs/Client.CLI.md) | -| Client UI (Avalonia desktop) | [docs/Client.UI.md](docs/Client.UI.md) | - -### v1 archive - -The original v1 in-process MXAccess docs (Galaxy.Host topology, -Configuration env vars, AlarmTracking, DataTypeMapping, -HistoricalDataAccess, Subscriptions, etc.) are preserved under -[docs/v1/](docs/v1/) — historical reference only. PR 7.2 retired the -v1 architecture on 2026-04-30; current state is documented in the -sections above. +`docs/v2/` holds the v2 plan and decision log, and `docs/plans/` the dated design and +implementation plans. The original v1 single-driver docs are archived under [docs/v1/](docs/v1/) +(historical only; v1 retired 2026-04-30). Open work is tracked in Gitea issues on +`dohertj2/lmxopcua`. ## License