[s7] S7 — Array tags (ValueRank=1) #339

Merged
dohertj2 merged 1 commits from auto/s7/PR-S7-A4 into auto/driver-gaps 2026-04-25 16:51:36 -04:00
Owner

Summary

S7 1-D array tags (ValueRank=1) for fixed-width element types.

  • S7TagDefinition.cs — new optional ElementCount property. When >1, the tag is a 1-D array of the configured S7DataType.
  • S7Driver.csReadOneAsync / WriteOneAsync issue a single ReadBytesAsync / WriteBytesAsync covering N × elementBytes, then slice / pack client-side via the existing big-endian scalar codecs and S7DateTimeCodec.
  • DiscoverAsync flows IsArray=true + ArrayDim=[ElementCount] so the address-space builder picks ValueRank=1.
  • Init-time validation runs ahead of TCP open: caps ElementCount at 8000 (realistic S7 PDU limit) and rejects unsupported element types (STRING/WSTRING/CHAR/WCHAR + BOOL) with a FormatException.

Supported element types: Byte, Int16/UInt16, Int32/UInt32, Int64/UInt64, Float32, Float64, Date, Time, TimeOfDay.

Deferred (per issue body):

  • BOOL arrays (Siemens packed-bit-per-element semantics)
  • String/WString arrays (variable per-element width)
  • Multi-dimensional arrays
  • Array-of-UDT (lands with PR-S7-D2)

Test plan

  • dotnet build src/ZB.MOM.WW.OtOpcUa.Driver.S7 — clean (0 / 0)
  • dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.S7.Tests123 / 123 passed (8 new in S7DriverArrayTests: Int16/Int32/Float32/Float64 round-trip, big-endian layout sanity, init-time rejection of String/Bool element types and oversized ElementCount)
  • Integration tests — Snap7-server fixture supports it; not exercised in this PR

🤖 Auto-generated by the Mode-B execution loop. Closes #290.

Closes #290

## Summary S7 1-D array tags (ValueRank=1) for fixed-width element types. - **`S7TagDefinition.cs`** — new optional `ElementCount` property. When `>1`, the tag is a 1-D array of the configured `S7DataType`. - **`S7Driver.cs`** — `ReadOneAsync` / `WriteOneAsync` issue a **single** `ReadBytesAsync` / `WriteBytesAsync` covering `N × elementBytes`, then slice / pack client-side via the existing big-endian scalar codecs and `S7DateTimeCodec`. - `DiscoverAsync` flows `IsArray=true` + `ArrayDim=[ElementCount]` so the address-space builder picks ValueRank=1. - Init-time validation runs ahead of TCP open: caps `ElementCount` at 8000 (realistic S7 PDU limit) and rejects unsupported element types (STRING/WSTRING/CHAR/WCHAR + BOOL) with a `FormatException`. **Supported element types**: Byte, Int16/UInt16, Int32/UInt32, Int64/UInt64, Float32, Float64, Date, Time, TimeOfDay. **Deferred** (per issue body): - BOOL arrays (Siemens packed-bit-per-element semantics) - String/WString arrays (variable per-element width) - Multi-dimensional arrays - Array-of-UDT (lands with PR-S7-D2) ## Test plan - [x] `dotnet build src/ZB.MOM.WW.OtOpcUa.Driver.S7` — clean (0 / 0) - [x] `dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.S7.Tests` — **123 / 123 passed** (8 new in `S7DriverArrayTests`: Int16/Int32/Float32/Float64 round-trip, big-endian layout sanity, init-time rejection of String/Bool element types and oversized ElementCount) - [ ] Integration tests — Snap7-server fixture supports it; not exercised in this PR 🤖 Auto-generated by the Mode-B execution loop. Closes #290. Closes #290
dohertj2 added 1 commit 2026-04-25 16:51:31 -04:00
- S7TagDefinition gets optional ElementCount; >1 marks the tag as a 1-D array.
- ReadOneAsync / WriteOneAsync: one byte-range Read/WriteBytesAsync covering
  N × elementBytes, sliced/packed client-side via the existing big-endian scalar
  codecs and S7DateTimeCodec.
- DiscoverAsync surfaces IsArray=true and ArrayDim=ElementCount → ValueRank=1.
- Init-time validation (now ahead of TCP open) caps ElementCount at 8000 and
  rejects unsupported element types: STRING/WSTRING/CHAR/WCHAR (variable-width)
  and BOOL (packed-bit layout) — both follow-ups.
- Supported element types: Byte, Int16/UInt16, Int32/UInt32, Int64/UInt64,
  Float32, Float64, Date, Time, TimeOfDay.

Closes #290
dohertj2 merged commit 6737edbad2 into auto/driver-gaps 2026-04-25 16:51:36 -04:00
dohertj2 deleted branch auto/s7/PR-S7-A4 2026-04-25 16:51:37 -04:00
Sign in to join this conversation.