using HC_APTBS.Infrastructure.Kwp.Packets; using System; using System.Collections.Generic; using System.Text; namespace HC_APTBS.Infrastructure.Kwp { /// /// The info returned when a controller wakes up. /// public class ControllerInfo { public ControllerInfo(IEnumerable 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; } } }