Ejemplo n.º 1
0
        public string Apt2JbiFirst(string fileName)
        {
            Txt2List txt2list=new Txt2List ();
            List2Txt list2txt=new List2Txt ();

            List<string> tmplist = new List<string>();

            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);

            StreamReader sr = new StreamReader(fs);

            sr.BaseStream.Seek(0, SeekOrigin.Begin);

            string tmp = sr.ReadLine();

            while (tmp != null)
            {

                    if (tmp.StartsWith( "GOTO") || tmp.StartsWith( "CIRCLE"))
                    {
                        tmplist.Add(tmp);
                    }

             tmp = sr.ReadLine();

            }

               sr.Close();
            fs.Close();
               string tmpjbistr="d:middleTranslation1.txt";
            list2txt.ListToTxtFile(tmplist,tmpjbistr );

            return tmpjbistr;
        }
Ejemplo n.º 2
0
        private void btnAPT_Click(object sender, EventArgs e)
        {
            Txt2List txt2list = new Txt2List();
            List2Txt list2txt = new List2Txt();

            List <string> tmplist = new List <string>();


            OpenFileDialog openDlg = new OpenFileDialog();

            openDlg.Filter = "txt_APT文件|*.txt";

            if (openDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string fileName = openDlg.FileName;

            StreamReader sr = new StreamReader(fileName, Encoding.Default);

            this.rtxbapt.Text = sr.ReadToEnd();

            sr.Close();


            tmplist = txt2list.ReadTxtToList(fileName);
            list2txt.ListToTxtFile(tmplist, "D:middleTranslation0.txt");
        }
Ejemplo n.º 3
0
        public string  Apt2JbiFirst(string fileName)
        {
            Txt2List txt2list = new Txt2List();
            List2Txt list2txt = new List2Txt();

            List <string> tmplist = new List <string>();


            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);

            StreamReader sr = new StreamReader(fs);

            sr.BaseStream.Seek(0, SeekOrigin.Begin);

            string tmp = sr.ReadLine();

            while (tmp != null)
            {
                if (tmp.StartsWith("GOTO") || tmp.StartsWith("CIRCLE"))
                {
                    tmplist.Add(tmp);
                }

                tmp = sr.ReadLine();
            }


            sr.Close();
            fs.Close();
            string tmpjbistr = "d:middleTranslation1.txt";

            list2txt.ListToTxtFile(tmplist, tmpjbistr);

            return(tmpjbistr);
        }
Ejemplo n.º 4
0
        public string writingJBItoText(List <string> tmplist)
        {
            List2Txt list2txt = new List2Txt();



            //list2txt.ListToTxtFile(tmplist, "D;middleTranslation2.txt");


            FileStream fsbegin = new FileStream("d:middleTranslation2.txt", FileMode.Create, FileAccess.Write);

            StreamWriter swbegin = new StreamWriter(fsbegin);

            swbegin.Flush();

            swbegin.BaseStream.Seek(0, SeekOrigin.Begin);

            swbegin.WriteLine("/JOB");
            swbegin.WriteLine("//NAME ***");
            swbegin.WriteLine("//POS");
            swbegin.WriteLine("///NPOS " + ((int)(tmplist.Count / 2 + 2)).ToString() + ",0,0,0,0,0");
            swbegin.WriteLine("///TOOL 5");
            swbegin.WriteLine("///POSTYPE PULSE");
            swbegin.WriteLine("///PULSE");


            for (int i = 0; i < tmplist.Count; i++)
            {
                if (i == (int)tmplist.Count / 2)
                {
                    swbegin.WriteLine("//INST");
                    swbegin.WriteLine("///DATE " + DateTime.Now.ToString("yyyy/MM/dd  HH:mm"));
                    swbegin.WriteLine("///ATTR SC,RW");
                    swbegin.WriteLine("///GROUP1 RB2");
                    swbegin.WriteLine("NOP");
                }
                swbegin.WriteLine(tmplist[i]);
            }

            swbegin.WriteLine("END");

            swbegin.Flush();
            swbegin.Close();
            fsbegin.Close();


            string str = "d:middleTranslation2.txt";

            return(str);
        }
