Renames all 11 projects (5 src + 6 tests), the .slnx solution file, all source-file namespaces, all axaml namespace references, and all v1 documentation references in CLAUDE.md and docs/*.md (excluding docs/v2/ which is already in OtOpcUa form). Also updates the TopShelf service registration name from "LmxOpcUa" to "OtOpcUa" per Phase 0 Task 0.6.
Preserves runtime identifiers per Phase 0 Out-of-Scope rules to avoid breaking v1/v2 client trust during coexistence: OPC UA `ApplicationUri` defaults (`urn:{GalaxyName}:LmxOpcUa`), server `EndpointPath` (`/LmxOpcUa`), `ServerName` default (feeds cert subject CN), `MxAccessConfiguration.ClientName` default (defensive — stays "LmxOpcUa" for MxAccess audit-trail consistency), client OPC UA identifiers (`ApplicationName = "LmxOpcUaClient"`, `ApplicationUri = "urn:localhost:LmxOpcUaClient"`, cert directory `%LocalAppData%\LmxOpcUaClient\pki\`), and the `LmxOpcUaServer` class name (class rename out of Phase 0 scope per Task 0.5 sed pattern; happens in Phase 1 alongside `LmxNodeManager → GenericDriverNodeManager` Core extraction). 23 LmxOpcUa references retained, all enumerated and justified in `docs/v2/implementation/exit-gate-phase-0.md`.
Build clean: 0 errors, 30 warnings (lower than baseline 167). Tests at strict improvement over baseline: 821 passing / 1 failing vs baseline 820 / 2 (one flaky pre-existing failure passed this run; the other still fails — both pre-existing and unrelated to the rename). `Client.UI.Tests`, `Historian.Aveva.Tests`, `Client.Shared.Tests`, `IntegrationTests` all match baseline exactly. Exit gate compliance results recorded in `docs/v2/implementation/exit-gate-phase-0.md` with all 7 checks PASS or DEFERRED-to-PR-review (#7 service install verification needs Windows service permissions on the reviewer's box).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
11 KiB
Galaxy Repository
GalaxyRepositoryService reads the Galaxy object hierarchy and attribute metadata from the System Platform Galaxy Repository SQL Server database. This data drives the construction of the OPC UA address space.
Connection Configuration
GalaxyRepositoryConfiguration controls database access:
| Property | Default | Description |
|---|---|---|
ConnectionString |
Server=localhost;Database=ZB;Integrated Security=true; |
SQL Server connection using Windows Authentication |
ChangeDetectionIntervalSeconds |
30 |
Polling frequency for deploy change detection |
CommandTimeoutSeconds |
30 |
SQL command timeout for all queries |
ExtendedAttributes |
false |
When true, loads primitive-level attributes in addition to dynamic attributes |
Scope |
Galaxy |
Galaxy loads all deployed objects. LocalPlatform filters to the local platform's subtree only |
PlatformName |
null |
Explicit platform hostname for LocalPlatform filtering. When null, uses Environment.MachineName |
The connection uses Windows Authentication because the Galaxy Repository database is local to the System Platform node and secured through domain credentials.
SQL Queries
All queries are embedded as const string fields in GalaxyRepositoryService. No dynamic SQL is used.
Hierarchy query
Returns deployed Galaxy objects with their parent relationships, browse names, and template derivation chains:
- Joins
gobjecttotemplate_definitionto filter by relevantcategory_idvalues (1, 3, 4, 10, 11, 13, 17, 24, 26) - Uses
contained_nameas the browse name, falling back totag_namewhencontained_nameis null or empty - Resolves the parent using
contained_by_gobject_idwhen non-zero, otherwise falls back toarea_gobject_id - Marks objects with
category_id = 13as areas - Filters to
is_template = 0(instances only, not templates) - Filters to
deployed_package_id <> 0(deployed objects only) - Returns a
template_chaincolumn built by a recursive CTE that walksgobject.derived_from_gobject_idfrom each instance through its immediate template and ancestor templates (depth guard< 10). Template names are ordered by depth and joined with|viaSTUFF(... FOR XML PATH('')). Example:TestMachine_001returns$TestMachine|$gMachine|$gUserDefined|$UserDefined. The C# repository reader splits the column on|, trims, and populatesGalaxyObjectInfo.TemplateChain, which is consumed byAlarmObjectFilterfor template-based alarm filtering. See Alarm Tracking. - Returns
template_definition.category_idas acategory_idcolumn, populated intoGalaxyObjectInfo.CategoryId. The runtime status probe manager filters this down toCategoryId == 1($WinPlatform) andCategoryId == 3($AppEngine) to decide which objects get a<Host>.ScanStateprobe advised. Also used byLmxNodeManager.BuildHostedVariablesMapto identify Platform/Engine ancestors during the hosted-variables walk. - Returns
gobject.hosted_by_gobject_idas ahosted_by_gobject_idcolumn, populated intoGalaxyObjectInfo.HostedByGobjectId. This is the runtime host of the object (e.g., which$AppEngineactually runs it), not the browse-containment parent (contained_by_gobject_id). The two are often different — an object can live in one Area in the browse tree but be hosted by an Engine on a different Platform for runtime execution. The node manager walks this chain duringBuildHostedVariablesMapto find the nearest$WinPlatformor$AppEngineancestor so subtree quality invalidation on a Stopped host reaches exactly the variables that were actually executing there. Note: the Galaxy schema column is namedhosted_by_gobject_id(nothost_gobject_idas some documentation sources guess). See MXAccess Bridge — Per-Host Runtime Status Probes.
Attributes query (standard)
Returns user-defined dynamic attributes for deployed objects:
- Uses a recursive CTE (
deployed_package_chain) to walk the package inheritance chain fromdeployed_package_idthroughderived_from_package_id, limited to 10 levels - Joins
dynamic_attributeon each package in the chain to collect inherited attributes - Uses
ROW_NUMBER() OVER (PARTITION BY gobject_id, attribute_name ORDER BY depth)to pick the most-derived definition when an attribute is overridden at multiple levels - Builds
full_tag_referenceastag_name.attribute_namewith[]appended for arrays - Extracts
array_dimensionfrom the binarymx_valuecolumn (bytes 13-16, little-endian int32) - Detects historized attributes by checking for a
HistoryExtensionprimitive instance - Detects alarm attributes by checking for an
AlarmExtensionprimitive instance - Excludes internal attributes (names starting with
_) and.Descriptionsuffixes - Filters by
mx_attribute_categoryto include only user-relevant categories
Attributes query (extended)
When ExtendedAttributes = true, a more comprehensive query runs that unions two sources:
- Primitive attributes -- Joins through
primitive_instanceandattribute_definitionto include system-level attributes from primitive components. Each attribute carries itsprimitive_nameso the address space can group them under their parent variable. - Dynamic attributes -- The same CTE-based query as the standard path, with an empty
primitive_name.
The full_tag_reference for primitive attributes follows the pattern tag_name.primitive_name.attribute_name (e.g., TestMachine_001.AlarmAttr.InAlarm).
Change detection query
A single-column query: SELECT time_of_last_deploy FROM galaxy. The galaxy table contains one row with the timestamp of the most recent deployment.
Why deployed_package_id Instead of checked_in_package_id
The Galaxy maintains two package references for each object:
checked_in_package_id-- The latest saved version, which may include undeployed configuration changesdeployed_package_id-- The version currently running on the target platform
The queries filter on deployed_package_id <> 0 because the OPC UA server must mirror what is actually running in the Galaxy runtime. Using checked_in_package_id would expose attributes and objects that exist in the IDE but have not been deployed, causing mismatches between the OPC UA address space and the MXAccess runtime.
Platform Scope Filter
When Scope is set to LocalPlatform, the repository applies a post-query C# filter to restrict the address space to objects hosted by the local platform. This reduces memory footprint, MXAccess subscription count, and address space size on multi-node Galaxy deployments where each OPC UA server instance only needs to serve its own platform's objects.
How it works
-
Platform lookup -- A separate
const stringSQL query (PlatformLookupSql) readsplatform_gobject_idandnode_namefrom theplatformtable for all deployed platforms. This runs once per hierarchy load. -
Platform matching -- The configured
PlatformName(orEnvironment.MachineNamewhen null) is matched case-insensitively against thenode_namecolumn. If no match is found, a warning is logged listing the available platforms, and the address space is empty. -
Host chain collection -- The filter collects the matching platform's
gobject_id, then iterates the hierarchy to find all$AppEngine(category 3) objects whoseHostedByGobjectIdequals the platform. This produces the full set of host gobject_ids under the local platform. -
Object inclusion -- All non-area objects whose
HostedByGobjectIdis in the host set are included, along with the hosts themselves. -
Area retention --
ParentGobjectIdchains are walked upward from included objects to pull in ancestor areas, keeping the browse tree connected. Areas that contain no local descendants are excluded. -
Attribute filtering -- The set of included
gobject_idvalues is cached afterGetHierarchyAsyncand reused byGetAttributesAsyncto filter attributes to the same scope.
Design rationale
The filter is applied in C# rather than SQL because the project convention GR-006 requires const string SQL queries with no dynamic SQL. The hierarchy query already returns HostedByGobjectId and CategoryId on every row, so all information needed for filtering is already in memory after the query runs. The only new SQL is the lightweight platform lookup query.
Configuration
"GalaxyRepository": {
"Scope": "LocalPlatform",
"PlatformName": null
}
- Set
Scopeto"LocalPlatform"to enable filtering. Default is"Galaxy"(load everything, backward compatible). - Set
PlatformNameto an explicit hostname to target a specific platform, or leave null to use the local machine name.
Startup log
When LocalPlatform is active, the startup log shows the filtering result:
GalaxyRepository.Scope="LocalPlatform", PlatformName=MYNODE
GetHierarchyAsync returned 49 objects
GetPlatformsAsync returned 2 platform(s)
Scope filter targeting platform 'MYNODE' (gobject_id=1042)
Scope filter retained 25 of 49 objects for platform 'MYNODE'
GetAttributesAsync returned 4206 attributes (extended=true)
Scope filter retained 2100 of 4206 attributes
Change Detection Polling
ChangeDetectionService runs a background polling loop that calls GetLastDeployTimeAsync at the configured interval. It compares the returned timestamp against the last known value:
- On the first poll (no previous state), the timestamp is recorded and
OnGalaxyChangedfires unconditionally - On subsequent polls,
OnGalaxyChangedfires only whentime_of_last_deploydiffers from the cached value
When the event fires, the host service queries fresh hierarchy and attribute data from the repository and calls LmxNodeManager.RebuildAddressSpace (which delegates to incremental SyncAddressSpace).
The polling approach is used because the Galaxy Repository database does not provide change notifications. The galaxy.time_of_last_deploy column updates only on completed deployments, so the polling interval controls how quickly the OPC UA address space reflects Galaxy changes.
TestConnection
TestConnectionAsync runs SELECT 1 against the configured database. This is used at service startup to verify connectivity before attempting the full hierarchy query.
Key source files
src/ZB.MOM.WW.OtOpcUa.Host/GalaxyRepository/GalaxyRepositoryService.cs-- SQL queries and data accesssrc/ZB.MOM.WW.OtOpcUa.Host/GalaxyRepository/PlatformScopeFilter.cs-- Platform-based hierarchy and attribute filteringsrc/ZB.MOM.WW.OtOpcUa.Host/GalaxyRepository/ChangeDetectionService.cs-- Deploy timestamp polling loopsrc/ZB.MOM.WW.OtOpcUa.Host/Configuration/GalaxyRepositoryConfiguration.cs-- Connection, polling, and scope settingssrc/ZB.MOM.WW.OtOpcUa.Host/Domain/PlatformInfo.cs-- Platform-to-hostname DTO