Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method adds the given file to the list of data sources to be
        /// totalized. In doing so, the file will be opened and the load profile data
        /// will be extracted.
        /// </summary>
        /// <param name="strMIFFileName" type="string">
        /// </param>
        /// <returns>
        /// True if the given file was successfully opened, the load profile data was
        /// extracted, and the file was added to the list of data sources.  False is
        /// returned if the file could not be added to the data source list.
        /// </returns>
        /// <remarks>
        ///  Revision History
        ///  MM/DD/YY Who Version Issue#        Description
        ///  -------- --- ------- ------------- -----------------------------------
        ///  08/26/08 MAH 9.50				    Created
        ///  12/22/08 MAH 9.50.28 CQ 124757     Added error handling to prevent
        ///  totaliation of more contributors with more than 16 channels of data
        ///  11/25/09 AF  2.30.22               Changed the catch block to preserve
        ///                                     the call stack and quiet compiler warning
        /// </remarks>
        public override Boolean AddContributor(String strMIFFileName)
        {
            Boolean boolSuccess = false;
            MIF     hhfFile     = null;

            try
            {
                if (MIF.IsMeterImageFile(strMIFFileName))
                {
                    hhfFile = new MIF(strMIFFileName);

                    TotalizationDataSource newContributor = new TotalizationDataSource(hhfFile);

                    // By default all new contributors will be added to the resulting data
                    newContributor.Calculation = TotalizationDataSource.CalculationType.Addition;

                    m_lstDataSources.Add(newContributor);

                    // We are successful only after we have added the file to the list of
                    // contributors
                    boolSuccess = true;

                    // Clear any previous totalized results.  They will need to be recalculated
                    FlushCachedValues();
                }
            }

            // If, for any reason we could not read the load profile data
            // simply treat it as if it doesn't exist
            catch (Exception)
            {
                throw;
            }

            finally
            {
                if (hhfFile != null)
                {
                    hhfFile.Close();
                }
            }

            return(boolSuccess);
        }