/// <summary> /// Initialize a new CIM Contingency Definition /// </summary> /// <param name="ElementSource">The XML source for this line</param> /// <param name="AddIfNew">Whether to add any new elements that may be created</param> public MM_Contingency(XmlElement ElementSource, bool AddIfNew) : base(ElementSource, AddIfNew) { this.ElemType = MM_Repository.FindElementType("Contingency"); RollUpCountiesAndVoltages(); }
/// <summary> /// Initialize a new CIM Electrical Bus /// </summary> /// <param name="ElementSource">The XML source for this line</param> /// <param name="AddIfNew">Whether to add any new elements that may be created</param> public MM_Electrical_Bus(XmlElement ElementSource, bool AddIfNew) : base(ElementSource, AddIfNew) { this.ElemType = MM_Repository.FindElementType("ElectricalBus"); }
/// <summary> /// Initialize a new contiengency /// </summary> /// <param name="ContingencyName">The name of the contingency</param> public MM_Contingency(String ContingencyName) { this.Name = ContingencyName; this.Description = ContingencyName; this.ElemType = MM_Repository.FindElementType("Contingency"); }
/// <summary> /// Initialize a new CIM Contingency Definition /// </summary> public MM_Contingency() { this.ElemType = MM_Repository.FindElementType("Contingency"); }
/// <summary> /// Initialize a new node from an XML document /// </summary> /// <param name="ElementSource"></param> /// <param name="AddIfNew"></param> public MM_BusbarSection(XmlElement ElementSource, bool AddIfNew) : base(ElementSource, AddIfNew) { this.ElemType = MM_Repository.FindElementType("BusbarSection"); }
/// <summary> /// Initialize a new blackstart corridor target /// </summary> public MM_Blackstart_Corridor_Element() { ElemType = MM_Repository.FindElementType("Blackstart_Corridor"); }
/// <summary> /// Initialize a parameterless node /// </summary> public MM_BusbarSection() : base() { this.ElemType = MM_Repository.FindElementType("BusbarSection"); }
/// <summary> /// Create a new element based on its definition /// </summary> /// <param name="xElem">The definition for the element</param> /// <param name="Prefix">The prefix for the element, if any</param> /// <param name="AddIfNew">Whether to add a new element to our master repository</param> /// <returns></returns> public static MM_Element CreateElement(XmlElement xElem, string Prefix, bool AddIfNew) { MM_Element OutElement = null; String ElemType; if (xElem.HasAttribute("ElemType")) { ElemType = String.IsNullOrEmpty(Prefix) ? xElem.Attributes["ElemType"].Value : xElem.HasAttribute(Prefix + ".ElemType") ? xElem.Attributes[Prefix + ".ElemType"].Value : Prefix; } else { ElemType = xElem.Name; } if (Prefix == "EPSMeter") { OutElement = new MM_EPSMeter(); OutElement.ElemType = MM_Repository.FindElementType(Prefix); } else if (xElem.HasAttribute("BaseElement.IsSeriesCompensator") && XmlConvert.ToBoolean(xElem.Attributes["BaseElement.IsSeriesCompensator"].Value)) { OutElement = new MM_Line(); } else if (ElemType == "Breaker" || ElemType == "Switch") { OutElement = new MM_Breaker_Switch(); } else if (ElemType == "DCTie") { OutElement = new MM_Tie(); } else if (ElemType == "Tie") { OutElement = new MM_Tie(); } else if (ElemType == "ElectricalBus") { OutElement = new MM_Electrical_Bus(); } else if (ElemType == "Line") { OutElement = new MM_Line(); } else if (ElemType == "Load" || ElemType.Equals("LaaR", StringComparison.CurrentCultureIgnoreCase)) { OutElement = new MM_Load(); } else if (ElemType == "Unit") { OutElement = new MM_Unit(); } else if (ElemType == "Capacitor" || ElemType == "Reactor") { OutElement = new MM_ShuntCompensator(); } else if (ElemType == "Transformer") { OutElement = new MM_Transformer(); } else if (ElemType == "TransformerWinding") { OutElement = new MM_TransformerWinding(); } else if (ElemType == "StaticVarCompensator") { OutElement = new MM_StaticVarCompensator(); } else if (ElemType == "Node") { OutElement = new MM_Node(); } else if (ElemType == "BusbarSection") { OutElement = new MM_Bus(); } else if (ElemType == "PricingVector") { OutElement = new MM_PricingVector(); ((MM_PricingVector)OutElement).EPSMeter = (MM_EPSMeter)CreateElement(xElem, "EPSMeter", false); } else if (ElemType == "EPSMeter") { OutElement = new MM_EPSMeter(); } else if (ElemType == "County" || ElemType == "State") { OutElement = new MM_Boundary(); } else if (ElemType == "Company") { OutElement = new MM_Company(); } else if (ElemType == "Flowgate") { OutElement = new MM_Flowgate(); } else if (ElemType == "Contingency") { OutElement = new MM_Contingency(); } else if (ElemType == "Substation") { OutElement = new MM_Substation(); } else if (ElemType == "VoltageLevel") { //OutElement = new MM_KVLevel(); } else { OutElement = new MM_Element(); } OutElement.ElemType = MM_Repository.FindElementType(ElemType); //Now, pull in our attributes foreach (XmlAttribute xAttr in xElem.Attributes) { if ((String.IsNullOrEmpty(Prefix) && xAttr.Name.IndexOf('.') == -1)) { MM_Serializable.AssignValue(xAttr.Name, xAttr.Value, OutElement, AddIfNew); } else if (!String.IsNullOrEmpty(Prefix) && xAttr.Name.StartsWith(Prefix + ".")) { MM_Serializable.AssignValue(xAttr.Name.Substring(xAttr.Name.IndexOf('.') + 1), xAttr.Value, OutElement, AddIfNew); } } if (xElem.HasAttribute("Contingencies")) { String[] splStr = xElem.Attributes["Contingencies"].Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (OutElement.Contingencies == null || OutElement.Contingencies.Count == 0) { OutElement.Contingencies = new List <MM_Contingency>(); } else { OutElement.Contingencies = OutElement.Contingencies.ToList(); } foreach (string str in splStr) { MM_Contingency con = null; MM_Repository.Contingencies.TryGetValue(str, out con); if (con != null && !OutElement.Contingencies.Any(c => c.Name == con.Name)) { OutElement.Contingencies.Add(con); } } } //If we're a transformer, pull in our windings if (ElemType == "Transformer") { List <MM_TransformerWinding> Windings = new List <MM_TransformerWinding>(); foreach (XmlElement xWind in xElem.SelectNodes("Winding")) { Windings.Add(MM_Element.CreateElement(xWind, "BaseElement", AddIfNew) as MM_TransformerWinding); } if (xElem.HasAttribute("BaseElement.KVLevel1")) { Windings[0].Voltage = XmlConvert.ToSingle(xElem.Attributes["BaseElement.KVLevel1"].Value.Split(' ')[0]); } if (xElem.HasAttribute("BaseElement.KVLevel2")) { Windings[1].Voltage = XmlConvert.ToSingle(xElem.Attributes["BaseElement.KVLevel2"].Value.Split(' ')[0]); } (OutElement as MM_Transformer).Windings = Windings.ToArray(); } //If we're a line, check for series compensator status to upgrade our type if (OutElement is MM_Line && xElem.HasAttribute("BaseElement.IsSeriesCompensator") && XmlConvert.ToBoolean(xElem.Attributes["BaseElement.IsSeriesCompensator"].Value)) { OutElement.ElemType = MM_Repository.FindElementType("SeriesCompensator"); } //Return our new element return(OutElement); }
/// <summary> /// When the primary/secondary path is selected, display all of our elements /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbPrimarySecondary_SelectedIndexChanged(object sender, EventArgs e) { try { lvItems.Columns.Clear(); lvItems.Items.Clear(); lvItems.View = View.Details; lvItems.Columns.Add("#"); lvItems.Columns.Add("Action"); lvItems.Columns.Add("Subsatation"); lvItems.Columns.Add("Type"); lvItems.Columns.Add("Element"); lvItems.Columns.Add("Operator"); lvItems.FullRowSelect = true; lvItems.CheckBoxes = true; MM_Blackstart_Corridor_Target Target = cmbCorridorTarget.SelectedItem as MM_Blackstart_Corridor_Target; FieldInfo fI = Target.GetType().GetField(cmbPrimarySecondary.Text); if (Target != null && fI != null) { MM_Blackstart_Corridor_Element[] Elems = fI.GetValue(Target) as MM_Blackstart_Corridor_Element[]; MM_Substation LastSub = null; for (int a = 0; a < Elems.Length; a++) { try { ListViewItem lvI = new ListViewItem((a + 1).ToString("#,##0")); lvI.UseItemStyleForSubItems = true; if (MM_Server_Interface.Client != null && Array.IndexOf(Data_Integration.UserOperatorships, 999999) == -1 && Array.IndexOf(Data_Integration.UserOperatorships, Elems[a].AssociatedElement.Operator.TEID) == -1) { lvI.ForeColor = Color.Gray; } lvI.SubItems.Add(Elems[a].Action.ToString()); if (Elems[a].AssociatedElement != null) { MM_Element Elem = Elems[a].AssociatedElement; if (Elem is MM_Line) { MM_Line Line = (MM_Line)Elem; if (LastSub == Line.Substation2) { lvI.SubItems.Add(Line.Substation2.Name + " to " + Line.Substation1.Name); } else { lvI.SubItems.Add(Line.Substation1.Name + " to " + Line.Substation2.Name); } LastSub = Line.Substation2; } else { lvI.SubItems.Add(Elem.Substation.Name); LastSub = Elem.Substation; } lvI.SubItems.Add(Elem.ElemType.Name); lvI.SubItems.Add(MM_Repository.TitleCase(Elem.Name)); lvI.SubItems.Add(Elem.Operator.Alias.Substring(0, 1) + MM_Repository.TitleCase(Elem.Operator.Alias.Substring(1))); } else { if (Elems[a].Substation == null) { lvI.SubItems.Add("?"); } else { lvI.SubItems.Add(MM_Repository.TitleCase(Elems[a].Substation.Name)); } lvI.SubItems.Add("?"); lvI.SubItems.Add("?"); lvI.SubItems.Add("?"); lvI.ForeColor = Color.Red; lvI.UseItemStyleForSubItems = true; } lvI.Tag = Elems[a]; lvItems.Items.Add(lvI); } catch (Exception ex) { MM_System_Interfaces.LogError(ex); } } tmrUpdate_Tick(tmrUpdate, EventArgs.Empty); lvItems.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); } } catch (Exception) { } }
/// <summary>Initialize a new transformer winding</summary> public MM_TransformerWinding(DbDataReader ElementSource, bool AddIfNew) : base(ElementSource, AddIfNew) { this.ElemType = MM_Repository.FindElementType("TransformerWinding"); }
/// <summary>Initialize a new transformer winding</summary> public MM_TransformerWinding() : base() { this.ElemType = MM_Repository.FindElementType("TransformerWinding"); }