using System; using MessagePack; namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Shared.Contracts; /// /// Phase 7 Stream D — IPC contracts for routing Part 9 alarm transitions from the /// main .NET 10 server into Galaxy.Host's already-loaded aahClientManaged /// DLLs. Reuses the Tier-C isolation + licensing pathway rather than loading 32-bit /// native historian code into the main server. /// /// /// /// Batched on the wire to amortize IPC overhead — the main server's SqliteStoreAndForwardSink /// ships up to 100 events per request per Phase 7 plan Stream D.5. /// /// /// Per-event outcomes (Ack / RetryPlease / PermanentFail) let the drain worker /// dead-letter malformed events without blocking neighbors in the batch. /// fires proactively from /// the Host when the SDK session drops so the /hosts + /alarms/historian Admin /// diagnostics pages flip to red promptly instead of waiting for the next /// drain cycle. /// /// [MessagePackObject] public sealed class HistorianAlarmEventRequest { [Key(0)] public HistorianAlarmEventDto[] Events { get; set; } = Array.Empty(); } [MessagePackObject] public sealed class HistorianAlarmEventResponse { /// Per-event outcome, same order as the request. [Key(0)] public HistorianAlarmEventOutcomeDto[] Outcomes { get; set; } = Array.Empty(); } /// Outcome enum — bytes on the wire so it stays compact. public enum HistorianAlarmEventOutcomeDto : byte { /// Successfully persisted to the historian — remove from queue. Ack = 0, /// Transient failure (historian disconnected, timeout, busy) — retry after backoff. RetryPlease = 1, /// Permanent failure (malformed, unrecoverable SDK error) — move to dead-letter. PermanentFail = 2, } /// One alarm-transition payload. Fields mirror Core.AlarmHistorian.AlarmHistorianEvent. [MessagePackObject] public sealed class HistorianAlarmEventDto { [Key(0)] public string AlarmId { get; set; } = string.Empty; [Key(1)] public string EquipmentPath { get; set; } = string.Empty; [Key(2)] public string AlarmName { get; set; } = string.Empty; /// Concrete Part 9 subtype name — "LimitAlarm" / "OffNormalAlarm" / "AlarmCondition" / "DiscreteAlarm". [Key(3)] public string AlarmTypeName { get; set; } = string.Empty; /// Numeric severity the Host maps to the historian's priority scale. [Key(4)] public int Severity { get; set; } /// Which transition this event represents — "Activated" / "Cleared" / "Acknowledged" / etc. [Key(5)] public string EventKind { get; set; } = string.Empty; /// Pre-rendered message — template tokens resolved upstream. [Key(6)] public string Message { get; set; } = string.Empty; /// Operator who triggered the transition. "system" for engine-driven events. [Key(7)] public string User { get; set; } = "system"; /// Operator-supplied free-form comment, if any. [Key(8)] public string? Comment { get; set; } /// Source timestamp (UTC Unix milliseconds). [Key(9)] public long TimestampUtcUnixMs { get; set; } } /// /// Proactive notification — Galaxy.Host pushes this when the historian SDK session /// transitions (connected / disconnected / degraded). The main server reflects this /// into the historian sink status so Admin UI surfaces the problem without the /// operator having to scrutinize drain cadence. /// [MessagePackObject] public sealed class HistorianConnectivityStatusNotification { [Key(0)] public string Status { get; set; } = "unknown"; // connected | disconnected | degraded [Key(1)] public string? Detail { get; set; } [Key(2)] public long ObservedAtUtcUnixMs { get; set; } }