private void CompilePortMappings() { PortMapping mapping = this.m_portMappings[0]; XmlNode node = this.m_setupNode.SelectSingleNode("Parallel1"); mapping.From = Convert.ToInt32(node.Attributes["from"].Value); mapping.To = Convert.ToInt32(node.Attributes["to"].Value); mapping.Mapped = (mapping.To + mapping.From) != 0; mapping.Reversed = node.Attributes["reversed"].Value[0] == '1'; mapping = this.m_portMappings[1]; node = this.m_setupNode.SelectSingleNode("Parallel2"); mapping.From = Convert.ToInt32(node.Attributes["from"].Value); mapping.To = Convert.ToInt32(node.Attributes["to"].Value); mapping.Mapped = (mapping.To + mapping.From) != 0; mapping.Reversed = node.Attributes["reversed"].Value[0] == '1'; mapping = this.m_portMappings[2]; node = this.m_setupNode.SelectSingleNode("Parallel3"); mapping.From = Convert.ToInt32(node.Attributes["from"].Value); mapping.To = Convert.ToInt32(node.Attributes["to"].Value); mapping.Mapped = (mapping.To + mapping.From) != 0; mapping.Reversed = node.Attributes["reversed"].Value[0] == '1'; int num = 0; foreach (PortMapping mapping2 in this.m_portMappings) { if (mapping2.Mapped) { num = Math.Max(num, mapping2.To); } } this.m_channelIndex = new byte[num]; this.SetDimmedChannels(this.m_setupNode.SelectSingleNode("Parallel1/dimming")); this.SetDimmedChannels(this.m_setupNode.SelectSingleNode("Parallel2/dimming")); this.SetDimmedChannels(this.m_setupNode.SelectSingleNode("Parallel3/dimming")); }
public void Event(byte[] channelValues) { PortMapping mapping = null; PortMapping mapping2 = null; byte[] array = new byte[channelValues.Length]; channelValues.CopyTo(array, 0); Array.Reverse(array); int length = array.Length; foreach (byte num3 in array) { mapping = null; foreach (PortMapping mapping3 in this.m_portMappings) { if ((mapping3.Mapped && (length >= mapping3.From)) && (length <= mapping3.To)) { mapping = mapping3; break; } } if (mapping == null) { throw new Exception("Attempt to write to unmapped channel " + length.ToString()); } if (mapping != mapping2) { if (mapping2 != null) { Out(mapping2.ControlPort, 1); Out(mapping2.ControlPort, 3); } mapping2 = mapping; } if (this.m_channelIndex[length - 1] == 0) { Out(mapping.DataPort, (num3 > 0) ? ((short)1) : ((short)0)); Out(mapping.ControlPort, 2); Out(mapping.ControlPort, 3); } else { int num4; if (mapping.Reversed) { num4 = 0xff - num3; } else { num4 = num3; } for (int i = 0; i < 8; i++) { Out(mapping.DataPort, (short)((num4 & 0x80) >> 7)); Out(mapping.ControlPort, 2); Out(mapping.ControlPort, 3); num4 = num4 << 1; } } length--; } if (mapping != null) { Out(mapping.ControlPort, 1); Out(mapping.ControlPort, 3); } }