v3(s7): apply Modbus RawTags exemplar to the S7 driver
Rename S7EquipmentTagParser -> S7TagDefinitionFactory; TryParse(reference)
-> FromTagConfig(tagConfig, rawPath, out def) (drops the leading-{ heuristic,
keys the def by RawPath, adds inverse ToTagConfig). Replace S7DriverOptions.Tags
(pre-declared S7TagDefinition list) with RawTags (IReadOnlyList<RawTagEntry>);
the driver builds its RawPath->def table from RawTags at Initialize via the
factory (skip+log on miss), resolver is byName-only, DiscoverAsync + init guards
+ address pre-parse now run off that table. Factory retires the pre-declared DTO
tag path (RawTags binding only). Cli BuildOptions serialises typed defs to
RawTagEntry. Tests migrated to a S7RawTags helper + FromTagConfig; parser test
files renamed. Coordinator's EquipmentTagConfigInspector S7 rename left to Wave-B
coordinator; Driver.S7.IntegrationTests (Docker-gated) left red per scope.
Driver.S7 + Cli build green; Driver.S7.Tests 264/264, S7.Cli.Tests 49/49.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
using S7NetDataType = global::S7.Net.DataType;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.S7.Tests;
|
||||
|
||||
@@ -63,3 +64,42 @@ internal sealed class RecordingAddressSpaceBuilder : IAddressSpaceBuilder
|
||||
=> throw new NotImplementedException("S7 driver never calls this — no alarm surfacing");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Minimal <see cref="IS7PlcFactory"/> whose connection opens cleanly and answers the CPU-status
|
||||
/// probe, but serves no data. Used by the tests that need the driver <c>Initialize</c>d — which in
|
||||
/// v3 is what builds the RawPath → definition table <see cref="S7Driver.DiscoverAsync"/> projects —
|
||||
/// without a live PLC or wire I/O.
|
||||
/// </summary>
|
||||
internal sealed class ConnectingFakeS7PlcFactory : IS7PlcFactory
|
||||
{
|
||||
/// <summary>Creates a fresh connecting fake connection.</summary>
|
||||
public IS7Plc Create(S7CpuType cpuType, string host, int port, short rack, short slot, TimeSpan timeout)
|
||||
=> new ConnectingFakeS7Plc();
|
||||
|
||||
private sealed class ConnectingFakeS7Plc : IS7Plc
|
||||
{
|
||||
/// <summary>Gets a value indicating whether the fake connection is open.</summary>
|
||||
public bool IsConnected { get; private set; }
|
||||
/// <summary>Opens the fake connection.</summary>
|
||||
public Task OpenAsync(CancellationToken ct) { IsConnected = true; return Task.CompletedTask; }
|
||||
/// <summary>Closes the fake connection.</summary>
|
||||
public void Close() => IsConnected = false;
|
||||
/// <summary>Not exercised by these tests.</summary>
|
||||
public Task<object?> ReadAsync(string address, CancellationToken ct)
|
||||
=> throw new NotSupportedException("ConnectingFakeS7Plc serves no data");
|
||||
/// <summary>Not exercised by these tests.</summary>
|
||||
public Task<byte[]> ReadBytesAsync(S7NetDataType area, int db, int startByteAdr, int count, CancellationToken ct)
|
||||
=> throw new NotSupportedException("ConnectingFakeS7Plc serves no data");
|
||||
/// <summary>Not exercised by these tests.</summary>
|
||||
public Task WriteAsync(string address, object value, CancellationToken ct)
|
||||
=> throw new NotSupportedException("ConnectingFakeS7Plc serves no data");
|
||||
/// <summary>Not exercised by these tests.</summary>
|
||||
public Task WriteBytesAsync(S7NetDataType area, int db, int startByteAdr, byte[] value, CancellationToken ct)
|
||||
=> throw new NotSupportedException("ConnectingFakeS7Plc serves no data");
|
||||
/// <summary>Answers the CPU-status probe.</summary>
|
||||
public Task ReadStatusAsync(CancellationToken ct) => Task.CompletedTask;
|
||||
/// <summary>Disposes the fake connection.</summary>
|
||||
public void Dispose() => IsConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user