コード例 #1
0
    /// <summary>
    /// 获取当前 ChannelFunction 下的 ChannelSet
    /// </summary>
    /// <param name="channelFunctionNode">ChannelFunction 节点</param>
    /// <param name="channelFunction">GDTF_DmxChannelFunction 对象</param>
    private static void GetDmxChannelSets(XmlNode channelFunctionNode, GDTF_DmxChannelFunction channelFunction)
    {
        // 如果 ChannelFunction 节点下面存在子节点
        if (channelFunctionNode.HasChildNodes)
        {
            List <XmlNode>            channelSetNodes = new List <XmlNode>();
            List <GDTF_DmxChannelSet> channelSets     = new List <GDTF_DmxChannelSet>();

            foreach (XmlNode channelSetNode in channelFunctionNode)
            {
                // 只保存 ChannelSet 节点
                if (channelSetNode.Name == "ChannelSet")
                {
                    channelSetNodes.Add(channelSetNode);
                }
            }

            // 遍历整理后有效的 ChannelSet 节点
            for (int i = 0; i < channelSetNodes.Count; i++)
            {
                GDTF_DmxChannelSet channelSet = new GDTF_DmxChannelSet();

                // 获取预设的起始通道值
                int dmxFrom = GetDmxValue(GetNodeAttribute(channelSetNodes[i], "DMXFrom"));

                // 预设的结束通道值
                int dmxTo;

                // 如果但当前已经索引到最后一个 ChannelSet,那么 ChannelSet 的 dmxTo 为 Channel 的最大 DmxTo 值
                // 否则 ChannelSet 的 dmxTo 值为,下一个 ChannelSet 的 dmxFrom 值减一
                if (i == channelSetNodes.Count - 1)
                {
                    dmxTo = channelFunction.functionDmxTo;
                }
                else
                {
                    dmxTo = GetDmxValue(GetNodeAttribute(channelSetNodes[i + 1], "DMXFrom")) - 1;
                }

                // 如果当前节点的 Name 属性不为空就添加
                if (GetNodeAttribute(channelSetNodes[i], "Name") != string.Empty)
                {
                    channelSet.setName        = GetNodeAttribute(channelSetNodes[i], "Name");
                    channelSet.setDmxForm     = dmxFrom;
                    channelSet.setDmxTo       = dmxTo;
                    channelSet.wheelSlotIndex = Convert.ToInt32(GetNodeAttribute(channelSetNodes[i], "WheelSlotIndex"));
                    channelSet.setName        = GetNodeAttribute(channelSetNodes[i], "Name");

                    channelSets.Add(channelSet);
                }
            }

            channelFunction.channelSets = channelSets;
        }
    }
