initial commit

This commit is contained in:
2026-04-11 12:45:18 +02:00
commit 6e1b929e2f
1246 changed files with 177580 additions and 0 deletions

43
Models/Alarm.cs Normal file
View File

@@ -0,0 +1,43 @@
using System.Xml.Linq;
namespace HC_APTBS.Models
{
/// <summary>
/// Defines a single alarm condition monitored by the bench controller.
/// Alarms are bit-mapped: the bench asserts a bitmask in the Alarms CAN parameter
/// (<see cref="BenchParameterNames.Alarms"/>) and each bit corresponds to a named condition.
/// </summary>
public class Alarm
{
/// <summary>Bit position in the alarm bitmask (0-based).</summary>
public int Bit { get; set; }
/// <summary>Human-readable description of this alarm condition.</summary>
public string Description { get; set; } = string.Empty;
/// <summary>
/// When true, this alarm immediately halts any running test and requires
/// operator acknowledgement before the bench can be restarted.
/// </summary>
public bool IsCritical { get; set; }
/// <summary>True while this alarm condition is currently active.</summary>
public bool IsActive { get; set; }
/// <summary>Serialises this alarm to XML for persistence in alarms.xml.</summary>
public XElement ToXml()
=> new XElement("Alarm",
new XAttribute("bit", Bit),
new XAttribute("desc", Description),
new XAttribute("critical", IsCritical));
/// <summary>Deserialises an alarm from an XML element.</summary>
public static Alarm FromXml(XElement element)
=> new Alarm
{
Bit = int.Parse(element.Attribute("bit")?.Value ?? "0"),
Description = element.Attribute("desc")?.Value ?? string.Empty,
IsCritical = bool.Parse(element.Attribute("critical")?.Value ?? "false")
};
}
}