コード例 #1
0
        public static int GetTaskIndex(CyPhy.TaskBase task, Dictionary <CyPhy.TaskBase, int> tasks)
        {
            int index;

            if (tasks.TryGetValue(task, out index))
            {
                if (index == -1)
                {
                    throw new ApplicationException("Workflow loop involving " + task.Name);
                }
                return(index);
            }
            index = 0;
            tasks.Add(task, -1);
            foreach (CyPhy.Flow connection in task.SrcConnections.FlowCollection)
            {
                index = Math.Max(index, GetTaskIndex(connection.SrcEnds.TaskBase, tasks) + 1);
            }
            tasks[task] = index;
            return(index);
        }
コード例 #2
0
        public void AddAllTasks(
            CyPhy.TestBenchType testBenchType,
            IEnumerable <global::META.ComComponent> interpreters,
            string relativePathToProjectDir)
        {
            Contract.Requires(testBenchType != null);
            Contract.Requires(interpreters != null);

            var workflowRef = testBenchType.Children
                              .WorkflowRefCollection
                              .ToList();

            if (workflowRef.Count == 1 && workflowRef[0].AllReferred != null)
            {
                var workflow = workflowRef[0].Referred.Workflow;
                var allTasks = workflow.Children.TaskBaseCollection;

                var startTask = allTasks
                                .Where(x => x.AllSrcConnections.Count() == 0)
                                .FirstOrDefault();
                CyPhy.TaskBase nextTask = startTask;

                int regularTaskIndex = 0;
                int regularTaskCount = interpreters.Count();
                var processed        = new List <CyPhy.TaskBase>();

                while (nextTask != null &&
                       processed.Contains(nextTask) == false)
                {
                    processed.Add(nextTask);

                    if (nextTask.Impl.MetaBase.Name == (typeof(CyPhy.Task).Name))
                    {
                        if (regularTaskIndex < regularTaskCount)
                        {
                            var currTask = interpreters.ElementAt(regularTaskIndex++);
                            if (currTask.result != null &&
                                currTask.result.RunCommand != null)
                            {
                                var step = new Step();
                                step.Invocation = currTask.result.RunCommand;
                                this.Steps.Add(step);
                            }
                        }
                    }
                    else if (nextTask.Impl.MetaBase.Name == (typeof(CyPhy.ExecutionTask).Name))
                    {
                        CyPhy.ExecutionTask executionTask = ISIS.GME.Dsml.CyPhyML.Classes.ExecutionTask.Cast(nextTask.Impl);

                        var step = new Step();

                        step.Description = executionTask.Attributes.Description;
                        // %project_dir% is relative path to MgaExtensions.MgaExtensions.GetProjectDirectoryPath(testBenchType.Impl.Project)
                        step.Invocation  = Regex.Replace(executionTask.Attributes.Invocation, "%project_dir%", relativePathToProjectDir, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
                        step.PreProcess  = executionTask.Attributes.PreProcess;
                        step.PostProcess = executionTask.Attributes.PostProcess;

                        var splitStrings = new string[] { Environment.NewLine, "\n" };
                        foreach (var parameterValue in executionTask.Attributes.Parameters.Split(splitStrings, StringSplitOptions.RemoveEmptyEntries))
                        {
                            Parameter parameter = new Parameter();
                            parameter.Name = parameterValue;
                            step.Parameters.Add(parameter);
                        }

                        this.Steps.Add(step);
                    }

                    var flow = nextTask.DstConnections.FlowCollection.FirstOrDefault();
                    if (flow == null)
                    {
                        nextTask = null;
                    }
                    else
                    {
                        nextTask = flow.DstEnds.TaskBase;
                    }
                }
            }
        }
コード例 #3
0
        public void AddAllTasks(
            CyPhy.TestBenchType testBenchType,
            IEnumerable <global::META.ComComponent> interpreters,
            string relativePathToProjectDir)
        {
            Contract.Requires(testBenchType != null);
            Contract.Requires(interpreters != null);

            var workflowRef = testBenchType.Children
                              .WorkflowRefCollection
                              .ToList();

            if (workflowRef.Count == 1 && workflowRef[0].AllReferred != null)
            {
                var workflow = workflowRef[0].Referred.Workflow;
                var allTasks = workflow.Children.TaskBaseCollection;

                var startTask = allTasks
                                .Where(x => x.AllSrcConnections.Count() == 0)
                                .FirstOrDefault();
                CyPhy.TaskBase nextTask = startTask;

                int regularTaskIndex = 0;
                int regularTaskCount = interpreters.Count();
                var processed        = new List <CyPhy.TaskBase>();

                while (nextTask != null &&
                       processed.Contains(nextTask) == false)
                {
                    processed.Add(nextTask);

                    if (nextTask.Impl.MetaBase.Name == (typeof(CyPhy.Task).Name))
                    {
                        if (regularTaskIndex < regularTaskCount)
                        {
                            var currTask = interpreters.ElementAt(regularTaskIndex++);
                            if (currTask.result != null &&
                                currTask.result.RunCommand != null)
                            {
                                var step = new Step();
                                step.Invocation = currTask.result.RunCommand;
                                this.Steps.Add(step);
                            }
                        }
                    }
                    else if (nextTask.Impl.MetaBase.Name == (typeof(CyPhy.ExecutionTask).Name))
                    {
                        CyPhy.ExecutionTask executionTask = ISIS.GME.Dsml.CyPhyML.Classes.ExecutionTask.Cast(nextTask.Impl);

                        Step step = CreateManifestStepForExecutionTask(relativePathToProjectDir, executionTask);

                        this.Steps.Add(step);
                    }

                    var flow = nextTask.DstConnections.FlowCollection.FirstOrDefault();
                    if (flow == null)
                    {
                        nextTask = null;
                    }
                    else
                    {
                        nextTask = flow.DstEnds.TaskBase;
                    }
                }
            }
            else if (testBenchType.Impl.MetaBase.Name == typeof(CyPhy.CADTestBench).Name)
            {
                // CADTestBench aka Structural FEA Test Bench is assumed to run with only CyPhy2CAD
                var step = new Step();
                step.Invocation = interpreters.Single().result.RunCommand;
                this.Steps.Add(step);
            }
        }