using System;

namespace ZB.MOM.WW.LmxProxy.Client.Domain;

/// <summary>
/// Value, Timestamp, and Quality structure for SCADA data.
/// </summary>
/// <param name="Value">The value.</param>
/// <param name="Timestamp">The timestamp when the value was read.</param>
/// <param name="Quality">The quality of the value.</param>
public readonly record struct Vtq(object? Value, DateTime Timestamp, Quality Quality)
{
	/// <summary>Creates a new VTQ with the specified value and quality, using the current UTC timestamp.</summary>
	public static Vtq New(object? value, Quality quality) => new(value, DateTime.UtcNow, quality);

	/// <summary>Creates a new VTQ with the specified value, timestamp, and quality.</summary>
	public static Vtq New(object? value, DateTime timestamp, Quality quality) => new(value, timestamp, quality);

	/// <summary>Creates a Good-quality VTQ with the current UTC time.</summary>
	public static Vtq Good(object? value) => new(value, DateTime.UtcNow, Quality.Good);

	/// <summary>Creates a Bad-quality VTQ with the current UTC time.</summary>
	public static Vtq Bad(object? value = null) => new(value, DateTime.UtcNow, Quality.Bad);

	/// <summary>Creates an Uncertain-quality VTQ with the current UTC time.</summary>
	public static Vtq Uncertain(object? value) => new(value, DateTime.UtcNow, Quality.Uncertain);
}
