-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathControllerInfo.cs
53 lines (47 loc) · 1.45 KB
/
ControllerInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using BitFab.KW1281Test.Blocks;
using System;
using System.Collections.Generic;
using System.Text;
namespace BitFab.KW1281Test
{
/// <summary>
/// The info returned when a controller wakes up.
/// </summary>
internal class ControllerInfo
{
public ControllerInfo(IEnumerable<Block> blocks)
{
var sb = new StringBuilder();
foreach (var block in blocks)
{
if (block is AsciiDataBlock asciiBlock)
{
sb.Append(asciiBlock);
if (asciiBlock.MoreDataAvailable)
{
MoreDataAvailable = true;
}
}
else if (block is CodingWscBlock codingBlock)
{
sb.Append($"{Environment.NewLine}{codingBlock}");
SoftwareCoding = codingBlock.SoftwareCoding;
WorkshopCode = codingBlock.WorkshopCode;
}
else
{
Log.WriteLine($"Controller wakeup returned block of type {block.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;
}
}
}