Esempio n. 1
0
        public static void ParallelToTxt(ref Step[,] canvasMatrix, int threadCol, int indentLevel, int pHeight, int pWidth, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString = new string(' ', indentLevel * 4);

            XmlNode     col  = canvasMatrix[0, 0].StepXmlNode.SelectSingleNode("List[@Key='Blocks']/StepBlock");
            XmlNodeList cols = col.SelectNodes("Array[@Key='OutputConnectors']//*[@Key='Offset']/@Value");

            var logs = new string[cols.Count];

            for (int i = 0; i < cols.Count; i++)
            {
                Step[,] threadSteps = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, 1, 0, canvasMatrix.GetLength(0) - 1, canvasMatrix.GetLength(1) - 1);
                string functions;
                int    column = int.Parse(cols[i].Value);
                PartialCanvasToTxt.Analyze(ref threadSteps, column, 0, 0, indentLevel + 1, out logs[i], out functions);
                ThreadFunctions += "\r\n" + functions;
            }

            for (int i = 0; i < logs.Length; i++)
            {
                ThreadLog += indentString + "Thread " + i.ToString();
                ThreadLog += "\r\n" + indentString + "{" + "\r\n";
                ThreadLog += indentString + "    " + logs[i].Trim();
                ThreadLog += "\r\n" + indentString + "}\r\n";
            }
        }
Esempio n. 2
0
        public static void LoopToTxt(ref Step[,] canvasMatrix, int threadCol, int indentLevel, int loopHeight, int loopWidth, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString = new string(' ', indentLevel * 4);

            XmlNode iterations = canvasMatrix[0, 0].StepXmlNode.SelectSingleNode(".//*[@Key='Iterations']");
            string  iterationsCount, dummy;

            ConditionXmlToTxt.ParseCondition(iterations, out iterationsCount, out dummy, out dummy, out dummy);

            Step[,] threadSteps = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, 1, 0, canvasMatrix.GetLength(0) - 1, canvasMatrix.GetLength(1) - 1);
            string log, functions;

            PartialCanvasToTxt.Analyze(ref threadSteps, threadCol, 0, 0, indentLevel + 1, out log, out functions);

            if (canvasMatrix[0, 0].ToolName == "LoopTool")
            {
                ThreadLog = "Loop " + iterationsCount + " times";
            }
            else if (canvasMatrix[0, 0].ToolName == "ParaLoopTool")
            {
                ThreadLog = "ParaLoop " + iterationsCount + " branches";
            }
            else
            {
                ThreadLog = "LoopToTxt - unrecognized tool name: " + canvasMatrix[0, 0].ToolName;
                return;
            }

            ThreadLog      += "\r\n" + indentString + "{" + "\r\n";
            ThreadLog      += indentString + "    " + log.Trim();
            ThreadLog      += "\r\n" + indentString + "}";
            ThreadFunctions = functions;
        }
Esempio n. 3
0
        public static void LockToTxt(ref Step[,] canvasMatrix, int threadCol, int indentLevel, int lockHeight, int lockWidth, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString = new string(' ', indentLevel * 4);

            XmlNode expression = canvasMatrix[0, 0].StepXmlNode.SelectSingleNode(".//*[@Key='LockExpression']");
            string  lockString, dummy;

            ConditionXmlToTxt.ParseCondition(expression, out lockString, out dummy, out dummy, out dummy);

            XmlNode timeoutxml = canvasMatrix[0, 0].StepXmlNode.SelectSingleNode(".//*[@Key='TimeoutExpression']");
            string  timeout    = "";

            if (timeoutxml != null && timeoutxml.Name != "Null")
            {
                timeout = TextfieldToTxt.Parse(timeoutxml);
            }

            Step[,] threadSteps = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, 1, 0, canvasMatrix.GetLength(0) - 1, canvasMatrix.GetLength(1) - 1);
            string log, functions;

            PartialCanvasToTxt.Analyze(ref threadSteps, threadCol, 0, 0, indentLevel + 1, out log, out functions);


            ThreadLog = "lock (" + lockString + ")";
            if (timeout.Length > 0)
            {
                ThreadLog += " // Timeout: " + timeout + " seconds";
            }
            ThreadLog      += "\r\n" + indentString + "{" + "\r\n";
            ThreadLog      += indentString + "    " + log.Trim();
            ThreadLog      += "\r\n" + indentString + "}";
            ThreadFunctions = functions;
        }
