private Simulation() { AppProject app = AppProject.GetInstance(); IShortBranchTreeGenerator graph = new DigraphBuilder(); graph.buildRoutes(); if (app.VccToGnd == null) { this.VccToGndView = graph.getVccToGndBranch(); } else { this.VccToGndView = app.VccToGnd; } if (app.GndToCF == null) { this.CFToGndView = graph.getCFToGndBranch(); } else { this.CFToGndView = app.GndToCF; } if (app.VccToCF == null) { this.CFToVccView = graph.getVccToCFBranch(); } else { this.CFToVccView = app.VccToCF; } load(); }
/// <summary> /// 整理出所有的回路 /// </summary> private void load() { //Vcc至Gnd的通路 ISet <ShortBranchNode> allNodes = DigraphBuilder.expandBranch(VccToGndView.Nodes); foreach (ShortBranchNode node in allNodes) { node.Uis.ForEach(p => allCpts.Add(p.Info)); if (node.Nodes.Count == 0 && node.EndName != "GND") { foreach (var child in VccToGndView.LabelToBranch[node.EndName].Nodes) { node.Nodes.Add(child); } } } List <List <ShortBranchNode> > rts1 = DigraphBuilder.getAllRoutes(VccToGndView.Nodes); vccToGndRoutes.AddRange(convertToNodes(rts1)); //CF至Gnd通路 allNodes = DigraphBuilder.expandBranch(CFToGndView.Nodes); foreach (ShortBranchNode node in allNodes) { node.Uis.ForEach(p => allCpts.Add(p.Info)); if (node.Nodes.Count == 0) { if (CFToGndView.LabelToBranch.ContainsKey(node.EndName)) { foreach (var child in CFToGndView.LabelToBranch[node.EndName].Nodes) { node.Nodes.Add(child); } } } } List <List <ShortBranchNode> > rts2 = DigraphBuilder.getAllRoutes(CFToGndView.Nodes); cfToGndRoutes.AddRange(convertToNodes(rts2)); //Vcc至CF的通路 allNodes = DigraphBuilder.expandBranch(CFToVccView.Nodes); foreach (ShortBranchNode node in allNodes) { node.Uis.ForEach(p => allCpts.Add(p.Info)); if (node.Nodes.Count == 0) { if (CFToVccView.LabelToBranch.ContainsKey(node.EndName)) { foreach (var child in CFToVccView.LabelToBranch[node.EndName].Nodes) { node.Nodes.Add(child); } } } } List <List <ShortBranchNode> > rts3 = DigraphBuilder.getAllRoutes(CFToVccView.Nodes); cfToVccRoutes.AddRange(convertToNodes(rts3)); }