Beispiel #1
0
        /// <summary>
        /// Creates the execution plan.
        /// </summary>
        /// <param name="project">The whole project from which the standard execution plan will be built.</param>
        /// <param name="initNodes">Ordered list of new nodes from which the initialization plan will be built.</param>
        /// <returns>The created execution plan.</returns>
        public MyExecutionPlan CreateExecutionPlan(MyProject project, IEnumerable <MyWorkingNode> initNodes = null)
        {
            MyExecutionPlan executionPlan = new MyExecutionPlan();

            IMyOrderingAlgorithm ordering = new MyHierarchicalOrdering();

            ordering.EvaluateOrder(project.Network);

            var initBlocks = new List <IMyExecutable>();

            if (initNodes != null)
            {
                initBlocks.AddRange(initNodes.Select(node => CreateNodeExecutionPlan(node, true)));
            }

            executionPlan.InitStepPlan = new MyExecutionBlock(initBlocks.ToArray())
            {
                Name = "Initialization"
            };

            executionPlan.StandardStepPlan = new MyExecutionBlock(
                CreateNodeExecutionPlan(project.World, false),
                CreateNodeExecutionPlan(project.Network, false))
            {
                Name = "Simulation"
            };

            return(executionPlan);
        }
Beispiel #2
0
        public MyExecutionPlan CreateExecutionPlan(MyProject project)
        {
            MyExecutionPlan executionPlan = new MyExecutionPlan();

            IMyOrderingAlgorithm ordering = new MyHierarchicalOrdering();

            ordering.EvaluateOrder(project.Network);

            executionPlan.InitStepPlan = new MyExecutionBlock(
                CreateNodeExecutionPlan(project.World, true),
                CreateNodeExecutionPlan(project.Network, true));
            executionPlan.InitStepPlan.Name = "Initialization";

            executionPlan.StandardStepPlan = new MyExecutionBlock(
                CreateNodeExecutionPlan(project.World, false),
                CreateNodeExecutionPlan(project.Network, false));
            executionPlan.StandardStepPlan.Name = "Simulation";

            return(executionPlan);
        }
Beispiel #3
0
        public bool UpdateMemoryModel()
        {
            MyLog.INFO.WriteLine("Updating memory blocks...");

            IMyOrderingAlgorithm topoOps      = new MyHierarchicalOrdering();
            List <MyNode>        orderedNodes = topoOps.EvaluateOrder(Project.Network);

            if (!orderedNodes.Any())
            {
                return(true);
            }

            int  attempts         = 0;
            bool anyOutputChanged = false;

            try
            {
                while (attempts < MAX_BLOCKS_UPDATE_ATTEMPTS)
                {
                    attempts++;
                    anyOutputChanged = false;

                    anyOutputChanged |= UpdateAndCheckChange(Project.World);
                    orderedNodes.ForEach(node => anyOutputChanged |= UpdateAndCheckChange(node));

                    if (!anyOutputChanged)
                    {
                        MyLog.INFO.WriteLine("Successful update after " + attempts + " cycle(s).");
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Exception occured while updating memory model: " + e.Message);
                return(true);
            }

            return(anyOutputChanged);
        }
        public static List <MyNode> OrderNetworkNodes(MyNodeGroup network)
        {
            IMyOrderingAlgorithm topoOps = new MyHierarchicalOrdering();

            return(topoOps.EvaluateOrder(network));
        }