review(Driver.TwinCAT): thread ArrayLength through factory DTO (Medium)
Re-review at 7286d320. -017 (Medium): TwinCATTagDto lacked ArrayLength, so JSON-authored
pre-declared array tags were silently scalar (Phase-4c array path dead for them). Fix:
add ArrayLength to the DTO + thread through BuildTag with positive-value guard + TDD.
This commit is contained in:
@@ -109,7 +109,11 @@ public static class TwinCATDriverFactoryExtensions
|
||||
$"TwinCAT tag '{t.Name}' in '{driverInstanceId}' missing SymbolPath"),
|
||||
DataType: dataType,
|
||||
Writable: t.Writable ?? true,
|
||||
WriteIdempotent: t.WriteIdempotent ?? false);
|
||||
WriteIdempotent: t.WriteIdempotent ?? false,
|
||||
// Driver.TwinCAT-017: thread arrayLength through so JSON-authored pre-declared tags can
|
||||
// declare 1-D arrays (Phase 4c). Only positive values are honoured; null / non-positive
|
||||
// keeps the scalar default (ArrayLength: null on TwinCATTagDefinition).
|
||||
ArrayLength: t.ArrayLength is > 0 ? t.ArrayLength : null);
|
||||
}
|
||||
|
||||
private static T ParseEnum<T>(string? raw, string? tagName, string driverInstanceId, string field)
|
||||
@@ -184,6 +188,14 @@ public static class TwinCATDriverFactoryExtensions
|
||||
|
||||
/// <summary>Gets or sets a value indicating whether writes are idempotent.</summary>
|
||||
public bool? WriteIdempotent { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional 1-D array element count. When positive, the tag is a 1-D array of this
|
||||
/// many <see cref="DataType"/> elements — drives <c>IsArray</c>/<c>ArrayDim</c> at
|
||||
/// discovery and a native ADS array read at runtime (Phase 4c, Driver.TwinCAT-017).
|
||||
/// <c>null</c> or non-positive = scalar (the default).
|
||||
/// </summary>
|
||||
public int? ArrayLength { get; init; }
|
||||
}
|
||||
|
||||
internal sealed class TwinCATProbeDto
|
||||
|
||||
Reference in New Issue
Block a user