namespace ZB.MOM.WW.OtOpcUa.Core.Abstractions;
///
/// Streaming builder API a driver uses to register OPC UA nodes during discovery.
/// Core owns the tree; driver streams AddFolder / AddVariable calls
/// as it discovers nodes — no buffering of the whole tree.
///
///
/// Per docs/v2/plan.md decision #52 — drivers register nodes via this builder
/// rather than returning a tree object. Supports incremental / large address spaces
/// without forcing the driver to buffer the whole tree.
///
public interface IAddressSpaceBuilder
{
///
/// Add a folder node. Returns a child builder scoped to inside this folder, so subsequent
/// calls on the child place nodes under it.
///
/// OPC UA browse name (the segment of the path under the parent).
/// Human-readable display name. May equal .
IAddressSpaceBuilder Folder(string browseName, string displayName);
///
/// Add a variable node corresponding to a tag. Driver-side full reference + data-type
/// metadata come from the DTO.
///
/// OPC UA browse name (the segment of the path under the parent folder).
/// Human-readable display name. May equal .
/// Driver-side metadata for the variable.
IVariableHandle Variable(string browseName, string displayName, DriverAttributeInfo attributeInfo);
///
/// Add a property to the current node (folder or variable). Properties are static metadata
/// read once at build time (e.g. OPC 40010 Identification fields per the schemas-repo
/// _base equipment-class template).
///
void AddProperty(string browseName, DriverDataType dataType, object? value);
}
/// Opaque handle for a registered variable. Used by Core for subscription routing.
public interface IVariableHandle
{
/// Driver-side full reference for read/write addressing.
string FullReference { get; }
///
/// Annotate this variable with an OPC UA AlarmConditionState. Drivers with
/// = true call this during discovery so the
/// concrete address-space builder can materialize a sibling condition node. The returned
/// sink receives lifecycle transitions raised through
/// — the generic node manager wires the subscription; the concrete builder decides how
/// to surface the state (e.g. OPC UA AlarmConditionState.Activate,
/// Acknowledge, Deactivate).
///
IAlarmConditionSink MarkAsAlarmCondition(AlarmConditionInfo info);
}
///
/// Metadata used to materialize an OPC UA AlarmConditionState sibling for a variable.
/// Populated by the driver's discovery step; concrete builders decide how to surface it.
///
/// Human-readable alarm name used for the SourceName event field.
/// Severity at address-space build time; updates arrive via .
/// Initial description; updates arrive via .
///
/// Driver-side full reference for the boolean attribute that toggles when the
/// alarm condition becomes active. Consumed by the server-level alarm-condition
/// service to subscribe to active/inactive transitions. Null when the driver
/// reports alarm transitions through some other channel.
///
///
/// Driver-side full reference for the integer attribute carrying the alarm's
/// current priority / severity. Live updates flow through the same subscription
/// pipeline as . Null when the driver does not
/// expose live priority changes.
///
///
/// Driver-side full reference for the string attribute carrying the human-readable
/// description / message. Null when the driver does not expose a live description.
///
///
/// Driver-side full reference for the boolean attribute that toggles when the
/// alarm is acknowledged. Null when acknowledgement is not observable on the
/// driver side.
///
///
/// Driver-side full reference the server writes to acknowledge the condition,
/// typically the alarm's .AckMsg attribute. Null when the driver does not
/// accept acknowledgement writes (or routes them through a separate API).
///
public sealed record AlarmConditionInfo(
string SourceName,
AlarmSeverity InitialSeverity,
string? InitialDescription,
string? InAlarmRef = null,
string? PriorityRef = null,
string? DescAttrNameRef = null,
string? AckedRef = null,
string? AckMsgWriteRef = null);
///
/// Sink a concrete address-space builder returns from .
/// The generic node manager routes per-alarm payloads here —
/// the sink translates the transition into an OPC UA condition state change or whatever the
/// concrete builder's backing address space supports.
///
public interface IAlarmConditionSink
{
/// Push an alarm transition (Active / Acknowledged / Inactive) for this condition.
void OnTransition(AlarmEventArgs args);
}