Files
mxaccessgw/src/mxgateway-worker-rust

Rust MXAccess worker prototype

This crate exercises the gateway's existing worker contract with native 32-bit Windows COM. Cargo generates the Rust protobuf types from the gateway's canonical schemas at build time.

The worker authenticates the launch nonce, negotiates a frame limit, activates LMXProxy on a dedicated message-pumping STA, and reports readiness and heartbeats. It supports Register, Unregister, AddItem, RemoveItem, Advise, UnAdvise, and the worker diagnostic commands. The worker uses the base MXAccess COM connection point for OnDataChange, OperationComplete, and OnWriteComplete notifications. OnDataChange carries the value, quality, MXAccess status records, source timestamp when available, and worker sequence and timestamp. The bounded queue faults the session on overflow. Shutdown detaches the sink, unadvises remaining items, and unregisters clients before releasing COM. The C# worker is the gateway default.

Event conversion supports standard Automation scalar values and homogeneous arrays of those types. Other variant types are reported as unknown with the Automation type in the diagnostic. Writes, buffered or supervisory advice, bulk commands, and alarms remain to be implemented. Unsupported commands return InvalidRequest. The worker serializes commands. If a COM call exceeds the STA timeout, the worker faults the session and exits.

Build and test

From this directory on Windows, with Rust, the x86 MSVC target and linker, and protoc on PATH:

cargo build --locked --release --target i686-pc-windows-msvc
cargo test --locked --target i686-pc-windows-msvc

On a development Windows host with 32-bit System Platform MXAccess registered, run the opt-in test against a temporary pipe. Set MXGATEWAY_RUST_SMOKE_ITEM to an item available in that host's Galaxy to include AddItem and RemoveItem in the smoke test.

$env:MXGATEWAY_RUST_SMOKE_ITEM = 'TestChildObject.TestInt'
cargo test --locked --target i686-pc-windows-msvc --test live_mxaccess -- --ignored

The smoke test starts and terminates its own worker and exercises the pipe handshake, heartbeat, registration, item lifecycle when configured, and graceful shutdown. It runs without a gateway service. Portable framing tests also run with cargo test --locked on macOS and Linux.

From the repository root on a Windows development host with TestMachine_001.TestChangingInt deployed, run the opt-in HTTP/2 test to verify the Rust worker through the gateway:

$env:MXGATEWAY_RUN_RUST_WORKER_LIVE_TESTS = '1'
$env:MXGATEWAY_LIVE_MXACCESS_WORKER_EXE = (Resolve-Path 'src/mxgateway-worker-rust/target/i686-pc-windows-msvc/release/mxgateway-worker-rust.exe').Path
dotnet test src/ZB.MOM.WW.MxGateway.IntegrationTests --filter FullyQualifiedName~GatewayGrpc_WithRustWorker_StreamsChangingIntegersAndUnadvises

The test starts the gateway gRPC service on an ephemeral loopback port and launches the configured Rust worker. It verifies that the client receives distinct good-quality integer values in sequence and that the worker emits no new data for the item after UnAdvise.

COM interface evidence

The native adapter uses the dual ILMXProxyServer interface from the installed ArchestrA.MxAccess 3.2.0.0 assembly. REA inspection confirmed the declaration order and managed signatures for Register, Unregister, AddItem, and RemoveItem. Windows reflection confirmed the interface IID, dual-interface flag, DISPIDs, and BSTR input annotations. REA and Windows reflection also identified the base event dispatch interface and the MXSTATUS_PROXY layout. The live tests exercise the corresponding native calls and event callbacks.

  • Assembly SHA-256 cba8b607305ee0c70ca38b09eca645ae3b98c35a7b78ec051eb4381f48d9e0b1
  • REA managed member evidence ev_78053da509335e3e3749b8e6bb020f28c45255b54d910546659c6760eb52160b
  • REA event member evidence ev_97162abcd831b2d84b5b43fb72cd9876252bbe3bb0af5c4673a6954911500e54