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

88
Models/Relay.cs Normal file
View File

@@ -0,0 +1,88 @@
using System.Xml.Linq;
namespace HC_APTBS.Models
{
/// <summary>
/// Represents a single relay or solenoid output on the test bench.
/// Each relay is mapped to a specific bit position within a CAN message.
/// The bench controller reads a bitmask from CAN message ID <see cref="MessageId"/>
/// and asserts the corresponding output.
/// </summary>
public class Relay
{
/// <summary>
/// True when the relay is energised (output ON); false when de-energised.
/// </summary>
public const bool On = true;
/// <summary>False indicates the relay is de-energised (output OFF).</summary>
public const bool Off = false;
/// <summary>Human-readable relay name (see <see cref="RelayNames"/>).</summary>
public string Name { get; set; } = string.Empty;
/// <summary>CAN message identifier that carries this relay's bitmask.</summary>
public uint MessageId { get; set; }
/// <summary>Bit position within the 64-bit relay bitmask sent in the CAN payload.</summary>
public int Bit { get; set; }
/// <summary>Current output state: true = energised, false = de-energised.</summary>
public bool State { get; set; }
/// <summary>Parameterless constructor for deserialisation.</summary>
public Relay() { }
/// <param name="name">Relay name constant from <see cref="RelayNames"/>.</param>
/// <param name="messageId">CAN message ID carrying the relay bitmask.</param>
/// <param name="bit">Bit position in the 64-bit bitmask.</param>
public Relay(string name, uint messageId, int bit)
{
Name = name;
MessageId = messageId;
Bit = bit;
}
/// <summary>Serialises this relay definition to XML for persistence.</summary>
public XElement ToXml()
=> new XElement("Rele",
new XAttribute("name", Name),
new XAttribute("id", MessageId.ToString("X")),
new XAttribute("bit", Bit));
}
/// <summary>Pump rotation direction constants.</summary>
public static class RotationDirection
{
/// <summary>CAN value for counter-clockwise (left) rotation.</summary>
public const short Left = 2;
/// <summary>CAN value for clockwise (right) rotation.</summary>
public const short Right = 1;
public const string LeftName = "left";
public const string RightName = "right";
}
/// <summary>Encoder operating mode constants.</summary>
public static class EncoderMode
{
public const double ModeOn = 1;
public const double ModeOff = 0;
/// <summary>4-cylinder pulse-per-revolution mode.</summary>
public const double Pumps4 = 1;
/// <summary>6-cylinder pulse-per-revolution mode.</summary>
public const double Pumps6 = 0;
public const double PositionRelative = 0;
public const double PositionAbsolute = 1;
}
/// <summary>CAN baudrate selector values sent to the bench firmware.</summary>
public static class BaudrateSelection
{
/// <summary>Select 500 kbps.</summary>
public const double Val500K = 1;
/// <summary>Select 250 kbps.</summary>
public const double Val250K = 0;
}
}