Exemple #1
0
 public static void DeleteFile(ushort no)
 {
     for (ushort i = 1; i <= no; i++)
     {
         CPUCardWrapper.DeleteFile(i);
     }
 }
Exemple #2
0
 private void button8_Click(object sender, EventArgs e)
 {
     for (ushort i = 1; i < maxFileID; i++)
     {
         string data = GetRandomData(r.Next(10, 100), i.ToString());
         CPUCardWrapper.CreateFile(i, data, out string msg);
     }
 }
Exemple #3
0
        public static bool TestFileNew()
        {
            ushort fileId      = 10;
            string fileContent = "abcdefg";

            if (!CPUCardWrapper.CreateFile(fileId, fileContent, out string msg))
            {
                Console.WriteLine("创建文件失败" + msg);
            }
            return(true);
        }
Exemple #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (CPUCardWrapper.DeleteFile(GetCurrentFileID()))
     {
         WireLog("删除成功");
     }
     else
     {
         WireLog("删除失败");
     }
 }
Exemple #5
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (CPUCardWrapper.ReadFile(GetCurrentFileID(), out string msg))
     {
         txtoutput.Text = msg;
         WireLog("读取成功" + msg);
     }
     else
     {
         txtoutput.Text = "读取失败" + msg;
         WireLog("读取失败" + msg);
     }
 }
Exemple #6
0
        /// <summary>
        /// 测试
        /// </summary>
        public static void TestMain()
        {
            //DateTime dt = DateTime.Now;
            ushort FileCount = 100;

            //DeleteFile(FileCount);
            //TestMaxFile();
            //Console.WriteLine();
            //return;



            for (ushort i = 1; i <= 100; i++)
            {
                int fileLenth = 1024;
                CPUCardWrapper.DeleteFile(i);
                byte[] data = new byte[fileLenth];

                r.NextBytes(data);


                if (TestFileByte(i, data))
                {
                    Console.WriteLine(" succ");
                }
                else
                {
                    Console.WriteLine(" false");
                }
            }


            return;

            for (int i = 100; i < 1024 * 70; i += 2000)
            {
                TestFile(1, GetRandomString(i));
            }
            return;


            for (ushort i = 1; i < FileCount; i++)
            {
                //测试文件大小
                int FileLenght = 1024;

                TestFile(i, GetRandomString(FileLenght));
            }
        }
Exemple #7
0
        public static bool CreateFile(ushort fileID, string content, out string msg)
        {
            //写之前先清空分区
            CPUCardWrapper.DeleteFile(fileID);

            msg = "";

            byte[] data   = encod.GetBytes(content);
            bool   reslut = CreateFile(fileID, data, out msg);

            WriteLog("***********************\r\n");
            WriteLog($"写入文件{fileID}---- {reslut} ---- {msg} ---- {content}");
            WriteLog("***********************\r\n");
            return(reslut);
        }
Exemple #8
0
        private void button11_Click(object sender, EventArgs e)
        {
            string data = GetRandomData(30000);

            CPUCardWrapper.CreateFile(GetCurrentFileID(), data, out string msg);

            CPUCardWrapper.ReadFile(GetCurrentFileID(), out string readData);
            if (data == readData)
            {
                MessageBox.Show("成功");
            }
            else
            {
                Console.WriteLine();
            }
        }
Exemple #9
0
 private void button10_Click(object sender, EventArgs e)
 {
     txtoutput.Text = "";
     for (ushort i = 1; i < maxFileID; i++)
     {
         txtoutput.AppendText("--------------------------------------\r\n");
         if (CPUCardWrapper.ReadFile(i, out string msg))
         {
             txtoutput.AppendText(i + "读取成功" + msg + "\r\n");
         }
         else
         {
             txtoutput.AppendText(i + "读取失败" + msg + "\r\n");
         }
     }
 }
Exemple #10
0
        public static bool TestFileByte(ushort fileId, byte[] fileContent)
        {
            bool     isPass  = true;
            DateTime dtStart = DateTime.Now;

            if (!CPUCardWrapper.CreateFile(fileId, fileContent, out string msg))
            {
                Console.WriteLine("创建文件失败" + msg);
                isPass = false;
            }

            DateTime dtEnd = DateTime.Now;

            TimeSpan ts = dtEnd - dtStart;

            Console.WriteLine();
            dtStart = DateTime.Now;

            byte[] readData = new byte[0];

            if (!CPUCardWrapper.ReadFile(fileId, out readData, out string m3sg))
            {
                Console.WriteLine("读取文件失败" + m3sg);
                isPass = false;
            }
            dtEnd = DateTime.Now;

            ts = dtEnd - dtStart;
            Console.WriteLine();


            if (!compData(fileContent, readData))
            {
                int count = fileContent.Length - m3sg.Length;
                Console.WriteLine("写入文件与读取文件不一致,读取比写入少" + count);
                isPass = false;
            }
            string result = "测试文件{0} ,测试长度{1},测试结果{2}";

            Console.WriteLine(string.Format(result, fileId, fileContent.Length, isPass ? "通过" : "不通过"));
            return(isPass);
        }
Exemple #11
0
        public static void ReadALlCard()
        {
            //string fileName = $"cpudata-{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}-{DateTime.Now.Hour}-{DateTime.Now.Second}-{DateTime.Now.Second}-{DateTime.Now.Millisecond}.log";
            //StreamWriter sw = File.CreateText(fileName);


            for (ushort i = 1; i <= 100; i++)
            {
                //sw.WriteLine(i.ToString());
                if (CPUCardWrapper.ReadFile(i, out string msg))
                {
                    Console.WriteLine(i + "分区读取失败" + msg);
                    //    sw.WriteLine(i + "分区读取成功" + msg);
                }
                else
                {
                    Console.WriteLine(i + "分区读取失败" + msg);
                    //sw.WriteLine(i + "分区读取失败" + msg);
                }
            }
        }
Exemple #12
0
 private void FrmCardTest_Load(object sender, EventArgs e)
 {
     CPUCardWrapper.WriteLog("开始");
     CPUCardWrapper.cpuCard.ShowLog += WireLog;
 }
Exemple #13
0
 private void button1_Click(object sender, EventArgs e)
 {
     CPUCardWrapper.CreateFile(GetCurrentFileID(), txtInput.Text, out string msg);
     WireLog(msg);
 }
Exemple #14
0
 private void button9_Click(object sender, EventArgs e)
 {
     CPUCardWrapper.ClearCard();
 }