/// <summary> /// Ctor for Contoso OPC UA server using the station description. /// </summary> public ContosoOpcUaServer( string uri, string name, string description, StationDescription stationDescription) : base(uri, name, description, stationDescription) { }
/// <summary> /// Add new stations to a new factory with a new production line. /// </summary> public void AddNewStations(List <string> opcUriList) { foreach (string opcUri in opcUriList) { try { ContosoTopologyNode newProductionLine = GetOrAddNewProductionLine(); StationDescription desc = new StationDescription(); desc.Name = opcUri; desc.Description = _newStationName; desc.OpcUri = opcUri; Station station = new Station(desc); station.Location = newProductionLine.Location; TopologyNode node = station as TopologyNode; AddChild(newProductionLine.Key, node); UpdateAllKPIAndOEEPerfItems(); } catch { Trace.TraceError("Failed to add station {0} to topology", opcUri); } } }
/// <summary> /// Ctor of the node using topology description data. /// </summary> /// <param name="stationDescription">The topology description for the station.</param> public Station(StationDescription stationDescription) : base(stationDescription.OpcUri, stationDescription.Name, stationDescription.Description, stationDescription) { // List of node relevances. List <ContosoPerformanceRelevance> opcUaNodeRelevances = null; foreach (var opcNode in stationDescription.OpcNodes) { // Initialize relevance and alerts. opcUaNodeRelevances = null; // Initialize relevance of the OPC UA node. This will be used to detect, when dashboard values needs to be udpated. if (opcNode.Relevance != null && opcNode.Relevance.Count > 0) { opcUaNodeRelevances = new List <ContosoPerformanceRelevance>(); ContosoPerformanceRelevance relevance = ContosoPerformanceRelevance.NotRelevant; foreach (var relevanceDescription in opcNode.Relevance) { switch (relevanceDescription) { case "OeeOverall": case "OeeAvailability": case "OeePerformance": case "OeeQuality": throw new Exception(string.Format("The node '{0}' in Station wit URI '{1}' shows '{2}' relevance. This is not allowed since this tag is used for internal processing only. Pllease change.", opcNode.NodeId, Key, relevanceDescription)); case "OeeAvailability_Running": case "OeeAvailability_Fault": case "OeeAvailability_Station_Running": case "OeeAvailability_Station_Fault": if (stationDescription.OeeAvailability == null) { throw new Exception(string.Format("The node '{0}' in Station wit URI '{1}' shows '{2}' relevance, but there are no performance settings for 'OeeAvailability' defined for the Station. Please change.", opcNode.NodeId, Key, relevanceDescription)); } goto case "SetRelevanceOperation"; case "OeePerformance_Ideal": case "OeePerformance_Actual": if (stationDescription.OeePerformance == null) { throw new Exception(string.Format("The node '{0}' in Station wit URI '{1}' shows '{2}' relevance, but there are no performance settings for 'OeePerformance' defined for the Station. Please change.", opcNode.NodeId, Key, relevanceDescription)); } goto case "SetRelevanceOperation"; case "OeeQuality_Good": case "OeeQuality_Bad": case "OeeQuality_Station_Good": case "OeeQuality_Station_Bad": if (stationDescription.OeeQuality == null) { throw new Exception(string.Format("The node '{0}' in Station wit URI '{1}' shows '{2}' relevance, but there are no performance settings for 'OeeQuality' defined for the Station. Please change.", opcNode.NodeId, Key, relevanceDescription)); } goto case "SetRelevanceOperation"; case "Kpi1": case "Kpi1_Station": if (stationDescription.Kpi1 == null) { throw new Exception(string.Format("The node '{0}' in Station wit URI '{1}' shows '{2}' relevance, but there are no performance settings for 'Kpi1' defined for the Station. Please change.", opcNode.NodeId, Key, relevanceDescription)); } goto case "SetRelevanceOperation"; case "Kpi2": if (stationDescription.Kpi2 == null) { throw new Exception(string.Format("The node '{0}' in Station wit URI '{1}' shows '{2}' relevance, but there are no performance settings for 'Kpi2' defined for the Station. Please change.", opcNode.NodeId, Key, relevanceDescription)); } goto case "SetRelevanceOperation"; default: throw new Exception(string.Format("The 'Relevance' value '{0}' in node '{1}' of Station with URI '{2}' is unknown. Please change.", relevanceDescription, opcNode.NodeId, Key)); case "SetRelevanceOperation": if (Enum.TryParse(relevanceDescription, out relevance)) { opcUaNodeRelevances.Add(relevance); } break; } } } // Add the OPC UA node to this station. AddOpcServerNode(opcNode, opcUaNodeRelevances); } }