Wire ApplyScaling, StorageRate; close out write-commands plan

ApplyScaling (HistorianTagDefinition.ApplyScaling):
The EnsT2 trailer's second byte controls server-side scaling — `FE 00`
mirrors MinRaw to MinEU and sets AnalogTag.Scaling=0; `FE 01` persists
distinct MinRaw/MaxRaw and sets Scaling=1. Decoded by toggling
set_ApplyScaling on the native harness and capturing the wire bytes for
both values with identical inputs. The earlier docs claimed
EnsureTagAsync needed a follow-up "UpdateTags" call; the WCF surface has
no such operation — toggling that one byte is the whole fix.

StorageRate (HistorianTagDefinition.StorageRateMs):
Serializer accepts a non-default rate, validated empirically against
the live server which only accepts quantized values
(1000/5000/10000/60000/300000 ms).

EnsureTagAsync upsert semantics:
Second call on the same tag name with different fields succeeds and
updates Description, MinEU, MaxEU, MinRaw, MaxRaw, Scaling in place
(verified by direct SQL inspection in a live test).

Plan + doc closeout:
write-commands-reverse-engineering.md rewritten as a current-state
plan with three workstreams (A doc closeout / B idempotency / C1
StorageRate) and a parallelism table; prior phase notes preserved as
appendix. handoff.md, implementation-status.md, wcf-contract-evidence.md,
README.md updated to remove "writes are out of scope" / non-existent
UpdateTags references and document the actual EnsT2 wire format
including the `FE xx` trailer.

Reverse-engineering harness gains --write-apply-scaling and a SQL
post-check that prints the persisted AnalogTag bounds so future RE
sessions can verify wire→DB causality without leaving the harness.

169/169 tests pass (was 165; +4 new tests covering ApplyScaling,
StorageRate golden bytes, StorageRate live persistence, and
EnsureTagAsync upsert semantics).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-05-04 22:04:27 -04:00
parent a175c6e5a0
commit 5ce62a5900
13 changed files with 561 additions and 721 deletions
+18 -3
View File
@@ -1,6 +1,6 @@
# AVEVA Historian Managed Driver Handoff
Last updated: 2026-05-04 (event-flow prereqs)
Last updated: 2026-05-04 (write surface live: EnsT2 + DelT + ApplyScaling)
## Project Direction
@@ -12,7 +12,7 @@ Do not pivot to REST or a P/Invoke production shim unless the project
requirements change. Native and P/Invoke tools in this repo are reverse
engineering aids only.
Required production surface remains narrowly scoped:
Required production surface (all live-verified):
- `ProbeAsync`
- `ReadRawAsync`
@@ -21,8 +21,23 @@ Required production surface remains narrowly scoped:
- `ReadEventsAsync`
- `BrowseTagNamesAsync`
- `GetTagMetadataAsync`
- Status helpers: `GetConnectionStatusAsync`, `GetStoreForwardStatusAsync`, `GetSystemParameterAsync`
Writes are out of scope for the current pass.
Write surface (added 2026-05-04 by explicit user request — see
`docs/plans/write-commands-reverse-engineering.md` Status section):
- `EnsureTagAsync` for analog Float / Double / Int2 / Int4 / UInt4
(with optional `ApplyScaling=true` for distinct MinRaw / MaxRaw
persistence — server sets `AnalogTag.Scaling=1` when the EnsT2
trailer's second byte is `0x01` instead of `0x00`).
- `DeleteTagAsync`.
`AddS2` (write samples) is **architecturally blocked** — server
runtime cache only ingests from configured IOServers / Application
Server pipelines. Discrete / String / Int1 / Int8 / UInt8 EnsT2 fail
at native `AddTag` and are unsupported. There is no `UpdateTags`
operation on the WCF surface; the misnomer in earlier write-up
drafts has been removed.
## Repository Map