예제 #1
0
        private void RemoveDuplicateRows(MeterData.HourlyTrendingSummaryDataTable table)
        {
            HashSet <int> ids = new HashSet <int>();

            for (int i = table.Count - 1; i >= 0; i--)
            {
                if (!ids.Add(table[i].ID))
                {
                    table.Rows.RemoveAt(i);
                }
            }
        }
예제 #2
0
        private void ProcessChannelNormals(MeterDataSet meterDataSet)
        {
            Dictionary <Channel, List <DataGroup> > trendingGroups;
            HourlyTrendingSummaryTableAdapter       hourlySummaryAdapter;

            MeterData.HourlyTrendingSummaryDataTable hourlySummaryTable;

            Channel channel;
            int     channelID;
            double  average;
            double  meanSquare;

            trendingGroups       = meterDataSet.GetResource <TrendingGroupsResource>().TrendingGroups;
            hourlySummaryAdapter = m_dbAdapterContainer.GetAdapter <HourlyTrendingSummaryTableAdapter>();
            hourlySummaryTable   = new MeterData.HourlyTrendingSummaryDataTable();

            hourlySummaryAdapter.ClearBeforeFill = false;

            foreach (KeyValuePair <Channel, List <DataGroup> > channelGroups in trendingGroups)
            {
                channel   = channelGroups.Key;
                channelID = channel.ID;
                hourlySummaryTable.Clear();

                foreach (DataGroup dataGroup in channelGroups.Value)
                {
                    hourlySummaryAdapter.FillBy(hourlySummaryTable, channelID, dataGroup.StartTime.AddHours(-1.0D), dataGroup.EndTime);
                }

                for (int i = hourlySummaryTable.Count - 1; i >= 0; i--)
                {
                    if (hourlySummaryTable[i].ValidCount + hourlySummaryTable[i].InvalidCount < channel.SamplesPerHour)
                    {
                        hourlySummaryTable.Rows.RemoveAt(i);
                    }
                }

                RemoveDuplicateRows(hourlySummaryTable);

                if (hourlySummaryTable.Count > 0)
                {
                    average    = hourlySummaryTable.Average(row => row.Average);
                    meanSquare = hourlySummaryTable.Average(row => row.Average * row.Average);

                    m_channelNormalTable.AddChannelNormalRow(channelID, average, meanSquare, 0.0D, hourlySummaryTable.Count);
                }
            }
        }
예제 #3
0
 public override void Prepare(DbAdapterContainer dbAdapterContainer)
 {
     m_dbAdapterContainer = dbAdapterContainer;
     m_hourlySummaryTable = new MeterData.HourlyTrendingSummaryDataTable();
     m_channelNormalTable = new MeterData.ChannelNormalDataTable();
 }