示例#1
0
        private void ResetPos(object sender, EventArgs e)
        {
            Button b = (Button)sender;

            if (!simulation_Manip27)
            {
                manip27.Motor m = (b.Tag.ToString() == "DC") ? (manip27.Motor)mDC : (manip27.Motor)mPAP;
                m.resPos();
            }
            else
            {
                if (b.Tag.ToString() == "DC")
                {
                    tBDCPosAct.Text = "0";
                    tBPosErr.Text   = "0";
                }
                else
                {
                    tBPAPPosTh.Text = "0";
                };
            }
        }
示例#2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                if (!simulation_Manip27)
                {
                    cG = new manip27.Controller(ControllerIP);
                    cG.Connect();
                    this.Text = cG.ControllerInfo;

                    mDC  = new manip27.Motor(manip27.tMotorType.DC);
                    mPAP = new manip27.Motor(manip27.tMotorType.PAP);

                    updateTxtBox = true;

                    timer1.Start();

                    cBDCMode.SelectedIndex = 0;
                    cBDCMode_SelectionChangeCommitted(cBDCMode, e);

                    cBPAPMode.SelectedIndex = 0;
                    cBPAPMode_SelectionChangeCommitted(cBPAPMode, e);

                    cBPAPStep.Checked = true;
                    cBPAPStep_CheckedChanged(cBPAPStep, e);
                }
                else
                {
                    timer1.Start();
                    cBDCMode.SelectedIndex  = 0;
                    cBPAPMode.SelectedIndex = 0;
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MessageBox.Show(ex.Message + "\nVerifier que le système est enclenché et le câble réseau branché\n\nLe programme va se terminer");
                System.Windows.Forms.Application.Exit();
            }
        }
示例#3
0
        private void UpdateValue(object sender, EventArgs e)
        {
            TextBox TB = (TextBox)sender;


            if (!simulation_Manip27)
            {
                bool          abs = (cBDCMode.SelectedIndex == 1) ? true : false;
                manip27.Motor m   = (TB.Name.Substring(2, 2) == "DC") ? (manip27.Motor)mDC : (manip27.Motor)mPAP;
                if (m.MotorType == manip27.tMotorType.PAP)
                {
                    abs = (cBPAPMode.SelectedIndex == 1) ? true : false;
                }

                try
                {
                    switch (TB.Tag.ToString())
                    {
                    case "PR":
                        m.CPosition = Convert.ToInt32(TB.Text);
                        break;

                    case "SP":
                        m.CSpeed = Convert.ToInt32(TB.Text);
                        break;

                    case "AC":
                        m.CAcceleration = Convert.ToInt32(TB.Text);
                        break;

                    case "DC":
                        m.CDeceleration = Convert.ToInt32(TB.Text);
                        break;

                    case "KP":
                        m.KP = Convert.ToDouble(TB.Text);
                        break;

                    case "KD":
                        m.KD = Convert.ToDouble(TB.Text);
                        break;

                    case "KI":
                        m.KI = Convert.ToDouble(TB.Text);
                        break;
                    }
                    cG.SendValue(TB.Tag.ToString(), TB.Text, m.MotorType, abs);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                switch (TB.Tag.ToString())
                {
                case "PR":
                    if (TB.Name.Substring(2, 2) == "DC")
                    {
                        s.CPosition = Convert.ToInt32(TB.Text);
                    }
                    else
                    {
                        s.PAP_CPosition = Convert.ToInt32(TB.Text);
                    }
                    break;

                case "SP":
                    if (TB.Name.Substring(2, 2) == "DC")
                    {
                        s.CSpeed = Convert.ToInt32(TB.Text);
                    }
                    else
                    {
                        s.PAP_CSpeed = Convert.ToInt32(TB.Text);
                    }
                    break;

                case "AC":
                    if (TB.Name.Substring(2, 2) == "DC")
                    {
                        s.CAcceleration = Convert.ToInt32(TB.Text);
                    }
                    else
                    {
                        s.PAP_CAcceleration = Convert.ToInt32(TB.Text);
                    }
                    break;

                case "DC":
                    if (TB.Name.Substring(2, 2) == "DC")
                    {
                        s.CDeceleration = Convert.ToInt32(TB.Text);
                    }
                    else
                    {
                        s.PAP_CDeceleration = Convert.ToInt32(TB.Text);
                    }
                    break;

                case "KP":
                    s.KP = Convert.ToDouble(TB.Text);
                    break;

                case "KD":
                    s.KD = Convert.ToDouble(TB.Text);
                    break;

                case "KI":
                    s.KI = Convert.ToDouble(TB.Text);
                    break;
                }
            }
            updateTxtBox = true;
        }