Exemplo n.º 1
0
 private void btnResetCounter_Click(object sender, EventArgs e)
 {
     axis.ResetPos();
 }
Exemplo n.º 2
0
        public override void Flow()
        {
            switch (this.Step1)
            {
                #region flow init

            case "0":
                //關掉軟體極限,
                _axis.DisableSoftLimit();
                _axis.Stop(StopType.SlowDown, false);
                _axis.ServoOn(CmdStatus.ON);
                ChangeStep1("1");

                this.TimeVar1 = 30000;
                //if (HomeStarted != null)
                //{
                //    HomeStarted(DeviceName);
                //}
                break;

            case "1":
                if (!_axis.IsBusy)
                {
                    switch (_axis.AxisPara.HomeMode)
                    {
                    case HomeMode.OnePoint:
                        ChangeStep1("1000");
                        break;

                    case HomeMode.TwoPoint:
                        ChangeStep1("2000");
                        break;

                    case HomeMode.ThreePointWithZPhase:
                        ChangeStep1("2000");
                        break;

                    case HomeMode.ThreePoint:
                        ChangeStep1("3000");
                        break;
                    }
                }
                break;

                #endregion flow init

                #region OnePoint

            case "1000":
                //不在原點上
                if (!_axis.IsORG)
                {
                    _axis.JogM(_axis.AxisPara.OPRDevVelH, RotationDirection.CCW);
                }
                ChangeStep1("1010");
                break;

            case "1010":
                if (_axis.IsORG)
                {
                    _axis.Stop(StopType.Emergency, false);
                    this.Timer1.Restart();
                    ChangeStep1("1020");
                }
                break;

            case "1020":
                if (this.Timer1.ElapsedMilliseconds > 100)
                {
                    _axis.JogM(5, RotationDirection.CW);
                    this.Timer1.Restart();
                    ChangeStep1("1030");
                }
                break;

            case "1030":
                if (this.Timer1.ElapsedMilliseconds > this.TimeVar1)
                {
                    //S.Result.Value = -1030;
                    //S.Result.Message = LanguageResourceManager.GetString("TimeoutOutOfORG") + "(" + DeviceName + ")";
                    ChangeStep1("9000");
                }
                else
                {
                    if (!_axis.IsORG)
                    {
                        _axis.Stop(StopType.Emergency, false);
                        _axis.DoHomeOrg();
                        this.Timer1.Restart();
                        ChangeStep1("7000");
                    }
                }
                break;

                #endregion OnePoint

                #region TwoPoint

            case "2000":
                if (_axis.IsLimitN)
                {
                    _axis.JogM(_axis.AxisPara.OPRDevVelH, RotationDirection.CW);
                    this.Timer1.Restart();
                    ChangeStep1("2100");
                }
                else if (_axis.IsLimitP)
                {
                    _axis.JogM(_axis.AxisPara.OPRDevVelH, RotationDirection.CCW);
                    this.Timer1.Restart();
                    ChangeStep1("2100");
                }
                else
                {
                    this.Timer1.Restart();
                    ChangeStep1("2100");
                }
                break;

            case "2100":
                if (this.Timer1.ElapsedMilliseconds > this.TimeVar1)
                {
                    //S.Result.Value = -2100;
                    //S.Result.Message = LanguageResourceManager.GetString("TimeoutOutOfLimitN") + "(" + _axis.DeviceName + ")";
                    ChangeStep1("9000");
                }
                else
                {
                    if (!_axis.IsLimitN && !_axis.IsLimitP)
                    {
                        _axis.Stop(StopType.Emergency, false);
                        this.Timer1.Restart();
                        ChangeStep1("2010");
                    }
                }
                break;

            case "2010":
                if (this.Timer1.ElapsedMilliseconds > this.TimeVar1)
                {
                    //S.Result.Value = -2010;
                    //S.Result.Message = LanguageResourceManager.GetString("TimeoutOutOfLimitN") + "(" + DeviceName + ")";
                    ChangeStep1("9000");
                }
                else
                {
                    if (!_axis.IsLimitN)
                    {
                        _axis.JogM(_axis.AxisPara.OPRDevVelH, RotationDirection.CCW);
                    }
                    ChangeStep1("2020");
                }
                break;

            case "2020":
                if (_axis.IsLimitN)
                {
                    _axis.Stop(StopType.Emergency, false);
                    this.Timer1.Restart();
                    ChangeStep1("2030");
                }
                break;

            case "2030":
                if (this.Timer1.ElapsedMilliseconds > 100)
                {
                    if (_axis.AxisPara.HomeMode == HomeMode.ThreePointWithZPhase)
                    {
                        _axis.DoHomeLimWithZPhase();
                    }
                    else
                    {
                        _axis.DoHomeLim();
                    }
                    ChangeStep1("7000");
                }
                break;

            case "2040":
                if (_axis.IsLimitN)
                {
                    _axis.Stop(StopType.Emergency, false);
                    ChangeStep1("7000");
                }
                break;

                #endregion TwoPoint

                #region ThreePoint

            case "3000":
                //if (!_axis.ORG && !_axis.LimitN)
                if (!_axis.IsLimitN)
                {
                    _axis.JogM(_axis.AxisPara.OPRDevVelH, RotationDirection.CCW);
                }
                ChangeStep1("3010");
                break;

            case "3010":
                //if (_axis.ORG || _axis.LimitN)
                if (_axis.IsLimitN)
                {
                    _axis.Stop(StopType.SlowDown, false);
                    this.Timer1.Restart();
                    ChangeStep1("3020");
                }
                break;

            case "3020":
                if (this.Timer1.ElapsedMilliseconds > 100)
                {
                    _axis.JogM(_axis.AxisPara.CreepDevVelH, RotationDirection.CW);
                    ChangeStep1("3030");
                }
                break;

            case "3030":
                if (this.Timer1.ElapsedMilliseconds > this.TimeVar1)
                {
                    //S.Result.Value = -3030;
                    //S.Result.Message = LanguageResourceManager.GetString("TimeoutEnterORG") + "(" + DeviceName + ")";
                    ChangeStep1("9000");
                }
                else
                {
                    if (_axis.IsORG)
                    {
                        ChangeStep1("3040");
                    }
                }
                break;

            case "3040":
                if (!_axis.IsORG)
                {
                    _axis.Stop(StopType.SlowDown, false);
                    this.Timer1.Restart();
                    ChangeStep1("3050");
                }
                break;

            case "3050":
                if (this.Timer1.ElapsedMilliseconds > 100)
                {
                    _axis.DoHomeOrg();
                    ChangeStep1("7000");
                }
                break;

                #endregion ThreePoint

                #region flow continue

            case "7000":
                if (this.Timer1.ElapsedMilliseconds > 500 && !_axis.IsBusy)
                {
                    ChangeStep1("7010");
                }
                break;

            case "7010":
                _axis.ResetPos();
                _axis.AbsolueMove(_axis.AxisPara.OffsetH, SpeedMode.Manual);
                ChangeStep1("7020");
                break;

            case "7020":
                if (_axis.IsReached)
                {
                    this.Timer1.Restart();
                    ChangeStep1("7030");
                }
                break;

            case "7030":
                if (this.Timer1.ElapsedMilliseconds >= _axis.AxisPara.ClearDelay * 1000)
                {
                    _axis.ResetPos();
                    ChangeStep1("8000");
                }
                break;

                #endregion flow continue

                #region flow end

            //flow finish
            case "8000":
                //if (HomeCompleted != null)
                //{
                //    HomeCompleted(DeviceName);
                //}
                _axis.IsHome = true;
                Stop();
                break;

            //flow trip
            case "9000":
                //if (HomeFailure != null)
                //{
                //    HomeFailure(DeviceName);
                //}
                _axis.IsHome = false;
                Fail();

                break;

                #endregion flow end
            }
        }