Advertisement
agmike

LseElectricScheme DFS logging

Aug 26th, 2015
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.21 KB | None | 0 0
  1.         LseElectricNode curr = source.Plus.DfsInit(plusMark);
  2.         // Interface.Log("+dfs from " + scheme.GetName(curr));
  3.  
  4.         while (curr) {
  5.             // Interface.Log("+dfs at " + scheme.GetName(curr));
  6.             if (curr == source.Minus) {
  7.                 float current = sourceVoltage / baseResistance;
  8.                 source.Current = source.Current - current;
  9.                 BackTraceCurrent(curr, current);
  10.                 goto sourcePassDone;
  11.             }
  12.  
  13.             LseElectricLink link;
  14.             while (link = curr.DfsNextLink()) {
  15.                 // Interface.Log(LStr.Format("+dfs via '$0' to '$1'", scheme.GetName(curr.DfsNext), scheme.GetName(link)));
  16.                 if (link.Resistance < LoadResistanceThreshold) {
  17.                     curr = curr.DfsPush();
  18.                     curr.Mark = plusMark;
  19.                     break;
  20.                 }
  21.             }
  22.  
  23.             if (!link) {
  24.                 curr = curr.DfsPrevious;
  25.                 // Interface.Log("+dfs pop ");
  26.             }
  27.         }
  28.  
  29.         loads[0, ] = null;
  30.         float totalLoadResistance = 0.0;
  31.  
  32.         curr = source.Minus.DfsInit(minusMark);
  33.         // Interface.Log("-dfs from " + scheme.GetName(curr));
  34.  
  35.         while (curr) {
  36.             // Interface.Log("-dfs at " + scheme.GetName(curr));
  37.             LseElectricLink link;
  38.             while (link = curr.DfsNextLink()) {
  39.                 if (link.Resistance < LoadResistanceThreshold) {
  40.                     // Interface.Log(LStr.Format("-dfs cond '$0' to '$1'", scheme.GetName(curr.DfsNext), scheme.GetName(link)));
  41.                     curr = curr.DfsPush();
  42.                     curr.Mark = minusMark;
  43.                     break;
  44.                 }
  45.                 if (link.Resistance < ConductiveResistanceThreshold) {
  46.                     // Interface.Log(LStr.Format("-dfs load '$0' to '$1'", scheme.GetName(curr.DfsNext), scheme.GetName(link)));
  47.                     loads[loads.size()] = link;
  48.                     totalLoadResistance = totalLoadResistance + 1.0 / link.Resistance;
  49.                 }
  50.             }
  51.  
  52.             if (!link) {
  53.                 curr = curr.DfsPrevious;
  54.                 // Interface.Log("-dfs pop ");
  55.             }
  56.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement