public void PlannerRespectsTaskOrder() { var planner = new MyDefaultExecutionPlanner(); var taskOrderNode = new TaskOrderNode(); MyNodeInfo.CollectNodeInfo(taskOrderNode.GetType()); MyExecutionBlock execBlock = planner.CreateNodeExecutionPlan(taskOrderNode, initPhase: false); var lastOrder = -1; foreach (IMyExecutable task in execBlock.Children) { var taskInfo = task.GetType().GetCustomAttribute <MyTaskInfoAttribute>(true); if (taskInfo == null) { continue; } Assert.True(lastOrder <= taskInfo.Order, "Task order must be greater or equal to the previous task order"); lastOrder = taskInfo.Order; } }
public void PlannerKeepsOrderOfTasksWithoutOrderAttribute() { var planner = new MyDefaultExecutionPlanner(); var unorderedTasksNode = new UnorderedTasksNode(); MyNodeInfo.CollectNodeInfo(unorderedTasksNode.GetType()); MyExecutionBlock execBlock = planner.CreateNodeExecutionPlan(unorderedTasksNode, initPhase: false); // This is maybe a bit fragile. Remove the test if it breaks due to unrelated and intended changes. Assert.Equal("CherryTask", execBlock.Children[1].Name); Assert.Equal("BananaTask", execBlock.Children[2].Name); Assert.Equal("AppleTask", execBlock.Children[3].Name); }
public override void Execute() { foreach (MyNode child in Owner.SortedChildren) { if (child is MyAbstractLayer) { foreach (PropertyInfo memBlockInfo in MyNodeInfo.Get(child.GetType()).OwnedMemoryBlocks) { Object memBlock = memBlockInfo.GetValue(child); if (memBlock is MyTemporalMemoryBlock<float>) { (memBlock as MyTemporalMemoryBlock<float>).RunMode(); } } } } }
protected virtual void InitBranches() { MyNodeInfo nodeInfo = Node.GetInfo(); foreach (PropertyInfo signalInfo in nodeInfo.RegisteredSignals) { MySignal signal = (MySignal)signalInfo.GetValue(Node); MySignalItem signalItem = new MySignalItem(signal); m_signals.Add(signalItem); AddItem(signalItem); } InitIoBranches(Node.InputBranches, m_iconItem.Input, m_inputBranches, nodeInfo.InputBlocks, isInput: true); InitIoBranches(Node.OutputBranches, m_iconItem.Output, m_outputBranches, nodeInfo.OutputBlocks, isInput: false); }
private void ConnectWorld() { if (Network != null && World != null) { if (Network.InputBranches != World.OutputBranches) { Network.InputBranches = World.OutputBranches; Network.InitInputNodes(); } for (int i = 0; i < World.OutputBranches; i++) { Network.GroupInputNodes[i].Name = ShortenMemoryBlockName(World.GetOutput(i).Name); } if (Network.OutputBranches != World.InputBranches) { Network.OutputBranches = World.InputBranches; Network.InitOutputNodes(); } for (int i = 0; i < World.InputBranches; i++) { Network.GroupOutputNodes[i].Name = ShortenMemoryBlockName(MyNodeInfo.Get(World.GetType()).InputBlocks[i].Name); } for (int i = 0; i < World.OutputBranches; i++) { MyConnection worldToNetwork = new MyConnection(World, Network, i, i); worldToNetwork.Connect(); } for (int i = 0; i < World.InputBranches; i++) { MyConnection networkToWorld = new MyConnection(Network, World, i, i); networkToWorld.Connect(); } } }
protected override void InitBranches() { MyNodeInfo nodeInfo = Node.GetInfo(); foreach (PropertyInfo signalInfo in nodeInfo.RegisteredSignals) { MySignal signal = (MySignal)signalInfo.GetValue(Node); MySignalItem signalItem = new MySignalItem(signal); m_signals.Add(signalItem); AddItem(signalItem); } for (int i = 0; i < Node.InputBranches; i++) { AddInputBranch(); } for (int i = 0; i < Node.OutputBranches; i++) { AddOutputBranch(); } }
protected virtual void InitBranches() { MyNodeInfo nodeInfo = Node.GetInfo(); foreach (PropertyInfo signalInfo in nodeInfo.RegisteredSignals) { MySignal signal = (MySignal)signalInfo.GetValue(Node); MySignalItem signalItem = new MySignalItem(signal); m_signals.Add(signalItem); AddItem(signalItem); } if (Node.InputBranches == 1) { m_iconItem.Input.Enabled = true; m_inputBranches.Add(m_iconItem); } else { for (int i = 0; i < Node.InputBranches; i++) { string name = (i + 1) + ""; if (Node is MyWorkingNode) { name = Node.GetInfo().InputBlocks[i].Name; } NodeLabelItem branch = new NodeLabelItem(MyProject.ShortenMemoryBlockName(name), true, false); branch.Tag = i; m_inputBranches.Add(branch); AddItem(branch); } } if (Node.OutputBranches == 1) { m_iconItem.Output.Enabled = true; m_outputBranches.Add(m_iconItem); } else { for (int i = 0; i < Node.OutputBranches; i++) { string name = (i + 1) + ""; if (Node is MyWorkingNode) { name = Node.GetInfo().OutputBlocks[i].Name; } NodeLabelItem branch = new NodeLabelItem(MyProject.ShortenMemoryBlockName(name), false, true); branch.Tag = i; m_outputBranches.Add(branch); AddItem(branch); } } }
private void UpdateWebBrowser() { if (Target != null) { string author; string status; string summary; string description; string include; m_mainForm.Documentation.HasAuthor(Target.GetType(), out author); CheckText(ref author); m_mainForm.Documentation.HasStatus(Target.GetType(), out status); CheckText(ref status); m_mainForm.Documentation.HasSummary(Target.GetType(), out summary); CheckText(ref summary); m_mainForm.Documentation.HasDescription(Target.GetType(), out description); CheckText(ref description); if (m_mainForm.Documentation.HasDocElement(Target.GetType(), "externdoc", out include)) { webBrowser.Navigate(include); } else { string html = "<html><head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=11\"/>"; html += "<style type=\"text/css\">" + m_style + "</style></head><body>"; html += "<h1>" + Target.GetType().Name + "</h1>"; html += "<em>Author: " + author + "<br/> Status: " + status + "</em>"; html += "<p>" + summary + "</p>"; html += "<h2>Node description</h2>"; html += "<p>" + description + "</p>"; MyNodeInfo nodeInfo = Target.GetInfo(); if (Target is MyWorkingNode) { foreach (string taskName in nodeInfo.KnownTasks.Keys) { MyTask task = (Target as MyWorkingNode).GetTaskByPropertyName(taskName); Type taskType = task.GetType(); m_mainForm.Documentation.HasSummary(taskType, out summary); CheckText(ref summary); if (taskType.Name != task.Name) { html += "<h3>" + taskType.Name + " \u2014 " + task.Name + "</h3>"; } else { html += "<h3>" + taskType.Name + "</h3>"; } html += "<p>" + summary + "</p>"; } html += "</body></html>"; webBrowser.DocumentText = html; } } } }