在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#语言基础 → ADTECH运动控制卡DEMO程序

ADTECH运动控制卡DEMO程序

C#语言基础

下载此实例
  • 开发语言:C#
  • 实例大小:0.65M
  • 下载次数:76
  • 浏览次数:533
  • 发布时间:2020-03-24
  • 实例类别:C#语言基础
  • 发 布 人:零点漂移
  • 文件格式:.zip
  • 所需积分:2

实例介绍

【实例简介】PCI运动控制卡开发

【实例截图】

from clipboard

【核心代码】


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        #region 全局参数声明代码部分
        CtrlCard g_CtrlCard = new CtrlCard();   //驱动类全局参数
        Int32 m_addmode = 0;//默认运动模式为T型
        const Int32 MAXAXI = 4;//最大轴号
        const Int32 MaxOUT = 31;//最大输出端口号
        const Int32 MaxIN = 34;//最大输入端口号
        static bool manual = false;//默认为禁用手轮
        Int32 g_AxiNo = 1;//默认参数界面为X轴
        Int32 g_ZeroAxi = 1;//单轴回零轴号
        bool m_StopFlag = false;
        Int32 m_dir = 0;

        //基本运动参数
        int[] m_nStartv = new int[MAXAXI], m_nSpeed = new int[MAXAXI], m_nAcc = new int[MAXAXI], m_nRatio = new int[MAXAXI], m_nDec = new int[MAXAXI], m_nPulse = new int[MAXAXI];

        //复合运动参数
        int[] m_nStartv1 = new int[MAXAXI], m_nSpeed1 = new int[MAXAXI], m_nVAcc = new int[MAXAXI];
        double[] m_nTAcc = new double[MAXAXI];
        int m_moveMode = 0;

        //特殊运动界面

        int[] m_SpePulse = new int[MAXAXI];
        int m_reg = 0;
        int m_relation = 0;
        int m_mainAxiKeep = 0;
        int m_SignalStatus = 0;
        int m_mainAxiStatus = 0;

        public struct SelectInfo
        {
            public Int32[] selectAxi;//被选中的轴号
            public Int32 AxiNo;//被选中的轴数
            public Int32 MinAxi;//被选中的最小轴号 
        }

        SelectInfo m_SelectInfo;//轴选择信息结构体

        struct Para//系统参数结构体
        {
            public Int32 m_pulsemode;//脉冲模式
            public Int32 m_Lmtdp;//正负限位有效电平
            public Int32 m_Stop0effective;//stop0是否有效
            public Int32 m_Stop0dp;//stop0有效电平
            public Int32 m_Stop1effective;//stop1是否有效
            public Int32 m_Stop1dp;//stop1有效电平
            public Int32 m_Stop2effective;//stop2是否有效
            public Int32 m_Stop2dp;//stop2有效电平
            public Int32 m_Alarmeffective;//stop2是否有效
            public Int32 m_Alarmdp;//stop2有效电平
            public Int32 m_Circleeffective;//可变环形是否有效
            public Int32 m_Inposeffective;//到位信号是否有效
            public Int32 m_Inposdp;//到位信号有效电平

        }

        Para[] m_para = new Para[MAXAXI];//默认四个轴

        public struct Zero//系统参数结构体
        {
            public Int32 m_dir;
            public Int32 m_stop0;
            public Int32 m_lmt;
            public Int32 m_stop1;
            public Int32 m_bkRange;
            public Int32 m_ZRange;
            public Int32 m_Off;
            public Int32 m_StartV;
            public Int32 m_SearchV;
            public Int32 m_Speed;
            public Int32 m_Acc;
            public Int32 m_ZSpeed;

        }

        Zero[] m_ZeroPara = new Zero[MAXAXI];//默认四个轴

        #endregion

        #region 基本界面代码部分

        //界面初始化
        private void Form1_Load(object sender, EventArgs e)
        {
            
                StartV_X.Text = "1000";
                StartV_Y.Text = "1000";
                StartV_Z.Text = "1000";
                StartV_A.Text = "1000";

                Speed_X.Text = "3000";
                Speed_Y.Text = "3000";
                Speed_Z.Text = "3000";
                Speed_A.Text = "3000";

                Acc_X.Text = "1500";
                Acc_Y.Text = "1500";
                Acc_Z.Text = "1500";
                Acc_A.Text = "1500";

                Dec_X.Text = "1500";
                Dec_Y.Text = "1500";
                Dec_Z.Text = "1500";
                Dec_A.Text = "1500";

                PulseX.Text = "10000";
                PulseY.Text = "10000";
                PulseZ.Text = "10000";
                PulseA.Text = "10000";

                StartV_X1.Text = "1000";
                StartV_Y1.Text = "1000";
                StartV_Z1.Text = "1000";
                StartV_A1.Text = "1000";

                Speed_X1.Text = "3000";
                Speed_Y1.Text = "3000";
                Speed_Z1.Text = "3000";
                Speed_A1.Text = "3000";

                TAccX.Text = "0.1";
                TAccY.Text = "0.1";
                TAccZ.Text = "0.1";
                TAccA.Text = "0.1";

                VAccX.Text = "300";
                VAccY.Text = "300";
                VAccZ.Text = "300";
                VAccA.Text = "300";

                for (int i = 0; i < MAXAXI; i  )//保存
                {

                    m_para[i].m_Stop0effective = 1;
                    m_para[i].m_Stop0dp = 0;


                    //回零参数
                    m_ZeroPara[i].m_dir = 0;
                    m_ZeroPara[i].m_stop0 = 0;
                    m_ZeroPara[i].m_lmt = 0;
                    m_ZeroPara[i].m_stop1 = -1;
                    m_ZeroPara[i].m_bkRange = 2000;
                    m_ZeroPara[i].m_ZRange = 400;
                    m_ZeroPara[i].m_Off = 200;
                    m_ZeroPara[i].m_StartV = 100;
                    m_ZeroPara[i].m_SearchV = 500;
                    m_ZeroPara[i].m_Speed = 200;
                    m_ZeroPara[i].m_Acc = 100;
                    m_ZeroPara[i].m_ZSpeed = 2000;
                    m_nRatio[i] = 5;
                  
                }

            
                      
            this.ActiveControl = this.Title;//设置焦点
            Int32 cardno = g_CtrlCard.Init_Board();

            if (cardno <= 0)
            {
                MessageBox.Show("控制卡初始化失败!", "提示");
                if (cardno == 0)
                {
                    MessageBox.Show("没有安装ADT8948A1卡!", "提示");
                }
                if (cardno == -1)
                {
                    MessageBox.Show("没有安装端口驱动程序!", "提示");
                }
                if (cardno == -2)
                {
                    MessageBox.Show("PCI桥故障!", "提示");
                }
            }
            else
            {
                MessageBox.Show("运动控制卡可以使用!", "提示");

                //获取运动控制卡数量
                ToolStripStatusLabel2.Text  = Convert.ToString(cardno);

                //获取库函数版本号
                Int32 LibVer;
                
                LibVer = Demo.adt8948A1m.adt8948_get_lib_vision(out LibVer);
                ToolStripStatusLabel3.Text  = Convert.ToString(LibVer);

                //默认联动选中
                Pmove.Checked = true;

                //插入卡号索引
                for (int i = 0; i < cardno; i  )
                {
                    CardIndex.Items.Insert(i, Convert.ToString(i));
                }

                CardIndex.Text = "0";

                Motion1.Checked = true;
                relative.Checked = true;

            }

            //默认四个运动轴都被选中
            CheckAll.Checked = true;
            CheckAll.Text = "反选";
            CheckAxiX.Checked = true;
            CheckAxiY.Checked = true;
            CheckAxiZ.Checked = true;
            CheckAxiA.Checked = true;

        }

        //全选
        private void CheckAll_CheckedChanged(object sender, EventArgs e)
        {
            if (CheckAll.Checked)
            {
                CheckAll.Text = "反选";
                CheckAxiX.Checked = true;
                CheckAxiY.Checked = true;
                CheckAxiZ.Checked = true;
                CheckAxiA.Checked = true;
            }
            else
            {
                CheckAll.Text = "全选";
                CheckAxiX.Checked = false;
                CheckAxiY.Checked = false;
                CheckAxiZ.Checked = false;
                CheckAxiA.Checked = false;

            }
        }

        //立即停止
        private void BtnStop_Click(object sender, EventArgs e)
        {
            m_StopFlag = true;
            for (int i = 1; i <= MAXAXI; i  )
            {
                g_CtrlCard.StopRun(i, 0);
            }
        }

        //减速停止
        private void BtnDecStop_Click(object sender, EventArgs e)
        {
            m_StopFlag = true;

            for (int i = 1; i <= MAXAXI; i  )
            {
                g_CtrlCard.StopRun(i, 1);
            }
        }

        //位置清零
        private void BtnClear_Click(object sender, EventArgs e)
        {
            for (int i = 1; i <= MAXAXI; i  )
            {
                g_CtrlCard.Setup_Pos(i, 0, 0);
                g_CtrlCard.Setup_Pos(i, 0, 1);

            }
        }

        //卡号切换
        private void CardIndex_SelectedIndexChanged(object sender, EventArgs e)
        {
            CtrlCard.g_cardIndex = Convert.ToInt32(CardIndex.Text);
        }

        //固定线速度
        private void BtnVector_CheckedChanged(object sender, EventArgs e)
        {
            if(BtnVector.Checked == true)
            {
                g_CtrlCard.Setup_VectorSpeed(1); //采用固定线速度
            }
            else
            {
                g_CtrlCard.Setup_VectorSpeed(1);
            }
        }

        //主定时器
        private void Timer1_Tick(object sender, EventArgs e)
        {
            Int32 log = 0, act = 0, spd = 0;
            Int32 i = 0, Value = 0;

            Label[] Log = { LogPosX, LogPosY, LogPosZ, LogPosA };
            Label[] Act = { ActPosX, ActPosY, ActPosZ, ActPosA };
            Label[] Speed = { RunSpeedX, RunSpeedY, RunSpeedZ, RunSpeedA };
            //检测限位、stop0和stop1信号
            CheckBox[] lmt1 = { LNT1X, LNT1Y, LNT1Z, LNT1A };
            CheckBox[] lmt2 = { LNT2X, LNT2Y, LNT2Z, LNT2A };
            CheckBox[] Stop0 = { Stop0X, Stop0Y, Stop0Z, Stop0A };
            CheckBox[] Stop1 = { Stop1X, Stop1Y, Stop1Z, Stop1A };
            CheckBox[] Stop2 = { Stop2X, Stop2Y, Stop2Z, Stop2A };
            Label[] StopInfo = { StopInfoX, StopInfoY, StopInfoZ, StopInfoA };

            for (i = 0; i < MAXAXI; i  )
            {
                g_CtrlCard.Get_CurrentInf(i   1, out log, out act, out spd);
                adt8948A1m.adt8948_get_stopdata(CtrlCard.g_cardIndex, i   1, out Value);

                Log[i].Text = Convert.ToString(log);//逻辑位置
                Act[i].Text = Convert.ToString(act);//实际位置
                Speed[i].Text = Convert.ToString(spd*m_nRatio[i]);//运行速度
                StopInfo[i].Text = Convert.ToString(Value);//运行速度


                if (g_CtrlCard.Read_Input((i - 1) * 6) == 0)//正限位
                {
                    lmt1[i].Checked = true;
                }
                else
                {
                    lmt1[i].Checked = false;
                }

                if (g_CtrlCard.Read_Input((i - 1) * 6   1) == 0)//负限位
                {
                    lmt2[i].Checked = true;
                }
                else
                {
                    lmt2[i].Checked = false;
                }

                if (g_CtrlCard.Read_Input((i - 1) * 6   2) == 0)//stop0
                {
                    Stop0[i].Checked = true;
                }
                else
                {
                    Stop0[i].Checked = false;
                }

                if (g_CtrlCard.Read_Input((i - 1) * 6   3) == 0)//stop1
                {
                    Stop1[i].Checked = true;
                }
                else
                {
                    Stop1[i].Checked = false;
                }

                if (g_CtrlCard.Read_Input((i - 1) * 6   4) == 0)//stop2
                {
                    Stop2[i].Checked = true;
                }
                else
                {
                    Stop2[i].Checked = false;
                }

            }
        }

        //刷新轴的选中状态
        public void RefreshSelectInfo()
        {
            m_nStartv[0] = Convert.ToInt32(this.StartV_X.Text);
            m_nStartv[1] = Convert.ToInt32(this.StartV_Y.Text);
            m_nStartv[2] = Convert.ToInt32(this.StartV_Z.Text);
            m_nStartv[3] = Convert.ToInt32(this.StartV_A.Text);

            m_nSpeed[0] = Convert.ToInt32(this.Speed_X.Text);
            m_nSpeed[1] = Convert.ToInt32(this.Speed_Y.Text);
            m_nSpeed[2] = Convert.ToInt32(this.Speed_Z.Text);
            m_nSpeed[3] = Convert.ToInt32(this.Speed_A.Text);

            m_nAcc[0] = Convert.ToInt32(this.Acc_X.Text);
            m_nAcc[1] = Convert.ToInt32(this.Acc_Y.Text);
            m_nAcc[2] = Convert.ToInt32(this.Acc_Z.Text);
            m_nAcc[3] = Convert.ToInt32(this.Acc_A.Text);

            m_nDec[0] = Convert.ToInt32(this.Dec_X.Text);
            m_nDec[1] = Convert.ToInt32(this.Dec_Y.Text);
            m_nDec[2] = Convert.ToInt32(this.Dec_Z.Text);
            m_nDec[3] = Convert.ToInt32(this.Dec_A.Text);

            m_nPulse[0] = Convert.ToInt32(this.PulseX.Text);
            m_nPulse[1] = Convert.ToInt32(this.PulseY.Text);
            m_nPulse[2] = Convert.ToInt32(this.PulseZ.Text);
            m_nPulse[3] = Convert.ToInt32(this.PulseA.Text);

            if (AddMode1.Checked == true)
            {
                m_addmode = 0;
            }
            if (AddMode2.Checked == true)
            {
                m_addmode = 1;
            }
            if (AddMode3.Checked == true)
            {
                m_addmode = 2;
            }

            //初始状态没有轴被选中
            m_SelectInfo.AxiNo = 0;
            m_SelectInfo.selectAxi = new Int32[MAXAXI];

            if (CheckAxiX.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 1;

            }

            if (CheckAxiY.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 2;

            }

            if (CheckAxiZ.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 3;

            }

            if (CheckAxiA.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 4;

            }


            //获取最小轴号信息
            m_SelectInfo.MinAxi = 100;

            for (int i = 0; i < m_SelectInfo.AxiNo; i  )
            {
                if (m_SelectInfo.selectAxi[i] < m_SelectInfo.MinAxi)
                {
                    m_SelectInfo.MinAxi = m_SelectInfo.selectAxi[i];
                }
            }

        }

        //启用手轮
        private void CheckManual_CheckedChanged(object sender, EventArgs e)
        {
            if (!manual)//禁用手轮驱动
            {
                CheckManual.Text = "启用手动驱动";
                manual = true;
                for (int i = 1; i <= MAXAXI; i  )
                {
                    Demo.adt8948A1m.adt8948_manual_disable(CtrlCard.g_cardIndex, i);
                }

            }

            else//启用手轮驱动
            {
                CheckManual.Text = "禁用手动驱动";
                manual = false;
                if (m_bManualContinue.Checked == true)//手动连续
                {
                    ManulCmove();
                }
                else
                {
                    ManulPmove();
                }
            }
        }

        //手轮驱动函数
        public void ManulPmove()
        {
            RefreshSelectInfo();

            if (CheckAxiX.Checked == true)
            {
                g_CtrlCard.Setup_Speed(1, m_nStartv[0], m_nSpeed[0], m_nAcc[0], m_nDec[0], m_nRatio[0],m_addmode);//设置速度
                g_CtrlCard.Manu_Pmove(1, m_nPulse[0]);//发送脉冲

            }
            if (CheckAxiY.Checked == true)
            {
                g_CtrlCard.Setup_Speed(2, m_nStartv[1], m_nSpeed[1], m_nAcc[1], m_nDec[1], m_nRatio[1], m_addmode);//设置速度
                g_CtrlCard.Manu_Pmove(2, m_nPulse[1]);//发送脉冲

            }
            if (CheckAxiZ.Checked == true)
            {
                g_CtrlCard.Setup_Speed(3, m_nStartv[2], m_nSpeed[2], m_nAcc[2], m_nDec[2], m_nRatio[2], m_addmode);//设置速度
                g_CtrlCard.Manu_Pmove(3, m_nPulse[2]);//发送脉冲

            }
            if (CheckAxiA.Checked == true)
            {
                g_CtrlCard.Setup_Speed(4, m_nStartv[3], m_nSpeed[3], m_nAcc[3], m_nDec[3], m_nRatio[3], m_addmode);//设置速度
                g_CtrlCard.Manu_Pmove(4, m_nPulse[3]);//发送脉冲

            }

        }

        //手轮连续运动函数
        public void ManulCmove()
        {
            RefreshSelectInfo();

            if (CheckAxiX.Checked == true)
            {
                g_CtrlCard.Setup_Speed(1, m_nStartv[0], m_nSpeed[0], m_nAcc[0], m_nDec[0], m_nRatio[0], m_addmode);//设置速度
                g_CtrlCard.Manu_Continue(1);//连续运动

            }
            if (CheckAxiY.Checked == true)
            {
                g_CtrlCard.Setup_Speed(2, m_nStartv[1], m_nSpeed[1], m_nAcc[1], m_nDec[1], m_nRatio[1], m_addmode);//设置速度
                g_CtrlCard.Manu_Continue(2);//连续运动

            }
            if (CheckAxiZ.Checked == true)
            {
                g_CtrlCard.Setup_Speed(3, m_nStartv[2], m_nSpeed[2], m_nAcc[2], m_nDec[2], m_nRatio[2], m_addmode);//设置速度
                g_CtrlCard.Manu_Continue(3);//连续运动

            }
            if (CheckAxiA.Checked == true)
            {
                g_CtrlCard.Setup_Speed(4, m_nStartv[3], m_nSpeed[3], m_nAcc[3], m_nDec[3], m_nRatio[3], m_addmode);//设置速度
                g_CtrlCard.Manu_Continue(4);//连续运动

            }

        }

        //启动
        private void Start_Click(object sender, EventArgs e)
        {
            if (Pmove.Checked == true)
            {
                Motion_Pmove();//联动
            }

            if (Cmove.Checked == true)
            {
                Motion_Cmove();//连续运动
            }

            if (LineInp.Checked == true)
            {
                Motion_LineInp();//插补
            }

            if (ArcInp.Checked == true)
            {
                Motion_ArcInp();//圆弧插补
            }

            if (CInp.Checked == true)
            {
                Motion_CInp();//连续插补
            }

        }

        //联动函数
        public void Motion_Pmove()
        {
            RefreshSelectInfo();

            if (CheckAxiX.Checked == true)
            {
                g_CtrlCard.Setup_Speed(1, m_nStartv[0], m_nSpeed[0], m_nAcc[0], m_nDec[0], m_nRatio[0], m_addmode);//设置速度
                g_CtrlCard.Axis_Pmove(1, m_nPulse[0]);//发送脉冲

            }
            if (CheckAxiY.Checked == true)
            {
                g_CtrlCard.Setup_Speed(2, m_nStartv[1], m_nSpeed[1], m_nAcc[1], m_nDec[1], m_nRatio[1], m_addmode);//设置速度
                g_CtrlCard.Axis_Pmove(2, m_nPulse[1]);//发送脉冲

            }
            if (CheckAxiZ.Checked == true)
            {
                g_CtrlCard.Setup_Speed(3, m_nStartv[2], m_nSpeed[2], m_nAcc[2], m_nDec[2], m_nRatio[2], m_addmode);//设置速度
                g_CtrlCard.Axis_Pmove(3, m_nPulse[2]);//发送脉冲

            }
            if (CheckAxiA.Checked == true)
            {
                g_CtrlCard.Setup_Speed(4, m_nStartv[3], m_nSpeed[3], m_nAcc[3], m_nDec[3], m_nRatio[3], m_addmode);//设置速度
                g_CtrlCard.Axis_Pmove(4, m_nPulse[3]);//发送脉冲

            }


        }

        //连续运动函数
        public void Motion_Cmove()
        {
            RefreshSelectInfo();

            if (CheckAxiX.Checked == true)
            {
                g_CtrlCard.Setup_Speed(1, m_nStartv[0], m_nSpeed[0], m_nAcc[0], m_nDec[0], m_nRatio[0], m_addmode);//设置速度
                g_CtrlCard.Axis_Cmove(1, 0);//连续运动

            }
            if (CheckAxiY.Checked == true)
            {
                g_CtrlCard.Setup_Speed(2, m_nStartv[1], m_nSpeed[1], m_nAcc[1], m_nDec[1], m_nRatio[1], m_addmode);//设置速度
                g_CtrlCard.Axis_Cmove(2, 0);//连续运动

            }
            if (CheckAxiZ.Checked == true)
            {
                g_CtrlCard.Setup_Speed(3, m_nStartv[2], m_nSpeed[2], m_nAcc[2], m_nDec[2], m_nRatio[2], m_addmode);//设置速度
                g_CtrlCard.Axis_Cmove(3, 0);//连续运动

            }
            if (CheckAxiA.Checked == true)
            {
                g_CtrlCard.Setup_Speed(4, m_nStartv[3], m_nSpeed[3], m_nAcc[3], m_nDec[3], m_nRatio[3], m_addmode);//设置速度
                g_CtrlCard.Axis_Cmove(4, 0);//连续运动

            }

        }

        //直线插补函数
        public void Motion_LineInp()
        {

            RefreshSelectInfo();

            Int32 axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2:
                    g_CtrlCard.Setup_Speed(axi, m_nStartv[axi - 1], m_nSpeed[axi - 1], m_nAcc[axi - 1], m_nDec[axi - 1], m_nRatio[axi - 1], m_addmode);//设置速度
                    g_CtrlCard.Interp_Move2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_nPulse[0], m_nPulse[1]);
                    break;

                case 3:
                    g_CtrlCard.Setup_Speed(axi, m_nStartv[axi - 1], m_nSpeed[axi - 1], m_nAcc[axi - 1], m_nDec[axi - 1], m_nRatio[axi - 1], m_addmode);//设置速度
                    g_CtrlCard.Interp_Move3(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_nPulse[0], m_nPulse[1], m_nPulse[2]);
                    break;

                default:
                    MessageBox.Show("请选择正确的插补轴!", "提示");
                    break;

            }

        }

        //圆弧插补函数
        public void Motion_ArcInp()
        {

            RefreshSelectInfo();

            Int32 Value;

            //在这里说明:圆弧插补只能用手动的直线加/减速驱动,不能使用S曲线加/减速驱动以及自动减速
            if (m_addmode == 2)
            {
                MessageBox.Show("不能选择S曲线加减速类型!", "提示");
                return;
            }

            Int32 axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2:
                g_CtrlCard.Setup_Speed(axi, m_nStartv[axi - 1], m_nSpeed[axi - 1], m_nAcc[axi - 1], m_nDec[axi - 1], m_nRatio[axi - 1], m_addmode);//设置速度
                if(m_nStartv[axi - 1] < m_nSpeed[axi - 1])
                {
                    g_CtrlCard.Set_DecMode(axi, 0, 1);   //中间的0:对称加减速  后面的1:说明是手动减速
                }

                //两轴圆弧加速度的脉冲数:先算出短轴每象限的脉冲数,这样乘8就能算出整个圆的脉冲数

               Value = Convert.ToInt32((System.Math.Sqrt(m_nPulse[0] * m_nPulse[0]   m_nPulse[1] * m_nPulse[1]) / 1.414) * 8);

               g_CtrlCard.Set_DecPos(axi, Value, m_nStartv[axi - 1], m_nSpeed[axi - 1], m_nAcc[axi - 1]);

               g_CtrlCard.Interp_Arc(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], 0, 0, m_nPulse[0], m_nPulse[1]);        //顺时针CW圆弧插补函数(0, 0,)表示圆弧插补的终点位置,后面是圆心位置

               break;

            default:
                MessageBox.Show("请选择正确的插补轴!", "提示");
                break;
            
            }

        }

        //连续插补函数
        public void Motion_CInp()
        {

            RefreshSelectInfo();

            Int32 nstate1, nstate2, axi;

            if (m_addmode == 2)
            {
                MessageBox.Show("不能选择S曲线加减速类型!", "提示");
                return;
            }

            axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2:
                    g_CtrlCard.Setup_Speed(axi, m_nStartv[axi - 1], m_nSpeed[axi - 1], m_nAcc[axi - 1], m_nDec[axi - 1], m_nRatio[axi - 1], m_addmode);//设置速度
                    g_CtrlCard.Set_DecMode(axi, 0, 1);   //中间的0:对称加减速  后面的1:说明是手动减速
                    g_CtrlCard.Set_DecPos(axi, m_nPulse[axi - 1] / 4, m_nStartv[axi - 1], m_nSpeed[axi - 1], m_nAcc[axi - 1]);
                    g_CtrlCard.ForbidDec();
                    //-----------------第一段----------------
                    g_CtrlCard.Interp_Move2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_nPulse[0] / 4, m_nPulse[1] / 4);
                    while (true)
                    {
                        if (m_StopFlag)
                        {
                            m_StopFlag = false;
                            return;
                        }
                        g_CtrlCard.Get_ErrorInf(m_SelectInfo.selectAxi[0], out nstate1);          //nstate1错误状态的指针  为0时就说明没有错误
                        if (nstate1 != 0)
                        {
                            goto err;
                        }
                        g_CtrlCard.Get_AllowInpStatus(out nstate2);   // nstate2:   0:不允许写入    1:允许写入
                        if (nstate2 != 0)
                        {
                            break;
                        }
                        System.Threading.Thread.Sleep(1000);
                        Application.DoEvents();
                    }
                    //-----------------第二段----------------
                    g_CtrlCard.Interp_Move2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_nPulse[0] / 4, m_nPulse[1] / 4);
                    while (true)
                    {
                        if (m_StopFlag)
                        {
                            m_StopFlag = false;
                            return;
                        }
                        g_CtrlCard.Get_ErrorInf(m_SelectInfo.selectAxi[0], out nstate1);          //nstate1错误状态的指针  为0时就说明没有错误
                        if (nstate1 != 0)
                        {
                            goto err;
                        }
                        g_CtrlCard.Get_AllowInpStatus(out nstate2);   // nstate2:   0:不允许写入    1:允许写入
                        if (nstate2 != 0)
                        {
                            break;
                        }
                        Application.DoEvents();
                    }
                    //-----------------第三段----------------
                    g_CtrlCard.Interp_Move2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_nPulse[0] / 4, m_nPulse[1] / 4);
                    while (true)
                    {
                        if (m_StopFlag)
                        {
                            m_StopFlag = false;
                            return;
                        }
                        g_CtrlCard.Get_ErrorInf(m_SelectInfo.selectAxi[0], out nstate1);          //nstate1错误状态的指针  为0时就说明没有错误
                        if (nstate1 != 0)
                        {
                            goto err;
                        }
                        g_CtrlCard.Get_AllowInpStatus(out nstate2);   // nstate2:   0:不允许写入    1:允许写入
                        if (nstate2 != 0)
                        {
                            break;
                        }
                        Application.DoEvents();
                    }
                    //-------------最后一段------------------
                    g_CtrlCard.AllowDec();

                    g_CtrlCard.Interp_Move2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_nPulse[0] / 4, m_nPulse[1] / 4);
                    while (true)
                    {
                        if (m_StopFlag)
                        {
                            m_StopFlag = false;
                            return;
                        }
                        g_CtrlCard.Get_ErrorInf(m_SelectInfo.selectAxi[0], out nstate1);          //nstate1错误状态的指针  为0时就说明没有错误
                        if (nstate1 != 0)
                        {
                            goto err;
                        }
                        g_CtrlCard.Get_AllowInpStatus(out nstate2);   // nstate2:   0:不允许写入    1:允许写入
                        if (nstate2 != 0)
                        {
                            return;
                        }
                        Application.DoEvents();
                    }
                err:
                    MessageBox.Show("error", "提示");
                    break;
                default:
                    MessageBox.Show("请选择正确的插补轴!", "提示");
                    break;

            }
        }

        #endregion

        #region 复合界面代码部分

        //复合运动
        private void BtnStart2_Click(object sender, EventArgs e)
        {
            if (Motion1.Checked == true)   //单轴运动
            {
                if (relative.Checked)//相对运动
                {
                    Axi_RelativeMove();
                }

                else//绝对运动
                {
                    Axi_AbsMove();
                }

            }

            if (Motion2.Checked == true) //插补运动
            {
                if (relative.Checked)//相对运动
                {
                    Inp_RelativeMove();
                }

                else//绝对运动
                {
                    Inp_AbsMove();
                }
            }

            if (Motion3.Checked == true) //圆弧插补运动
            {
                if (relative.Checked)//相对运动
                {
                    Arc_RelativeMove();
                }

                else//绝对运动
                {
                    Arc_AbsMove();
                }
            }
        }

        //刷新复合运动的参数
        public void RefreshPara1()
        {
            m_nStartv1[0] = Convert.ToInt32(this.StartV_X1.Text);
            m_nStartv1[1] = Convert.ToInt32(this.StartV_Y1.Text);
            m_nStartv1[2] = Convert.ToInt32(this.StartV_Z1.Text);
            m_nStartv1[3] = Convert.ToInt32(this.StartV_A1.Text);


            m_nSpeed1[0] = Convert.ToInt32(this.Speed_X1.Text);
            m_nSpeed1[1] = Convert.ToInt32(this.Speed_Y1.Text);
            m_nSpeed1[2] = Convert.ToInt32(this.Speed_Z1.Text);
            m_nSpeed1[3] = Convert.ToInt32(this.Speed_A1.Text);


            m_nTAcc[0] = Convert.ToDouble(this.TAccX.Text);
            m_nTAcc[1] = Convert.ToDouble(this.TAccY.Text);
            m_nTAcc[2] = Convert.ToDouble(this.TAccZ.Text);
            m_nTAcc[3] = Convert.ToDouble(this.TAccA.Text);

            m_nVAcc[0] = Convert.ToInt32(this.VAccX.Text);
            m_nVAcc[1] = Convert.ToInt32(this.VAccY.Text);
            m_nVAcc[2] = Convert.ToInt32(this.VAccZ.Text);
            m_nVAcc[3] = Convert.ToInt32(this.VAccA.Text);

            m_nPulse[0] = Convert.ToInt32(this.PulseX.Text);
            m_nPulse[1] = Convert.ToInt32(this.PulseY.Text);
            m_nPulse[2] = Convert.ToInt32(this.PulseZ.Text);
            m_nPulse[3] = Convert.ToInt32(this.PulseA.Text);

            if (Style1.Checked == true)
            {
                m_moveMode = 0;

            }

            if (Style2.Checked == true)
            {
                m_moveMode = 1;

            }

            if (Dir1.Checked == true)
            {
                m_dir = 0;

            }

            if (Dir2.Checked == true)
            {
                m_dir = 1;

            }

            //初始状态没有轴被选中
            m_SelectInfo.AxiNo = 0;
            m_SelectInfo.selectAxi = new Int32[MAXAXI];

            if (CheckAxiX.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 1;

            }

            if (CheckAxiY.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 2;

            }

            if (CheckAxiZ.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 3;

            }

            if (CheckAxiA.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 4;

            }


            //获取最小轴号信息
            m_SelectInfo.MinAxi = 100;

            for (int i = 0; i < m_SelectInfo.AxiNo; i  )
            {
                if (m_SelectInfo.selectAxi[i] < m_SelectInfo.MinAxi)
                {
                    m_SelectInfo.MinAxi = m_SelectInfo.selectAxi[i];
                }
            }

        }


        //单轴相对运动函数
        public void Axi_RelativeMove()
        {
            RefreshPara1();

            if (CheckAxiX.Checked == true)
            {
                g_CtrlCard.Symmetry_RelativeMove(1, m_nPulse[0], m_nStartv1[0], m_nSpeed1[0], m_nTAcc[0], m_nVAcc[0], m_moveMode);

            }
            if (CheckAxiY.Checked == true)
            {
                g_CtrlCard.Symmetry_RelativeMove(2, m_nPulse[1], m_nStartv1[1], m_nSpeed1[1], m_nTAcc[1], m_nVAcc[1], m_moveMode);

            }
            if (CheckAxiZ.Checked == true)
            {
                g_CtrlCard.Symmetry_RelativeMove(3, m_nPulse[2], m_nStartv1[2], m_nSpeed1[2], m_nTAcc[2], m_nVAcc[2], m_moveMode);

            }
            if (CheckAxiA.Checked == true)
            {
                g_CtrlCard.Symmetry_RelativeMove(4, m_nPulse[3], m_nStartv1[3], m_nSpeed1[3], m_nTAcc[3], m_nVAcc[3], m_moveMode);

            }

        }

        //单轴绝对运动函数
        public void Axi_AbsMove()
        {
            RefreshPara1();

            if (CheckAxiX.Checked == true)
            {
                g_CtrlCard.Symmetry_AbsoluteMove(1, m_nPulse[0], m_nStartv1[0], m_nSpeed1[0], m_nTAcc[0], m_nVAcc[0], m_moveMode);

            }
            if (CheckAxiY.Checked == true)
            {
                g_CtrlCard.Symmetry_AbsoluteMove(2, m_nPulse[1], m_nStartv1[1], m_nSpeed1[1], m_nTAcc[1], m_nVAcc[1], m_moveMode);

            }
            if (CheckAxiZ.Checked == true)
            {
                g_CtrlCard.Symmetry_AbsoluteMove(3, m_nPulse[2], m_nStartv1[2], m_nSpeed1[2], m_nTAcc[2], m_nVAcc[2], m_moveMode);

            }
            if (CheckAxiA.Checked == true)
            {
                g_CtrlCard.Symmetry_AbsoluteMove(4, m_nPulse[3], m_nStartv1[3], m_nSpeed1[3], m_nTAcc[3], m_nVAcc[3], m_moveMode);

            }

        }

        //插补相对运动函数
        public void Inp_RelativeMove()
        {
            RefreshPara1();

            Int32 axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2://两轴插补
                    g_CtrlCard.Symmetry_RelativeLine2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_nPulse[0], m_nPulse[1], m_nStartv1[axi - 1], m_nSpeed1[axi - 1], m_nTAcc[axi - 1], m_nVAcc[axi - 1], m_moveMode);
                    break;

                case 3://三轴插补
                    g_CtrlCard.Symmetry_RelativeLine3(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_nPulse[0], m_nPulse[1], m_nPulse[2], m_nStartv1[axi - 1], m_nSpeed1[axi - 1], m_nTAcc[axi - 1], m_nVAcc[axi - 1], m_moveMode);
                    break;

                default:
                    MessageBox.Show("请选择正确的插补轴!", "提示");
                    break;

            }
        }

        //插补绝对运动函数
        public void Inp_AbsMove()
        {
            RefreshPara1();

            Int32 axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2://两轴插补
                    g_CtrlCard.Symmetry_AbsoluteLine2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_nPulse[0], m_nPulse[1], m_nStartv1[axi - 1], m_nSpeed1[axi - 1], m_nTAcc[axi - 1], m_nVAcc[axi - 1], m_moveMode);
                    break;

                case 3://三轴插补
                    g_CtrlCard.Symmetry_AbsoluteLine3(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_nPulse[0], m_nPulse[1], m_nPulse[2], m_nStartv1[axi - 1], m_nSpeed1[axi - 1], m_nTAcc[axi - 1], m_nVAcc[axi - 1], m_moveMode);
                    break;

                default:
                    MessageBox.Show("请选择正确的插补轴!");
                    break;

            }
        }

        //圆弧相对运动
        public void Arc_RelativeMove()
        {
            RefreshPara1();
            Int32 axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2://两轴插补
                    g_CtrlCard.Symmetry_Relativearc(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1],0, 0, m_nPulse[0], m_nPulse[1], m_dir,m_nStartv1[axi - 1], m_nSpeed1[axi - 1], m_nTAcc[axi - 1], m_nVAcc[axi - 1], m_moveMode);

                    break;
                default:
                    MessageBox.Show("请选择正确的插补轴!");
                    break;

            }
        }

        //圆弧绝对运动
        public void Arc_AbsMove()
        {
            RefreshPara1();
            Int32 axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2://两轴插补
                    g_CtrlCard.Symmetry_AbsoluteArc(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], 0, 0, m_nPulse[0], m_nPulse[1], m_dir, m_nStartv1[axi - 1], m_nSpeed1[axi - 1], m_nTAcc[axi - 1], m_nVAcc[axi - 1], m_moveMode);
                    break;
                default:
                    MessageBox.Show("请选择正确的插补轴!");
                    break;

            }
        }

        #endregion

        #region IO界面代码部分

        //输出全关
        private void BtnAllClose_Click(object sender, EventArgs e)
        {
            CheckBox[] TOutput ={ OUT0, OUT1, OUT2, OUT3, OUT4, OUT5, OUT6, OUT7, OUT8, OUT9, OUT10, OUT11, OUT12, OUT13, OUT14, OUT15, OUT16, OUT17, OUT18, OUT19, OUT20, OUT21, OUT22, OUT23, OUT24, OUT25, OUT26, OUT27, OUT28, OUT29, OUT30, OUT31 };
            int i;

            for (i = 0; i <= MaxOUT; i  )
            {
                TOutput[i].Checked = false;
                g_CtrlCard.Write_Output(i, 0); //关闭输出
            }
        }

        //输出全开
        private void BtnAllOpen_Click(object sender, EventArgs e)
        {
            CheckBox[] TOutput ={ OUT0, OUT1, OUT2, OUT3, OUT4, OUT5, OUT6, OUT7, OUT8, OUT9, OUT10, OUT11, OUT12, OUT13, OUT14, OUT15, OUT16, OUT17, OUT18, OUT19, OUT20, OUT21, OUT22, OUT23, OUT24, OUT25, OUT26, OUT27, OUT28, OUT29, OUT30, OUT31 };
            int i;

            for (i = 0; i <= MaxOUT; i  )
            {
                TOutput[i].Checked = true;
                g_CtrlCard.Write_Output(i, 1); //打开输出
            }
        }

        //输入检测函数
        public void CheckInput()
        {
            CheckBox[] TInput = { INO, IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, IN9, IN10, IN11, IN12, IN13, IN14, IN15, IN16, IN17, IN18, IN19, IN20, IN21, IN22, IN23, IN24, IN25, IN26, IN27, IN28, IN29, IN30, IN31, IN32, IN33, IN34 };
            int Value, i;

            for (i = 0; i <= MaxIN; i  )
            {
                Value = g_CtrlCard.Read_Input(i);                         //读取输入点
                if (Value == 0)
                {
                    TInput[i].Checked = true;
                }
                else
                {
                    TInput[i].Checked = false;
                }
            }

        }
        //输出检测函数
        public void CheckOutput()
        {
            CheckBox[] TOutput ={ OUT0, OUT1, OUT2, OUT3, OUT4, OUT5, OUT6, OUT7, OUT8, OUT9, OUT10, OUT11, OUT12, OUT13, OUT14, OUT15, OUT16, OUT17, OUT18, OUT19, OUT20, OUT21, OUT22, OUT23, OUT24, OUT25, OUT26, OUT27, OUT28, OUT29, OUT30, OUT31 };
            int i;


            for (i = 0; i <= MaxOUT; i  )
            {
                if (TOutput[i].Checked == true)
                {
                    g_CtrlCard.Write_Output(i, 1);
                }
                else
                {
                    g_CtrlCard.Write_Output(i, 0);
                }
            }

        }

        //IO定时器
        private void Timer2_Tick(object sender, EventArgs e)
        {
            CheckOutput();
            CheckInput();
        }

        //进入IO界面时打开IO计时器
        private void TabPage6_Enter(object sender, EventArgs e)
        {
            Timer2.Enabled = true;
        }

        //离开IO界面的时候关闭IO计时器
        private void TabPage6_Leave(object sender, EventArgs e)
        {
            Timer2.Enabled = false;
        }

        #endregion

        #region 位置锁存界面代码部分
        private void BtnLockMode_Click(object sender, EventArgs e)
        {
            for (int i = 1; i <= MAXAXI; i  )
            {
                g_CtrlCard.Setup_LockPosition(i, Convert.ToInt32((RLAct.Checked)), Convert.ToInt32((RLHigh.Checked)));
            }
            MessageBox.Show("设置成功!", "提示");
        }

        private void BtnLockPos_Click(object sender, EventArgs e)
        {
            int status = 0;
            int[] pos = new int[MAXAXI];

            if (RLSignalX.Checked == true)
            {
                g_CtrlCard.Get_LockStatus(1, out status);
            }
            if (RLSignalY.Checked == true)
            {
                g_CtrlCard.Get_LockStatus(2, out status);
            }
            if (RLSignalZ.Checked == true)
            {
                g_CtrlCard.Get_LockStatus(3, out status);
            }
            if (RLSignalA.Checked == true)
            {
                g_CtrlCard.Get_LockStatus(4, out status);
            }

            for (int i = 1; i <= MAXAXI; i  )
            {
                if (status == 1)
                {
                    g_CtrlCard.Get_LockPosition(i, out pos[i - 1]);
                }
            }

            MessageBox.Show("锁存的位置  "   "  X:"   Convert.ToString(pos[0])   "  Y:"   Convert.ToString(pos[1])   "  Z:"   Convert.ToString(pos[2])   "  A:"   Convert.ToString(pos[3]));

        }

        #endregion

        #region 参数界面代码部分

        //更新参数
        public void RefreshParaSet()
        {
            if (pulseMode1.Checked)
            {
                m_para[g_AxiNo - 1].m_pulsemode = 0;//脉冲 脉冲
            }
            else
            {
                m_para[g_AxiNo - 1].m_pulsemode = 1;//脉冲 方向
            }        

            if (LimitP1.Checked)
            {
                m_para[g_AxiNo - 1].m_Lmtdp = 0;//限位低电平有效
            }
            else
            {
                m_para[g_AxiNo - 1].m_Lmtdp = 1;//限位高电平有效
            }

            if (Stop01.Checked)
            {
                m_para[g_AxiNo - 1].m_Stop0effective = 0;//Stop0无效
            }
            else
            {
                m_para[g_AxiNo - 1].m_Stop0effective = 1;//Stop0有效
            }

            if (Stop02.Checked)
            {
                m_para[g_AxiNo - 1].m_Stop0dp = 0;//Stop0低电平有效
            }
            if (Stop03.Checked)
            {
                m_para[g_AxiNo - 1].m_Stop0dp = 1;//Stop0高电平有效
            }

            if (Stop11.Checked)
            {
                m_para[g_AxiNo - 1].m_Stop1effective = 0;//Stop1无效
            }
            else
            {
                m_para[g_AxiNo - 1].m_Stop1effective = 1;//Stop1有效
            }

            if (Stop12.Checked)
            {
                m_para[g_AxiNo - 1].m_Stop1dp = 0;//Stop1低电平有效
            }
            if (Stop13.Checked)
            {
                m_para[g_AxiNo - 1].m_Stop1dp = 1;//Stop1高电平有效
            }

            if (Stop21.Checked)
            {
                m_para[g_AxiNo - 1].m_Stop2effective = 0;//Stop2无效
            }
            else
            {
                m_para[g_AxiNo - 1].m_Stop2effective = 1;//Stop2有效
            }

            if (Stop22.Checked)
            {
                m_para[g_AxiNo - 1].m_Stop2dp = 0;//Stop2低电平有效
            }
            if (Stop23.Checked)
            {
                m_para[g_AxiNo - 1].m_Stop2dp = 1;//Stop2高电平有效
            }

            if (Circle1.Checked)
            {
                m_para[g_AxiNo - 1].m_Circleeffective = 0;//可变环形无效
            }
            else
            {
                m_para[g_AxiNo - 1].m_Circleeffective = 1;//可变环形有效
            }           

            if (Inpos1.Checked)
            {
                m_para[g_AxiNo - 1].m_Inposeffective = 0;//到位信号无效
            }
            else
            {
                m_para[g_AxiNo - 1].m_Inposeffective = 1;//到位信号有效
            }

            if (Inpos2.Checked)
            {
                m_para[g_AxiNo - 1].m_Inposdp = 0;//到位信号低电平有效
            }
            if (Inpos3.Checked)
            {
                m_para[g_AxiNo - 1].m_Inposdp = 1;//到位信号高电平有效
            }

            if (Alarm1.Checked)
            {
                m_para[g_AxiNo - 1].m_Alarmeffective = 0;//报警信号无效
            }
            else
            {
                m_para[g_AxiNo - 1].m_Alarmeffective = 1;//报警信号有效
            }

            if (Alarm2.Checked)
            {
                m_para[g_AxiNo - 1].m_Alarmdp = 0;//报警信号低电平有效
            }
            if (Alarm3.Checked)
            {
                m_para[g_AxiNo - 1].m_Alarmdp = 1;//报警信号高电平有效
            }

            m_nRatio[g_AxiNo - 1] = Convert.ToInt32(BeiLv.Text);


        }

        public void LoadParaEx()
        {
            if (m_para[g_AxiNo - 1].m_pulsemode == 1)
            {
                pulseMode2.Checked = true;
            }
            else
            {
                pulseMode1.Checked = true;
            }


            if (m_para[g_AxiNo - 1].m_Lmtdp == 0)
            {
                LimitP1.Checked = true;
            }
            else
            {
                LimitP2.Checked = true;
           }
            

            if (m_para[g_AxiNo - 1].m_Stop0effective == 0)
            {
                Stop01.Checked = true;
            }
            else
            {
                if (m_para[g_AxiNo - 1].m_Stop0dp == 0)
                {
                    Stop02.Checked = true;
                }
                else
                {
                    Stop03.Checked = true;
                }
            }

            if (m_para[g_AxiNo - 1].m_Stop1effective == 0)
            {
                Stop11.Checked = true;
            }
            else
            {
                if (m_para[g_AxiNo - 1].m_Stop1dp == 0)
                {
                    Stop12.Checked = true;
                }
                else
                {
                    Stop13.Checked = true;
                }
            }

            if (m_para[g_AxiNo - 1].m_Stop2effective == 0)
            {
                Stop21.Checked = true;
            }
            else
            {
                if (m_para[g_AxiNo - 1].m_Stop2dp == 0)
                {
                    Stop22.Checked = true;
                }
                else
                {
                    Stop23.Checked = true;
                }
            }

            if (m_para[g_AxiNo - 1].m_Circleeffective == 0)
            {
                Circle1.Checked = true;
            }
            else
            {
                
                Circle2.Checked = true;
               
            }

            if (m_para[g_AxiNo - 1].m_Inposeffective == 0)
            {
                Inpos1.Checked = true;
            }
            else
            {
                if (m_para[g_AxiNo - 1].m_Inposdp == 0)
                {
                    Inpos2.Checked = true;
                }
                else
                {
                    Inpos3.Checked = true;
                }
            }

            if (m_para[g_AxiNo - 1].m_Alarmeffective == 0)
            {
                Alarm1.Checked = true;
            }
            else
            {
                if (m_para[g_AxiNo - 1].m_Alarmdp == 0)
                {
                    Alarm2.Checked = true;
                }
                else
                {
                    Alarm3.Checked = true;
                }
            }

            BeiLv.Text = Convert.ToString(m_nRatio[g_AxiNo - 1]);

        }

        private void BtnSure_Click(object sender, EventArgs e)
        {
            RefreshParaSet();

            g_CtrlCard.Setup_PulseMode(g_AxiNo, m_para[g_AxiNo - 1].m_pulsemode);
            g_CtrlCard.Setup_LimitMode(g_AxiNo, 0, m_para[g_AxiNo - 1].m_Lmtdp);

            g_CtrlCard.Setup_Stop0Mode(g_AxiNo, m_para[g_AxiNo - 1].m_Stop0effective, m_para[g_AxiNo - 1].m_Stop0dp);
            g_CtrlCard.Setup_Stop1Mode(g_AxiNo, m_para[g_AxiNo - 1].m_Stop1effective, m_para[g_AxiNo - 1].m_Stop1dp);
            g_CtrlCard.Setup_Stop2Mode(g_AxiNo, m_para[g_AxiNo - 1].m_Stop2effective, m_para[g_AxiNo - 1].m_Stop2dp);
            g_CtrlCard.Setup_AlarmMode(g_AxiNo, m_para[g_AxiNo - 1].m_Alarmeffective, m_para[g_AxiNo - 1].m_Alarmdp);
            g_CtrlCard.SetCircle_Mode(g_AxiNo, m_para[g_AxiNo - 1].m_Circleeffective);
            g_CtrlCard.Inpos_Mode(g_AxiNo, m_para[g_AxiNo - 1].m_Inposeffective, m_para[g_AxiNo - 1].m_Inposdp);
            adt8948A1m.adt8948_set_range(CtrlCard.g_cardIndex, g_AxiNo, 8000000 / m_nRatio[g_AxiNo - 1]);
            MessageBox.Show("设置成功!", "提示");
        }

        //索引轴改变
        private void AxiIndex_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (AxiIndex.Text == "X轴")
            {
                g_AxiNo = 1;
                LoadParaEx();
            }

            if (AxiIndex.Text == "Y轴")
            {
                g_AxiNo = 2;
                LoadParaEx();
            }

            if (AxiIndex.Text == "Z轴")
            {
                g_AxiNo = 3;
                LoadParaEx();
            }

            if (AxiIndex.Text == "A轴")
            {
                g_AxiNo = 4;
                LoadParaEx();

            }
        }

        //进入Tab5界面就刷新当前参数
        private void TabPage5_Enter(object sender, EventArgs e)
        {
            LoadParaEx();
        }

        #endregion

        #region 特殊运动界面代码部分

        //参数刷新
        public void RefreshParaSpe()
        {
            m_SpePulse[0] = Convert.ToInt32(this.EPX.Text);
            m_SpePulse[1] = Convert.ToInt32(this.EPY.Text);
            m_SpePulse[2] = Convert.ToInt32(this.EPZ.Text);
            m_SpePulse[3] = Convert.ToInt32(this.EPA.Text);

            if (Rcomp1.Checked == true)
            {
                m_reg = 0;

            }

            if (Rcomp2.Checked == true)
            {
                m_reg = 1;

            }

            if (RBig.Checked == true)
            {
                m_relation = 0;

            }

            if (RSmall.Checked == true)
            {
                m_relation = 1;

            }

            if (RMainStop.Checked == true)
            {
                m_mainAxiKeep = 0;

            }

            if (RMainKeep.Checked == true)
            {
                m_mainAxiKeep = 1;

            }

            if (RMoveKeep.Checked == true)
            {
                m_SignalStatus = 0;

            }

            if (RMovePulse.Checked == true)
            {
                m_SignalStatus = 1;

            }

            if (RMStop.Checked == true)
            {
                m_mainAxiStatus = 0;

            }

            if (RMKeep.Checked == true)
            {
                m_mainAxiStatus = 1;

            }

            //初始状态没有轴被选中
            m_SelectInfo.AxiNo = 0;
            m_SelectInfo.selectAxi = new Int32[MAXAXI];

            if (m_bX.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 1;

            }

            if (m_bY.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 2;

            }

            if (m_bZ.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 3;

            }

            if (m_bA.Checked == true)
            {
                m_SelectInfo.AxiNo  = 1;
                m_SelectInfo.selectAxi[m_SelectInfo.AxiNo - 1] = 4;

            }


            //获取最小轴号信息
            m_SelectInfo.MinAxi = 100;

            for (int i = 0; i < m_SelectInfo.AxiNo; i  )
            {
                if (m_SelectInfo.selectAxi[i] < m_SelectInfo.MinAxi)
                {
                    m_SelectInfo.MinAxi = m_SelectInfo.selectAxi[i];
                }
            }
        }

        //位置比较运动
        private void BtnCmpMove_Click(object sender, EventArgs e)
        {
             //刷新各运动参数
             RefreshParaSpe();
             Int32 axi; 
             axi = m_SelectInfo.MinAxi;

             switch (m_SelectInfo.AxiNo)
             {
             case 2:
                 g_CtrlCard.Setup_Pmove1(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SpePulse[0], m_SpePulse[1], m_reg, m_relation);
             break;

             case 3:
                 g_CtrlCard.Setup_Pmove2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_SpePulse[0], m_SpePulse[1], m_SpePulse[2], m_reg, m_relation);
                 break;

             case 4:
                 g_CtrlCard.Setup_Pmove3(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_SelectInfo.selectAxi[3], m_SpePulse[0], m_SpePulse[1], m_SpePulse[2], m_SpePulse[3], m_reg, m_relation);
                 break;
             
             }
       
        }

        //位置比较停止
        private void BtnCmpStop_Click(object sender, EventArgs e)
        {
            RefreshParaSpe();
            //刷新各运动参数
            RefreshParaSpe();
            Int32 axi;
            axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2:
                    g_CtrlCard.Setup_Stop1(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SpePulse[0], m_reg, m_relation, m_mainAxiKeep);
                    break;

                case 3:
                    g_CtrlCard.Setup_Stop2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_SpePulse[0], m_reg, m_relation, m_mainAxiKeep);
                    break;

                case 4:
                    g_CtrlCard.Setup_Stop3(m_SelectInfo.selectAxi[0], m_SpePulse[0], m_reg, m_relation, m_mainAxiKeep);
                    break;

            }
        }

        //信号式随动
        private void BtnInMove_Click(object sender, EventArgs e)
        {
            //刷新各运动参数
            RefreshParaSpe();
            Int32 axi;
            axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2:
                    g_CtrlCard.Set_InMove1(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SpePulse[0], m_SpePulse[1],0, m_SignalStatus);
                    break;

                case 3:
                    g_CtrlCard.Set_InMove2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_SpePulse[0], m_SpePulse[1], m_SpePulse[2],  0, m_SignalStatus);
                    break;

                case 4:
                    g_CtrlCard.Set_InMove3(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_SelectInfo.selectAxi[3], m_SpePulse[0], m_SpePulse[1], m_SpePulse[2], m_SpePulse[3], 0, m_SignalStatus);
                    break;

            }
        }

        //信号式随停
        private void BtnInStop_Click(object sender, EventArgs e)
        {
            RefreshParaSpe();
            //刷新各运动参数
            RefreshParaSpe();
            Int32 axi;
            axi = m_SelectInfo.MinAxi;

            switch (m_SelectInfo.AxiNo)
            {
                case 2:
                    g_CtrlCard.Set_InStop1(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], 0, m_mainAxiStatus);
                    break;

                case 3:
                    g_CtrlCard.Set_InStop2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], 0, m_mainAxiStatus);
                    break;

                case 4:
                    g_CtrlCard.Set_InStop3(m_SelectInfo.selectAxi[0], 0, m_mainAxiStatus);
                    break;

            }
        }

        //步进单步命令
        private void BtnStepCmd_Click(object sender, EventArgs e)
        {
            g_CtrlCard.Inp_StepMove();
        }

        //步进插补
        private void BtnInpStep_Click(object sender, EventArgs e)
        {
            //刷新各运动参数
            RefreshParaSpe();
            Int32 axi;
            axi = m_SelectInfo.MinAxi;
            if (CSignalMode.Checked == true)
            {
                switch (m_SelectInfo.AxiNo)
                {
                    case 2:
                        g_CtrlCard.Inp_Signal2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SpePulse[0], m_SpePulse[1]);
                        break;

                    case 3:
                        g_CtrlCard.Inp_Signal3(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_SpePulse[0], m_SpePulse[1], m_SpePulse[2]);
                        break;

                    default:
                        MessageBox.Show("请选择正确的插补轴!");
                        break;     

                }
            }
            else
            {
                switch (m_SelectInfo.AxiNo)
                {
                    case 2:
                        g_CtrlCard.Inp_Command2(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SpePulse[0], m_SpePulse[1]);
                        break;

                    case 3:
                        g_CtrlCard.Inp_Command3(m_SelectInfo.selectAxi[0], m_SelectInfo.selectAxi[1], m_SelectInfo.selectAxi[2], m_SpePulse[0], m_SpePulse[1], m_SpePulse[2]);
                        break;

                    default:
                        MessageBox.Show("请选择正确的插补轴!");
                        break; 

                }
            }
            
        }

        //步进插补停止
        private void BtnStepStop_Click(object sender, EventArgs e)
        {
         
            for(int i=1;i<MAXAXI 1;i  )
            {
                g_CtrlCard.Inp_Stop(i);
            
            }
        }

        #endregion

        #region 回原点界面代码部分

        //改变轴号后加载数据
        public void LoadZeroParaEx()
        {

            if (m_ZeroPara[g_ZeroAxi - 1].m_dir == 1)//方向
            {
                ZeroDir2.Checked = true;
            }
            else
            {
                ZeroDir1.Checked = true;
            }

            if (m_ZeroPara[g_ZeroAxi - 1].m_stop0 == 1)//stop0
            {
                ZeroStop02.Checked = true;
            }
            else
            {
                ZeroStop01.Checked = true;
            }

            if (m_ZeroPara[g_ZeroAxi - 1].m_lmt == 1)//Lmt
            {
                ZeroLmt2.Checked = true;
            }
            else
            {
                ZeroLmt1.Checked = true;
            }

            if (m_ZeroPara[g_ZeroAxi - 1].m_stop1 == -1)//stop1
            {
                ZeroStop11.Checked = true;
            }
            else if (m_ZeroPara[g_ZeroAxi - 1].m_stop1 == 0)
            {
                ZeroStop12.Checked = true;
            }
            else
            {

                ZeroStop13.Checked = true;
            }

            ZeroAcc.Text = Convert.ToString(m_ZeroPara[g_ZeroAxi - 1].m_Acc);
            ZeroStartV.Text = Convert.ToString(m_ZeroPara[g_ZeroAxi - 1].m_StartV);
            ZeroSearchV.Text = Convert.ToString(m_ZeroPara[g_ZeroAxi - 1].m_SearchV);
            ZeroHomeSpeed.Text = Convert.ToString(m_ZeroPara[g_ZeroAxi - 1].m_Speed);
            ZeroZspeed.Text = Convert.ToString(m_ZeroPara[g_ZeroAxi - 1].m_ZSpeed);
            ZeroBackRange.Text = Convert.ToString(m_ZeroPara[g_ZeroAxi - 1].m_bkRange);
            ZeroZRange.Text = Convert.ToString(m_ZeroPara[g_ZeroAxi - 1].m_ZRange);
            ZeroOff.Text = Convert.ToString(m_ZeroPara[g_ZeroAxi - 1].m_Off);

        }

        //回零轴号切换
        private void ZeroAxi_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ZeroAxi.Text == "X轴")
            {
                g_ZeroAxi = 1;
                LoadZeroParaEx();
            }

            if (ZeroAxi.Text == "Y轴")
            {
                g_ZeroAxi = 2;
                LoadZeroParaEx();
            }

            if (ZeroAxi.Text == "Z轴")
            {
                g_ZeroAxi = 3;
                LoadZeroParaEx();
            }

            if (ZeroAxi.Text == "A轴")
            {
                g_ZeroAxi = 4;
                LoadZeroParaEx();

            }
        }

        //当前轴参数生效
        private void button1_Click(object sender, EventArgs e)
        {
            if (ZeroDir1.Checked)
            {
                m_ZeroPara[g_ZeroAxi - 1].m_dir = 0;//负向
            }
            else
            {
                m_ZeroPara[g_ZeroAxi - 1].m_dir = 1;//正向
            }

            if (ZeroStop01.Checked)
            {
                m_ZeroPara[g_ZeroAxi - 1].m_stop0 = 0;//低电平有效
            }
            else
            {
                m_ZeroPara[g_ZeroAxi - 1].m_stop0 = 1;//高电平有效
            }

            if (ZeroLmt1.Checked)
            {
                m_ZeroPara[g_ZeroAxi - 1].m_lmt = 0;//低电平停止
            }
            else
            {
                m_ZeroPara[g_ZeroAxi - 1].m_lmt = 1;//高电平停止
            }

            if (ZeroStop11.Checked)
            {
                m_ZeroPara[g_ZeroAxi - 1].m_stop1 = -1;//无效
            }
            if (ZeroStop12.Checked)
            {
                m_ZeroPara[g_ZeroAxi - 1].m_stop1 = 0;//低电平有效
            }
            if (ZeroStop13.Checked)
            {
                m_ZeroPara[g_ZeroAxi - 1].m_stop1 = 1;//高电平有效
            }

            m_ZeroPara[g_ZeroAxi - 1].m_Acc = Convert.ToInt32(ZeroAcc.Text);
            m_ZeroPara[g_ZeroAxi - 1].m_StartV = Convert.ToInt32(ZeroStartV.Text);
            m_ZeroPara[g_ZeroAxi - 1].m_SearchV = Convert.ToInt32(ZeroSearchV.Text);
            m_ZeroPara[g_ZeroAxi - 1].m_Speed = Convert.ToInt32(ZeroHomeSpeed.Text);
            m_ZeroPara[g_ZeroAxi - 1].m_ZSpeed = Convert.ToInt32(ZeroZspeed.Text);
            m_ZeroPara[g_ZeroAxi - 1].m_bkRange = Convert.ToInt32(ZeroBackRange.Text);
            m_ZeroPara[g_ZeroAxi - 1].m_ZRange = Convert.ToInt32(ZeroZRange.Text);
            m_ZeroPara[g_ZeroAxi - 1].m_Off = Convert.ToInt32(ZeroOff.Text);

            MessageBox.Show("当前轴参数生效!", "提示");
        }

        //单轴回零
        private void btn_AxiZero_Click(object sender, EventArgs e)
        {
            Int32 retnX = -1;

            retnX = adt8948A1m.adt8948_SetHomeMode_Ex(CtrlCard.g_cardIndex, g_ZeroAxi, m_ZeroPara[g_ZeroAxi - 1].m_dir, m_ZeroPara[g_ZeroAxi - 1].m_stop0, m_ZeroPara[g_ZeroAxi - 1].m_lmt, m_ZeroPara[g_ZeroAxi - 1].m_stop1, m_ZeroPara[g_ZeroAxi - 1].m_bkRange, m_ZeroPara[g_ZeroAxi - 1].m_ZRange, m_ZeroPara[g_ZeroAxi - 1].m_Off);//设置回零模式

            retnX = adt8948A1m.adt8948_SetHomeSpeed_Ex(CtrlCard.g_cardIndex, g_ZeroAxi, m_ZeroPara[g_ZeroAxi - 1].m_StartV, m_ZeroPara[g_ZeroAxi - 1].m_SearchV, m_ZeroPara[g_ZeroAxi - 1].m_Speed, m_ZeroPara[g_ZeroAxi - 1].m_Acc, m_ZeroPara[g_ZeroAxi - 1].m_ZSpeed); //设置回零速度

            retnX = adt8948A1m.adt8948_HomeProcess_Ex(CtrlCard.g_cardIndex, g_ZeroAxi); //启动回零

            if (retnX < 0 || retnX > 20)
            {
                MessageBox.Show("回零失败!", "提示");
            }

            while (true)
            {
                Application.DoEvents();
                retnX = adt8948A1m.adt8948_GetHomeStatus_Ex(CtrlCard.g_cardIndex, g_ZeroAxi);
                Return0Status.Text = "回原点状态:"   Convert.ToString(retnX);
                if (retnX < 0 || retnX > 20)
                {
                    MessageBox.Show("回零失败!", "提示");
                    return;
                }

                if (retnX == 0)
                {
                    MessageBox.Show("回零成功!", "提示");
                    return;
                }

            }
        }

        //所有轴回零
        private void btn_AllZero_Click(object sender, EventArgs e)
        {
            Int32 retnX = -1, retnY = -1, retnZ = -1, retnA = -1;

            retnX = adt8948A1m.adt8948_SetHomeMode_Ex(CtrlCard.g_cardIndex, 1, m_ZeroPara[0].m_dir, m_ZeroPara[0].m_stop0, m_ZeroPara[0].m_lmt, m_ZeroPara[0].m_stop1, m_ZeroPara[0].m_bkRange, m_ZeroPara[0].m_ZRange, m_ZeroPara[0].m_Off);//设置回零模式
            retnX = adt8948A1m.adt8948_SetHomeSpeed_Ex(CtrlCard.g_cardIndex, 1, m_ZeroPara[0].m_StartV, m_ZeroPara[0].m_SearchV, m_ZeroPara[0].m_Speed, m_ZeroPara[0].m_Acc, m_ZeroPara[0].m_ZSpeed); //设置回零速度

            retnY = adt8948A1m.adt8948_SetHomeMode_Ex(CtrlCard.g_cardIndex, 2, m_ZeroPara[1].m_dir, m_ZeroPara[1].m_stop0, m_ZeroPara[1].m_lmt, m_ZeroPara[1].m_stop1, m_ZeroPara[1].m_bkRange, m_ZeroPara[1].m_ZRange, m_ZeroPara[1].m_Off);//设置回零模式
            retnY = adt8948A1m.adt8948_SetHomeSpeed_Ex(CtrlCard.g_cardIndex, 2, m_ZeroPara[1].m_StartV, m_ZeroPara[1].m_SearchV, m_ZeroPara[1].m_Speed, m_ZeroPara[1].m_Acc, m_ZeroPara[1].m_ZSpeed); //设置回零速度

            retnZ = adt8948A1m.adt8948_SetHomeMode_Ex(CtrlCard.g_cardIndex, 3, m_ZeroPara[2].m_dir, m_ZeroPara[2].m_stop0, m_ZeroPara[2].m_lmt, m_ZeroPara[2].m_stop1, m_ZeroPara[2].m_bkRange, m_ZeroPara[2].m_ZRange, m_ZeroPara[2].m_Off);//设置回零模式
            retnZ = adt8948A1m.adt8948_SetHomeSpeed_Ex(CtrlCard.g_cardIndex, 3, m_ZeroPara[2].m_StartV, m_ZeroPara[2].m_SearchV, m_ZeroPara[2].m_Speed, m_ZeroPara[2].m_Acc, m_ZeroPara[2].m_ZSpeed); //设置回零速度

            retnA = adt8948A1m.adt8948_SetHomeMode_Ex(CtrlCard.g_cardIndex, 4, m_ZeroPara[3].m_dir, m_ZeroPara[3].m_stop0, m_ZeroPara[3].m_lmt, m_ZeroPara[3].m_stop1, m_ZeroPara[3].m_bkRange, m_ZeroPara[3].m_ZRange, m_ZeroPara[3].m_Off);//设置回零模式
            retnA = adt8948A1m.adt8948_SetHomeSpeed_Ex(CtrlCard.g_cardIndex, 4, m_ZeroPara[3].m_StartV, m_ZeroPara[3].m_SearchV, m_ZeroPara[3].m_Speed, m_ZeroPara[3].m_Acc, m_ZeroPara[3].m_ZSpeed); //设置回零速度

            retnX = adt8948A1m.adt8948_HomeProcess_Ex(CtrlCard.g_cardIndex, 1); //启动回零
            retnY = adt8948A1m.adt8948_HomeProcess_Ex(CtrlCard.g_cardIndex, 2); //启动回零
            retnZ = adt8948A1m.adt8948_HomeProcess_Ex(CtrlCard.g_cardIndex, 3); //启动回零
            retnA = adt8948A1m.adt8948_HomeProcess_Ex(CtrlCard.g_cardIndex, 4); //启动回零

            if (retnX < 0 || retnX > 20)
            {
                MessageBox.Show("回零失败!", "提示");
                return;
            }
            if (retnY < 0 || retnY > 20)
            {
                MessageBox.Show("回零失败!", "提示");
                return;
            }
            if (retnZ < 0 || retnZ > 20)
            {
                MessageBox.Show("回零失败!", "提示");
                return;
            }
            if (retnA < 0 || retnA > 20)
            {
                MessageBox.Show("回零失败!", "提示");
                return;
            }

            while (true)
            {
                Application.DoEvents();

                retnX = adt8948A1m.adt8948_GetHomeStatus_Ex(CtrlCard.g_cardIndex, 1);
                retnX = adt8948A1m.adt8948_GetHomeStatus_Ex(CtrlCard.g_cardIndex, 2);
                retnX = adt8948A1m.adt8948_GetHomeStatus_Ex(CtrlCard.g_cardIndex, 3);
                retnX = adt8948A1m.adt8948_GetHomeStatus_Ex(CtrlCard.g_cardIndex, 4);

                //Return0Status.Text = "回原点状态:"   Convert.ToString(retnX);


                if (retnX == 0 && retnY == 0 && retnZ == 0 && retnA == 0)
                {
                    MessageBox.Show("回零成功!", "提示");
                    return;
                }

                else if (retnX < 0 || retnX > 20)
                {
                    MessageBox.Show("X回零失败!", "提示");
                    return;
                }

                else if (retnY < 0 || retnY > 20)
                {
                    MessageBox.Show("Y回零失败!", "提示");
                    return;
                }

                else if (retnZ < 0 || retnZ > 20)
                {
                    MessageBox.Show("Z回零失败!", "提示");
                    return;
                }

                else if (retnY < 0 || retnY > 20)
                {
                    MessageBox.Show("A回零失败!", "提示");
                    return;
                }

            }
        }

        //进入界面时的操作
        private void tabPage13_Enter(object sender, EventArgs e)
        {
            LoadZeroParaEx();
        }

        #endregion

        //关闭界面时保存参数
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
 
        }

    }//End Form1
}//End Demo


实例下载地址

ADTECH运动控制卡DEMO程序

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警