Ejemplo n.º 5
0
        private void btnAPT_Click(object sender, EventArgs e)
        {
            Txt2List txt2list = new Txt2List();
            List2Txt list2txt = new List2Txt();

            List<string> tmplist = new List<string>();

            OpenFileDialog openDlg = new OpenFileDialog();

            openDlg.Filter = "txt_APT文件|*.txt";

            if (openDlg.ShowDialog() != DialogResult.OK) return;

            string fileName = openDlg.FileName;

            StreamReader sr = new StreamReader(fileName, Encoding.Default);

            this.rtxbapt.Text = sr.ReadToEnd();

            sr.Close();

            tmplist = txt2list.ReadTxtToList(fileName);
            list2txt.ListToTxtFile(tmplist, "D:middleTranslation0.txt");
        }
Ejemplo n.º 6
0
        private void btnJBI_Click(object sender, EventArgs e)
        {
            APTtoJBI apt2jbi  = new APTtoJBI();
            Txt2List txt2list = new Txt2List();
            List2Txt list2txt = new List2Txt();

            List <string> tmplist = new List <string>();



            float parameter_a, parameter_b, parameter_c, Length, toolV;
            int   bol;

            if (cmbpdMachineSurface.Text == "XY平面")
            {
                bol = 0;
            }
            else
            {
                bol = 1;
            }

            parameter_a = float.Parse(this.txbpda.Text);
            parameter_b = float.Parse(this.txbpdb.Text);
            parameter_c = float.Parse(this.txbpdc.Text);
            Length      = float.Parse(this.txbpdToolLength.Text) + 375;
            toolV       = float.Parse(this.txbpdToolV.Text);


            SaveFileDialog sfdlg = new SaveFileDialog();

            sfdlg.ShowDialog();
            sfdlg.Filter = "文本文件|*.JBI";

            string pathstr = apt2jbi.Apt2JbiFirst("D:middleTranslation0.txt");

            tmplist = apt2jbi.Apt2Jbi_math(pathstr, Length, parameter_a, parameter_b, parameter_c, toolV, bol);

            string tmpstrin = apt2jbi.writingJBItoText(tmplist);



            StreamReader sr = new StreamReader(tmpstrin, Encoding.Default);

            this.rtxbjbi.Text = sr.ReadToEnd();

            sr.Close();



            if (sfdlg.ShowDialog() == DialogResult.OK)
            {
                string savefile = sfdlg.FileName;

                string namestr       = Path.GetFileNameWithoutExtension(savefile);
                string directoryname = Path.GetDirectoryName(savefile);


                int count  = (int)(tmplist.Count / 2 / 850 + 1);
                int offset = 0;


                for (int i = 0; i < count; i++)
                {
                    int pointNumbers = 0;
                    int tmpoffset    = offset;

                    FileStream fsbegin = new FileStream(@directoryname + "\\" + namestr + i.ToString(), FileMode.Create, FileAccess.Write);

                    StreamWriter swbegin = new StreamWriter(fsbegin);

                    swbegin.Flush();

                    swbegin.BaseStream.Seek(0, SeekOrigin.Begin);

                    swbegin.WriteLine("/JOB");
                    swbegin.WriteLine("//NAME " + namestr + i.ToString());
                    swbegin.WriteLine("//POS");

                    if (count == 1)
                    {
                        pointNumbers = tmplist.Count / 2 + 2;
                    }

                    else if ((i < count - 1) && count > 1)
                    {
                        if (tmplist[tmplist.Count / 2 + (i + 1) * 850].StartsWith("MOVL"))
                        {
                            pointNumbers = 850 - offset + 2;
                            offset       = 0;
                        }
                        else if (tmplist[tmplist.Count / 2 + (i + 1) * 850 + 1].StartsWith("MOVL"))
                        {
                            pointNumbers = 850 + 1 - offset + 2;
                            offset       = 1;
                        }
                        else if (tmplist[tmplist.Count / 2 + (i + 1) * 850 + 2].StartsWith("MOVL"))
                        {
                            pointNumbers = 850 + 2 - offset + 2;
                            offset       = 2;
                        }
                        else if (tmplist[tmplist.Count / 2 + (i + 1) * 850 + 3].StartsWith("MOVL"))
                        {
                            pointNumbers = 850 + 3 - offset + 2;
                            offset       = 3;
                        }
                    }
                    else if (i == count - 1 && count > 1)
                    {
                        pointNumbers = tmplist.Count / 2 - 850 * i - tmpoffset + 2;
                    }
                    swbegin.WriteLine("///NPOS " + pointNumbers.ToString() + ",0,0,0,0,0");
                    swbegin.WriteLine("///TOOL 0");
                    swbegin.WriteLine("///POSTYPE PULSE");
                    swbegin.WriteLine("///PULSE");

                    swbegin.WriteLine("C00000=0,0,0,0,0,0");

                    int line = 1;

                    for (int tmpN = tmpoffset; tmpN < pointNumbers - 2; tmpN++, line++)
                    {
                        string tmpstr = tmplist[850 * i + tmpN];
                        string str    = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);

                        swbegin.WriteLine(str);

                        if (tmpN == pointNumbers - 3)
                        {
                            if (tmplist[i * 850 + tmpN + 1].StartsWith("MOVL"))
                            {
                            }
                            else if (tmplist[i * 850 + tmpN + 2].StartsWith("MOVL"))
                            {
                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 1];
                                str    = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);
                            }
                            else if (tmplist[i * 850 + tmpN + 3].StartsWith("MOVL"))
                            {
                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 1];
                                str    = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);

                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 2];
                                str    = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);
                            }
                            else if (tmplist[i * 850 + tmpN + 4].StartsWith("MOVL"))
                            {
                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 1];
                                str    = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);

                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 2];
                                str    = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);

                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 3];
                                str    = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);
                            }
                        }
                    }
                    swbegin.WriteLine("C" + string.Format("{0:00000}", line) + "=0,0,0,0,0,0");

                    swbegin.WriteLine("//INST");
                    swbegin.WriteLine("///DATE " + DateTime.Now.ToString("yyyy/MM/dd  HH:mm"));
                    swbegin.WriteLine("///ATTR SC,RW");
                    swbegin.WriteLine("///GROUP1 RB2");
                    swbegin.WriteLine("NOP");


                    swbegin.WriteLine("MOVL C00000 V=110.00 PL=0");

                    for (int j = 0; j < pointNumbers - 2; j++)
                    {
                        string tmpstr = tmplist[tmplist.Count / 2 + i * 850 + tmpoffset + j];
                        string str    = tmpstr.Substring(0, 6) + string.Format("{0:00000}", j + 1) + " V=110.00 PL=0";
                        swbegin.WriteLine(str);
                    }

                    swbegin.WriteLine("MOVL C" + string.Format("{0:00000}", pointNumbers - 1) + " V=110.00 PL=0");

                    swbegin.WriteLine("END");

                    swbegin.Flush();
                    swbegin.Close();
                    fsbegin.Close();
                }
            }
        }