Esempio n. 4
0
        public static void WhileToTxt(ref Step[,] canvasMatrix, int threadCol, int indentLevel, int loopHeight, int loopWidth, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString = new string(' ', indentLevel * 4);

            XmlNode conditions = canvasMatrix[0, 0].StepXmlNode.SelectSingleNode(".//BinaryExpression[@Key='Condition']/*");
            string  conditionString, dummy;

            ConditionXmlToTxt.ParseCondition(conditions, out conditionString, out dummy, out dummy, out dummy);

            Step[,] threadSteps = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, 1, 0, canvasMatrix.GetLength(0) - 1, canvasMatrix.GetLength(1) - 1);
            string log, functions;

            PartialCanvasToTxt.Analyze(ref threadSteps, threadCol, 0, 0, indentLevel + 1, out log, out functions);

            bool isDoWhile = bool.Parse(canvasMatrix[0, 0].StepXmlNode.SelectSingleNode(".//Boolean[@Key='IsDoWhile']/@Value").Value);

            if (isDoWhile)
            {
                ThreadLog = "do";
            }
            else
            {
                ThreadLog = "while (" + conditionString + ")";
            }

            ThreadLog += "\r\n" + indentString + "{" + "\r\n";
            ThreadLog += indentString + "    " + log.Trim();
            ThreadLog += "\r\n" + indentString + "}";

            if (isDoWhile)
            {
                ThreadLog += " while (" + conditionString + ")";
            }

            ThreadFunctions = functions;
        }
Esempio n. 5
0
        public static void CaseToTxt(ref Step[,] canvasMatrix, int threadCol, int indentLevel, int caseHeight, int caseWidth, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString = new string(' ', indentLevel * 4);

            XmlNodeList conditions = GetConditions(canvasMatrix[0, 0]);
            string      left, right, operatorTxt;
            var         conditionTxt = new string[conditions.Count];
            int         curcon       = 0;

            foreach (XmlNode condition in conditions)
            {
                ConditionXmlToTxt.ParseCondition(condition, out conditionTxt[curcon], out left, out operatorTxt, out right);
                curcon++;
            }

            XmlNode     col  = canvasMatrix[0, 0].StepXmlNode.SelectSingleNode("List[@Key='Blocks']/StepBlock");
            XmlNodeList cols = col.SelectNodes("Array[@Key='OutputConnectors']//*[@Key='Offset']/@Value");

            XmlNode hasDefaultXml = canvasMatrix[0, 0].StepXmlNode.SelectSingleNode(".//*[@Key=\"HasDefaultBranch\"]");
            int     branches      = conditions.Count;

            if (hasDefaultXml != null)
            {
                if (hasDefaultXml.Attributes["Value"].Value == "True")
                {
                    branches++;
                }
            }
            else
            {
                //before the case tool could had 1 column
                branches++;
            }
            var logs = new string[conditions.Count + 1];

            for (curcon = 0; curcon < branches; curcon++)
            {
                Step[,] threadSteps = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, 1, 0, canvasMatrix.GetLength(0) - 1, canvasMatrix.GetLength(1) - 1);
                string functions;
                int    column = int.Parse(cols[curcon].Value);
                PartialCanvasToTxt.Analyze(ref threadSteps, column, 0, 0, indentLevel + 1, out logs[curcon], out functions);
                ThreadFunctions += "\r\n" + functions;
            }
            for (curcon = 0; curcon < branches; curcon++)
            {
                if (curcon == 0)
                {
                    ThreadLog += "if " + conditionTxt[curcon];
                }
                else if (curcon < logs.Length - 1)
                {
                    ThreadLog += "\r\n" + indentString + "else if " + conditionTxt[curcon];
                }
                else
                {
                    ThreadLog += "\r\n" + indentString + "else";
                }

                ThreadLog += "\r\n" + indentString + "{" + "\r\n";
                ThreadLog += indentString + "    " + logs[curcon].Trim();
                ThreadLog += "\r\n" + indentString + "}";
            }
        }