コード例 #2
0
    /// <summary>
    /// 获取当前 DMX LogicalChannel 下的 ChannelFunction
    /// </summary>
    /// <param name="logicalChannelNode">LogicalChannel 节点</param>
    /// <param name="logicalChannel">DMXChannelData 对象</param>
    /// <param name="data">GDTF_Data 对象</param>
    private static void GetDmxChannelFuctions(XmlNode logicalChannelNode, GDTF_DmxLogicalChannel logicalChannel, GDTF_Data data)
    {
        // 如果 LogicalChannel 节点下存在子节点
        if (logicalChannelNode.HasChildNodes)
        {
            List <XmlNode> channelFunctionNodes = new List <XmlNode>();

            // 获取所有 ChannelFunction 节点
            foreach (XmlNode channelFunctionNode in logicalChannelNode)
            {
                // 只保存 ChannelFunction 节点
                if (channelFunctionNode.Name == "ChannelFunction")
                {
                    channelFunctionNodes.Add(channelFunctionNode);
                }
            }

            for (int i = 0; i < channelFunctionNodes.Count; i++)
            {
                GDTF_DmxChannelFunction channelFunction = new GDTF_DmxChannelFunction();

                int functionDmxFrom = GetDmxValue(GetNodeAttribute(channelFunctionNodes[i], "DMXFrom"));
                int functionDmxTo;

                if (i == channelFunctionNodes.Count - 1)
                {
                    functionDmxTo = (1 << ((int)GetDmxValueResolution(GetNodeAttribute(channelFunctionNodes[i], "DMXFrom")) * 8)) - 1;
                }
                else
                {
                    functionDmxTo = GetDmxValue(GetNodeAttribute(channelFunctionNodes[i + 1], "DMXFrom")) - 1;
                }

                channelFunction.functionName = GetNodeAttribute(channelFunctionNodes[i], "Name");
                string attributeName = GetNodeAttribute(channelFunctionNodes[i], "Attribute");
                if (attributeName != null)
                {
                    channelFunction.attribute = data.attributeDefinitions.attributes[attributeName];
                }
                channelFunction.functionDmxFrom      = functionDmxFrom;
                channelFunction.functionDmxTo        = functionDmxTo;
                channelFunction.functionPhysicalFrom = Convert.ToSingle(GetNodeAttribute(channelFunctionNodes[i], "PhysicalFrom"));
                channelFunction.functionPhysicalTo   = Convert.ToSingle(GetNodeAttribute(channelFunctionNodes[i], "PhysicalTo"));
                channelFunction.wheelName            = GetNodeAttribute(channelFunctionNodes[i], "Wheel");

                // 为该 ChannelFunction 添加 ChannelSet
                GetDmxChannelSets(channelFunctionNodes[i], channelFunction);

                // 为该 Channel 添加 ChannelFunction
                logicalChannel.channelFunctions.Add(channelFunction);
            }
        }
    }
コード例 #3
0
    private void ConfigChannelData()
    {
        NumChannels = GetFixtureModeChannelCount();

        for (int i = 0; i < fixtureSelector.dmxMode.channelsData.Count; i++)
        {
            // 配置 Pan 轴信息
            if (fixtureSelector.dmxMode.channelsData[i].logicalChannel.attribute.attributeName == "Pan")
            {
                panAddr = fixtureSelector.dmxMode.channelsData[i].offset;
                panFrom = fixtureSelector.dmxMode.channelsData[i].logicalChannel.channelFunctions[0].functionPhysicalFrom;
                panTo   = fixtureSelector.dmxMode.channelsData[i].logicalChannel.channelFunctions[0].functionPhysicalTo;
            }

            // 配置 Tilt 轴信息
            if (fixtureSelector.dmxMode.channelsData[i].logicalChannel.attribute.attributeName == "Tilt")
            {
                tiltAddr = fixtureSelector.dmxMode.channelsData[i].offset;
                tiltFrom = fixtureSelector.dmxMode.channelsData[i].logicalChannel.channelFunctions[0].functionPhysicalFrom;
                tiltTo   = fixtureSelector.dmxMode.channelsData[i].logicalChannel.channelFunctions[0].functionPhysicalTo;
            }

            // 配置 Dimmer 信息
            if (fixtureSelector.dmxMode.channelsData[i].logicalChannel.attribute.attributeName == "Dimmer")
            {
                dimmerAddr = fixtureSelector.dmxMode.channelsData[i].offset;
            }

            foreach (var item in fixtureSelector.dmxMode.channelsData[i].logicalChannel.channelFunctions)
            {
                if (Regex.IsMatch(item.attribute.attributeName, @"Color[0-9]+$"))
                {
                    colornFunction = item;
                    colorAddr      = fixtureSelector.dmxMode.channelsData[i].offset;
                    colorSlots     = fixtureSelector.descriptionData.wheels.Find(w => w.wheelName == item.wheelName).slots;
                    break;
                }
            }

            foreach (var item in fixtureSelector.dmxMode.channelsData[i].logicalChannel.channelFunctions)
            {
                if (Regex.IsMatch(item.attribute.attributeName, @"Gobo[0-9]+$"))
                {
                    gobonFunction = item;
                    goboAddr      = fixtureSelector.dmxMode.channelsData[i].offset;
                    goboSlots     = fixtureSelector.descriptionData.wheels.Find(w => w.wheelName == item.wheelName).slots;
                    break;
                }
            }
        }
    }