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, AdviseSupervisory, 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. The worker serializes commands and faults the session if a COM call exceeds the STA timeout. Buffered advice, bulk subscriptions, snapshot reads, and alarm commands are outside the current implementation.

The worker supports Write, Write2, WriteSecured, and WriteSecured2, including their bulk forms. It converts scalar and typed array inputs to Automation VARIANTs. For a timestamped write, a protobuf timestamp becomes local wall-clock time for MXAccess. Single-item replies carry the matching OnWriteComplete status rows when MXAccess responds within the configured wait (default 1,500 ms). This correlation uses the server and item handles supplied by MXAccess. The event also flows through StreamEvents. Bulk results report per-item COM acceptance and clients can observe commit outcomes on the event stream.

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.

Run the write round-trip on a development host with a writable integer test item. The test writes and reads back distinct values, checks OnWriteComplete and unary status rows, exercises partial bulk failure, and restores the original value through Write2.

$env:MXGATEWAY_LIVE_MXACCESS_ITEM = 'TestChildObject.TestInt'
dotnet test src/ZB.MOM.WW.MxGateway.IntegrationTests --filter FullyQualifiedName~GatewayGrpc_WithRustWorker_WritesAndReceivesOnWriteComplete

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
  • REA write member evidence for ILMXProxyServer and ILMXProxyServer4 ev_1b4fe7ab436437391b76f9fa3a300f45b58a4e1cff6aa84e30854f653c0a20df