/// <summary> /// Update status through the topology hierarchy. /// </summary> public void UpdateAllStatusTopology() { // topology is updated from bottom to top nodes, add Production Line view List <string> orderedlist = GetAllChildren(TopologyRoot.Key, typeof(ProductionLine)); // add factory view orderedlist.AddRange(GetAllChildren(TopologyRoot.Key, typeof(Factory))); // add top view orderedlist.Add(TopologyRoot.Key); foreach (string item in orderedlist) { ContosoPerformanceStatus status = ContosoPerformanceStatus.Good; ContosoTopologyNode actualNode = this[item] as ContosoTopologyNode; if (actualNode != null) { List <string> children = actualNode.GetChildren(); foreach (string child in children) { // special case for child as OPC UA server Station station = this[child] as Station; if (station != null) { foreach (ContosoOpcUaNode node in station.NodeList) { status = node.Status; if (node.Status == ContosoPerformanceStatus.Poor) { break; } } } ContosoTopologyNode childNode = this[child] as ContosoTopologyNode; if (childNode != null) { if (childNode.Status == ContosoPerformanceStatus.Poor) { status = ContosoPerformanceStatus.Poor; break; } } } actualNode.Status = status; } } }
/// <summary> /// Update the OEE and KPI values. /// </summary> public void UpdateAllKPIAndOEEPerfItems() { // topology is updated from bottom to top nodes, add Production Line view List <string> orderedlist = GetAllChildren(TopologyRoot.Key, typeof(ProductionLine)); // add factory view orderedlist.AddRange(GetAllChildren(TopologyRoot.Key, typeof(Factory))); // add top view orderedlist.Add(TopologyRoot.Key); // update all, list is already in the right order to process sequentially foreach (string item in orderedlist) { ContosoTopologyNode actualNode = this[item] as ContosoTopologyNode; if (actualNode != null) { List <string> children = actualNode.GetChildren(); double addedChilds = 0.0; actualNode.PerformanceSettingUpdateReset(); foreach (string child in children) { // special case for child as OPC UA server Station station = this[child] as Station; if (station != null) { addedChilds += 1.0; actualNode.PerformanceSettingAddStation(station); continue; } ContosoTopologyNode childNode = this[child] as ContosoTopologyNode; if (childNode != null) { addedChilds += 1.0; actualNode.PerformanceSettingAdd(childNode); } } actualNode.PerformanceSettingUpdateDone(addedChilds); } } }
/// <summary> /// Update the OEE and KPI values /// </summary> public void UpdateAllKPIAndOEEValues(int histogram = 0) { // topology is updated from bottom to top nodes, add Production Line view List <string> orderedlist = GetAllChildren(TopologyRoot.Key, typeof(ProductionLine)); // add factory view orderedlist.AddRange(GetAllChildren(TopologyRoot.Key, typeof(Factory))); // add top view orderedlist.Add(TopologyRoot.Key); bool updateStatus = false; // update all, list is already in the right order to process sequentially foreach (string item in orderedlist) { ContosoTopologyNode actualNode = this[item] as ContosoTopologyNode; if (actualNode != null) { ContosoAggregatedOeeKpiHistogram oeeKpiHistogram = actualNode[histogram]; for (int i = 0; i < oeeKpiHistogram.Intervals.Count; i++) { ContosoAggregatedOeeKpiTimeSpan oeeKpiNode = oeeKpiHistogram[i]; oeeKpiNode.Reset(); List <string> children = actualNode.GetChildren(); foreach (string child in children) { // special case for child as OPC UA server Station childStation = this[child] as Station; if (childStation != null) { ContosoAggregatedOeeKpiTimeSpan oeeKpiChild = childStation[histogram, i]; // add all Oee and KPI using the metric for stations oeeKpiNode.AddStation(oeeKpiChild); // update alerts for the station ContosoAggregatedOeeKpiHistogram childOeeKpiHistogram = childStation[histogram]; if (childOeeKpiHistogram.CheckAlerts) { UpdateKPIAndOeeAlerts(childStation); } } else { ContosoTopologyNode childNode = this[child] as ContosoTopologyNode; if (childNode != null) { ContosoAggregatedOeeKpiTimeSpan oeeKpiChild = childNode[histogram, i]; // add all Oee and KPI using the default metric oeeKpiNode.Add(oeeKpiChild); } else { continue; } } } if (oeeKpiNode.EndTime > oeeKpiHistogram.EndTime) { oeeKpiHistogram.EndTime = oeeKpiNode.EndTime; } } if (oeeKpiHistogram.CheckAlerts) { // check for alerts UpdateKPIAndOeeAlerts(actualNode); updateStatus = true; } } } if (updateStatus) { UpdateAllStatusTopology(); } }