Esempio n. 1
0
        //设定进给距离
        private void btnFeed_Click(object sender, EventArgs e)
        {
            string pAnswer      = null;
            string feedDistance = txtSetFeed.Text.Trim();

            if (regexInt.IsMatch(feedDistance))
            {
                PMAC.GetResponse(pmacNumber, "#1j:" + feedDistance, out pAnswer);
                labSetP.Text = feedDistance;
            }
            else
            {
                MessageBox.Show("请输入正确的整数");
            }
        }
Esempio n. 2
0
        float speed;//设定速度变量,浮点型
        private void btnStart_Click(object sender, EventArgs e)
        {
            string pReponse = "";
            int    pStatus  = 0;
            string answer   = null;
            //浮点型正则表达式   ^(-?\d+)(\.\d+)?$
            string speedText = setSpeed.Text.ToString().Trim();
            Regex  reg       = new Regex(@"^(-?\d+)(\.\d+)?$");

            if (reg.IsMatch(speedText))
            {
                speed = float.Parse(speedText);
                PMAC.GetResponseEx(pmacNumber, "I122=" + speedText, true, out pReponse, out pStatus);
            }
            else
            {
                MessageBox.Show("请输入正确的参数");
            }
            PMAC.GetResponse(pmacNumber, "#1j+", out answer);
        }
Esempio n. 3
0
        /*****************************************************************************************************************************
        *  //电机信息 返回一个二维数组,包含速度和位置信息
        *  private string[] getMotorInfo(int motorNum)
        *  {
        *   //中间变量
        *   int status = 0;
        *   string motorPosition;       //电机读取到的位置信息
        *   string motorVelocity;       //电机读取到的速度信息
        *   string position;            //计算出来的位置信息
        *   string velocity;            //计算出来的速度信息
        *   switch (motorNum)
        *   {
        *       case 1:   //#1电机
        *           PMAC.GetResponseEx(pmacNumber, "#1P", false, out motorPosition, out status);
        *           position = (float.Parse(motorPosition)).ToString("f1");
        *           PMAC.GetResponseEx(pmacNumber, "#1V", false, out motorVelocity, out status);
        *           velocity = (float.Parse(motorVelocity) * 8388608 / 3713991).ToString();
        *           break;
        *
        *       case 2:   //#2电机
        *           PMAC.GetResponseEx(pmacNumber, "#2P", false, out motorPosition, out status);
        *           position = (float.Parse(motorPosition)).ToString("f1");
        *           PMAC.GetResponseEx(pmacNumber, "#2V", false, out motorVelocity, out status);
        *           velocity = (float.Parse(motorVelocity) * 8388608 / 3713991).ToString();
        *           break;
        *       case 3:   //#3电机
        *           PMAC.GetResponseEx(pmacNumber, "#3P", false, out motorPosition, out status);
        *           position = (float.Parse(motorPosition)).ToString("f1");
        *           PMAC.GetResponseEx(pmacNumber, "#3V", false, out motorVelocity, out status);
        *           velocity = (float.Parse(motorVelocity) * 8388608 / 3713991).ToString();
        *           break;
        *       default:
        *           velocity = "0";
        *           position = "0";
        *           break;
        *   }
        *   string[] motorInfo = new string[2]{ velocity, position };
        *   return motorInfo;
        *  }
        *****************************************************************************************************************************/


        //连续进给  "#*j+"
        private void feed(int motorNum)
        {
            string pAnswer = null;

            PMAC.GetResponse(pmacNumber, "#" + motorNum + "j+", out pAnswer);   //开始加工
        }