namespace ZB.MOM.WW.OtOpcUa.Driver.Modbus; /// /// Modbus TCP driver configuration. Bound from the driver's DriverConfig JSON at /// DriverHost.RegisterAsync. Every register the driver exposes appears in /// ; names become the OPC UA browse name + full reference. /// public sealed class ModbusDriverOptions { public string Host { get; init; } = "127.0.0.1"; public int Port { get; init; } = 502; public byte UnitId { get; init; } = 1; public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(2); /// Pre-declared tag map. Modbus has no discovery protocol — the driver returns exactly these. public IReadOnlyList Tags { get; init; } = []; } /// /// One Modbus-backed OPC UA variable. Address is zero-based (Modbus spec numbering, not /// the documentation's 1-based coil/register conventions). /// /// /// Tag name, used for both the OPC UA browse name and the driver's full reference. Must be /// unique within the driver. /// /// Coils / DiscreteInputs / InputRegisters / HoldingRegisters. /// Zero-based address within the region. /// Logical data type. Int16/UInt16 = single register; Int32/UInt32/Float32 = two registers big-endian. /// When true and Region supports writes (Coils / HoldingRegisters), IWritable routes writes here. public sealed record ModbusTagDefinition( string Name, ModbusRegion Region, ushort Address, ModbusDataType DataType, bool Writable = true); public enum ModbusRegion { Coils, DiscreteInputs, InputRegisters, HoldingRegisters } public enum ModbusDataType { Bool, Int16, UInt16, Int32, UInt32, Float32 }