Ejemplo n.º 7
0
        private void btnJBI_Click(object sender, EventArgs e)
        {
            APTtoJBI apt2jbi = new APTtoJBI();
            Txt2List txt2list = new Txt2List();
            List2Txt list2txt = new List2Txt();

            List<string> tmplist = new List<string>();

            float parameter_a, parameter_b, parameter_c, Length, toolV;
            int bol;

            if (cmbpdMachineSurface.Text == "XY平面")
                bol = 0;
            else
                bol = 1;

            parameter_a = float.Parse(this.txbpda.Text);
            parameter_b = float.Parse(this.txbpdb.Text);
            parameter_c = float.Parse(this.txbpdc.Text);
            Length = float.Parse(this.txbpdToolLength.Text)+375;
            toolV = float.Parse(this.txbpdToolV.Text);

            SaveFileDialog sfdlg = new SaveFileDialog();
            sfdlg.ShowDialog();
            sfdlg.Filter = "文本文件|*.JBI";

            string pathstr = apt2jbi.Apt2JbiFirst("D:middleTranslation0.txt");

            tmplist = apt2jbi.Apt2Jbi_math(pathstr,Length ,parameter_a ,parameter_b ,parameter_c ,toolV,bol );

            string tmpstrin = apt2jbi.writingJBItoText(tmplist);

            StreamReader sr = new StreamReader(tmpstrin, Encoding.Default);

            this.rtxbjbi.Text = sr.ReadToEnd();

            sr.Close();

            if (sfdlg.ShowDialog() == DialogResult.OK)
            {
                string savefile = sfdlg.FileName;

                string namestr = Path.GetFileNameWithoutExtension(savefile);
                string directoryname = Path.GetDirectoryName(savefile);

                int count = (int)(tmplist.Count / 2 / 850 + 1);
                int offset = 0;

                for (int i = 0; i < count; i++)
                {
                    int pointNumbers = 0;
                    int tmpoffset = offset;

                    FileStream fsbegin = new FileStream(@directoryname + "\\" + namestr + i.ToString(), FileMode.Create, FileAccess.Write);

                    StreamWriter swbegin = new StreamWriter(fsbegin);

                    swbegin.Flush();

                    swbegin.BaseStream.Seek(0, SeekOrigin.Begin);

                    swbegin.WriteLine("/JOB");
                    swbegin.WriteLine("//NAME " + namestr + i.ToString());
                    swbegin.WriteLine("//POS");

                    if (count == 1)
                    {
                        pointNumbers = tmplist.Count / 2 + 2;

                    }

                    else if ((i < count - 1) && count > 1)
                    {

                        if (tmplist[tmplist.Count / 2 + (i + 1) * 850].StartsWith("MOVL"))
                        {
                            pointNumbers = 850 - offset + 2;
                            offset = 0;

                        }
                        else if (tmplist[tmplist.Count / 2 + (i + 1) * 850 + 1].StartsWith("MOVL"))
                        {
                            pointNumbers = 850 + 1 - offset + 2;
                            offset = 1;

                        }
                        else if (tmplist[tmplist.Count / 2 + (i + 1) * 850 + 2].StartsWith("MOVL"))
                        {
                            pointNumbers = 850 + 2 - offset + 2;
                            offset = 2;

                        }
                        else if (tmplist[tmplist.Count / 2 + (i + 1) * 850 + 3].StartsWith("MOVL"))
                        {
                            pointNumbers = 850 + 3 - offset + 2;
                            offset = 3;

                        }
                    }
                    else if (i == count - 1 && count > 1)
                    {
                        pointNumbers = tmplist.Count / 2 - 850 * i - tmpoffset + 2;
                    }
                    swbegin.WriteLine("///NPOS " + pointNumbers.ToString() + ",0,0,0,0,0");
                    swbegin.WriteLine("///TOOL 0");
                    swbegin.WriteLine("///POSTYPE PULSE");
                    swbegin.WriteLine("///PULSE");

                    swbegin.WriteLine("C00000=0,0,0,0,0,0");

                    int line = 1;

                    for (int tmpN = tmpoffset; tmpN < pointNumbers - 2; tmpN++, line++)
                    {

                        string tmpstr = tmplist[850 * i + tmpN];
                        string str = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);

                        swbegin.WriteLine(str);

                        if (tmpN == pointNumbers - 3)
                        {

                            if (tmplist[i * 850 + tmpN + 1].StartsWith("MOVL"))
                            {
                            }
                            else if (tmplist[i * 850 + tmpN + 2].StartsWith("MOVL"))
                            {
                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 1];
                                str = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);

                            }
                            else if (tmplist[i * 850 + tmpN + 3].StartsWith("MOVL"))
                            {
                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 1];
                                str = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);

                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 2];
                                str = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);

                            }
                            else if (tmplist[i * 850 + tmpN + 4].StartsWith("MOVL"))
                            {
                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 1];
                                str = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);

                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 2];
                                str = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);

                                line++;
                                tmpstr = tmplist[850 * i + tmpN + 3];
                                str = "C" + string.Format("{0:00000}", line) + tmpstr.Remove(0, 6);
                                swbegin.WriteLine(str);

                            }
                        }
                    }
                    swbegin.WriteLine("C" + string.Format("{0:00000}", line) + "=0,0,0,0,0,0");

                    swbegin.WriteLine("//INST");
                    swbegin.WriteLine("///DATE " + DateTime.Now.ToString("yyyy/MM/dd  HH:mm"));
                    swbegin.WriteLine("///ATTR SC,RW");
                    swbegin.WriteLine("///GROUP1 RB2");
                    swbegin.WriteLine("NOP");

                    swbegin.WriteLine("MOVL C00000 V=110.00 PL=0");

                    for (int j = 0; j < pointNumbers - 2; j++)
                    {
                        string tmpstr = tmplist[tmplist.Count / 2 + i * 850 + tmpoffset + j];
                        string str = tmpstr.Substring(0, 6) + string.Format("{0:00000}", j + 1) + " V=110.00 PL=0";
                        swbegin.WriteLine(str);

                    }

                    swbegin.WriteLine("MOVL C" + string.Format("{0:00000}", pointNumbers - 1) + " V=110.00 PL=0");

                    swbegin.WriteLine("END");

                    swbegin.Flush();
                    swbegin.Close();
                    fsbegin.Close();

                }
            }
        }
