private Disturbance ToDisturbance(Line line, ReportedDisturbance reportedDisturbance)
        {
            double nominalValue = line.VoltageKV * 1000.0D;

            if (new[] { Phase.AN, Phase.BN, Phase.CN }.Contains(reportedDisturbance.Phase))
            {
                nominalValue /= Math.Sqrt(3.0D);
            }

            Disturbance disturbance = new Disturbance();

            double value = m_isMoreSevere(reportedDisturbance.Maximum, reportedDisturbance.Minimum)
                ? reportedDisturbance.Maximum
                : reportedDisturbance.Minimum;

            if (reportedDisturbance.Units == QuantityUnits.Percent)
            {
                value *= nominalValue / 100.0D;
            }
            else if (reportedDisturbance.Units == QuantityUnits.PerUnit)
            {
                value *= nominalValue;
            }

            disturbance.EventType        = m_eventType;
            disturbance.Phase            = reportedDisturbance.Phase;
            disturbance.StartTime        = reportedDisturbance.Time;
            disturbance.EndTime          = reportedDisturbance.Time + reportedDisturbance.Duration;
            disturbance.Magnitude        = value;
            disturbance.PerUnitMagnitude = value / nominalValue;

            return(disturbance);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a disturbance to the group of data.
        /// </summary>
        /// <param name="disturbance">The disturbance to be added to the group.</param>
        /// <returns>True if the disturbance was successfully added.</returns>
        public bool Add(ReportedDisturbance disturbance)
        {
            // Unable to add null disturbance
            if ((object)disturbance == null)
            {
                return(false);
            }

            // Do not add the same disturbance twice
            if (m_disturbances.Contains(disturbance))
            {
                return(false);
            }

            // If the data in this data group is trending data,
            // do not add the disturbance to the data group
            if (Classification == DataClassification.Trend)
            {
                return(false);
            }

            // Get the start time and end time of the disturbance.
            DateTime startTime = disturbance.Time;
            DateTime endTime   = startTime + disturbance.Duration;

            // If there are no data series and no other disturbances,
            // make this the first piece of data to be added to the data group
            if (!m_dataSeries.Any() && !m_disturbances.Any())
            {
                m_startTime = startTime;
                m_endTime   = endTime;
                m_disturbances.Add(disturbance);
                m_classification = DataClassification.Event;
                return(true);
            }

            // If the disturbance overlaps with
            // this data group, add the disturbance
            if (startTime <= m_endTime && m_startTime <= endTime)
            {
                // If the only data in the data group is disturbances,
                // adjust the start time and end time
                if (!m_dataSeries.Any() && startTime < m_startTime)
                {
                    m_startTime = startTime;
                }

                if (!m_dataSeries.Any() && endTime > m_endTime)
                {
                    m_endTime = endTime;
                }

                m_disturbances.Add(disturbance);
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Removes a disturbance from the data group.
        /// </summary>
        /// <param name="disturbance">THe disturbance to be removed from the data group.</param>
        /// <returns>True if the disturbance existed in the group and was removed; false otherwise.</returns>
        public bool Remove(ReportedDisturbance disturbance)
        {
            if (m_disturbances.Remove(disturbance))
            {
                if (!m_disturbances.Any())
                {
                    m_classification = DataClassification.Unknown;
                }

                return(true);
            }

            return(false);
        }
        private Range <int> ToRange(DataGroup dataGroup, ReportedDisturbance disturbance)
        {
            if (dataGroup.Samples == 0)
            {
                return(null);
            }

            DateTime startTime = disturbance.Time;
            DateTime endTime   = startTime + disturbance.Duration;

            TimeSpan eventSpan = dataGroup.EndTime - dataGroup.StartTime;
            TimeSpan startSpan = startTime - dataGroup.StartTime;
            TimeSpan endSpan   = endTime - dataGroup.EndTime;

            int startIndex = (int)(startSpan.TotalSeconds / eventSpan.TotalSeconds * dataGroup.Samples);
            int endIndex   = (int)(endSpan.TotalSeconds / eventSpan.TotalSeconds * dataGroup.Samples);

            return(new Range <int>(startIndex, endIndex));
        }
        private Disturbance ToDisturbance(Asset asset, ReportedDisturbance reportedDisturbance)
        {
            double nominalValue = asset.VoltageKV * 1000.0D;

            if (asset.AssetTypeID == (int)AssetType.Transformer)
            {
                //Special Case that needs to be treated seperately No Solution Yet
                nominalValue = 0 * 1000.0D;
            }

            if (new[] { Phase.AN, Phase.BN, Phase.CN }.Contains(reportedDisturbance.Phase))
            {
                nominalValue /= Math.Sqrt(3.0D);
            }

            Disturbance disturbance = new Disturbance();

            double value = m_isMoreSevere(reportedDisturbance.Maximum, reportedDisturbance.Minimum)
                ? reportedDisturbance.Maximum
                : reportedDisturbance.Minimum;

            if (reportedDisturbance.Units == QuantityUnits.Percent)
            {
                value *= nominalValue / 100.0D;
            }
            else if (reportedDisturbance.Units == QuantityUnits.PerUnit)
            {
                value *= nominalValue;
            }

            disturbance.EventType        = m_eventType;
            disturbance.Phase            = reportedDisturbance.Phase;
            disturbance.StartTime        = reportedDisturbance.Time;
            disturbance.EndTime          = reportedDisturbance.Time + reportedDisturbance.Duration;
            disturbance.Magnitude        = value;
            disturbance.PerUnitMagnitude = value / nominalValue;

            return(disturbance);
        }