Files
lmxopcua/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.S7.IntegrationTests/S7_1500/S7_1500Profile.cs
T
Joseph Doherty 9f62f2c242 refactor(driver-s7): extract S7DriverOptions to .Contracts with parallel CpuType enum
Introduces Driver.S7.Contracts (dependency-free POCO project) and moves
S7DriverOptions / S7ProbeOptions / S7TagDefinition / S7DataType into it.
Adds S7CpuType enum mirroring S7.Net.CpuType exactly (7 values with
explicit integer codes). Runtime S7CpuTypeMap bridges S7CpuType →
S7.Net.CpuType at the single Plc construction site in S7Driver.InitializeAsync.
S7DriverFactoryExtensions and S7CommandBase updated to use S7CpuType; test
files updated to match (S7_1500Profile, S7DriverScaffoldTests). AdminUI can
now reference Driver.S7.Contracts without pulling in S7netplus.
2026-05-28 09:08:27 -04:00

55 lines
2.3 KiB
C#

namespace ZB.MOM.WW.OtOpcUa.Driver.S7.IntegrationTests.S7_1500;
/// <summary>
/// Driver-side configuration matching what <c>Docker/profiles/s7_1500.json</c> seeds
/// into the simulator's DB1 + MB areas. Tag names here become the full references
/// the smoke tests read/write against; addresses map 1:1 to the JSON profile's
/// seed offsets so a seed drift in the JSON surfaces as a driver-side read
/// mismatch, not a mystery test failure.
/// </summary>
public static class S7_1500Profile
{
public const string ProbeTag = "ProbeProbeWord";
public const int ProbeSeedValue = 4242;
public const string SmokeI16Tag = "SmokeI16";
public const short SmokeI16SeedValue = -12345;
public const string SmokeI32Tag = "SmokeI32";
public const int SmokeI32SeedValue = 1234567890;
public const string SmokeF32Tag = "SmokeF32";
public const float SmokeF32SeedValue = 3.14159f;
public const string SmokeBoolTag = "SmokeBool";
public const string WriteScratchTag = "WriteScratch";
/// <summary>Builds the S7 driver options for the S7-1500 integration tests.</summary>
/// <param name="host">The hostname or IP address of the S7 PLC.</param>
/// <param name="port">The port number for the S7 PLC connection.</param>
public static S7DriverOptions BuildOptions(string host, int port) => new()
{
Host = host,
Port = port,
CpuType = S7CpuType.S71500,
Rack = 0,
Slot = 0,
Timeout = TimeSpan.FromSeconds(5),
// Disable the probe loop — the integration tests run their own reads +
// a background probe would race with them for the S7netplus mailbox
// gate, injecting flakiness that has nothing to do with the code
// under test.
Probe = new S7ProbeOptions { Enabled = false },
Tags =
[
new S7TagDefinition(ProbeTag, "DB1.DBW0", S7DataType.UInt16),
new S7TagDefinition(SmokeI16Tag, "DB1.DBW10", S7DataType.Int16),
new S7TagDefinition(SmokeI32Tag, "DB1.DBD20", S7DataType.Int32),
new S7TagDefinition(SmokeF32Tag, "DB1.DBD30", S7DataType.Float32),
new S7TagDefinition(SmokeBoolTag, "DB1.DBX50.3", S7DataType.Bool),
new S7TagDefinition(WriteScratchTag, "DB1.DBW100", S7DataType.UInt16),
],
};
}