Ejemplo n.º 8
0
        public List<string> Apt2Jbi_math(string fileName,float toollength ,
           float a ,float b ,float c ,float toolV,int bol)
        {
            Txt2List txt2list=new Txt2List ();
            List2Txt list2txt=new List2Txt ();

               BasicData basicData=new BasicData();

             List<string> tmplist = new List<string>();

             List<string> tmplistJbi = new List<string>();

             List<string> tmplistJbi_down = new List<string>();

              tmplist= txt2list.ReadTxtToList(fileName);

             int i=0;
             int j = 0;
             string tmpNext = null;
             string tmpNexttr = null;
             for (i = 0; i < tmplist.Count; i++)
             {

                 string tmpNow = tmplist[i];

                 if (i == tmplist.Count - 1)
                     tmpNext ="Nothing";

                 else
                 tmpNext = tmplist[i + 1];

                 if (i >= tmplist.Count -3)
                     tmpNexttr = "Nothing";

                 else
                 tmpNexttr = tmplist[i + 3];

                 if (tmpNow.StartsWith("GOTO"))
                 {
                     if (tmpNext.StartsWith("CIRCLE"))
                     {
                         float[][]  allNumbers= GotoCircleToMovl(tmpNow,tmpNext,tmplist [i+2]);

                         float[] pxyz = basicData.SolvingPxyzFromXyz(allNumbers[0][0],allNumbers [0][1],allNumbers [0][2],a,b,c,toollength,bol );

                         float[] locationP0and1 = basicData.InverseSolution(pxyz[0], pxyz[1], pxyz[2], bol);

                         float[] pxyz2 = basicData.SolvingPxyzFromXyz(allNumbers[3][0], allNumbers[3][1], allNumbers[3][2],a,b,c, toollength,bol);

                         float[] locationP2 = basicData.InverseSolution(pxyz2[0], pxyz2[1], pxyz2[2], bol);

                         float[] pxyz3 = basicData.SolvingPxyzFromXyz(allNumbers[2][0], allNumbers[2][1], allNumbers[2][2],a,b,c, toollength,bol);

                         float[] locationP3 = basicData.InverseSolution(pxyz3[0], pxyz3[1], pxyz3[2], bol);

                         string tmpLocationP0and1 = '=' + locationP0and1[6].ToString() + ',' + locationP0and1[7].ToString()
                                            + ',' + locationP0and1[8].ToString() + ',' + locationP0and1[9].ToString()
                                            + ',' + locationP0and1[10].ToString() + ',' + locationP0and1[11].ToString();

                         string tmpLocationP2 = '=' + locationP2[6].ToString() + ',' + locationP2[7].ToString()
                                              + ',' + locationP2[8].ToString() + ',' + locationP2[9].ToString()
                                              + ',' + locationP2[10].ToString() + ',' + locationP2[11].ToString();

                         string tmpLocationP3 = '=' + locationP3[6].ToString() + ',' + locationP3[7].ToString()
                                              + ',' + locationP3[8].ToString() + ',' + locationP3[9].ToString()
                                              + ',' + locationP3[10].ToString() + ',' + locationP3[11].ToString();

                         string tmpJbi_up_zero = "C" + string.Format("{0:00000}", j) + tmpLocationP0and1;
                         string tmpJbi_down_zero = "MOVL C" + string.Format("{0:00000}", j) + " V="+toolV.ToString ()+" PL=0";

                         j++;

                         string tmpJbi_up_one = "C" + string.Format("{0:00000}", j) + tmpLocationP0and1;
                         string tmpJbi_down_one = "MOVC C" + string.Format("{0:00000}", j) + " V=" + toolV.ToString() + " PL=0";

                         j++;

                         string tmpJbi_up_two = "C" + string.Format("{0:00000}", j) + tmpLocationP2;
                         string tmpJbi_down_two = "MOVC C" + string.Format("{0:00000}", j) + " V=" + toolV.ToString() + " PL=0";

                         j++;

                         string tmpJbi_up_three = "C" + string.Format("{0:00000}", j) + tmpLocationP3;
                         string tmpJbi_down_three = "MOVC C" + string.Format("{0:00000}", j) + " V=" + toolV.ToString() + " PL=0";

                         tmplistJbi.Add(tmpJbi_up_zero);
                         tmplistJbi_down.Add(tmpJbi_down_zero);

                         tmplistJbi.Add(tmpJbi_up_one);
                         tmplistJbi_down.Add(tmpJbi_down_one);

                         tmplistJbi.Add(tmpJbi_up_two);
                         tmplistJbi_down.Add(tmpJbi_down_two);

                         tmplistJbi.Add(tmpJbi_up_three);
                         tmplistJbi_down.Add(tmpJbi_down_three);

                         if (tmpNexttr.StartsWith("CIRCLE"))
                         {

                             // i++;
                             i++;
                             j++;
                         }
                         else
                         {
                             i++;
                             i++;
                             j++;
                         }
                     }
                     else
                     {

                         float[] xyz = GotoLinesToMovl(tmpNow);

                         float[] pxyz = basicData.SolvingPxyzFromXyz(xyz[0], xyz[1], xyz[2],a,b,c, toollength,bol);

                         float[] locationP = basicData.InverseSolution(pxyz[0], pxyz[1], pxyz[2], bol);

                         string tmpLocationP = '=' + locationP[6].ToString() + ',' + locationP[7].ToString()
                                             + ',' + locationP[8].ToString() + ',' + locationP[9].ToString()
                                             + ',' + locationP[10].ToString() + ',' + locationP[11].ToString();

                         string tmpJbi_up = "C"+string.Format("{0:00000}", j) + tmpLocationP;
                         string tmpJbi_down = "MOVL C" + string.Format("{0:00000}", j) + " V=" + toolV.ToString() + " PL=0";

                         tmplistJbi.Add(tmpJbi_up);
                         tmplistJbi_down.Add(tmpJbi_down);
                         j++;

                     }

                 }

             }

               tmplistJbi.AddRange(tmplistJbi_down);

               return tmplistJbi;
        }
