/** * void makeIOTree * * This function generates a tree based on the dot-seperated names of the sinter_IVariables * So this scrictly covers the variables sinter knows about. The VariableTree covers the variables * the simulation knows about. */ public void makeIOTree() { int i = 0; int j = 0; int k = 0; string[] path = null; IOTreeNode node = new IOTreeNode(); int found = 0; int old_found = 0; int parent = 0; node.name = "root"; node.level = 0; node.parent = 0; node.IOListIndex = 0; node.children = new List <int>(); o_IOTree.Clear(); o_IOTree.Add(node); for (i = 1; i <= o_setupFile.Variables.Count; i++) { parent = 0; found = -1; path = Strings.Split(((sinter_Variable)o_setupFile.Variables[i]).name, "."); for (j = 0; j <= path.Length - 2; j++) { old_found = found; for (k = 0; k <= o_IOTree[parent].children.Count - 1; k++) { if (path[j] == o_IOTree[o_IOTree[parent].children[k]].name) { found = j; parent = o_IOTree[parent].children[k]; break; // TODO: might not be correct. Was : Exit For } } if (found == old_found) { break; // TODO: might not be correct. Was : Exit For } } for (j = found + 1; j <= path.Length - 2; j++) { parent = addNode(parent, path[j], 0); } addNode(parent, path[path.Length - 1], i); } }
private int addNode(int parent, string name, int ioindex) { int n = 0; IOTreeNode node = new IOTreeNode(); n = o_IOTree.Count; node.children = new List <int>(); node.parent = parent; node.name = name; node.IOListIndex = ioindex; node.level = o_IOTree[parent].level + 1; o_IOTree.Add(node); o_IOTree[parent].children.Add(n); //node = Nothing return(n); }