/// <summary> /// Adds an OPC UA Node to this OPC UA server topology node using the OPC UA node description. /// </summary> public void AddOpcServerNode(ContosoOpcNodeDescription opcUaNodeDescription, List <ContosoPerformanceRelevance> opcUaNodeRelevance) { foreach (var node in NodeList) { if (OpCodeRequiresOpcUaNode(opcUaNodeDescription.OpCode) && node.NodeId == opcUaNodeDescription.NodeId ) { throw new Exception(string.Format("The OPC UA node with NodeId '{0}' and SymbolicName '{1}' does already exist. Please change.", opcUaNodeDescription.NodeId, opcUaNodeDescription.SymbolicName)); } } ContosoOpcUaNode opcUaNodeObject = new ContosoOpcUaNode( opcUaNodeDescription.NodeId, opcUaNodeDescription.SymbolicName, opcUaNodeRelevance, opcUaNodeDescription); NodeList.Add(opcUaNodeObject); }
/// <summary> /// Adds an OPC UA Node to this OPC UA server topology node. /// </summary> public void AddOpcServerNode( string opcUaNodeId, string opcUaSymbolicName, List <ContosoPerformanceRelevance> opcUaNodeRelevance, ContosoOpcNodeOpCode opCode, string units, bool visible, double?constValue, double?minimum, double?maximum, List <ContosoAlertActionDefinition> minimumAlertActionDefinitions, List <ContosoAlertActionDefinition> maximumAlertActionDefinitions, ContosoPushPinCoordinates imagePushpin, string warning) { foreach (var node in NodeList) { if (OpCodeRequiresOpcUaNode(opCode) && node.NodeId == opcUaNodeId ) { throw new Exception(string.Format("The OPC UA node with NodeId '{0}' and SymbolicName '{1}' does already exist. Please change.", opcUaNodeId, opcUaSymbolicName)); } } ContosoOpcUaNode opcUaNodeObject = new ContosoOpcUaNode( opcUaNodeId, opcUaSymbolicName, opcUaNodeRelevance, opCode, units, visible, constValue, minimum, maximum, minimumAlertActionDefinitions, maximumAlertActionDefinitions, imagePushpin, warning); NodeList.Add(opcUaNodeObject); }
/// <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); }
/// <summary> /// Get the alert actions definitions for the given alert cause.. /// </summary> public List <ContosoAlertActionDefinition> GetAlertActions(ContosoAlertCause alertCause, string subKey) { List <ContosoAlertActionDefinition> alertActionDefinitions = null; // Handle topology nodes if no subKey (OPC UA nodeid) is given. if (string.IsNullOrEmpty(subKey) || subKey.Equals("null")) { // Choose actions. switch (alertCause) { case ContosoAlertCause.AlertCauseOeeOverallBelowMinimum: alertActionDefinitions = OeeOverallPerformanceSetting.MinimumAlertActions; break; case ContosoAlertCause.AlertCauseOeeOverallAboveMaximum: alertActionDefinitions = OeeOverallPerformanceSetting.MaximumAlertActions; break; case ContosoAlertCause.AlertCauseOeeAvailabilityBelowMinimum: alertActionDefinitions = OeeAvailabilityPerformanceSetting.MinimumAlertActions; break; case ContosoAlertCause.AlertCauseOeeAvailabilityAboveMaximum: alertActionDefinitions = OeeAvailabilityPerformanceSetting.MaximumAlertActions; break; case ContosoAlertCause.AlertCauseOeePerformanceBelowMinimum: alertActionDefinitions = OeePerformancePerformanceSetting.MinimumAlertActions; break; case ContosoAlertCause.AlertCauseOeePerformanceAboveMaximum: alertActionDefinitions = OeePerformancePerformanceSetting.MaximumAlertActions; break; case ContosoAlertCause.AlertCauseOeeQualityBelowMinimum: alertActionDefinitions = OeeQualityPerformanceSetting.MinimumAlertActions; break; case ContosoAlertCause.AlertCauseOeeQualityAboveMaximum: alertActionDefinitions = OeeQualityPerformanceSetting.MaximumAlertActions; break; case ContosoAlertCause.AlertCauseKpi1BelowMinimum: alertActionDefinitions = Kpi1PerformanceSetting.MinimumAlertActions; break; case ContosoAlertCause.AlertCauseKpi1AboveMaximum: alertActionDefinitions = Kpi1PerformanceSetting.MaximumAlertActions; break; case ContosoAlertCause.AlertCauseKpi2BelowMinimum: alertActionDefinitions = Kpi2PerformanceSetting.MinimumAlertActions; break; case ContosoAlertCause.AlertCauseKpi2AboveMaximum: alertActionDefinitions = Kpi2PerformanceSetting.MaximumAlertActions; break; } } else { Station station = this as Station; ContosoOpcUaNode opcUaNode = station.NodeList.Find(node => node.NodeId == subKey) as ContosoOpcUaNode; switch (alertCause) { case ContosoAlertCause.AlertCauseValueBelowMinimum: alertActionDefinitions = opcUaNode.MinimumAlertActions; break; case ContosoAlertCause.AlertCauseValueAboveMaximum: alertActionDefinitions = opcUaNode.MaximumAlertActions; break; } } return(alertActionDefinitions); }