46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using adas_core.Domain.Enums;
|
|
|
|
namespace adas_core.Domain.Models.MongoModels;
|
|
|
|
/// <summary>
|
|
/// Represents an alarm item entity.
|
|
/// </summary>
|
|
public class AlarmItem
|
|
{
|
|
public bool Enabled { get; set; }
|
|
public int StartBefore { get; set; } // seconds
|
|
public int EndAfter { get; set; } // seconds overrides
|
|
|
|
public string? Color
|
|
{
|
|
get => BeaconColor.ToString();
|
|
set
|
|
{
|
|
if (!string.IsNullOrEmpty(value) && Enum.TryParse(value, out AlarmEnum.BeaconColor color))
|
|
BeaconColor = color;
|
|
}
|
|
}
|
|
|
|
public AlarmEnum.Severity Severity { get; set; } = AlarmEnum.Severity.None;
|
|
public AlarmEnum.BeaconColor BeaconColor { get; set; } = AlarmEnum.BeaconColor.None;
|
|
|
|
/// <summary>
|
|
/// Returns a formatted string representation of the <see cref="AlarmItem"/>, including the Enabled, StartBefore, EndAfter, Severity, and BeaconColor values, and optionally appending the Color value when it is not null or empty.
|
|
/// </summary>
|
|
/// <returns>A string in the format "AlarmItem[item1, item2, ...]" containing the key properties of the alarm item.</returns>
|
|
public override string ToString()
|
|
{
|
|
List<string> items =
|
|
[
|
|
$"Enabled: {Enabled}",
|
|
$"StartBefore: {StartBefore}",
|
|
$"EndAfter: {EndAfter}",
|
|
$"Severity: {Severity}",
|
|
$"BeaconColorEnum: {BeaconColor}"
|
|
];
|
|
if (!string.IsNullOrEmpty(Color)) items.Add($"Color: {Color}");
|
|
|
|
|
|
return "AlarmItem[" + string.Join(", ", items) + "]";
|
|
}
|
|
} |