Exemplo n.º 1
0
        public void ManualMoveAction(int Distance)
        {
            if (this.MoveDistxtBox.Text == null)
            {
                MessageBox.Show("请输入有效运动脉冲数!");
                return;
            }
            int MoveDis = Math.Abs(Convert.ToInt32(this.MoveDistxtBox.Text)) * -1;

            ControlCardObj.PMove(SelectAxis, MoveDis, ProFileType.T_Profile);
            this.Invoke(new Action(delegate { this.CurPulstxtbox.Text = ControlCardObj.GetPosition(SelectAxis).ToString(); }));
            uint Iostatus = ControlCardObj.CheckIOStatus(SelectAxis);

            if ((Iostatus & (0x01)) == 1)
            {
                MessageBox.Show($"{SelectAxis.Name}-已经到达正极限!");
                this.Invoke(new Action(delegate { this.UpMoveBtn.Enabled = false; }));
            }
            else if ((Iostatus & (0x01 << 1)) == 1)
            {
                MessageBox.Show($"{SelectAxis.Name}-已经到达负极限!");
                this.Invoke(new Action(delegate { this.DownMoveBtn.Enabled = false; }));
            }
            else
            {
                this.Invoke(new Action(delegate { this.UpMoveBtn.Enabled = true; }));
                this.Invoke(new Action(delegate { this.DownMoveBtn.Enabled = true; }));
            }
            UpdataAxisData();
        }
Exemplo n.º 2
0
        public bool AxisReset(AxisCard axiscard)
        {
            try
            {
                int Res       = 999;
                int WaitTimes = 0;
                //Thread.Sleep(2000);
                PrinterLog($"{axiscard.Name}轴开始回原点....", WriteLogType.Action);

                //Different Control Card.The HomeMode will Change PCI9014 :1/Forward,0/Opposite  DMC2C80:1/Forward 2/Opposite;
                int LocalPosition = ControlcardObj.GetPosition(axiscard);

                if (Math.Abs(LocalPosition) <= axiscard.HomeBackDis)
                {
                    if (axiscard.HomeModel == 1)
                    {
                        axiscard.HomeModel *= -1;
                    }
                    Res = ControlcardObj.PMove(axiscard, axiscard.HomeBackDis, ProFileType.T_Profile);
                    //PCI9014:0/Free 1/working     DMC2C80:0/working 1/Free;
                    while (ControlcardObj.CheckAxisStatus(axiscard) == 1)
                    {
                        WaitTimes++;
                        if (WaitTimes == 300)
                        {
                            PrinterLog($"{axiscard.Name} 运动到 [{axiscard.HomeBackDis}]超时!", WriteLogType.Error);
                            return(false);
                        }
                        Thread.Sleep(100);
                    }
                    LocalPosition = ControlcardObj.GetPosition(axiscard);
                    if (LocalPosition != axiscard.HomeBackDis)
                    {
                        PrinterLog($"{axiscard.Name} 未运动到指定位置:{axiscard.HomeBackDis}!", WriteLogType.Error);
                        return(false);
                    }
                }
                WaitTimes = 0;
                Res       = ControlcardObj.HomeMove(axiscard);
                while (ControlcardObj.CheckAxisStatus(axiscard) == 1)
                {
                    WaitTimes++;
                    if (WaitTimes == 300)
                    {
                        PrinterLog($"{axiscard.Name} 回原运动超时!", WriteLogType.Error);
                        return(false);
                    }
                    Thread.Sleep(100);
                }
                LocalPosition = ControlcardObj.GetPosition(axiscard);
                if (LocalPosition != 0 || Res != 0)
                {
                    PrinterLog($"{axiscard.Name}回原运动后未到达原点位置,轴卡现在所在位置脉冲:{LocalPosition}", WriteLogType.Error);
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                PrinterLog(ex.Message, WriteLogType.Error);
                throw new Exception(ex.Message);
            }
        }