Beispiel #1
0
 /// <summary>
 /// Create an alert if conditions are met.
 /// </summary>
 ContosoPerformanceStatus UpdateAlert(
     ContosoTopologyNode node,
     double value,
     DateTime time,
     ContosoPerformanceSetting setting,
     ContosoAlertCause causeMin = ContosoAlertCause.AlertCauseValueBelowMinimum,
     ContosoAlertCause causeMax = ContosoAlertCause.AlertCauseValueAboveMaximum)
 {
     if (value != 0 && value < setting.Minimum)
     {
         ContosoAlert alert = new ContosoAlert(causeMin, node.Key, time);
         node.AddAlert(alert);
         node.Status = ContosoPerformanceStatus.Poor;
     }
     else if (value != 0 && value > setting.Maximum)
     {
         ContosoAlert alert = new ContosoAlert(causeMax, node.Key, time);
         node.AddAlert(alert);
         node.Status = ContosoPerformanceStatus.Poor;
     }
     else
     {
         node.Status = ContosoPerformanceStatus.Good;
     }
     return(node.Status);
 }
        /// <summary>
        /// Ctor for a topology node in the topology using the topology node description.
        /// </summary>
        public ContosoTopologyNode(string key, string name, string description, ContosoTopologyDescriptionCommon topologyDescription) : this(key, name, description, topologyDescription.ImagePushpin)
        {
            if (topologyDescription == null)
            {
                throw new ArgumentException("topologyDescription must be a non-null value");
            }

            // Initialize all OEE/KPI definitions and time series.
            if (topologyDescription.OeeOverall != null)
            {
                OeeOverallPerformanceSetting = new ContosoPerformanceSetting(ContosoPerformanceSettingAggregator.Percent, key, topologyDescription.OeeOverall);
            }
            if (topologyDescription.OeePerformance != null)
            {
                OeePerformancePerformanceSetting = new ContosoPerformanceSetting(ContosoPerformanceSettingAggregator.Percent, key, topologyDescription.OeePerformance);
            }
            if (topologyDescription.OeeAvailability != null)
            {
                OeeAvailabilityPerformanceSetting = new ContosoPerformanceSetting(ContosoPerformanceSettingAggregator.Percent, key, topologyDescription.OeeAvailability);
            }
            if (topologyDescription.OeeQuality != null)
            {
                OeeQualityPerformanceSetting = new ContosoPerformanceSetting(ContosoPerformanceSettingAggregator.Percent, key, topologyDescription.OeeQuality);
            }
            if (topologyDescription.Kpi1 != null)
            {
                Kpi1PerformanceSetting = new ContosoPerformanceSetting(ContosoPerformanceSettingAggregator.MinStation, key, topologyDescription.Kpi1);
            }
            if (topologyDescription.Kpi2 != null)
            {
                Kpi2PerformanceSetting = new ContosoPerformanceSetting(ContosoPerformanceSettingAggregator.Add, key, topologyDescription.Kpi2);
            }

            // Create all aggregated OEE and KPI data structures
            // Access of the specific views is hardcoded in AggregationView
            Aggregations = new List <ContosoAggregatedOeeKpiHistogram>();
            // this is the 'Last' aggregation used for the dashboard and has just one timespan
            Aggregations.Add(new ContosoAggregatedOeeKpiHistogram(TimeSpan.FromMinutes(60), 1, TimeSpan.FromSeconds(10), false, true, true, true));
            // all other aggregations are used for the time series and span an hour, a day and a week
            Aggregations.Add(new ContosoAggregatedOeeKpiHistogram(TimeSpan.FromMinutes(5), 12, TimeSpan.FromMinutes(5), true));
            Aggregations.Add(new ContosoAggregatedOeeKpiHistogram(TimeSpan.FromHours(1), 24, TimeSpan.FromHours(1), true));
            Aggregations.Add(new ContosoAggregatedOeeKpiHistogram(TimeSpan.FromDays(1), 7, TimeSpan.FromDays(1), true));

            // Create alert list.
            Alerts      = new List <ContosoAlert>();
            _alertsLock = new Object();

            // Initialize image path.
            if (topologyDescription.Image != null && topologyDescription.Image != "")
            {
                ImagePath = "/Content/img/" + topologyDescription.Image;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Add a performance settings child station in performance aggregation.
        /// </summary>
        public virtual void AddChildStation(ContosoPerformanceSetting child)
        {
            switch (PerfType)
            {
            case ContosoPerformanceSettingAggregator.MinStation:
                Minimum = Math.Min(Minimum, child.Minimum);
                Target  = Math.Min(Target, child.Target);
                Maximum = Math.Min(Maximum, child.Maximum);
                break;

            case ContosoPerformanceSettingAggregator.Percent:
            case ContosoPerformanceSettingAggregator.Add:
                Minimum += child.Minimum;
                Target  += child.Target;
                Maximum += child.Maximum;
                break;

            case ContosoPerformanceSettingAggregator.Undefined:
                break;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Add a performance settings child node in performance aggregation.
        /// </summary>
        public virtual void AddChild(ContosoPerformanceSetting child)
        {
            switch (PerfType)
            {
            case ContosoPerformanceSettingAggregator.MinStation:
                if (Minimum == double.MaxValue)
                {
                    Minimum = Target = Maximum = 0;
                }
                goto case ContosoPerformanceSettingAggregator.Add;

            case ContosoPerformanceSettingAggregator.Percent:
            case ContosoPerformanceSettingAggregator.Add:
                Minimum += child.Minimum;
                Target  += child.Target;
                Maximum += child.Maximum;
                break;

            case ContosoPerformanceSettingAggregator.Undefined:
                break;
            }
        }