Exemplo n.º 1
0
        protected bool LoadPCDInfo()
        {
            UnloadPCDInfo();

            try
            {
                if (!File.Exists(PCDFile))
                {
                    return(false);
                }

                PadtCodeRepository repository = new PadtCodeRepository();
                if (repository.LoadRepositoryEx(PCDFile, 1) == 0)
                {
                    Trace.WriteLine(string.Format("Load repository from PCD file [{0}] failed!", PCDFile));
                    return(false);
                }
                IPadtCRDNode root = repository.GetBaseNode() as IPadtCRDNode;
                if (root == null)
                {
                    return(false);
                }

                ResourceType type = (ResourceType)root.GetType();
                if (type != ResourceType.kCrdExeNode)
                {
                    Trace.WriteLine(string.Format("Root node's type is {0}, it should be {1}!", type, ResourceType.kCrdExeNode));
                    return(false);
                }

                string path = root.GetInstancePath();
                if (string.Compare(CrdPath, path, true) != 0)
                {
                    Trace.WriteLine(string.Format("CPU name in PCD file is {0}, it should be {1}!", path, CrdPath));
                    return(false);
                }

                string shownText = ShownText;
                if (!CreateResource(root))
                {
                    return(false);
                }
                CrdPath   = path.ToUpper();
                ShownText = shownText;
                CreateTasks(root.GetChildList() as IPadtCRDNodeList);
                CreateDVariables();
            }
            catch (Exception ee)
            {
                Trace.WriteLine("### [" + ee.Source + "] Exception: " + ee.Message);
                Trace.WriteLine("### " + ee.StackTrace);
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据 PADT Node 信息,创建变量信息。
        /// </summary>
        /// <param name="node">PADT Variable Node</param>
        /// <returns>成功与否?</returns>
        public bool CreateVariable(IPadtCRDNode node)
        {
            if (!CreateResource(node))
            {
                return(false);
            }

            ShownText = node.GetInstanceText();
            VarType   = (VariableType)node.GetVarType();

            return(true);
        }
Exemplo n.º 3
0
        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;
                }
            }
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 从 CRDNode 的资源信息加载资源对象信息。
        /// </summary>
        /// <param name="node">CRDNode 资源。</param>
        /// <returns>成功与否?</returns>
        public bool CreateResource(IPadtCRDNode node)
        {
            if (node == null)
            {
                return(false);
            }
            int type = node.GetType();

            if (type <= (int)ResourceType.kCrdUndefNode ||
                type >= (int)ResourceType.kCrdResourceCount)
            {
                return(false);
            }

            Type      = (ResourceType)type;
            CrdPath   = node.GetInstancePath();
            ShownText = node.GetInstanceName();
            return(!string.IsNullOrEmpty(CrdPath));
        }
Exemplo n.º 6
0
 public ViGETResource(IPadtCRDNode node)
 {
     this.CreateResource(node);
 }
Exemplo n.º 7
0
 public ViGETResTask(IPadtCRDNode node)
 {
     this.CreateTask(node);
 }