Beispiel #1
0
        private Dictionary <EventClassification, int> GetEventTypeLookup(DbAdapterContainer dbAdapterContainer)
        {
            MeterData.EventTypeDataTable eventTypeTable      = new MeterData.EventTypeDataTable();
            EventClassification          eventClassification = default(EventClassification);

            foreach (EventClassification classification in Enum.GetValues(typeof(EventClassification)))
            {
                eventTypeTable.AddEventTypeRow(classification.ToString(), classification.ToString());
            }

            BulkLoader bulkLoader = new BulkLoader();

            bulkLoader.Connection     = dbAdapterContainer.Connection;
            bulkLoader.CommandTimeout = dbAdapterContainer.CommandTimeout;

            bulkLoader.MergeTableFormat = "MERGE INTO {0} AS Target " +
                                          "USING {1} AS Source " +
                                          "ON Source.Name = Target.Name " +
                                          "WHEN NOT MATCHED THEN " +
                                          "    INSERT (Name, Description) " +
                                          "    VALUES (Source.Name, Source.Description);";

            bulkLoader.Load(eventTypeTable);

            dbAdapterContainer.GetAdapter <EventTypeTableAdapter>().Fill(eventTypeTable);

            return(Enumerable.Select(eventTypeTable
                                     .Where(row => Enum.TryParse(row.Name, out eventClassification)), row => Tuple.Create(eventClassification, row.ID))
                   .ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2));
        }
Beispiel #2
0
        private static bool ValidateEventType(EventClassification eventClassification, AssetType asset)
        {
            switch (eventClassification)
            {
            case (EventClassification.BreakerOpen):
                return(asset == AssetType.Breaker);

            case (EventClassification.Fault):
                return((asset == AssetType.Transformer) || (asset == AssetType.Line));

            case (EventClassification.RecloseIntoFault):
                return((asset == AssetType.Transformer) || (asset == AssetType.Line));

            case (EventClassification.Interruption):
                return((asset == AssetType.Bus) || (asset == AssetType.CapacitorBank));

            case (EventClassification.Sag):
                return((asset == AssetType.Bus) || (asset == AssetType.CapacitorBank));

            case (EventClassification.Swell):
                return((asset == AssetType.Bus) || (asset == AssetType.CapacitorBank));

            case (EventClassification.Transient):
                return((asset == AssetType.Bus) || (asset == AssetType.CapacitorBank));

            default:
                return(true);
            }
        }
        public VoltageDisturbanceAnalyzer(Func<DataPoint, bool> isDisturbed, Func<double, double, bool> isMoreSevere, EventClassification eventType)
        {
            if ((object)isDisturbed == null)
                throw new ArgumentNullException(nameof(isDisturbed));

            if ((object)isMoreSevere == null)
                throw new ArgumentNullException(nameof(isMoreSevere));

            m_isDisturbed = isDisturbed;
            m_isMoreSevere = isMoreSevere;
            m_eventType = eventType;
        }
        public VoltageDisturbanceAnalyzer(Func <DataPoint, bool> isDisturbed, Func <double, double, bool> isMoreSevere, EventClassification eventType)
        {
            if ((object)isDisturbed == null)
            {
                throw new ArgumentNullException(nameof(isDisturbed));
            }

            if ((object)isMoreSevere == null)
            {
                throw new ArgumentNullException(nameof(isMoreSevere));
            }

            m_isDisturbed  = isDisturbed;
            m_isMoreSevere = isMoreSevere;
            m_eventType    = eventType;
        }
