示例#1
0
        /// <summary>
        /// Create alert information for the UX from the given alert.
        /// </summary>
        private ContosoAlertInfo CreateDashboardAlertInfo(ContosoAlert alert, long sameCauseAlertsCount, string nodeKey)
        {
            ContosoAlertInfo    alertInfo    = new ContosoAlertInfo();
            ContosoTopologyNode topologyNode = TopologyTable[alert.Key] as ContosoTopologyNode;

            alertInfo.AlertId          = alert.AlertId;
            alertInfo.CauseDescription = alert.GetAlertCauseDescription();
            alertInfo.Cause            = alert.Cause;
            alertInfo.Occurences       = sameCauseAlertsCount;
            List <string> parentList = GetFullHierarchy(nodeKey);

            alertInfo.TopologyDetails = new string[ContosoAlertInfo.MaxTopologyDetailsCount];
            int index = 0;

            if (parentList.Count == 1)
            {
                alertInfo.TopologyDetails[index] = topologyNode.Name;
            }
            else
            {
                parentList.Reverse();
                parentList.RemoveAt(0);
                foreach (var parent in parentList)
                {
                    ContosoTopologyNode parentNode = (ContosoTopologyNode)TopologyTable[parent];
                    alertInfo.TopologyDetails[index++] = parentNode.Name;
                }
                // Check if the alert has been caused by an OPC UA node value.
                if (alert.SubKey != "null")
                {
                    OpcUaNode opcUaNode = ((Station)TopologyTable[alert.Key]).GetOpcUaNode(alert.SubKey);
                    alertInfo.TopologyDetails[index] = opcUaNode.SymbolicName;
                }
            }
            alertInfo.Key             = alert.Key;
            alertInfo.SubKey          = alert.SubKey;
            alertInfo.UxTime          = string.Format("{0}-{1}", alert.Time.ToString("t"), alert.Time.ToString("d"));
            alertInfo.Time            = alert.Time;
            alertInfo.Status          = alert.Status;
            alertInfo.AlertActionInfo = topologyNode.CreateAlertActionInfo(alert.Cause, alert.SubKey);
            return(alertInfo);
        }
示例#2
0
        /// <summary>
        /// Create alert information for the UX from the given alert.
        /// </summary>
        private ContosoAlertInfo CreateDashboardAlertInfo(ContosoAlert alert, long sameCauseAlertsCount, string nodeKey)
        {
            ContosoAlertInfo    alertInfo    = new ContosoAlertInfo();
            ContosoTopologyNode topologyNode = TopologyTable[alert.Key] as ContosoTopologyNode;

            alertInfo.AlertId    = alert.AlertId;
            alertInfo.Cause      = alert.Cause;
            alertInfo.Occurences = sameCauseAlertsCount;
            List <string> parentList = GetFullHierarchy(nodeKey);

            alertInfo.TopologyDetails = new string[ContosoAlertInfo.MaxTopologyDetailsCount];
            int index = 0;

            if (parentList.Count == 1)
            {
                alertInfo.TopologyDetails[index] = topologyNode.Name;
            }
            else
            {
                parentList.Reverse();
                parentList.RemoveAt(0);
                foreach (var parent in parentList)
                {
                    ContosoTopologyNode parentNode = (ContosoTopologyNode)TopologyTable[parent];
                    alertInfo.TopologyDetails[index++] = parentNode.Name;
                }
                // Check if the alert has been caused by an OPC UA node value.
                if (alert.SubKey != "null")
                {
                    ContosoOpcUaNode contosoOpcUaNode = Startup.Topology.GetOpcUaNode(alert.Key, alert.SubKey);
                    alertInfo.TopologyDetails[index] = contosoOpcUaNode.SymbolicName;
                    alertInfo.Maximum = contosoOpcUaNode.Maximum;
                    alertInfo.Minimum = contosoOpcUaNode.Minimum;
                }
                else
                {
                    switch (alert.Cause)
                    {
                    case ContosoAlertCause.AlertCauseOeeOverallBelowMinimum:
                    case ContosoAlertCause.AlertCauseOeeOverallAboveMaximum:
                        alertInfo.Maximum = topologyNode.OeeOverallPerformanceSetting.Maximum;
                        alertInfo.Minimum = topologyNode.OeeOverallPerformanceSetting.Minimum;
                        break;

                    case ContosoAlertCause.AlertCauseOeeAvailabilityBelowMinimum:
                    case ContosoAlertCause.AlertCauseOeeAvailabilityAboveMaximum:
                        alertInfo.Maximum = topologyNode.OeeAvailabilityPerformanceSetting.Maximum;
                        alertInfo.Minimum = topologyNode.OeeAvailabilityPerformanceSetting.Minimum;
                        break;

                    case ContosoAlertCause.AlertCauseOeePerformanceBelowMinimum:
                    case ContosoAlertCause.AlertCauseOeePerformanceAboveMaximum:
                        alertInfo.Maximum = topologyNode.OeePerformancePerformanceSetting.Maximum;
                        alertInfo.Minimum = topologyNode.OeePerformancePerformanceSetting.Minimum;
                        break;

                    case ContosoAlertCause.AlertCauseOeeQualityBelowMinimum:
                    case ContosoAlertCause.AlertCauseOeeQualityAboveMaximum:
                        alertInfo.Maximum = topologyNode.OeeQualityPerformanceSetting.Maximum;
                        alertInfo.Minimum = topologyNode.OeeQualityPerformanceSetting.Minimum;
                        break;

                    case ContosoAlertCause.AlertCauseKpi1BelowMinimum:
                    case ContosoAlertCause.AlertCauseKpi1AboveMaximum:
                        alertInfo.Maximum = topologyNode.Kpi1PerformanceSetting.Maximum;
                        alertInfo.Minimum = topologyNode.Kpi1PerformanceSetting.Minimum;
                        break;

                    case ContosoAlertCause.AlertCauseKpi2BelowMinimum:
                    case ContosoAlertCause.AlertCauseKpi2AboveMaximum:
                        alertInfo.Maximum = topologyNode.Kpi2PerformanceSetting.Maximum;
                        alertInfo.Minimum = topologyNode.Kpi2PerformanceSetting.Minimum;
                        break;
                    }
                }
            }
            alertInfo.Key             = alert.Key;
            alertInfo.SubKey          = alert.SubKey;
            alertInfo.UxTime          = string.Format("{0}-{1}", alert.Time.ToString("t"), alert.Time.ToString("d"));
            alertInfo.Time            = alert.Time;
            alertInfo.Status          = alert.Status;
            alertInfo.AlertActionInfo = topologyNode.CreateAlertActionInfo(alert.Cause, alert.SubKey);
            return(alertInfo);
        }