/// <summary> /// Used to convert the function into dot file. Will declare a node and recursively declare it's linked inputs /// </summary> /// <param name="node">The node to declare</param> /// <param name="id">Current node identifier that will be incremented</param> /// <param name="declared">Dictionarry of already declared node</param> /// <returns>The dot file lines to add to the file</returns> private string DeclareNode(Execution.Instruction node, ref int id, Dictionary <Execution.Instruction, string> declared) { //name of the node to declare string name = "node_" + id.ToString(); id++; declared[node] = name; //process its inputs if (node.Inputs.Count > 0) { //contains inputs declaration string decl = ""; //containes inputs links string links = ""; //node input unique identifier int inputId = 0; //concatenation of declared name to make splitted node string inputs = ""; //resolve inputs declaration foreach (KeyValuePair <string, Execution.Input> curr in node.Inputs) { //input name that depends on node name string inpName = name + "_var_" + inputId.ToString(); //label of the input in order to be able to link it string label = "<" + inpName + "> " + curr.Key + (curr.Value.IsLinked ? " = " + curr.Value.ToString() : ""); ++inputId; //concatenate label to inputs for splitted box effect inputs += label + (inputId < node.Inputs.Count ? "|" : ""); if (!curr.Value.IsLinked) { continue; } //in case there is a linked node to the input, declare it if (!declared.ContainsKey(curr.Value.Link.Instruction)) { decl += DeclareNode(curr.Value.Link.Instruction, ref id, declared); } //link this node to the labeled input links += declared[curr.Value.Link.Instruction] + " -> " + name + ":" + inpName + " [style=dotted;label=\"" + curr.Value.Link.Output + "\"];\r\n"; } //splitted box format with each inputs labeled and linked to their node return(decl + name + " [shape=record,label=\"{" + inputs + "}|<" + name + "_exec> " + node.GetType().ToString().Split('.').Last() + "\",color=" + (typeof(Execution.ExecutionRefreshInstruction).IsAssignableFrom(node.GetType()) ? "red" : "blue") + "];\r\n" + links); } //basic node, circle in red or blue return(name + " [label=\"" + node.GetType().ToString().Split('.').Last() + "\",color=" + (typeof(Execution.ExecutionRefreshInstruction).IsAssignableFrom(node.GetType()) ? "red" : "blue") + "];\r\n"); }
public Link(Instruction tolink, string outputname) { instruction = tolink; output = outputname; }
/// <summary> /// Allow user to add an instruction into the function /// </summary> /// <param name="toadd">Instruction to add</param> /// <returns>Instruction uid which will be used to retreive instruction</returns> public UInt32 addInstruction(Execution.Instruction toadd) { instructions[currentIndex] = toadd; return(currentIndex++); }