public void ShowVertexDetails(DataVertex dv, VertexControl vc) { //open context vertex switch (dv.typeOfVertex) { case DataVertex.TypeOfVertex.REGULATOR_VERTEX: w = new RegulatorView(dv); break; case DataVertex.TypeOfVertex.TRANSFORMER_VERTEX: w = new TransformerView(dv); break; case DataVertex.TypeOfVertex.SPOT_LOAD_VERTEX: SpotLoad spotLoad = FindSpotLoadVertex(dv); if (spotLoad == null) { w = new SpotLoadView(dv as SpotLoad, false); } else { w = new SpotLoadView(spotLoad); } break; default: return; } w.Show(); }
private void UpdateSpotLoad(object sender, RoutedEventArgs e) { _mn = (MainWindow)Application.Current.MainWindow; Button button = sender as Button; SpotLoad sl = button.DataContext as SpotLoad; _mn.UpdateSpotLoad(sl); }
public void Update(ICircuitElement element) { SpotLoad spotLoad = element as SpotLoad; MainWindow mainWindow = GetMainWindow(); if (mainWindow.GlobalSpotLoads.ContainsKey(spotLoad.Element_id)) { mainWindow.GlobalSpotLoads.Remove(spotLoad.Element_id); } mainWindow.DeleteSpotLoad(spotLoad.Element_id); }
public SpotLoadView(SpotLoad sl, bool v) { InitializeComponent(); _mn = App.Current.MainWindow as MainWindow; _gv = _mn.GlobalVertices; current_spot_load = new SpotLoad(); loadModelEnum.ItemsSource = Enum.GetValues(typeof(SpotLoad.LoadModelEnum)).Cast <SpotLoad.LoadModelEnum>(); loadModelEnum.SelectedIndex = 0; _gsl = _mn.GlobalSpotLoads; //Initial population of data populateViewData(sl, v); }
private void populateViewData(SpotLoad sl, bool ischecked) { node_id.Text = "Spot Load number: " + sl.Element_id; loadModelEnum.SelectedIndex = 0; if (ischecked) { ph1.Text = sl.Ph_1.ToString(); ph1_1.Text = sl.Ph_1_2.ToString(); ph2.Text = sl.Ph_2.ToString(); ph2_1.Text = sl.Ph_2_2.ToString(); ph3.Text = sl.Ph_3.ToString(); ph3_1.Text = sl.Ph_3_2.ToString(); } }
public SpotLoadView(SpotLoad sl) { InitializeComponent(); this.sl = sl; _mn = App.Current.MainWindow as MainWindow; _gv = _mn.GlobalVertices; current_spot_load = new SpotLoad(); //Initial population of data populateViewData(sl, true); loadModelEnum.ItemsSource = Enum.GetValues(typeof(SpotLoad.LoadModelEnum)).Cast <SpotLoad.LoadModelEnum>(); loadModelEnum.SelectedIndex = 0; this.dynamicButton.Content = "Update"; }
private void DeleteSpotLoad(object sender, RoutedEventArgs e) { _mn = (MainWindow)Application.Current.MainWindow; Button button = sender as Button; SpotLoad sl = button.DataContext as SpotLoad; _mn.DeleteSpotLoad(sl.Element_id); (_mn.graphView.DataContext as GraphViewModel).DeleteVertex(sl); //_mn.graphView.deleteNode(_mn.GlobalVertices[sl.Node.Element_id],false,false); }
private UsagePoint CreateSpotLoad(SpotLoad sl) { UsagePoint usagePoint = new UsagePoint(); ServiceLocation serviceLocation = new ServiceLocation(); string usage_point_mrid = Guid.NewGuid().ToString(); usagePoint.ID = usage_point_mrid; usagePoint.MRID = usage_point_mrid; usagePoint.Name = sl.Text; serviceLocation = createServiceLocation(serviceLocation); usagePoint.ServiceLocation = serviceLocation; usagePoint.RatedPower = 0; return(usagePoint); }
private void CreateSpotLoadVertex(DataVertex dv, double m = 0, double n = 0) { SpotLoad sp = new SpotLoad(); VertexControl vc; sp.Text = "Spot load: " + dv.Element_id; sp.Element_id = dv.Element_id; sp.typeOfVertex = DataVertex.TypeOfVertex.SPOT_LOAD_VERTEX; vc = new VertexControl(sp); mainWindow.GlobalVertices.Add(sp.Element_id, sp); if (mainWindow.GlobalSpotLoads.ContainsKey(sp.Element_id)) { mainWindow.GlobalSpotLoads[sp.Element_id] = sp; } else { mainWindow.GlobalSpotLoads.Add(sp.Element_id, sp); } mainWindow.spotLoadTab._globalSpotLoads = mainWindow.GlobalSpotLoads; mainWindow.spotLoadTab.populateListView(); if (m == 0) { vc.SetPosition(new Point(x, y)); } else { vc.SetPosition(m, n); } vc.Background = Brushes.Gray; mainWindow.graphView.Area.AddVertexAndData(sp, vc, true); if (graphState == GraphState.NORMAL) { x += 30; y += 30; } return; }
public void Create(ICircuitElement element) { SpotLoad spotLoad = element as SpotLoad; MainWindow mainWindow = GetMainWindow(); if (mainWindow.GlobalSpotLoads.ContainsKey(spotLoad.Element_id) == false) { mainWindow.GlobalSpotLoads.Add(spotLoad.Element_id, spotLoad); } else { mainWindow.GlobalSpotLoads[spotLoad.Element_id] = spotLoad; } mainWindow.CloseAllWindows(); mainWindow.spotLoadTab._globalSpotLoads = mainWindow.GlobalSpotLoads; mainWindow.spotLoadTab.populateListView(); }
internal void UpdateSpotLoad(SpotLoad sl) { //w.Content = new SpotLoadView(this, globalVertices, globalSpotLoads, sl w = new SpotLoadView(sl); w.Show(); }
internal void CreateSpotLoad(SpotLoad current_spot_load) { spotLoadTab._globalSpotLoads = globalSpotLoads; spotLoadTab.populateListView(); }
public Dictionary <Type, Dictionary <string, IdentifiedObject> > CreateObjectModel(Dictionary <string, DataVertex> globalVertices, Dictionary <string, List <DataEdge> > globalEdges, Dictionary <string, CableConfiguration> globalCableConfiguration, Dictionary <string, SpotLoad> globalSpotLoads) { globalComponentDictionary = new Dictionary <Type, Dictionary <string, IdentifiedObject> >(); terminalPairsContainer = new List <TerminalPair>(); perLengthImpedanceContainer = new Dictionary <string, PerLengthImpedance>(); wireInfoContainer = new Dictionary <string, WireInfo>(); usagePointContainer = new Dictionary <string, SpotLoad>(); powerTransformerEnding = new Dictionary <string, DataVertexTransformer>(); PSRType local_psr_pt = new PSRType(); circuit = new Circuit(); string mrid = Guid.NewGuid().ToString(); PSRType psrTypeCircuit = new PSRType() { MRID = "Feeder", Name = "Feeder" }; circuit.PSRType = psrTypeCircuit; circuit.ID = mrid; circuit.MRID = mrid; circuit.Name = "Feeder_36"; addComponentToGlobalDictionary(circuit, circuit.GetType()); addComponentToGlobalDictionary(psrTypeCircuit, psrTypeCircuit.GetType()); Dictionary <string, ConnectivityNode> connectivityNodeContainer = new Dictionary <string, ConnectivityNode>(); foreach (DataVertex dataVertex in globalVertices.Values) { if (dataVertex.typeOfVertex == DataVertex.TypeOfVertex.TRANSFORMER_VERTEX) { PowerTransformer powerTransformer = new PowerTransformer(); DataVertexTransformer dvt = (DataVertexTransformer)dataVertex; string power_transformer_mrid = Guid.NewGuid().ToString(); powerTransformer.ID = power_transformer_mrid; powerTransformer.MRID = power_transformer_mrid; powerTransformer.Name = "2 winding power transformer"; local_psr_pt = new PSRType() { Name = "Consumer Transformer", MRID = "Consumer Transformer" }; powerTransformer.PSRType = local_psr_pt; powerTransformer.EquipmentContainer = circuit; addComponentToGlobalDictionary(local_psr_pt, local_psr_pt.GetType()); ConnectivityNode w1T_cn = new ConnectivityNode(); string connectivity_node_mrid = Guid.NewGuid().ToString(); w1T_cn.ID = connectivity_node_mrid; w1T_cn.MRID = connectivity_node_mrid; w1T_cn.ConnectivityNodeContainer = circuit; if ((dataVertex as DataVertexTransformer).Line_from == null) { continue; } ; w1T_cn.Name = (dataVertex as DataVertexTransformer).Line_from; connectivityNodeContainer.Add((dataVertex as DataVertexTransformer).Line_from, w1T_cn); addComponentToGlobalDictionary(w1T_cn, w1T_cn.GetType()); ConnectivityNode w2T_cn = new ConnectivityNode(); connectivity_node_mrid = Guid.NewGuid().ToString(); w2T_cn.ID = connectivity_node_mrid; w2T_cn.MRID = connectivity_node_mrid; w2T_cn.ConnectivityNodeContainer = circuit; w2T_cn.Name = (dataVertex as DataVertexTransformer).Line_to; connectivityNodeContainer.Add((dataVertex as DataVertexTransformer).Line_to, w2T_cn); if ((dataVertex as DataVertexTransformer).Line_to == null) { continue; } ; addComponentToGlobalDictionary(w2T_cn, w2T_cn.GetType()); Terminal w1T = new Terminal(); w1T.MRID = power_transformer_mrid + ".W1.T"; w1T.ID = power_transformer_mrid + ".W1.T"; w1T.SequenceNumber = 1; w1T.ConductingEquipment = powerTransformer; w1T.ConnectivityNode = w1T_cn; w1T.Phases = PhaseCode.s2N; w1T.Name = "Transformer end terminal 1"; Terminal w2T = new Terminal(); w2T.MRID = power_transformer_mrid + ".W2.T"; w2T.ID = power_transformer_mrid + ".W2.T"; w2T.SequenceNumber = 2; w2T.ConductingEquipment = powerTransformer; w2T.ConnectivityNode = w2T_cn; w2T.Phases = PhaseCode.s2N; w2T.Name = "Transformer end terminal 2"; terminalPairsContainer.Add(new TerminalPair() { terminalA = w1T, terminalB = w2T }); addComponentToGlobalDictionary(w1T, w1T.GetType()); addComponentToGlobalDictionary(w2T, w2T.GetType()); PowerTransformerEnd powerTransformerEnd1 = new PowerTransformerEnd(); powerTransformerEnd1.ID = power_transformer_mrid + ".W1"; powerTransformerEnd1.MRID = power_transformer_mrid + ".W1"; powerTransformerEnd1.Name = dvt.NameA; powerTransformerEnd1.Terminal = w1T; powerTransformerEnd1.Grounded = false; powerTransformerEnd1.EndNumber = 1; powerTransformerEnd1.PowerTransformer = powerTransformer; powerTransformerEnd1.ConnectionKind = WindingConnection.D; powerTransformerEnd1.PhaseAngleClock = 0; powerTransformerEnd1.RatedS = (float)dvt._kVA_A; powerTransformerEnd1.RatedU = (float)dvt._kV_LowA; PowerTransformerEnd powerTransformerEnd2 = new PowerTransformerEnd(); powerTransformerEnd2.ID = power_transformer_mrid + ".W2"; powerTransformerEnd2.MRID = power_transformer_mrid + ".W2"; powerTransformerEnd2.Name = dvt.NameB; powerTransformerEnd2.Terminal = w2T; powerTransformerEnd2.Grounded = false; powerTransformerEnd2.EndNumber = 1; powerTransformerEnd2.PowerTransformer = powerTransformer; powerTransformerEnd2.ConnectionKind = WindingConnection.D; powerTransformerEnd2.PhaseAngleClock = 0; powerTransformerEnd2.RatedS = (float)dvt._kVA_B; powerTransformerEnd2.RatedU = (float)dvt._kV_LowB; addComponentToGlobalDictionary(powerTransformer, powerTransformer.GetType()); addComponentToGlobalDictionary(powerTransformerEnd1, powerTransformerEnd1.GetType()); addComponentToGlobalDictionary(powerTransformerEnd2, powerTransformerEnd2.GetType()); } if (dataVertex.typeOfVertex == DataVertex.TypeOfVertex.REGULATOR_VERTEX) { string sync_machine = Guid.NewGuid().ToString(); PSRType psr_sync_machine = new PSRType() { MRID = "Generator", Name = "Generator" }; SynchronousMachine sm = new SynchronousMachine() { Name = dataVertex.Text, MRID = sync_machine, ID = sync_machine, EquipmentContainer = circuit }; addComponentToGlobalDictionary(sm, sm.GetType()); addComponentToGlobalDictionary(psr_sync_machine, psr_sync_machine.GetType()); } } foreach (List <DataEdge> dataEdgeCollection in globalEdges.Values) { foreach (DataEdge dataEdge in dataEdgeCollection) { string acLineSegment_mrid = Guid.NewGuid().ToString(); ConnectivityNode T1_cn = new ConnectivityNode(); string connectivity_node_mrid = Guid.NewGuid().ToString(); T1_cn.ID = connectivity_node_mrid; T1_cn.MRID = connectivity_node_mrid; T1_cn.ConnectivityNodeContainer = circuit; T1_cn.Name = (dataEdge.Source as DataVertex).Element_id; if (connectivityNodeContainer.ContainsKey((dataEdge.Source as DataVertex).Element_id) == false) { connectivityNodeContainer.Add(dataEdge.Source.Element_id, T1_cn); addComponentToGlobalDictionary(T1_cn, T1_cn.GetType()); } ConnectivityNode T2_cn = new ConnectivityNode(); connectivity_node_mrid = Guid.NewGuid().ToString(); T2_cn.ID = connectivity_node_mrid; T2_cn.MRID = connectivity_node_mrid; T2_cn.ConnectivityNodeContainer = circuit; T2_cn.Name = (dataEdge.Target as DataVertex).Element_id; if (connectivityNodeContainer.ContainsKey((dataEdge.Target as DataVertex).Element_id) == false) { connectivityNodeContainer.Add(dataEdge.Target.Element_id, T2_cn); addComponentToGlobalDictionary(T2_cn, T2_cn.GetType()); } Terminal T1 = new Terminal(); //string terminal_mrid = Guid.NewGuid().ToString(); T1.ID = acLineSegment_mrid + ".T1"; T1.MRID = acLineSegment_mrid + ".T1"; T1.Name = dataEdge.Source.Element_id; T1.Phases = PhaseCode.ABC; ACDCTerminal acdc_terminal = new ACDCTerminal() { SequenceNumber = 1 }; T1.SequenceNumber = acdc_terminal.SequenceNumber; T1.ConnectivityNode = T1_cn; Terminal T2 = new Terminal(); T2.ID = acLineSegment_mrid + ".T2"; T2.MRID = acLineSegment_mrid + ".T2"; T2.Name = dataEdge.Target.Element_id; T2.Phases = PhaseCode.ABC; ACDCTerminal acdc_terminal2 = new ACDCTerminal() { SequenceNumber = 2 }; T2.SequenceNumber = acdc_terminal2.SequenceNumber; T2.ConnectivityNode = T2_cn; string perLengthImpedance_mrid = Guid.NewGuid().ToString(); PerLengthImpedance pli = createPerLengthImpedanceObject(dataEdge.Configuration, perLengthImpedance_mrid); AssetInfo wi = createWireInfoObject(dataEdge.Configuration, perLengthImpedance_mrid); PSRType acPSRType = new PSRType() { MRID = "Section", Name = "Section" }; if (!globalComponentDictionary[acPSRType.GetType()].ContainsKey(acPSRType.Name)) { addComponentToGlobalDictionary(acPSRType, acPSRType.GetType()); } ACLineSegment acLineSegment = new ACLineSegment() { ID = acLineSegment_mrid, MRID = acLineSegment_mrid, Name = T1.Name.Split(' ').Last() + "-" + T2.Name.Split(' ').Last(), PSRType = acPSRType, EquipmentContainer = circuit, Length = (float)feetsToMeters(dataEdge.Length), PerLengthImpedance = pli, AssetDatasheet = wi }; addComponentToGlobalDictionary(acLineSegment, acLineSegment.GetType()); TerminalPair terminalPair = new TerminalPair() { terminalA = T1, terminalB = T2 }; terminalPairsContainer.Add(terminalPair); addComponentToGlobalDictionary(T1, T1.GetType()); addComponentToGlobalDictionary(T2, T2.GetType()); } } UsagePoint usagePoint = new UsagePoint(); foreach (DataVertex dv in globalVertices.Values) { if (dv.typeOfVertex == DataVertex.TypeOfVertex.SPOT_LOAD_VERTEX) { SpotLoad sl = (SpotLoad)dv; usagePoint = CreateSpotLoad(sl); addComponentToGlobalDictionary(usagePoint, usagePoint.GetType()); } } return(globalComponentDictionary); }