protected void CreateTasks(IPadtCRDNodeList nodes) { if (nodes == null || nodes.GetCount() <= 0) { return; } nodes.SetToHeadPos(); while (true) { IPadtCRDNode node = nodes.GetNext() as IPadtCRDNode; if (node == null) { break; } switch ((ResourceType)node.GetType()) { case ResourceType.kCrdTaskNode: case ResourceType.kCrdTaskContainerNode: CreateTasks(node.GetChildList() as IPadtCRDNodeList); break; case ResourceType.kCrdTuiTaskNode: ViGETResTask task = new ViGETResTask(); if (task.CreateTask(node)) { if (DTasks.ContainsKey(task.Key)) { DTasks[task.Key].DBlocks = task.DBlocks; DTasks[task.Key].DVariables = task.DVariables; } else { string shownPath = task.ShownPath; if (DTasks.ContainsKey(shownPath)) { ViGETResTask exist = DTasks[shownPath]; exist.CrdPath = task.CrdPath; exist.DBlocks = task.DBlocks; exist.DVariables = task.DVariables; } else { DTasks[task.Key] = task; } } } break; } } }
/// <summary> /// 根据 PADT 的 Node 信息,创建 Task。 /// </summary> /// <param name="node">PADT Task Node</param> /// <returns>成功与否?</returns> public bool CreateTask(IPadtCRDNode node) { if (!CreateResource(node)) { return(false); } IPadtCRDNodeList children = node.GetChildList() as IPadtCRDNodeList; if (children == null || children.GetCount() <= 0) { return(true); } children.SetToHeadPos(); while (true) { node = children.GetNext() as IPadtCRDNode; if (node == null) { break; } switch ((ResourceType)node.GetType()) { case ResourceType.kCrdProgramNode: case ResourceType.kCrdFbNode: case ResourceType.kCrdFunctionNode: ViGETResBlock block = new ViGETResBlock(); if (block.CreateBlock(node)) { DBlocks[block.Key] = block; } break; case ResourceType.kCrdVariableNode: ViGETResVariable variable = new ViGETResVariable(); if (variable.CreateVariable(node)) { DVariables[variable.Key] = variable; } break; } } return(true); }