Ejemplo n.º 9
0
        public string writingJBItoText(List <string>tmplist)
        {
            List2Txt list2txt=new List2Txt ();

               //list2txt.ListToTxtFile(tmplist, "D;middleTranslation2.txt");

            FileStream fsbegin = new FileStream("d:middleTranslation2.txt", FileMode.Create, FileAccess.Write);

            StreamWriter swbegin = new StreamWriter(fsbegin);

            swbegin.Flush();

            swbegin.BaseStream.Seek(0, SeekOrigin.Begin);

            swbegin.WriteLine("/JOB");
            swbegin.WriteLine("//NAME ***");
            swbegin.WriteLine("//POS");
            swbegin.WriteLine("///NPOS " + ((int)(tmplist.Count / 2+2)).ToString() + ",0,0,0,0,0");
            swbegin.WriteLine("///TOOL 5");
            swbegin.WriteLine("///POSTYPE PULSE");
            swbegin.WriteLine("///PULSE");

            for (int i = 0; i < tmplist.Count; i++)
            {
            if (i == (int)tmplist.Count / 2)
            {

                swbegin.WriteLine("//INST");
                swbegin.WriteLine("///DATE " + DateTime.Now.ToString("yyyy/MM/dd  HH:mm"));
                swbegin.WriteLine("///ATTR SC,RW");
                swbegin.WriteLine("///GROUP1 RB2");
                swbegin.WriteLine("NOP");
            }
            swbegin.WriteLine(tmplist[i]);
            }

            swbegin.WriteLine("END");

            swbegin.Flush();
            swbegin.Close();
            fsbegin.Close();

            string str="d:middleTranslation2.txt";
              return  str;
        }
