Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string str1 = "0012000000SW9000";//0012000000SW9000RESULT3B9F94801FC78031E073FE21135786811586984018BE
            string str2 = "";

            PrgToTxt.GetPrgLine(str1, ref str2);
            MessageBox.Show(str2);
        }
Beispiel #2
0
        private static void GetPrg(string sScriptName, string sOutName)
        {
            StreamReader streamReader = new StreamReader(sScriptName);
            StreamWriter streamWriter = new StreamWriter(sOutName);
            string       text         = "";
            string       sLine;

            while ((sLine = streamReader.ReadLine()) != null)
            {
                PrgToTxt.GetPrgLine(sLine, ref text);
                if (text.Length != 0)
                {
                    streamWriter.WriteLine(text);
                }
            }
            streamReader.Dispose();
            streamWriter.Dispose();
        }
Beispiel #3
0
        private void btnHcos_Click(object sender, EventArgs e)
        {
            if (txtPrgPath.Text == "")
            {
                return;
            }
            if (txtMCAPath.Text == "")
            {
                return;
            }

            StreamReader mcaReader    = new StreamReader(txtMCAPath.Text, Encoding.Default);
            StreamReader prgReader    = new StreamReader(txtPrgPath.Text, Encoding.Default);
            StreamWriter streamWriter = new StreamWriter(txtPrgPath.Text + ".txt");

            string sLine;

            //读取mca变量并定义
            streamWriter.WriteLine("clear string");
            streamWriter.WriteLine(";定义");
            sLine = mcaReader.ReadLine();
            string[] variables = sLine.Split(',');
            int      count     = 0;

            for (int i = 0; i < variables.Length; i++)
            {
                if (variables[i].IndexOf("打印数据", 0) == -1)
                {
                    count++;
                    streamWriter.WriteLine("edit Hstring $" + variables[i] + "$");
                }
            }
            streamWriter.WriteLine();
            streamWriter.WriteLine(";赋值");
            //读取mca数据并输出
            sLine = mcaReader.ReadLine();
            string[] datas = sLine.Split(',');
            for (int i = 0; i < count; i++)
            {
                streamWriter.WriteLine("edit $" + variables[i] + "$" + "=" + datas[i]);
            }
            streamWriter.WriteLine();
            //脚本转换
            string text   = "";
            int    iCount = 0;

            while ((sLine = prgReader.ReadLine()) != null)
            {
                PrgToTxt.GetPrgLine(sLine, ref text);
                if (text.Length != 0)
                {
                    iCount++;

                    streamWriter.WriteLine(text);
                }
            }

            mcaReader.Dispose();
            prgReader.Dispose();
            streamWriter.Dispose();
            MessageBox.Show("完成");
        }