Beispiel #5
0
        public override void Initialize(MeterDataSet meterDataSet)
        {
            DataGroupsResource dataGroupsResource = meterDataSet.GetResource <DataGroupsResource>();
            CycleDataResource  cycleDataResource  = meterDataSet.GetResource <CycleDataResource>();
            FaultDataResource  faultDataResource  = meterDataSet.GetResource <FaultDataResource>();

            for (int i = 0; i < cycleDataResource.DataGroups.Count; i++)
            {
                DataGroup   dataGroup   = cycleDataResource.DataGroups[i];
                VIDataGroup viDataGroup = cycleDataResource.VIDataGroups[i];
                FaultGroup  faultGroup;

                if (!faultDataResource.FaultLookup.TryGetValue(dataGroup, out faultGroup))
                {
                    faultGroup = null;
                }

                EventClassification classification = Classify(meterDataSet, dataGroup, viDataGroup, faultGroup);

                if (!ValidateEventType(classification, (AssetType)dataGroup.Asset.AssetTypeID))
                {
                    classification = EventClassification.Other;
                }

                m_classifications.Add(dataGroup, classification);
            }

            foreach (DataGroup dataGroup in dataGroupsResource.DataGroups)
            {
                if (dataGroup.DataSeries.Count > 0)
                {
                    continue;
                }

                EventClassification classification = Classify(meterDataSet, dataGroup);

                if (!ValidateEventType(classification, (AssetType)dataGroup.Asset.AssetTypeID))
                {
                    classification = EventClassification.Other;
                }

                m_classifications.Add(dataGroup, classification);
            }
        }
Beispiel #6
0
        private Dictionary <EventClassification, int> GetEventTypeLookup(DbAdapterContainer dbAdapterContainer)
        {
            MeterData.EventTypeDataTable eventTypeTable      = new MeterData.EventTypeDataTable();
            EventClassification          eventClassification = default(EventClassification);

            foreach (EventClassification classification in Enum.GetValues(typeof(EventClassification)))
            {
                eventTypeTable.AddEventTypeRow(classification.ToString(), classification.ToString());
            }

            BulkLoader bulkLoader = new BulkLoader();

            bulkLoader.Connection     = dbAdapterContainer.Connection;
            bulkLoader.CommandTimeout = dbAdapterContainer.CommandTimeout;

            bulkLoader.MergeTableFormat = "MERGE INTO {0} AS Target " +
                                          "USING {1} AS Source " +
                                          "ON Source.Name = Target.Name " +
                                          "WHEN NOT MATCHED THEN " +
                                          "    INSERT (Name, Description) " +
                                          "    VALUES (Source.Name, Source.Description);";

            bulkLoader.Load(eventTypeTable);

            dbAdapterContainer.GetAdapter <EventTypeTableAdapter>().Fill(eventTypeTable);

            return(eventTypeTable
                   .Where(row => Enum.TryParse(row.Name, out eventClassification))
                   .Select(row => new { EventClassification = eventClassification, row.ID })
                   .ToList()
                   .GroupBy(obj => obj.EventClassification)
                   .ToDictionary(grouping => grouping.Key, grouping =>
            {
                if (grouping.Count() > 1)
                {
                    Log.Warn($"Found duplicate event type: {grouping.Key}");
                }

                return grouping.First().ID;
            }));
        }
        public VoltageDisturbanceAnalyzer(Func <DataPoint, bool> isDisturbed, Func <DataSeries, double> getMagnitude, Func <DataPoint, DataPoint, DataPoint, DataPoint> getVAllPoint, EventClassification eventType)
        {
            if ((object)isDisturbed == null)
            {
                throw new ArgumentNullException("isDisturbed");
            }

            if ((object)getMagnitude == null)
            {
                throw new ArgumentNullException("getMagnitude");
            }

            if ((object)getVAllPoint == null)
            {
                throw new ArgumentNullException("getVAllPoint");
            }

            m_isDisturbed  = isDisturbed;
            m_getMagnitude = getMagnitude;
            m_getVAllPoint = getVAllPoint;
            m_eventType    = eventType;
        }
 private static string FormatClassification(EventClassification classification)
 {
     switch (classification)
     {
         case EventClassification.Ok:
             return "";
         case EventClassification.NotOk:
             return "Affected";
         case EventClassification.Unknown:
             return "May be affected";
         default:
             return "Unknown";
     }
 }