using System;
using System.Collections.Generic;
using ZB.MOM.WW.OtOpcUa.Host.Domain;
using ZB.MOM.WW.OtOpcUa.Host.Metrics;
namespace ZB.MOM.WW.OtOpcUa.Host.Status
{
///
/// DTO containing all dashboard data. (DASH-001 through DASH-009)
///
public class StatusData
{
///
/// Gets or sets the current MXAccess and service connectivity summary shown on the dashboard.
///
public ConnectionInfo Connection { get; set; } = new();
///
/// Gets or sets the overall health state communicated to operators.
///
public HealthInfo Health { get; set; } = new();
///
/// Gets or sets subscription counts that show how many live tag streams the bridge is maintaining.
///
public SubscriptionInfo Subscriptions { get; set; } = new();
///
/// Gets or sets Galaxy-specific metadata such as deploy timing and address-space counts.
///
public GalaxyInfo Galaxy { get; set; } = new();
///
/// Gets or sets MXAccess data change dispatch queue metrics.
///
public DataChangeInfo DataChange { get; set; } = new();
///
/// Gets or sets per-operation performance statistics used to diagnose bridge throughput and latency.
///
public Dictionary Operations { get; set; } = new();
///
/// Gets or sets the historian integration status (plugin load outcome, server target).
///
public HistorianStatusInfo Historian { get; set; } = new();
///
/// Gets or sets the alarm integration status and event counters.
///
public AlarmStatusInfo Alarms { get; set; } = new();
///
/// Gets or sets the redundancy state when redundancy is enabled.
///
public RedundancyInfo? Redundancy { get; set; }
///
/// Gets or sets the listening OPC UA endpoints and active security profiles.
///
public EndpointsInfo Endpoints { get; set; } = new();
///
/// Gets or sets the Galaxy runtime host state (Platforms + AppEngines).
///
public RuntimeStatusInfo RuntimeStatus { get; set; } = new();
///
/// Gets or sets footer details such as the snapshot timestamp and service version.
///
public FooterInfo Footer { get; set; } = new();
}
///
/// Dashboard model summarizing per-host Galaxy runtime state.
///
public class RuntimeStatusInfo
{
///
/// Gets or sets the total number of tracked runtime hosts ($WinPlatform + $AppEngine).
///
public int Total { get; set; }
///
/// Gets or sets the count of hosts currently reported Running.
///
public int RunningCount { get; set; }
///
/// Gets or sets the count of hosts currently reported Stopped.
///
public int StoppedCount { get; set; }
///
/// Gets or sets the count of hosts whose state is still Unknown (either awaiting initial
/// probe resolution or transported-through-disconnected).
///
public int UnknownCount { get; set; }
///
/// Gets or sets the per-host state in stable alphabetical order.
///
public List Hosts { get; set; } = new();
}
///
/// Dashboard model describing the OPC UA server's listening endpoints and active security profiles.
///
public class EndpointsInfo
{
///
/// Gets or sets the list of opc.tcp base addresses the server is listening on.
///
public List BaseAddresses { get; set; } = new();
///
/// Gets or sets the list of configured user token policies (Anonymous, UserName, Certificate).
///
public List UserTokenPolicies { get; set; } = new();
///
/// Gets or sets the active security profiles reported to clients.
///
public List SecurityProfiles { get; set; } = new();
}
///
/// Dashboard model for a single configured OPC UA server security profile.
///
public class SecurityProfileInfo
{
///
/// Gets or sets the OPC UA security policy URI (e.g., http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256).
///
public string PolicyUri { get; set; } = "";
///
/// Gets or sets the short policy name extracted from the policy URI.
///
public string PolicyName { get; set; } = "";
///
/// Gets or sets the message security mode (None, Sign, SignAndEncrypt).
///
public string SecurityMode { get; set; } = "";
}
///
/// Dashboard model for current runtime connection details.
///
public class ConnectionInfo
{
///
/// Gets or sets the current MXAccess connection state shown to operators.
///
public string State { get; set; } = "Disconnected";
///
/// Gets or sets how many reconnect attempts have occurred since the service started.
///
public int ReconnectCount { get; set; }
///
/// Gets or sets the number of active OPC UA sessions connected to the bridge.
///
public int ActiveSessions { get; set; }
}
///
/// Dashboard model for the overall health banner.
///
public class HealthInfo
{
///
/// Gets or sets the high-level health state, such as Healthy, Degraded, or Unhealthy.
///
public string Status { get; set; } = "Unknown";
///
/// Gets or sets the operator-facing explanation for the current health state.
///
public string Message { get; set; } = "";
///
/// Gets or sets the color token used by the dashboard UI to render the health banner.
///
public string Color { get; set; } = "gray";
}
///
/// Dashboard model for subscription load.
///
public class SubscriptionInfo
{
///
/// Gets or sets the number of active tag subscriptions mirrored from MXAccess into OPC UA.
/// This total includes bridge-owned runtime status probes; see for the
/// subset attributable to probes.
///
public int ActiveCount { get; set; }
///
/// Gets or sets the count of bridge-owned runtime status probes included in
/// . Surfaced on the dashboard so operators can distinguish probe
/// overhead from client-driven subscription load.
///
public int ProbeCount { get; set; }
}
///
/// Dashboard model for Galaxy metadata and rebuild status.
///
public class GalaxyInfo
{
///
/// Gets or sets the Galaxy name currently being bridged into OPC UA.
///
public string GalaxyName { get; set; } = "";
///
/// Gets or sets a value indicating whether the repository database is currently reachable.
///
public bool DbConnected { get; set; }
///
/// Gets or sets the most recent deploy timestamp observed in the Galaxy repository.
///
public DateTime? LastDeployTime { get; set; }
///
/// Gets or sets the number of Galaxy objects currently represented in the address space.
///
public int ObjectCount { get; set; }
///
/// Gets or sets the number of Galaxy attributes currently represented as OPC UA variables.
///
public int AttributeCount { get; set; }
///
/// Gets or sets the UTC timestamp of the last completed address-space rebuild.
///
public DateTime? LastRebuildTime { get; set; }
}
///
/// Dashboard model for MXAccess data change dispatch metrics.
///
public class DataChangeInfo
{
///
/// Gets or sets the rate of MXAccess data change events received per second.
///
public double EventsPerSecond { get; set; }
///
/// Gets or sets the average number of items processed per dispatch cycle.
///
public double AvgBatchSize { get; set; }
///
/// Gets or sets the number of items currently waiting in the dispatch queue.
///
public int PendingItems { get; set; }
///
/// Gets or sets the total MXAccess data change events received since startup.
///
public long TotalEvents { get; set; }
}
///
/// Dashboard model for the Wonderware historian integration (runtime-loaded plugin).
///
public class HistorianStatusInfo
{
///
/// Gets or sets a value indicating whether historian support is enabled in configuration.
///
public bool Enabled { get; set; }
///
/// Gets or sets the most recent plugin load outcome as a string.
/// Values: Disabled, NotFound, LoadFailed, Loaded.
///
public string PluginStatus { get; set; } = "Disabled";
///
/// Gets or sets the error message from the last load attempt when is LoadFailed.
///
public string? PluginError { get; set; }
///
/// Gets or sets the absolute path the loader probed for the plugin assembly.
///
public string PluginPath { get; set; } = "";
///
/// Gets or sets the configured historian server hostname.
///
public string ServerName { get; set; } = "";
///
/// Gets or sets the configured historian TCP port.
///
public int Port { get; set; }
///
/// Gets or sets the total number of historian read queries attempted since startup.
///
public long QueryTotal { get; set; }
///
/// Gets or sets the number of historian queries that completed without an exception.
///
public long QuerySuccesses { get; set; }
///
/// Gets or sets the number of historian queries that raised an exception.
///
public long QueryFailures { get; set; }
///
/// Gets or sets the number of consecutive failures since the last successful query.
///
public int ConsecutiveFailures { get; set; }
///
/// Gets or sets the UTC timestamp of the last successful query.
///
public DateTime? LastSuccessTime { get; set; }
///
/// Gets or sets the UTC timestamp of the last query failure.
///
public DateTime? LastFailureTime { get; set; }
///
/// Gets or sets the exception message from the most recent failure.
///
public string? LastQueryError { get; set; }
///
/// Gets or sets a value indicating whether the plugin currently holds an open process-path
/// SDK connection.
///
public bool ProcessConnectionOpen { get; set; }
///
/// Gets or sets a value indicating whether the plugin currently holds an open event-path
/// SDK connection.
///
public bool EventConnectionOpen { get; set; }
///
/// Gets or sets the total number of configured historian cluster nodes.
///
public int NodeCount { get; set; }
///
/// Gets or sets the number of cluster nodes currently eligible for new connections
/// (i.e., not in failure cooldown).
///
public int HealthyNodeCount { get; set; }
///
/// Gets or sets the node currently serving process (historical value) queries, or null
/// when no process connection is open.
///
public string? ActiveProcessNode { get; set; }
///
/// Gets or sets the node currently serving event (alarm history) queries, or null when
/// no event connection is open.
///
public string? ActiveEventNode { get; set; }
///
/// Gets or sets the per-node cluster state in configuration order.
///
public List Nodes { get; set; } = new();
}
///
/// Dashboard model for alarm integration health and event counters.
///
public class AlarmStatusInfo
{
///
/// Gets or sets a value indicating whether alarm condition tracking is enabled in configuration.
///
public bool TrackingEnabled { get; set; }
///
/// Gets or sets the number of distinct alarm conditions currently tracked.
///
public int ConditionCount { get; set; }
///
/// Gets or sets the number of alarms currently in the InAlarm=true state.
///
public int ActiveAlarmCount { get; set; }
///
/// Gets or sets the total number of InAlarm transitions observed since startup.
///
public long TransitionCount { get; set; }
///
/// Gets or sets the total number of alarm acknowledgement transitions observed since startup.
///
public long AckEventCount { get; set; }
///
/// Gets or sets the total number of alarm acknowledgement MXAccess writes that have failed since startup.
///
public long AckWriteFailures { get; set; }
///
/// Gets or sets a value indicating whether the template-based alarm object filter is active.
///
public bool FilterEnabled { get; set; }
///
/// Gets or sets the number of compiled alarm filter patterns.
///
public int FilterPatternCount { get; set; }
///
/// Gets or sets the number of Galaxy objects included by the alarm filter during the most recent build.
///
public int FilterIncludedObjectCount { get; set; }
///
/// Gets or sets the raw alarm filter patterns exactly as configured, for dashboard display.
///
public List FilterPatterns { get; set; } = new();
}
///
/// Dashboard model for redundancy state. Only populated when redundancy is enabled.
///
public class RedundancyInfo
{
///
/// Gets or sets whether redundancy is enabled.
///
public bool Enabled { get; set; }
///
/// Gets or sets the redundancy mode (e.g., "Warm", "Hot").
///
public string Mode { get; set; } = "";
///
/// Gets or sets this instance's role ("Primary" or "Secondary").
///
public string Role { get; set; } = "";
///
/// Gets or sets the current ServiceLevel byte.
///
public byte ServiceLevel { get; set; }
///
/// Gets or sets this instance's ApplicationUri.
///
public string ApplicationUri { get; set; } = "";
///
/// Gets or sets the list of all server URIs in the redundant set.
///
public List ServerUris { get; set; } = new();
}
///
/// DTO for the /api/health endpoint. Includes component-level health, ServiceLevel, and redundancy state.
///
public class HealthEndpointData
{
///
/// Gets or sets the overall health status: Healthy, Degraded, or Unhealthy.
///
public string Status { get; set; } = "Unknown";
///
/// Gets or sets the computed OPC UA ServiceLevel byte (0-255). Only meaningful when redundancy is enabled.
///
public byte ServiceLevel { get; set; }
///
/// Gets or sets whether redundancy is enabled.
///
public bool RedundancyEnabled { get; set; }
///
/// Gets or sets this instance's redundancy role when enabled (Primary/Secondary), or null when disabled.
///
public string? RedundancyRole { get; set; }
///
/// Gets or sets the redundancy mode when enabled (Warm/Hot), or null when disabled.
///
public string? RedundancyMode { get; set; }
///
/// Gets or sets the per-component health breakdown.
///
public ComponentHealth Components { get; set; } = new();
///
/// Gets or sets the server uptime since the health endpoint was initialized.
///
public string Uptime { get; set; } = "";
///
/// Gets or sets the UTC timestamp of this health snapshot.
///
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
}
///
/// Per-component health breakdown for the health endpoint.
///
public class ComponentHealth
{
///
/// Gets or sets MXAccess runtime connectivity status.
///
public string MxAccess { get; set; } = "Disconnected";
///
/// Gets or sets Galaxy repository database connectivity status.
///
public string Database { get; set; } = "Disconnected";
///
/// Gets or sets OPC UA server status.
///
public string OpcUaServer { get; set; } = "Stopped";
///
/// Gets or sets the historian plugin status.
/// Values: Disabled, NotFound, LoadFailed, Loaded.
///
public string Historian { get; set; } = "Disabled";
///
/// Gets or sets whether alarm condition tracking is enabled.
/// Values: Disabled, Enabled.
///
public string Alarms { get; set; } = "Disabled";
}
///
/// Dashboard model for the status page footer.
///
public class FooterInfo
{
///
/// Gets or sets the UTC time when the status snapshot was generated.
///
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
///
/// Gets or sets the service version displayed to operators for support and traceability.
///
public string Version { get; set; } = "";
}
}