Example #1
0
        /// <summary>
        /// 修改 CPU 使用的文件名称。
        /// </summary>
        /// <param name="oldName">旧的文件名称。</param>
        /// <param name="newName">新的文件名称。</param>
        /// <returns>成功与否?</returns>
        public bool RenameFile(string oldName, string newName)
        {
            if (string.IsNullOrEmpty(oldName) ||
                string.IsNullOrEmpty(newName))
            {
                return(false);
            }

            if (!IsFileExist(oldName))
            {
                return(false);
            }

            string oldKey = PCSFile.GetFileKey(oldName);
            string newKey = PCSFile.GetFileKey(newName);

            if (oldKey != newKey && IsFileExist(newName))
            {
                return(false);
            }

            CPUFileType fileType = this.DTypes[oldKey];
            string      oldFile  = this.DFiles[oldKey].File;

            PCSFile pcsFile = this.Project.GetPCSFile(newName);

            if (pcsFile == null && fileType != CPUFileType.TASKS)
            {
                pcsFile = new PCSFile(FileType.Variable, newName);
            }
            if (pcsFile == null)
            {
                return(false);
            }

            if (oldKey != newKey)
            {
                this.DFiles.Remove(oldKey);
                this.DTypes.Remove(oldKey);
                if (fileType == CPUFileType.TASKS)
                {
                    this.DTasks.Remove(oldKey);
                }
            }

            if (fileType == CPUFileType.TASKS)
            {
                this.DTasks[pcsFile.Key] = new ViGETResTask(ResourceType.kCrdTuiTaskNode, pcsFile.Key, pcsFile.Key);
            }
            this.DFiles[pcsFile.Key] = pcsFile;
            this.DTypes[pcsFile.Key] = fileType;
            //
            this.UnloadPCDInfo();

            ViGETVarFile.RenameFileInfo(new IniFile(this.MakeFile), fileType.ToString(),
                                        ViGETVarFile.GetSaveFileName(oldFile, this.Project.ProjectPath, false),
                                        ViGETVarFile.GetSaveFileName(pcsFile.File, this.Project.ProjectPath, false));

            return(true);
        }
Example #2
0
        /// <summary>
        /// 向 CPU 添加使用的文件。
        /// </summary>
        /// <param name="fileType">文件类型。</param>
        /// <param name="fileName">文件全路径名称。</param>
        /// <returns>成功与否?</returns>
        public bool AddFile(CPUFileType fileType, string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return(false);
            }

            if (IsFileExist(fileName))
            {
                return(false);
            }

            PCSFile pcsFile = this.Project.GetPCSFile(fileName);

            if (pcsFile == null && fileType != CPUFileType.TASKS)
            {
                pcsFile = new PCSFile(FileType.Variable, fileName);
            }
            if (pcsFile == null)
            {
                return(false);
            }

            if (fileType == CPUFileType.TASKS)
            {
                this.DTasks[pcsFile.Key] = new ViGETResTask(ResourceType.kCrdTuiTaskNode, pcsFile.Key, pcsFile.Key);
            }
            this.DFiles[pcsFile.Key] = pcsFile;
            this.DTypes[pcsFile.Key] = fileType;
            //
            this.UnloadPCDInfo();

            ViGETVarFile.AddFileInfo(new IniFile(this.MakeFile), fileType.ToString(),
                                     ViGETVarFile.GetSaveFileName(fileName, this.Project.ProjectPath, false));

            return(true);
        }
Example #3
0
        /// <summary>
        /// 删除 CPU 使用的文件。
        /// </summary>
        /// <param name="fileName">文件名称。</param>
        /// <returns>成功与否?</returns>
        public bool DeleteFile(string fileName)
        {
            if (!IsFileExist(fileName))
            {
                return(false);
            }

            string fileKey = PCSFile.GetFileKey(fileName);

            fileName = this.DFiles[fileKey].File;
            CPUFileType fileType = this.DTypes[fileKey];

            //
            this.DFiles.Remove(fileKey);
            this.DTypes.Remove(fileKey);
            this.DTasks.Remove(fileKey);
            //
            this.UnloadPCDInfo();

            ViGETVarFile.DeleteFileInfo(new IniFile(this.MakeFile), fileType.ToString(),
                                        ViGETVarFile.GetSaveFileName(fileName, this.Project.ProjectPath, false));

            return(true);
        }
Example #4
0
        protected void LoadMakInfo(string makFile)
        {
            IniFile iniFile = new IniFile(makFile);

            this.Stage       = CPUDataStage.Base;
            this.ShownText   = iniFile.GetValue(makSection, "SHOWNTEXT", PCSFile.GetFileKey(this.MakeFile));
            this._station    = iniFile.GetValue(makSection, "STATION", "");
            this._hardware   = iniFile.GetValue(makSection, "HARDWARE", "");
            this._connection = iniFile.GetValue(makSection, "CONNECTION", "");

            this.PCDFile = string.Format(@"{0}{1}\{1}.PCD", this.Project.ProjectGenPath, this.CrdPath);

            this.DFiles.Clear();
            this.DTypes.Clear();
            this.DTasks.Clear();
            this.DCVariables.Clear();
            if (this._DSVariables != null)
            {
                this._DSVariables.Clear();
            }

            CPUFileType fileType = CPUFileType.TASKS;
            PCSFile     pcsFile; ViGETResTask task;

            iniFile.LoopSections(
                (section) =>
            {
                if (section.Equals("TASKS", StringComparison.OrdinalIgnoreCase))
                {
                    fileType = CPUFileType.TASKS;
                }
                else if (section.Equals("GLOBAL", StringComparison.OrdinalIgnoreCase))
                {
                    fileType = CPUFileType.GLOBAL;
                }
                else if (section.Equals("DIRECT_GLOBAL", StringComparison.OrdinalIgnoreCase))
                {
                    fileType = CPUFileType.DIRECT_GLOBAL;
                }
                else if (section.Equals("PIV_FILES", StringComparison.OrdinalIgnoreCase))
                {
                    fileType = CPUFileType.PIV_FILES;
                }
                else
                {
                    return(false);
                }
                return(true);
            },
                (key, value) =>
            {
                if (key.IsPrefixIndex("FILE") && !string.IsNullOrEmpty(value))
                {
                    if (fileType != CPUFileType.TASKS)
                    {
                        pcsFile = new PCSFile(FileType.Variable,
                                              ViGETVarFile.GetFullFileName(value, this.Project.ProjectPath, ".POE"));
                    }
                    else
                    {
                        pcsFile = this.Project.GetPCSFile(value);
                    }

                    if (pcsFile != null)
                    {
                        key = PCSFile.GetFileKey(value);
                        if (fileType == CPUFileType.TASKS)
                        {
                            task             = new ViGETResTask(ResourceType.kCrdTuiTaskNode, key, key);
                            task.File        = pcsFile.File;
                            this.DTasks[key] = task;
                        }
                        //
                        this.DFiles[key] = pcsFile;
                        this.DTypes[key] = fileType;
                    }
                }
                return(true);
            });
        }