Ejemplo n.º 10
0
        public List <string> Apt2Jbi_math(string fileName, float toollength,
                                          float a, float b, float c, float toolV, int bol)
        {
            Txt2List txt2list = new Txt2List();
            List2Txt list2txt = new List2Txt();

            BasicData basicData = new BasicData();

            List <string> tmplist = new List <string>();

            List <string> tmplistJbi = new List <string>();

            List <string> tmplistJbi_down = new List <string>();


            tmplist = txt2list.ReadTxtToList(fileName);

            int    i         = 0;
            int    j         = 0;
            string tmpNext   = null;
            string tmpNexttr = null;

            for (i = 0; i < tmplist.Count; i++)
            {
                string tmpNow = tmplist[i];

                if (i == tmplist.Count - 1)
                {
                    tmpNext = "Nothing";
                }

                else
                {
                    tmpNext = tmplist[i + 1];
                }

                if (i >= tmplist.Count - 3)
                {
                    tmpNexttr = "Nothing";
                }

                else
                {
                    tmpNexttr = tmplist[i + 3];
                }

                if (tmpNow.StartsWith("GOTO"))
                {
                    if (tmpNext.StartsWith("CIRCLE"))
                    {
                        float[][] allNumbers = GotoCircleToMovl(tmpNow, tmpNext, tmplist [i + 2]);

                        float[] pxyz = basicData.SolvingPxyzFromXyz(allNumbers[0][0], allNumbers [0][1], allNumbers [0][2], a, b, c, toollength, bol);

                        float[] locationP0and1 = basicData.InverseSolution(pxyz[0], pxyz[1], pxyz[2], bol);


                        float[] pxyz2 = basicData.SolvingPxyzFromXyz(allNumbers[3][0], allNumbers[3][1], allNumbers[3][2], a, b, c, toollength, bol);

                        float[] locationP2 = basicData.InverseSolution(pxyz2[0], pxyz2[1], pxyz2[2], bol);


                        float[] pxyz3 = basicData.SolvingPxyzFromXyz(allNumbers[2][0], allNumbers[2][1], allNumbers[2][2], a, b, c, toollength, bol);

                        float[] locationP3 = basicData.InverseSolution(pxyz3[0], pxyz3[1], pxyz3[2], bol);



                        string tmpLocationP0and1 = '=' + locationP0and1[6].ToString() + ',' + locationP0and1[7].ToString()
                                                   + ',' + locationP0and1[8].ToString() + ',' + locationP0and1[9].ToString()
                                                   + ',' + locationP0and1[10].ToString() + ',' + locationP0and1[11].ToString();

                        string tmpLocationP2 = '=' + locationP2[6].ToString() + ',' + locationP2[7].ToString()
                                               + ',' + locationP2[8].ToString() + ',' + locationP2[9].ToString()
                                               + ',' + locationP2[10].ToString() + ',' + locationP2[11].ToString();

                        string tmpLocationP3 = '=' + locationP3[6].ToString() + ',' + locationP3[7].ToString()
                                               + ',' + locationP3[8].ToString() + ',' + locationP3[9].ToString()
                                               + ',' + locationP3[10].ToString() + ',' + locationP3[11].ToString();



                        string tmpJbi_up_zero   = "C" + string.Format("{0:00000}", j) + tmpLocationP0and1;
                        string tmpJbi_down_zero = "MOVL C" + string.Format("{0:00000}", j) + " V=" + toolV.ToString() + " PL=0";

                        j++;

                        string tmpJbi_up_one   = "C" + string.Format("{0:00000}", j) + tmpLocationP0and1;
                        string tmpJbi_down_one = "MOVC C" + string.Format("{0:00000}", j) + " V=" + toolV.ToString() + " PL=0";

                        j++;

                        string tmpJbi_up_two   = "C" + string.Format("{0:00000}", j) + tmpLocationP2;
                        string tmpJbi_down_two = "MOVC C" + string.Format("{0:00000}", j) + " V=" + toolV.ToString() + " PL=0";

                        j++;

                        string tmpJbi_up_three   = "C" + string.Format("{0:00000}", j) + tmpLocationP3;
                        string tmpJbi_down_three = "MOVC C" + string.Format("{0:00000}", j) + " V=" + toolV.ToString() + " PL=0";



                        tmplistJbi.Add(tmpJbi_up_zero);
                        tmplistJbi_down.Add(tmpJbi_down_zero);

                        tmplistJbi.Add(tmpJbi_up_one);
                        tmplistJbi_down.Add(tmpJbi_down_one);

                        tmplistJbi.Add(tmpJbi_up_two);
                        tmplistJbi_down.Add(tmpJbi_down_two);

                        tmplistJbi.Add(tmpJbi_up_three);
                        tmplistJbi_down.Add(tmpJbi_down_three);

                        if (tmpNexttr.StartsWith("CIRCLE"))
                        {
                            // i++;
                            i++;
                            j++;
                        }
                        else
                        {
                            i++;
                            i++;
                            j++;
                        }
                    }
                    else
                    {
                        float[] xyz = GotoLinesToMovl(tmpNow);

                        float[] pxyz = basicData.SolvingPxyzFromXyz(xyz[0], xyz[1], xyz[2], a, b, c, toollength, bol);

                        float[] locationP = basicData.InverseSolution(pxyz[0], pxyz[1], pxyz[2], bol);


                        string tmpLocationP = '=' + locationP[6].ToString() + ',' + locationP[7].ToString()
                                              + ',' + locationP[8].ToString() + ',' + locationP[9].ToString()
                                              + ',' + locationP[10].ToString() + ',' + locationP[11].ToString();

                        string tmpJbi_up   = "C" + string.Format("{0:00000}", j) + tmpLocationP;
                        string tmpJbi_down = "MOVL C" + string.Format("{0:00000}", j) + " V=" + toolV.ToString() + " PL=0";

                        tmplistJbi.Add(tmpJbi_up);
                        tmplistJbi_down.Add(tmpJbi_down);
                        j++;
                    }
                }
            }


            tmplistJbi.AddRange(tmplistJbi_down);

            return(tmplistJbi);
        }