private PerLengthImpedance createPerLengthImpedanceObject(CableConfiguration configuration, string acLineSegment_mrid) { PerLengthSequenceImpedance pli = new PerLengthSequenceImpedance(); if (!perLengthImpedanceContainer.ContainsKey(configuration.Name)) { if (configuration.Name != "xfm_1") { string pli_mrid = acLineSegment_mrid + "_PLI"; pli.ID = pli_mrid; pli.MRID = pli_mrid; pli.Name = configuration.Name; pli.Bch = (float)configuration.Susceptance; pli.B0ch = 0; pli.R = (float)configuration.Primar_value.Real_part; pli.R0 = 0; pli.X = (float)configuration.Primar_value.Imaginary_part; pli.X0 = 0; perLengthImpedanceContainer.Add(configuration.Name, pli); addComponentToGlobalDictionary(pli, pli.GetType()); } } else { pli = (PerLengthSequenceImpedance)perLengthImpedanceContainer[configuration.Name]; return(pli); } return(pli); }
private void Button_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; string content = button.Content as string; if (!allFilled()) { MessageBox.Show("You have to fill all data."); return; } CableConfiguration cableConfiguration = setupCableConfiguration(); if (selectedConfiguration != null) { if (globalCableConfiguration.ContainsKey(selectedConfiguration.Name) && content == "Update") { globalCableConfiguration.Remove(selectedConfiguration.Name); } } if (globalCableConfiguration.ContainsKey(conf_id.Text) && content == "Save") { MessageBox.Show("Configuration with that name already exists"); return; } (this.DataContext as CreateConfigurationViewModel).AddCableConfiguration(cableConfiguration, globalCableConfiguration); }
private AssetInfo createWireInfoObject(CableConfiguration configuration, string mRID) { WireInfo wi = new WireInfo(); if (!wireInfoContainer.ContainsKey(configuration.Name)) { if (configuration.Name != "xfm_1") { string wi_mrid = mRID + "_WI"; wi.ID = wi_mrid; wi.MRID = wi_mrid; wi.Name = configuration.Name; wi.Material = (WireMaterialKind)((int)configuration.Cable.MaterialKind); wi.SizeDescription = configuration.Cable.SizeDescription; wi.Gmr = (float)0.001; wi.Radius = 0; wi.RatedCurrent = 0; wireInfoContainer.Add(configuration.Name, wi); addComponentToGlobalDictionary(wi, wi.GetType()); } //RADIUS and RATED_CURRENT are going to have values } else { wi = wireInfoContainer[configuration.Name]; return(wi); } return(wi); }
private void populateData(CableConfiguration selectedConfiguration) { conf_id.Text = selectedConfiguration.Name; comboboxPhasing.SelectedIndex = 0; sizeDescription.Text = selectedConfiguration.Cable.SizeDescription; materialKind.SelectedIndex = 0; wireSpacing.Text = selectedConfiguration.Cable.PhaseWireSpacing.ToString(); real_part1_1.Text = selectedConfiguration.Primar_value.Real_part.ToString(); imaginary_part1_1.Text = selectedConfiguration.Primar_value.Imaginary_part.ToString(); real_part1_2.Text = selectedConfiguration.Secondary_value[0].Real_part.ToString(); imaginary_part1_2.Text = selectedConfiguration.Secondary_value[0].Imaginary_part.ToString(); real_part1_3.Text = selectedConfiguration.Terciar_value[0].Real_part.ToString(); imaginary_part1_3.Text = selectedConfiguration.Terciar_value[0].Imaginary_part.ToString(); real_part2_2.Text = selectedConfiguration.Secondary_value[1].Real_part.ToString(); imaginary_part2_2.Text = selectedConfiguration.Secondary_value[1].Imaginary_part.ToString(); real_part2_3.Text = selectedConfiguration.Terciar_value[1].Real_part.ToString(); imaginary_part2_3.Text = selectedConfiguration.Terciar_value[1].Imaginary_part.ToString(); real_part3_3.Text = selectedConfiguration.Terciar_value[2].Real_part.ToString(); imaginary_part3_3.Text = selectedConfiguration.Terciar_value[2].Imaginary_part.ToString(); suscenptance_per_length.Text = selectedConfiguration.Susceptance.ToString(); }
//Initital value for xfm-1 configuration private void AddDefaultConfig() { CableConfiguration cc = new CableConfiguration() { Name = "xfm-1", Phasing = CableConfiguration.PhasingEnum.ABC, Primar_value = new ComplexValue() { Real_part = 1, Imaginary_part = 1 }, Secondary_value = new List <ComplexValue>() { new ComplexValue() { Real_part = 1, Imaginary_part = 1 }, new ComplexValue() { Real_part = 1, Imaginary_part = 1 } }, Terciar_value = new List <ComplexValue>() { new ComplexValue() { Real_part = 1, Imaginary_part = 1 }, new ComplexValue() { Real_part = 1, Imaginary_part = 1 }, new ComplexValue() { Real_part = 1, Imaginary_part = 1 } }, Cable = new Models.Cable() { MaterialKind = Models.Cable.MaterialEnum.aluminum, SizeDescription = "111", PhaseWireSpacing = 1, Radius = 1, RatedCurrent = 1 }, Susceptance = 1 }; globalCableConfiguration.Add(cc.Name, cc); }
public CreateConfigurationView(MainWindow mainWindow, Dictionary <string, CableConfiguration> _globalCableConfiguration, CableConfiguration selectedConfiguration) : this(mainWindow, _globalCableConfiguration) { _mn = mainWindow; _mn.ccView = this; this.selectedConfiguration = selectedConfiguration; globalCableConfiguration = _globalCableConfiguration; dynamicButton.Content = "Update"; InitializeComponent(); populateData(selectedConfiguration); }
public void DeserializeConfigurationData(string cable_file) { List <GraphSerializationData> gds = FileServiceProvider.DeserializeDataFromFile(cable_file); foreach (GraphSerializationData x in gds) { CableConfiguration cc = x.Data as CableConfiguration; (mainWindow.ccView.DataContext as CreateConfigurationViewModel).AddCableConfiguration(cc); } }
private void EditConfiguration(object sender, RoutedEventArgs e) { Button button = (Button)sender; selectedConfiguration = button.DataContext as CableConfiguration; var w = new Window(); w = new CreateConfigurationView(mainWindow, _configurationContainer, selectedConfiguration); w.Show(); }
private void DeleteConfiguration(object sender, RoutedEventArgs e) { Button button = (Button)sender; selectedConfiguration = button.DataContext as CableConfiguration; (mainWindow.ccView.DataContext as CreateConfigurationViewModel).RemoveExistingConfiguration(selectedConfiguration); _configurationContainer.Remove(selectedConfiguration.Name); cableConfigurations.ItemsSource = mainWindow.GlobalCableConfiguration.Values; //mainWindow.CloseAllWindows(); }
internal void AddCableConfiguration(CableConfiguration cableConfiguration, Dictionary <string, CableConfiguration> _globalCableConfiguration = null) { if (_globalCableConfiguration != null) { if (_globalCableConfiguration.Count != 0) { (App.Current.MainWindow as MainWindow).GlobalCableConfiguration = _globalCableConfiguration; } } (App.Current.MainWindow as MainWindow).GlobalCableConfiguration.Add(cableConfiguration.Name, cableConfiguration); (App.Current.MainWindow as MainWindow).CloseAllWindows(); }
internal void CreateComplexVertexWithPartialType(DataVertex existing_transformer_vertex, DataVertex existing_transformer_vertex_partial, DataVertex clicked_vertex, string length = null, CableConfiguration cableConfiguration = null) { mainWindow.GlobalVertices[existing_transformer_vertex.Element_id] = existing_transformer_vertex; string local_length = "0"; foreach (VertexControl vc in Area.VertexList.Values) { DataVertex dv = (DataVertex)vc.Vertex; if (length != null) { local_length = length; } if (dv.Text == clicked_vertex.Text) { //update areas vertex vc.Vertex = existing_transformer_vertex; //remove old and add updated vertex mainWindow.graphView.Area.VertexList.Remove(dv); mainWindow.graphView.Area.VertexList.Add(existing_transformer_vertex, vc); //create CreateDataVertexBase(existing_transformer_vertex_partial.typeOfVertex, existing_transformer_vertex_partial.Element_id); //connect new partial and existing _ecFrom = GetVertexControlWithDataVertex(dv.Element_id); VertexControl target = GetVertexControlWithDataVertex(existing_transformer_vertex_partial.Element_id); graphState = GraphState.PARTIAL_CONNECTING; ConnectEdges(target, int.Parse(local_length)); graphState = GraphState.NORMAL; break; } } }
public void RemoveExistingConfiguration(CableConfiguration selectedConfiguration) { (App.Current.MainWindow as MainWindow).GlobalCableConfiguration.Remove(selectedConfiguration.Name); }
internal void AddEdge(DataEdge data, EdgeControl ec, VertexControl ecFrom, CableConfiguration cableConfiguration = null) { if (data == null) { return; } if (_ecFrom == null) { VertexControl vc = GetVertexControlWithDataVertex(data.Source.Element_id);; _ecFrom = vc; } if (mainWindow.graphView.Area.EdgesList.ContainsKey(data)) { return; } if (graphState == GraphState.NORMAL) { data.Length = length; data.Text = length.ToString(); } if (data.Source.typeOfVertex == DataVertex.TypeOfVertex.REGULATOR_VERTEX || data.Source.typeOfVertex == DataVertex.TypeOfVertex.TRANSFORMER_VERTEX) { cableConfiguration = new CableConfiguration() { Name = "xfm_1" }; data.Configuration = cableConfiguration; } if (mainWindow.GlobalEdges.ContainsKey(data.Source.Element_id)) { mainWindow.GlobalEdges[data.Source.Element_id].Add(data); } else { mainWindow.GlobalEdges.Add(data.Source.Element_id, new List <DataEdge>() { data }); } bool its_needed = CheckIfLabelNeeded(data); if (its_needed) { mainWindow.graphView.Area.AddEdge(data, ec, true); } else { mainWindow.graphView.Area.AddEdge(data, ec, false); } setEdgesDashStyle(ec, data.Source.typeOfVertex); HighlightBehaviour.SetHighlighted(_ecFrom, true); _ecFrom = null; DestroyVirtualEdge(); mainWindow.segmentData.IsEnabled = true; if (graphState == GraphState.NORMAL) { undoRedoCommander.addUndoCommand(new Command("AddEdge", data)); } }
private CableConfiguration setupCableConfiguration() { CableConfiguration.PhasingEnum pe = (CableConfiguration.PhasingEnum)comboboxPhasing.SelectedItem; Cable.MaterialEnum me = (Cable.MaterialEnum)materialKind.SelectedItem; ComplexValue primarValue = new ComplexValue() { Real_part = Double.Parse(real_part1_1.Text), Imaginary_part = Double.Parse(imaginary_part1_1.Text) }; List <ComplexValue> secondaryValues = new List <ComplexValue>(); ComplexValue secondaryValue1 = new ComplexValue() { Real_part = Double.Parse(real_part1_2.Text), Imaginary_part = Double.Parse(imaginary_part1_2.Text) }; ComplexValue secondaryValue2 = new ComplexValue() { Real_part = Double.Parse(real_part2_2.Text), Imaginary_part = Double.Parse(imaginary_part2_2.Text) }; secondaryValues.Add(secondaryValue1); secondaryValues.Add(secondaryValue2); List <ComplexValue> terciarValues = new List <ComplexValue>(); ComplexValue terciarValue1 = new ComplexValue() { Real_part = Double.Parse(real_part1_3.Text), Imaginary_part = Double.Parse(imaginary_part1_3.Text) }; ComplexValue terciarValue2 = new ComplexValue() { Real_part = Double.Parse(real_part2_3.Text), Imaginary_part = Double.Parse(imaginary_part2_3.Text) }; ComplexValue terciarValue3 = new ComplexValue() { Real_part = Double.Parse(real_part3_3.Text), Imaginary_part = Double.Parse(imaginary_part3_3.Text) }; terciarValues.Add(terciarValue1); terciarValues.Add(terciarValue2); terciarValues.Add(terciarValue3); Cable cable = new Cable() { MaterialKind = me, SizeDescription = sizeDescription.Text, PhaseWireSpacing = Double.Parse(wireSpacing.Text) }; CableConfiguration cableConfiguration = new CableConfiguration() { Name = conf_id.Text, Phasing = pe, Primar_value = primarValue, Secondary_value = secondaryValues, Terciar_value = terciarValues, Cable = cable, Susceptance = Double.Parse(suscenptance_per_length.Text) }; return(cableConfiguration); }