54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using HC_APTBS.Infrastructure.Kwp.Packets;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace HC_APTBS.Infrastructure.Kwp
|
|
{
|
|
/// <summary>
|
|
/// The info returned when a controller wakes up.
|
|
/// </summary>
|
|
public class ControllerInfo
|
|
{
|
|
public ControllerInfo(IEnumerable<Packet> packets)
|
|
{
|
|
var sb = new StringBuilder();
|
|
foreach (var packet in packets)
|
|
{
|
|
if (packet is AsciiDataPacket asciiPacket)
|
|
{
|
|
sb.Append(asciiPacket);
|
|
if (asciiPacket.MoreDataAvailable)
|
|
{
|
|
MoreDataAvailable = true;
|
|
}
|
|
}
|
|
else if (packet is CodingWscPacket codingPacket)
|
|
{
|
|
sb.Append($"{Environment.NewLine}{codingPacket}");
|
|
SoftwareCoding = codingPacket.SoftwareCoding;
|
|
WorkshopCode = codingPacket.WorkshopCode;
|
|
}
|
|
else
|
|
{
|
|
System.Diagnostics.Debug.WriteLine($"Controller wakeup returned packet of type {packet.GetType()}");
|
|
}
|
|
}
|
|
Text = sb.ToString();
|
|
}
|
|
|
|
public string Text { get; }
|
|
|
|
public bool MoreDataAvailable { get; }
|
|
|
|
public int SoftwareCoding { get; }
|
|
|
|
public int WorkshopCode { get; }
|
|
|
|
public override string ToString()
|
|
{
|
|
return Text;
|
|
}
|
|
}
|
|
}
|