예제 #1
0
 public void ReadToolOffset(string cncAdress, ushort portNumber, short useNo)
 {
     Focas1.ODBTOFS bufX = new Focas1.ODBTOFS();
     Focas1.ODBTOFS bufZ = new Focas1.ODBTOFS();
     Focas1.ODBTOFS bufR = new Focas1.ODBTOFS();
     ComReturnValue = Focas1.cnc_allclibhndl3(cncAdress, portNumber, TimeOut, out Handle);
     if (ComReturnValue == Focas1.EW_OK)
     {
         ErrorCode = "None";
         ret       = Focas1.cnc_rdtofs(Handle, useNo, 0, 8, bufX);
         Console.WriteLine("X({0}) = {1}", useNo, bufX.data);
         ret = Focas1.cnc_rdtofs(Handle, useNo, 2, 8, bufZ);
         Console.WriteLine("Z({0}) = {1}", useNo, bufZ.data);
         ret = Focas1.cnc_rdtofs(Handle, useNo, 4, 8, bufR);
         Console.WriteLine("R({0}) = {1}", useNo, bufR.data);
     }
     else
     {
         Console.WriteLine("ERROR!({0})", ComReturnValue);
         ErrorCode = $"({ComReturnValue})";
     }
 }
예제 #2
0
        private void btnToolRead_Click(object sender, EventArgs e)
        {
            //µ¶¾ßÉúÃüÖÜÆÚ
            //short data_num = 1;
            //Focas1.IODBTLMNG iod = new Focas1.IODBTLMNG();
            //short ret = Focas1.cnc_rdtool(cncHandle, 1, ref data_num, iod);
            //if (ret == Focas1.EW_OK)
            //{
            //    MessageBox.Show("½á¹û£º" + iod.data1.custom1);
            //}

            //ÐÎ×´²¹³¥¶ÁÈ¡
            StringBuilder sbShape = new StringBuilder();

            Focas1.ODBTOFS iod = new Focas1.ODBTOFS();
            short          ret = Focas1.cnc_rdtofs(cncHandle, 1, 1, 8, iod);//ÐÎ×´ XÖá

            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("ÐÎ×´XÖá½á¹û£º" + iod.data / 1000.0);
            }

            ret = Focas1.cnc_rdtofs(cncHandle, 1, 3, 8, iod);//ÐÎ×´ ZÖá
            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("ÐÎ×´ZÖá½á¹û£º" + iod.data / 1000.0);
            }

            ret = Focas1.cnc_rdtofs(cncHandle, 1, 9, 8, iod);//ÐÎ×´ YÖá
            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("ÐÎ×´YÖá½á¹û£º" + iod.data / 1000.0);
            }

            ret = Focas1.cnc_rdtofs(cncHandle, 1, 5, 8, iod);//ÐÎ×´ °ë¾¶R
            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("°ë¾¶R½á¹û£º" + iod.data / 1000.0);
            }

            ret = Focas1.cnc_rdtofs(cncHandle, 1, 7, 8, iod);//ÐÎ×´ T
            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("ÐÎ×´T½á¹û£º" + iod.data);
            }

            //Ä¥Ëð²¹³¥¶ÁÈ¡
            ret = Focas1.cnc_rdtofs(cncHandle, 1, 0, 8, iod);//Ä¥Ëð XÖá
            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("Ä¥ËðXÖá½á¹û£º" + iod.data / 1000.0);
            }

            ret = Focas1.cnc_rdtofs(cncHandle, 1, 2, 8, iod);//Ä¥Ëð ZÖá
            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("Ä¥ËðZÖá½á¹û£º" + iod.data / 1000.0);
            }

            ret = Focas1.cnc_rdtofs(cncHandle, 1, 8, 8, iod);//Ä¥Ëð YÖá
            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("Ä¥ËðYÖá½á¹û£º" + iod.data / 1000.0);
            }

            ret = Focas1.cnc_rdtofs(cncHandle, 1, 4, 8, iod);//Ä¥Ëð °ë¾¶R
            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("Ä¥ËðR½á¹û£º" + iod.data / 1000.0);
            }

            ret = Focas1.cnc_rdtofs(cncHandle, 1, 6, 8, iod);//Ä¥Ëð T
            if (ret == Focas1.EW_OK)
            {
                sbShape.AppendLine("Ä¥ËðT½á¹û£º" + iod.data);
            }
            MessageBox.Show(sbShape.ToString());
        }