Extract historian into a runtime-loaded plugin so hosts without the Wonderware SDK can run with Historian.Enabled=false
The aahClientManaged SDK is now isolated in ZB.MOM.WW.LmxOpcUa.Historian.Aveva and loaded via HistorianPluginLoader from a Historian/ subfolder only when enabled, removing the SDK from Host's compile-time and deploy-time surface. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -61,7 +61,7 @@ This is necessary because Windows services default their working directory to `S
|
||||
5. **Create and connect MXAccess client** -- Starts the STA COM thread, creates the `MxAccessClient`, and attempts an initial connection. If the connection fails, the service logs a warning and continues -- the monitor loop will retry in the background.
|
||||
6. **Start MXAccess monitor** -- Starts the connectivity monitor loop that probes the runtime connection at the configured interval and handles auto-reconnect.
|
||||
7. **Test Galaxy repository connection** -- Calls `TestConnectionAsync()` on the Galaxy repository to verify the SQL Server database is reachable. If it fails, the service continues without initial address-space data.
|
||||
8. **Create OPC UA server host** -- Creates `OpcUaServerHost` with the effective MXAccess client (real, override, or null fallback), performance metrics, and optional historian data source.
|
||||
8. **Create OPC UA server host** -- Creates `OpcUaServerHost` with the effective MXAccess client (real, override, or null fallback), performance metrics, and an optional `IHistorianDataSource` obtained from `HistorianPluginLoader.TryLoad` when `Historian.Enabled=true` (returns `null` if the plugin is absent or fails to load).
|
||||
9. **Query Galaxy hierarchy** -- Fetches the object hierarchy and attribute definitions from the Galaxy repository database, recording object and attribute counts.
|
||||
10. **Start server and build address space** -- Starts the OPC UA server, retrieves the `LmxNodeManager`, and calls `BuildAddressSpace()` with the queried hierarchy and attributes. If the query or build fails, the server still starts with an empty address space.
|
||||
11. **Start change detection** -- Creates and starts `ChangeDetectionService`, which polls `galaxy.time_of_last_deploy` at the configured interval. When a change is detected, it triggers an address-space rebuild via the `OnGalaxyChanged` event.
|
||||
@@ -153,21 +153,37 @@ See [Redundancy Guide](Redundancy.md) for full deployment details.
|
||||
|
||||
## Required Runtime Assemblies
|
||||
|
||||
The build uses Costura.Fody to embed all NuGet dependencies into the single `ZB.MOM.WW.LmxOpcUa.Host.exe`. However, the following ArchestrA and Historian DLLs are **excluded from embedding** and must be present alongside the executable at runtime:
|
||||
The build uses Costura.Fody to embed all NuGet dependencies into the single `ZB.MOM.WW.LmxOpcUa.Host.exe`. The only native dependency that must sit alongside the executable in every deployment is the MXAccess COM toolkit:
|
||||
|
||||
| Assembly | Purpose |
|
||||
|----------|---------|
|
||||
| `ArchestrA.MxAccess.dll` | MXAccess COM interop — runtime data access to Galaxy tags |
|
||||
| `aahClientManaged.dll` | Wonderware Historian managed SDK — historical data queries |
|
||||
| `aahClient.dll` | Historian native dependency |
|
||||
| `aahClientCommon.dll` | Historian native dependency |
|
||||
| `Historian.CBE.dll` | Historian native dependency |
|
||||
| `Historian.DPAPI.dll` | Historian native dependency |
|
||||
| `ArchestrA.CloudHistorian.Contract.dll` | Historian contract dependency |
|
||||
|
||||
These DLLs are sourced from the `lib/` folder in the repository and are copied to the build output directory automatically. When deploying, ensure all seven DLLs are in the same directory as the executable.
|
||||
The Wonderware Historian SDK is packaged as a **runtime-loaded plugin** so hosts that will not use historical data access do not need the SDK installed. The plugin lives in a `Historian/` subfolder next to `ZB.MOM.WW.LmxOpcUa.Host.exe`:
|
||||
|
||||
These assemblies are not redistributable — they are provided by the AVEVA System Platform and Historian installations on the target machine. The copies in `lib/` are taken from `Program Files (x86)\ArchestrA\Framework\bin` on a machine with the platform installed.
|
||||
```
|
||||
ZB.MOM.WW.LmxOpcUa.Host.exe
|
||||
ArchestrA.MxAccess.dll
|
||||
Historian/
|
||||
ZB.MOM.WW.LmxOpcUa.Historian.Aveva.dll
|
||||
aahClientManaged.dll
|
||||
aahClientCommon.dll
|
||||
aahClient.dll
|
||||
Historian.CBE.dll
|
||||
Historian.DPAPI.dll
|
||||
ArchestrA.CloudHistorian.Contract.dll
|
||||
```
|
||||
|
||||
At startup, if `Historian.Enabled=true` in `appsettings.json`, `HistorianPluginLoader` probes `Historian/ZB.MOM.WW.LmxOpcUa.Historian.Aveva.dll` via `Assembly.LoadFrom` and instantiates the plugin's entry point. An `AppDomain.AssemblyResolve` handler redirects the SDK assembly lookups (`aahClientManaged`, `aahClientCommon`, …) to the same subfolder so the CLR can resolve them when the plugin first JITs. If the plugin directory is absent or any SDK dependency fails to load, the loader logs a warning and the server continues to run with history support disabled — `LmxNodeManager` returns `BadHistoryOperationUnsupported` for every history call.
|
||||
|
||||
Deployment matrix:
|
||||
|
||||
| Scenario | Host exe | `ArchestrA.MxAccess.dll` | `Historian/` subfolder |
|
||||
|----------|----------|--------------------------|------------------------|
|
||||
| `Historian.Enabled=false` | required | required | **omit** |
|
||||
| `Historian.Enabled=true` | required | required | required |
|
||||
|
||||
`ArchestrA.MxAccess.dll` and the historian SDK DLLs are not redistributable — they are provided by the AVEVA System Platform and Historian installations on the target machine. The copies in `lib/` are taken from `Program Files (x86)\ArchestrA\Framework\bin` on a machine with the platform installed.
|
||||
|
||||
## Platform Target
|
||||
|
||||
|
||||
Reference in New Issue
Block a user