I want to control a color (in this example "red") in 512 DMX-channels. I read the red color from an XML-file and put it in a Dictionary:
<Channel Id="Lamp1Red" Key="2"/>
<Channel Id="Lamp1Green" Key="3"/>
<Channel Id="Lamp1Blue" Key="4"/>
<Channel Id="Lamp2Red" Key="5"/>
<Channel Id="Lamp2Green" Key="6"/>
<Channel Id="Lamp2Blue" Key="7"/>
<Channel Id="Lamp3Red" Key="8"/>
etc. ... up to 512 keys/channels.
I have the following Dictionary
which contains IDs (string) and Channel(Key+Value)
public Dictionary<string, Tuple<byte, byte>> DmxChannelsDictionary
{
get;
set;
}
I want to lookup all strings (red) containing ID "LampXRed" and get the Key (2, 5, 8) for each one of them and use them in the following method SetColor:
SetColor(red, green, blue);
public void SetColor(Tuple<byte, byte> redTuple, Tuple<byte, byte> greenTuple, Tuple<byte, byte> blueTuple)
SetColor passes the Tuples to DmxDataMessage()
public static byte[] DmxDataMessage(Tuple<byte, byte> redTuple, Tuple<byte, byte> greenTuple, Tuple<byte, byte> blueTuple)
{
//Initialize DMX-buffer: Must be full buffer (512Bytes)
var dmxBuffer = new byte[512];
dmxBuffer.Initialize();
// Fill DATA Buffer: Item1 (Key/Channel) = Item2 (Value)
// Channel1
dmxBuffer[redTuple.Item1] = redTuple.Item2;
dmxBuffer[greenTuple.Item1] = greenTuple.Item2;
dmxBuffer[blueTuple.Item1] = blueTuple.Item2;
// Here I need a foreach or something else to set the the value for each channel (up to 512)
....
How do I make a smart search/interation in the Dictionary and save all red-IDs + Keys for use in SetColor()
???
This is the way I do it for one "red" channel:
var red = DmxChannelsDictionary["Lamp1Red"];
red = Tuple.Create(red.Item1, _redValue); // _redValue = 0-255
I hope this makes sense. Thanks a lot for your help!