2024-05-21 19:41:16 +01:00
|
|
|
|
namespace M6502.HarteTest
|
|
|
|
|
{
|
2024-07-18 11:38:02 +01:00
|
|
|
|
public sealed class Cycle
|
2024-05-21 19:41:16 +01:00
|
|
|
|
{
|
|
|
|
|
public ushort Address { get; set; }
|
|
|
|
|
|
|
|
|
|
public byte Value { get; set; }
|
|
|
|
|
|
|
|
|
|
public string? Type { get; set; }
|
|
|
|
|
|
|
|
|
|
public Cycle(ushort address, byte value, string type)
|
|
|
|
|
{
|
|
|
|
|
this.Address = address;
|
|
|
|
|
this.Value = value;
|
|
|
|
|
this.Type = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Cycle(List<object> input)
|
|
|
|
|
{
|
|
|
|
|
if (input.Count != 3)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(input), input, "Cycles can only have three elements");
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-18 11:38:02 +01:00
|
|
|
|
this.Address = AsElement(input[0]).GetUInt16();
|
|
|
|
|
this.Value = AsElement(input[1]).GetByte();
|
|
|
|
|
this.Type = AsElement(input[2]).GetString();
|
2024-05-21 19:41:16 +01:00
|
|
|
|
}
|
2024-07-18 11:38:02 +01:00
|
|
|
|
|
|
|
|
|
private static System.Text.Json.JsonElement AsElement(object part) => (System.Text.Json.JsonElement)part;
|
2024-05-21 19:41:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|