示例#1
0
        private void LoadDisturbances(MeterDataSet meterDataSet, List <DataGroup> dataGroups)
        {
            SagDataResource          sagDataResource          = SagDataResource.GetResource(meterDataSet, m_dbAdapterContainer);
            SwellDataResource        swellDataResource        = SwellDataResource.GetResource(meterDataSet, m_dbAdapterContainer);
            InterruptionDataResource interruptionDataResource = InterruptionDataResource.GetResource(meterDataSet, m_dbAdapterContainer);

            EventKey           eventKey;
            List <Disturbance> disturbances;

            m_disturbanceTable = new MeterData.DisturbanceDataTable();
            m_disturbanceList  = new List <Tuple <EventKey, MeterData.DisturbanceRow> >();

            foreach (DataGroup dataGroup in dataGroups)
            {
                if (dataGroup.Classification == DataClassification.Trend || dataGroup.Classification == DataClassification.Unknown)
                {
                    continue;
                }

                eventKey = CreateEventKey(meterDataSet.FileGroup, dataGroup);

                if (sagDataResource.Sags.TryGetValue(dataGroup, out disturbances))
                {
                    foreach (Disturbance sag in disturbances)
                    {
                        AddDisturbanceRow(eventKey, dataGroup, sag);
                    }
                }

                if (swellDataResource.Swells.TryGetValue(dataGroup, out disturbances))
                {
                    foreach (Disturbance swell in disturbances)
                    {
                        AddDisturbanceRow(eventKey, dataGroup, swell);
                    }
                }

                if (interruptionDataResource.Interruptions.TryGetValue(dataGroup, out disturbances))
                {
                    foreach (Disturbance interruption in disturbances)
                    {
                        AddDisturbanceRow(eventKey, dataGroup, interruption);
                    }
                }
            }
        }
        public override void Execute(MeterDataSet meterDataSet)
        {
            CycleDataResource        cycleDataResource        = CycleDataResource.GetResource(meterDataSet, m_dbAdapterContainer);
            SagDataResource          sagDataResource          = SagDataResource.GetResource(meterDataSet, m_dbAdapterContainer);
            SwellDataResource        swellDataResource        = SwellDataResource.GetResource(meterDataSet, m_dbAdapterContainer);
            InterruptionDataResource interruptionDataResource = InterruptionDataResource.GetResource(meterDataSet, m_dbAdapterContainer);

            DisturbanceTableAdapter disturbanceAdapter = m_dbAdapterContainer.GetAdapter <DisturbanceTableAdapter>();
            DisturbanceDataTable    disturbanceTable   = disturbanceAdapter.GetDataByFileGroup(meterDataSet.FileGroup.ID);

            SystemInfoDataContext systemInfo = m_dbAdapterContainer.GetAdapter <SystemInfoDataContext>();

            m_disturbanceSeverityTable = new DisturbanceSeverityDataTable();

            foreach (VoltageEnvelope envelope in systemInfo.VoltageEnvelopes)
            {
                foreach (DisturbanceRow disturbance in disturbanceTable)
                {
                    IEnumerable <VoltageCurvePoint> points = envelope.VoltageCurves.Select(curve => curve.VoltageCurvePoints
                                                                                           .Where(p => p.DurationSeconds <= disturbance.DurationSeconds)
                                                                                           .OrderBy(p => p.LoadOrder)
                                                                                           .LastOrDefault());

                    IEnumerable <int> severityCodes = points.Select(point => ((object)point != null)
                        ? (int)((1.0D - disturbance.PerUnitMagnitude) / (1.0D - point.PerUnitMagnitude))
                        : 0);

                    int maxSeverityCode = severityCodes
                                          .DefaultIfEmpty(0)
                                          .Max();

                    if (maxSeverityCode < 0)
                    {
                        maxSeverityCode = 0;
                    }
                    else if (maxSeverityCode > 5)
                    {
                        maxSeverityCode = 5;
                    }

                    m_disturbanceSeverityTable.AddDisturbanceSeverityRow(envelope.ID, disturbance.ID, maxSeverityCode);
                }
            }
        }