Пример #1
0
        /// <summary>
        /// Create an instance of a color organ band.
        /// </summary>
        /// <param name="xmlData"></param>
        public ColorOrganBand(XmlNode xmlData,
                              Dictionary <string, FrequencyBand> frequencyBands,
                              EventSequence newSequence,
                              ColorOrgan colorOrgan)
        {
            // save the sequence data
            Sequence = newSequence;

            m_colorOrgan = colorOrgan;

            m_frequencyBands = frequencyBands;

            // Set the name for this Color Band
            m_id = DateTime.Now.ToString("yyyyMMddHHmmssffffff", System.Globalization.CultureInfo.InvariantCulture);
            Name = "All Frequencies" + m_id;

            // parse the XML file
            m_id = Xml.GetNodeAlways(xmlData, m_xmlName_id, m_id).InnerText;
            Name = Xml.GetNodeAlways(xmlData, m_xmlName_name, Name).InnerText;
            bool.TryParse(Xml.GetNodeAlways(xmlData, m_xmlName_usePeakLevels, m_usePeakLevels.ToString()).InnerText, out m_usePeakLevels);
            m_minBinVariableRange = float.Parse(Xml.GetNodeAlways(xmlData, m_xmlName_minBinVariableRange, m_minBinVariableRange.ToString()).InnerText);
            m_maxBinVariableRange = float.Parse(Xml.GetNodeAlways(xmlData, m_xmlName_maxBinVariableRange, m_maxBinVariableRange.ToString()).InnerText);
            bool.TryParse(Xml.GetNodeAlways(xmlData, m_xmlName_clearChannelsOnWrite, m_clearChannelsOnWrite.ToString()).InnerText, out m_clearChannelsOnWrite);

            // convert the list of Frequency bands into a list we can use
            buildMapOfFrequencyBands(false);

            // mark the frequency bands that are a member of this color organ band
            XmlNodeList frequencyBandNodes = xmlData.SelectNodes(m_xmlName_mapOfFrequencyBands + "/*");

            foreach (XmlNode xmlFrequencyBandNode in frequencyBandNodes)
            {
                string frequencyBandName = xmlFrequencyBandNode.InnerText;
                m_mapOfFrequencyBands[frequencyBandName].Member = true;
                m_energySumAvg += m_mapOfFrequencyBands[frequencyBandName].Avg;
                m_energyPeak    = Math.Max(m_energyPeak, m_mapOfFrequencyBands[frequencyBandName].Peak);
                m_energyMin     = Math.Min(m_energyMin, m_mapOfFrequencyBands[frequencyBandName].Min);
                m_energyCount++;
            }             // end build member list

            // build a list of the current channels
            foreach (Vixen.Channel channel in Sequence.Channels)
            {
                ColorOrganChannel newChannel = new ColorOrganChannel(channel);
                m_mapOfChannels.Add(newChannel.Id, newChannel);
            }             // end each channel in the sequence

            // mark the channels that are a member of this color organ band
            XmlNodeList channelNodes = xmlData.SelectNodes(m_xmlName_mapOfChannels + "/*");

            foreach (XmlNode xmlChannelNode in channelNodes)
            {
                // is this channel still in the list of channels?
                if (true == m_mapOfChannels.ContainsKey(xmlChannelNode.InnerText))
                {
                    // mark the channel as active
                    m_mapOfChannels[xmlChannelNode.InnerText].Member = true;
                }
            }     // end build member list
        }         // ColorOrganBand(xml)
Пример #2
0
        }         // ColorOrganBand(xml)

        /// <summary>
        /// Create a default color band
        /// </summary>
        /// <param name="frequencyBands"></param>
        /// <param name="newSequence"></param>
        /// <param name="colorOrgan"></param>
        public ColorOrganBand(Dictionary <string, FrequencyBand> frequencyBands,
                              EventSequence newSequence,
                              ColorOrgan colorOrgan,
                              bool defaultFrequencyState = true)
        {
            m_colorOrgan = colorOrgan;

            // save the sequence info
            Sequence = newSequence;

            m_frequencyBands = frequencyBands;

            // Set the name for this Color Band
            m_id = DateTime.Now.ToString("yyyyMMddHHmmssffffff", System.Globalization.CultureInfo.InvariantCulture);
            Name = "All Frequencies" + m_id;

            // build the list of frequencies associated with this band
            buildMapOfFrequencyBands(defaultFrequencyState);

            // build a list of the current channels
            foreach (Vixen.Channel channel in Sequence.Channels)
            {
                ColorOrganChannel newChannel = new ColorOrganChannel(channel);
                m_mapOfChannels.Add(newChannel.Id, newChannel);
            }     // end each channel in the sequence
        }         // default Color Organ Band
        }         // ColorOrganChannel

        public ColorOrganChannel(ColorOrganChannel template)
        {
            m_channel = template.m_channel;
            m_member  = template.m_member;
        }         // ColorOrganChannel