示例#1
0
        public byte[] CardSendCommand(byte[] cmd)
        {
            if (ShowLog != null)
            {
                ShowLog("------------------------------\r\n");
                ApduCommand msg = new ApduCommand(cmd);

                if (msg.CmdNote.Trim().StartsWith("建立文件"))
                {
                    CPUFileType cpy = (CPUFileType)(msg.Data[0]);
                    msg.CmdNote += "类型" + cpy.ToString() + "    ";
                }
                string log = $"发送原始命令:{BitConverter.ToString(cmd)} \r\n" + msg.ToString() + "\r\n";



                ShowLog(log);
            }

            byte[] result = this.carder.SendCommand(cmd);

            if (ShowLog != null)
            {
                ApduMsg apduMsg = ApduMsgHelper.GetApduMsg(result);

                string msg = "状态:{0}  信息:{1} 结果:{2} \r\n";

                msg = string.Format(msg, apduMsg.Status, apduMsg.Msg, BitConverter.ToString(apduMsg.ResponseData));

                string log = "接收: " + msg;
                ShowLog(log);
            }
            return(result);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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);
        }