/// <summary>
        ///
        /// </summary>
        /// <param name="lpResult" type="Itron.Metering.DeviceDataTypes.LoadProfileEnergyData">
        /// </param>
        /// <returns>
        ///     A Itron.Metering.Datafiles.TotalizationContributorList.TotalizationResult value...
        /// </returns>
        private TotalizationResult Totalize(out LoadProfileEnergyData lpResult)
        {
            lpResult = null;

            TotalizationResult Result = ValidateDataSources();

            if (Result == TotalizationResult.Success)
            {
                lpResult = new LoadProfileEnergyData(IntervalLength);

                // Add the appropriate number of channels
                for (int nChannelIndex = 0; nChannelIndex < NumProfileChannels; nChannelIndex++)
                {
                    // The channels will assume the same name as the first contributor
                    lpResult.AddChannel(m_lstDataSources[0].LPData.Channels[nChannelIndex].ChannelName,
                                        (float)1.0,
                                        (float)1.0);
                }

                // Next combine the load profile data from all the contributors
                foreach (LoadProfileDataSource ProfileContributor in m_lstDataSources)
                {
                    TotalizationDataSource contributor = ProfileContributor as TotalizationDataSource;

                    if (contributor != null)
                    {
                        TotalizeIntervalData(lpResult, contributor.LPData.EnergyData, contributor.Calculation);
                    }
                }
            }

            return(Result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="lpResult" type="Itron.Metering.DeviceDataTypes.LoadProfileEnergyData">
        ///     <para>
        ///
        ///     </para>
        /// </param>
        private void NegateLastInterval(LoadProfileEnergyData lpResult)
        {
            LPInterval lpiLastInterval = lpResult.Intervals[lpResult.Intervals.Count - 1];

            // Negate each interval
            for (int nChannelIndex = 0; nChannelIndex < NumProfileChannels; nChannelIndex++)
            {
                lpiLastInterval.Data[nChannelIndex] = -lpiLastInterval.Data[nChannelIndex];
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="lpResult" type="Itron.Metering.DeviceDataTypes.LoadProfileEnergyData">
        /// </param>
        /// <param name="lpContributor" type="Itron.Metering.DeviceDataTypes.LoadProfileEnergyData">
        /// </param>
        /// <param name="eCalculation" type="Itron.Metering.Datafiles.TotalizationContributorList.CalculationType">
        /// </param>
        private void TotalizeIntervalData(LoadProfileEnergyData lpResult,
                                          LoadProfileEnergyData lpContributor,
                                          TotalizationDataSource.CalculationType eCalculation)
        {
            if (lpResult.NumberIntervals == 0)
            {
                // This is the first contributor

                // Find the starting point
                int nIntervalIndex = FindIntervalIndex(lpContributor, ProfileStartTime);

                bool boolFinished = false;

                if (nIntervalIndex >= 0)
                {
                    while (nIntervalIndex < lpContributor.NumberIntervals && !boolFinished)
                    {
                        if (lpContributor.Intervals[nIntervalIndex].Time <= ProfileEndTime)
                        {
                            lpResult.Intervals.Add(lpContributor.Intervals[nIntervalIndex]);

                            if (eCalculation == TotalizationDataSource.CalculationType.Subtraction)
                            {
                                NegateLastInterval(lpResult);
                            }

                            // Move to the next interval
                            nIntervalIndex++;
                        }
                        else
                        {
                            boolFinished = true;
                        }
                    }
                }
            }
            else
            {
                // Find the starting point
                int nResultIndex      = 0;
                int nContributorIndex = FindIntervalIndex(lpContributor, ProfileStartTime);

                bool boolFinished = false;

                if (nContributorIndex >= 0)
                {
                    while (nContributorIndex < lpContributor.NumberIntervals && !boolFinished)
                    {
                        if (lpContributor.Intervals[nContributorIndex].Time <= ProfileEndTime)
                        {
                            // The two time stamps must match
                            CombineIntervals(lpResult.Intervals[nResultIndex],
                                             lpContributor.Intervals[nContributorIndex],
                                             eCalculation);

                            // Move to the next interval
                            nResultIndex++;
                            nContributorIndex++;
                        }
                        else
                        {
                            boolFinished = true;
                        }
                    }
                }
            }
        }