-
Notifications
You must be signed in to change notification settings - Fork 0
/
xController.cs
87 lines (76 loc) · 1.9 KB
/
xController.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using xLights22;
using XMLhelper;
namespace wLights
{
public class xController : xMember
// For the xlights_networks.xml (not rgb_effects.xml)
{
private string xmlData = "";
protected int myChannelCount = 0;
protected int myStartChannel = 0;
protected xNetworks myNetwork= null;
protected List<string> networks = new List<string>();
public xController(string xmlData, xNetworks parent)
{
myXMLdata = xmlData;
myName = XMLhelp.getKeyWord(xmlData, "name");
myNetwork = parent;
}
public override xMemberType MemberType
{ get { return xMemberType.Controller; } }
public void AddNetwork(string networkInfo)
{ networks.Add(networkInfo); }
public int StartChannel
{
get
{
// Already cached?
if (myStartChannel < 1)
{
// No, calculate it then cache it for future queries
myStartChannel= 1;
// Begin a loop thru all the [other] controllers that come BEFORE this one.
foreach (xController ctlr in xNetworks.Controllers)
{
// Have we reached ourself in the list?
if (ctlr.Name == myName)
{
// Yes, exit the loop. All controllers AFTER this do not effect start channel
break;
}
else
{
// No, controller comes before this one, so add its count to the start of this one
myStartChannel += ctlr.ChannelCount;
}
}
}
return myStartChannel;
}
}
public int EndChannel
{ get { return (StartChannel + ChannelCount - 1); } }
public int ChannelCount
{
get
{
// Already cached?
if (myChannelCount < 1)
{
// No, calculate it then cache it for future queries
foreach (string nw in networks)
{
int mc = XMLhelp.getKeyValue(nw, "MaxChannels");
myChannelCount += mc;
}
}
return myChannelCount;
}
}
}
}