Example #1
0
        private void btnBatchCreate_Click(object sender, EventArgs e)
        {
            var x = HoleOperate.XStart;
            var y = HoleOperate.YStart;
            var w = HoleOperate.WStart;
            var b = HoleOperate.BStart;
            var c = HoleOperate.CStart;

            for (int i = 0; i < HoleOperate.Repeat; i++)
            {
                var holeInfo = new HoleInfo()
                {
                    IsJiaGong = HoleOperate.IsJiagong,
                    X         = x + HoleOperate.XInterval,
                    Y         = y + HoleOperate.YInterval,
                    W         = w + HoleOperate.WInterval,
                    B         = b + HoleOperate.BInterval,
                    C         = c + HoleOperate.CInterval,
                    AxisType  = HoleOperate.AxisType,
                    Param     = HoleOperate.Param
                };
                x += HoleOperate.XInterval;
                y += HoleOperate.YInterval;
                w += HoleOperate.WInterval;
                b += HoleOperate.BInterval;
                c += HoleOperate.CInterval;
                HoleCollection.Insert(this.bindingSourceHole.Position + 1 + i, holeInfo);
            }
            bindingSourceHole.ResetBindings(false);
        }
Example #2
0
        public void SingleMoveZ(HoleInfo moveInfo, string axisType, decimal speed = 0)
        {
            if (moveInfo.Z.HasValue)
            {
                Contra.LogPosZ       = GetActPos(AxisSet.ZReadAxis) * AxisSet.ZResolution;
                Contra.LogPosA       = GetLogPos(AxisSet.AxisZ);
                Contra.TempLogPosA   = Contra.LogPosZ + Contra.TempLogPosZ - Contra.LogPosA;
                Contra.TempLogPosA55 = Contra.LogPosZ + Contra.TempLogPosZ55 - Contra.LogPosA;
                Contra.TempLogPosA56 = Contra.LogPosZ + Contra.TempLogPosZ56 - Contra.LogPosA;
                Contra.TempLogPosA57 = Contra.LogPosZ + Contra.TempLogPosZ57 - Contra.LogPosA;
                Contra.TempLogPosA58 = Contra.LogPosZ + Contra.TempLogPosZ58 - Contra.LogPosA;
                Contra.TempLogPosA59 = Contra.LogPosZ + Contra.TempLogPosZ59 - Contra.LogPosA;

                Contra.TempLogPosA60 = Contra.LogPosZ + Contra.TempLogPosZ60 - Contra.LogPosA;
                Contra.TempLogPosA61 = Contra.LogPosZ + Contra.TempLogPosZ61 - Contra.LogPosA;
                Contra.TempLogPosA62 = Contra.LogPosZ + Contra.TempLogPosZ62 - Contra.LogPosA;
                Contra.TempLogPosA63 = Contra.LogPosZ + Contra.TempLogPosZ63 - Contra.LogPosA;
                Contra.TempLogPosA64 = Contra.LogPosZ + Contra.TempLogPosZ64 - Contra.LogPosA;
                Contra.TempLogPosA65 = Contra.LogPosZ + Contra.TempLogPosZ65 - Contra.LogPosA;

                decimal actPosA = Contra.GetActPosZ(axisType);
                var     v       = GetMovePosition("Z", moveInfo.Z, actPosA, Contra.LogPosA, isAPlus != isOldAPlus, isOldAPlus, out jianxiA);
                isAPlus = moveInfo.Z.Value >= actPosA;
                CtrlCard.Sym_AbsoluteMove(AxisSet.AxisZ,
                                          v,
                                          Contra.StartSpeed, (int)(speed == 0 ? AxisSet.SpeedZPerSecond : speed), (double)Contra.AddSpeedTime);
                isOldAPlus = isAPlus;
            }
        }
Example #3
0
 public void SingleMoveB(HoleInfo moveInfo, string axisType)
 {
     if (moveInfo.B.HasValue)
     {
         decimal actPosB = Contra.GetActPosB(axisType);
         isBPlus = moveInfo.B.Value >= actPosB;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisB,
                                   GetMovePosition("B", moveInfo.B, actPosB, Contra.LogPosB, isBPlus != isOldBPlus, isOldBPlus, out jianxiB),
                                   Contra.StartSpeed, (int)AxisSet.SpeedBPerSecond, (double)Contra.AddSpeedTime);
         isOldBPlus = isBPlus;
     }
 }
Example #4
0
 public void SingleMoveW(HoleInfo moveInfo, string axisType)
 {
     if (moveInfo.W.HasValue)
     {
         decimal actPosW = Contra.GetActPosW(axisType);
         isWPlus = moveInfo.W.Value >= actPosW;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisW,
                                   GetMovePosition("W", moveInfo.W, actPosW, Contra.LogPosW, isWPlus != isOldWPlus, isOldWPlus, out jianxiW),
                                   Contra.StartSpeed, (int)AxisSet.SpeedWPerSecond, (double)Contra.AddSpeedTime);
         isOldWPlus = isWPlus;
     }
 }
Example #5
0
 public void SingleMoveY(HoleInfo moveInfo, string axisType)
 {
     if (moveInfo.Y.HasValue)
     {
         decimal actPosY = Contra.GetActPosY(axisType);
         isYPlus = moveInfo.Y.Value >= actPosY;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisY,
                                   GetMovePosition("Y", moveInfo.Y, actPosY, Contra.LogPosY, isYPlus != isOldYPlus, isOldYPlus, out jianxiY),
                                   Contra.StartSpeed, (int)AxisSet.SpeedYPerSecond, (double)Contra.AddSpeedTime);
         isOldYPlus = isYPlus;
     }
 }
Example #6
0
 public void SingleMoveX(HoleInfo moveInfo, string axisType)
 {
     if (moveInfo.X.HasValue)
     {
         decimal actPosX = Contra.GetActPosX(axisType);
         isXPlus = moveInfo.X.Value >= actPosX;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisX,
                                   GetMovePosition("X", moveInfo.X, actPosX, Contra.LogPosX, isXPlus != isOldXPlus, isOldXPlus, out jianxiX),
                                   Contra.StartSpeed, (int)AxisSet.SpeedXPerSecond, (double)Contra.AddSpeedTime);
         isOldXPlus = isXPlus;
     }
 }
Example #7
0
 public void SingleMoveC(HoleInfo moveInfo, string axisType, int?speed)
 {
     if (moveInfo.C.HasValue)
     {
         decimal actPosC = Contra.GetActPosC(axisType);
         isCPlus = moveInfo.C.Value >= actPosC;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisC,
                                   GetMovePosition("C", moveInfo.C, actPosC, Contra.LogPosC, isCPlus != isOldCPlus, isOldCPlus, out jianxiC),
                                   Contra.StartSpeed, speed ?? (int)AxisSet.SpeedCPerSecond, (double)Contra.AddSpeedTime);
         isOldCPlus = isCPlus;
     }
 }
Example #8
0
 public void btnAddHole_Click(object sender, EventArgs e)
 {
     var holeInfo = new HoleInfo()
         {
             IsJiaGong = true,
             X = contra.GetActPosX(axisType),
             Y = contra.GetActPosY(axisType),
             W = contra.GetActPosW(axisType),
             B = contra.GetActPosB(axisType),
             C = contra.GetActPosC(axisType),
             AxisType = axisType,
             Param = "E1"
         };
     HoleCollection.Insert(this.bindingSourceHole.Position + 1, holeInfo);
     bindingSourceHole.ResetBindings(false);
 }
Example #9
0
        public void btnAddHole_Click(object sender, EventArgs e)
        {
            var holeInfo = new HoleInfo()
            {
                IsJiaGong = true,
                X         = contra.GetActPosX(axisType),
                Y         = contra.GetActPosY(axisType),
                W         = contra.GetActPosW(axisType),
                B         = contra.GetActPosB(axisType),
                C         = contra.GetActPosC(axisType),
                AxisType  = axisType,
                Param     = "E1"
            };

            HoleCollection.Insert(this.bindingSourceHole.Position + 1, holeInfo);
            bindingSourceHole.ResetBindings(false);
        }
Example #10
0
        private void btnBatchCreate2_Click(object sender, EventArgs e)
        {
            var     operate = HoleOperate2;
            var     x       = operate.XStart;
            var     y       = operate.YStart;
            var     w       = operate.WStart;
            var     b       = operate.BStart;
            var     c       = operate.CStart;
            var     xe      = operate.XInterval;
            var     ye      = operate.YInterval;
            var     we      = operate.WInterval;
            var     be      = operate.BInterval;
            var     ce      = operate.CInterval;
            decimal?xs      = (xe - x) / (operate.Repeat + 1);
            decimal?ys      = (ye - y) / (operate.Repeat + 1);
            decimal?ws      = (we - w) / (operate.Repeat + 1);
            decimal?bs      = (be - b) / (operate.Repeat + 1);
            decimal?cs      = (ce - c) / (operate.Repeat + 1);

            for (int i = 0; i < operate.Repeat; i++)
            {
                var holeInfo = new HoleInfo()
                {
                    IsJiaGong = operate.IsJiagong,
                    X         = x + xs,
                    Y         = y + ys,
                    W         = w + ws,
                    B         = b + bs,
                    C         = c + cs,
                    AxisType  = operate.AxisType,
                    Param     = operate.Param
                };
                x += xs;
                y += ys;
                w += ws;
                b += bs;
                c += cs;
                HoleCollection.Insert(this.bindingSourceHole.Position + 1 + i, holeInfo);
            }
            bindingSourceHole.ResetBindings(false);
        }
Example #11
0
 private void btnBatchCreate_Click(object sender, EventArgs e)
 {
     var x = HoleOperate.XStart;
     var y = HoleOperate.YStart;
     var w = HoleOperate.WStart;
     var b = HoleOperate.BStart;
     var c = HoleOperate.CStart;
     for (int i = 0; i < HoleOperate.Repeat; i++)
     {
         var holeInfo = new HoleInfo()
         {
             IsJiaGong = HoleOperate.IsJiagong,
             X = x + HoleOperate.XInterval,
             Y = y + HoleOperate.YInterval,
             W = w + HoleOperate.WInterval,
             B = b + HoleOperate.BInterval,
             C = c + HoleOperate.CInterval,
             AxisType = HoleOperate.AxisType,
             Param = HoleOperate.Param
         };
         x += HoleOperate.XInterval;
         y += HoleOperate.YInterval;
         w += HoleOperate.WInterval;
         b += HoleOperate.BInterval;
         c += HoleOperate.CInterval;
         HoleCollection.Insert(this.bindingSourceHole.Position + 1 + i, holeInfo);
     }
     bindingSourceHole.ResetBindings(false);
 }
Example #12
0
        private void btnBatchCreate2_Click(object sender, EventArgs e)
        {
            var operate = HoleOperate2;
            var x = operate.XStart;
            var y = operate.YStart;
            var w = operate.WStart;
            var b = operate.BStart;
            var c = operate.CStart;
            var xe = operate.XInterval;
            var ye = operate.YInterval;
            var we = operate.WInterval;
            var be = operate.BInterval;
            var ce = operate.CInterval;
            decimal? xs = (xe - x) / (operate.Repeat + 1);
            decimal? ys = (ye - y) / (operate.Repeat + 1);
            decimal? ws = (we - w) / (operate.Repeat + 1);
            decimal? bs = (be - b) / (operate.Repeat + 1);
            decimal? cs = (ce - c) / (operate.Repeat + 1);

            for (int i = 0; i < operate.Repeat; i++)
            {
                var holeInfo = new HoleInfo()
                {
                    IsJiaGong = operate.IsJiagong,
                    X = x + xs,
                    Y = y + ys,
                    W = w + ws,
                    B = b + bs,
                    C = c + cs,
                    AxisType = operate.AxisType,
                    Param = operate.Param
                };
                x += xs;
                y += ys;
                w += ws;
                b += bs;
                c += cs;
                HoleCollection.Insert(this.bindingSourceHole.Position + 1 + i, holeInfo);
            }
            bindingSourceHole.ResetBindings(false);
        }
Example #13
0
 private void btnJiagong_CheckedChanged(object sender, EventArgs e)
 {
     if (!btnJiagong.Checked || OtherSet.ShuibengDelay == 0) //延时加工
     {
         IOHelper.SetJiagong(btnJiagong.Checked ? 1 : 0);
         plcHelper.SendMsg(btnJiagong.Checked ? PortHelper.JiagongOn : PortHelper.JiagongOff);
     }
     if (!isM21 && btnJiagong.Checked)
     {
         param = L.R("FormMain.Manual", "手动");
         M21();
     }
     else if (isM21 && !btnJiagong.Checked)
     {
         StopImmediately();
         inputInfo = null;
         inputHole = null;
         timerTotal.Enabled = false;
         timerCurrent.Enabled = false;
         isM21FinishCloseShuibeng = false;
         this.btnFushi.Value = this.btnFushi.Value == 2 ? 2 : 1; //绿色的变成绿色红色的变成黄色
         this.btnMen.Value = this.btnMen.Value == 2 ? 2 : 1;//绿色的变成绿色红色的变成黄色
         IOHelper.SetMen(0);
         plcHelper.SendMsg(PortHelper.FushiOff);
         isM21 = false;
     }
     else if (!btnJiagong.Checked)
     {
         btnMen.Value = btnMen.Value == 2 ? 2 : 1; //绿色的变成绿色红色的变成黄色
         IOHelper.SetMen(0);
     }
 }
Example #14
0
        private void timer_Tick(object sender, EventArgs e)
        {
            //读取所有输入信号供下方判断
            IOHelper.ReadInputs();
            //检查轴正限位
            CheckWPlus();
            //检查伺服报警
            CheckAlarm();
            //检查Z轴正限位
            //CheckZPlus();
            CheckZPlus();
            //检测刀库
            CheckDaoKu();
            //检查Z负限位
            CheckZMinus();
            //检查急停
            CheckUrgencyStop();
            //输出清零状态
            SetZeroState();
            //输出穿透状态
            SetThrowState();
            //输出W撞击状态
            SetWHitState();
            //读取各轴位置
            card.ReadPos();
            if (isBackToZChange && card.Contra.GetActPosZ(axisType) > backToChangePosition)
            {
                isBackToZChange = false;
                plcHelper.SendMsg(PortHelper.ZUpOff);
            }
            //检查扶丝
            CheckFusi();
            //没有移动,没有执行M21
            bool flag = !card.IsRunning();
            if (flag)
            {
                if (isZeroAttemp < 20)
                {
                    isZeroAttemp++;
                }
                if (isZeroAttemp >= 20)
                {
                    isZero = false;
                }
                card.JianxiTiaozheng();
                isChangeDianji = false;
            }
            #region 按钮可用控制
            btnAutoCenter.Enabled = !isAutoCenter && !isContinue && OtherSet.UseAutoCenter;
            btnStopCenter.Enabled = isAutoCenter && !isContinue;
            //顶部
            this.btnMovePanel.Enabled = flag && !isContinue;
            this.btnDaoKu.Enabled = flag && !isContinue;
            //右侧按钮
            this.btnStart.Enabled = flag && !isContinue && !isM21;
            this.btnStop.Enabled = (!flag || isContinue || isM21);
            this.btnReset.Enabled = flag && !isContinue && !isM21;
            this.btnToZero.Enabled = flag && !isContinue && !isM21;
            this.btnNext.Enabled = flag && !isContinue && !isM21;
            this.btnZeroRestart.Enabled = flag && !isContinue && !isM21;

            this.btnDuidao.Enabled = flag && !isContinue && !isM21;

            //列表
            //this.gridViewParam.OptionsBehavior.ReadOnly = !(flag && !isContinue );

            //孔位按钮
            this.btnLoadFile.Enabled = flag && !isContinue && !isM21;
            //this.btnAddHole.Enabled = flag && !isContinue && !isM21;
            //this.btnDeleteHole.Enabled = flag && !isContinue && !isM21;
            this.btnSaveScript.Enabled = flag && !isContinue && !isM21;
            this.btnMoreOperate.Enabled = flag && !isContinue && !isM21;
            this.btnNewHoles.Enabled = flag && !isContinue && !isM21;
            this.cbEmptyRun.Enabled = flag && !isContinue && !isM21;

            //this.btnNew.Enabled = flag && !isContinue && isZero;
            //this.miEdit.Enabled = flag && !isContinue && isZero;

            //参数按钮
            this.btnAddParam.Enabled = this.btnStart.Enabled;
            this.btnDeleteParam.Enabled = this.btnStart.Enabled;
            //this.btnLoadParam.Enabled = this.btnStart.Enabled;
            //this.btnSaveParam.Enabled = this.btnStart.Enabled;

            this.btnZeroX.Enabled = flag && !isContinue && !AxisSet.IgnoreX && !isM21;
            this.btnZeroY.Enabled = flag && !isContinue && !AxisSet.IgnoreY && !isM21;
            this.btnZeroW.Enabled = flag && !isContinue && !AxisSet.IgnoreW && !isM21;
            this.btnZeroB.Enabled = flag && !isContinue && !AxisSet.IgnoreB && !isM21;
            this.btnZeroC.Enabled = flag && !isContinue && !AxisSet.IgnoreC && !isM21;
            this.btnZeroZ.Enabled = flag && !isContinue && !AxisSet.IgnoreZ && !isM21;

            this.btnSetX.Enabled = flag && !isContinue && !AxisSet.IgnoreX && !isM21;
            this.btnSetY.Enabled = flag && !isContinue && !AxisSet.IgnoreY && !isM21;
            this.btnSetW.Enabled = flag && !isContinue && !AxisSet.IgnoreW && !isM21;
            this.btnSetB.Enabled = flag && !isContinue && !AxisSet.IgnoreB && !isM21;
            this.btnSetC.Enabled = flag && !isContinue && !AxisSet.IgnoreC && !isM21;
            this.btnSetZ.Enabled = flag && !isContinue && !AxisSet.IgnoreZ && !isM21;

            this.btnHalfX.Enabled = flag && !isContinue && !AxisSet.IgnoreX && !isM21;
            this.btnHalfY.Enabled = flag && !isContinue && !AxisSet.IgnoreY && !isM21;
            this.btnHalfW.Enabled = flag && !isContinue && !AxisSet.IgnoreW && !isM21;
            this.btnHalfZ.Enabled = flag && !isContinue && !AxisSet.IgnoreZ && !isM21;
            this.btnHalfB.Enabled = flag && !isContinue && !AxisSet.IgnoreB && !isM21;
            this.btnHalfC.Enabled = flag && !isContinue && !AxisSet.IgnoreC && !isM21;

            this.btnSet.Enabled = flag && !isContinue && !isM21;
            this.btnShutdown.Enabled = flag && !isContinue && !isM21;

            this.txtInput1.Enabled = flag && !isContinue && !isM21;
            this.btnInput1.Enabled = flag && !isContinue && !isM21;

            this.spSafeHeight.Enabled = flag && !isContinue && !isM21;
            this.chkUseWSafeHeight.Enabled = flag && !isContinue && !isM21;

            this.rgThrowMode.Enabled = flag && !isContinue && !isM21;
            this.txtThrowStartHeight.Enabled = flag && !isContinue && !isM21;
            this.cmbThrowResponse.Enabled = flag && !isContinue && !isM21;
            this.txtThrowLeft.Enabled = flag && !isContinue && !isM21;
            this.txtThrowStartHeight2.Enabled = flag && !isContinue && !isM21;
            this.cmbThrowResponse2.Enabled = flag && !isContinue && !isM21;
            this.txtThrowLeft2.Enabled = flag && !isContinue && !isM21;
            //this.gridViewCnc.GridControl.Enabled = flag && !isContinue && !isM21;
            #endregion

            if (isM21)
            {
                if (flag)//如果轴停下来了,在Z轴有了穿透再下降过程中
                {
                    if (isThrowZEndStoped)
                    {
                        if (IOHelper.IsWHit())  //如果有短路信号,那么代表还没移动到位,需要等待判断是否短路信号清了继续移动
                        {
                            isThrowZWHitDetected = true;
                        }
                        else if (isThrowZWHitDetected && !IOHelper.IsWHit())  //如果检查到过有短信信号并且 短路信号又没有了,把剩下的位置走完
                        {
                            isThrowZWHitDetected = false;
                            this.CurrInfo.LogPosZ = card.GetActPos(AxisSet.ZReadAxis) * AxisSet.ZResolution;
                            var position = this.CurrInfo.GetActPosZ(axisType);
                            card.SingleMoveZ(new HoleInfo() { Z = throwZReachPosition }, this.axisType, AxisSet.ThrowSpeed);
                            plcHelper.SendMsg(PortHelper.ZDownOn);
                        }
                        else
                        {
                            isThrowZStoped = true; //如果不是短路信号 那么代表穿透已经到位,停止穿透
                            isThrowZEndStoped = false;
                        }
                    }
                    else if (isM21ZDown) //
                    {
                        if (IOHelper.IsWHit())
                        {
                            isM21ZUpWHit = true;
                        }
                        else if (isM21ZUpWHit)
                        {
                            isM21ZUpWHit = false;
                            card.SingleMoveZ(new HoleInfo() { Z = backHeight * OtherSet.BackHeightRate, IsJiaGong = false }, this.axisType);
                            PlcHelpr.SendMsg(PortHelper.ZUpOn);
                        }
                    }
                }
                CheckWaitForJiaong();
                CheckChangeDaoFailureHeight();
                CheckDuanlu();
                WaitForM21ZDown();
                WaitForM21ZUp();
            }
            this.bindingSource.ResetBindings(false);

            #region 手动执行
            //手动执行

            //继续执行
            if (isContinue && !IOHelper.IsWHit())
            {
                if (isRestart)
                {
                    isRestart = false;
                    isContinue = true;
                    StartMove();
                }
                else if (flag && !isM21)
                {
                    if (card.moveState == 1 || card.moveState == 2 || isEndStartMove)
                    {
                        StartMove();
                        if ((card.moveState == 1 || card.moveState == 2) && !isLastWMoved)
                        {
                            isLastWMoved = true;
                        }
                        else if (isEndStartMove && isLastWMoved && card.moveState == 0)
                        {
                            isLastWMoved = false;
                            isEndStartMove = false;
                        }
                    }
                    else if (isEndM21)
                    {
                        if (isSingle && isSingleM21 == false)
                        {
                            isSingleM21 = true;
                            isContinue = false;
                            isSingle = false;
                        }
                        else
                        {
                            M21();
                            isSingleM21 = false;
                        }
                    }
                    else if (isEndStop)
                    {
                        if (isChangeDaoMove && IOHelper.IsZPlusLimit())
                        {
                            isChangeDaoMove = false;
                            plcHelper.SendMsg(PortHelper.ChangePie);
                        }
                        if (!isChangeDaoMove)
                        {
                            inputHole = null;
                            inputInfo = null;
                            isEndStop = false;
                            isContinue = false;
                        }
                        if (isLnsMove)
                        {
                            inputInfo = null;
                            inputHole = null;
                            isLnsMove = false;
                            isLnsMoved = true;
                            isContinue = false;
                        }
                    }
                    else
                    {
                        currPostion += 1;
                        if (!isSingle)
                        {
                            if (currPostion >= this.gridViewCnc.RowCount || isM21FinishCloseShuibeng)//加工完成后
                            {
                                CloseAllOutput();
                                isM21FinishCloseShuibeng = false;
                                timerTotal.Enabled = false;
                                isContinue = false;
                                this.btnMen.Value = this.btnMen.Value == 2 ? 2 : 1;
                                IOHelper.SetMen(0);
                                if (currPostion >= this.gridViewCnc.RowCount)
                                    miRestart_ItemClick(null, null);
                                return;
                            }
                            StartMove();
                        }
                        else
                        {
                            isContinue = false;
                            isSingle = false;
                        }
                    }
                    if (this.gridViewCnc.RowCount > 0)
                    {
                        if (currPostion == -1)
                            this.gridViewCnc.FocusedRowHandle = 0;
                        else if (currPostion < this.gridViewCnc.RowCount)
                            this.gridViewCnc.FocusedRowHandle = currPostion;
                        else
                            this.gridViewCnc.FocusedRowHandle = this.gridViewCnc.RowCount - 1;
                        if (currPostion >= this.gridViewCnc.RowCount)
                        {
                            isContinue = false;
                            isSingle = false;
                        }
                    }
                }

            }

            if (isInput)
            {
                isInput = false;

                if (inputInfo != null)
                {
                    if (inputInfo is SingleMoveInfo)
                    {
                        var singleInfo = inputInfo as SingleMoveInfo;
                        inputHole = new HoleInfo()
                        {
                            IsJiaGong = false,
                            X = singleInfo.X,
                            Y = singleInfo.Y,
                            W = singleInfo.W,
                            B = singleInfo.B,
                            C = singleInfo.C,
                            Z = singleInfo.A,
                            AxisType = singleInfo.AxisType ?? this.axisType
                        };
                        StartMove();
                    }
                    else if (inputInfo is M21Info)
                    {
                        var m21Info = inputInfo as M21Info;
                        inputHole = new HoleInfo()
                        {
                            IsJiaGong = true,
                            Param = m21Info.E
                        };
                        StartMove();
                    }
                }
                isEndStop = true;
                isContinue = true;
            }

            #region 自动分中
            if (!isContinue && isAutoCenter && !IOHelper.IsStopButton())
            {
                //200速度X正方向
                if (centerType == 0)
                {
                    MoveCenter(AxisSet.AxisX, 1, () =>
                    {
                        centerXPlus = (firstValue + secondValue + thirdValue) / 2;
                        centerAttemps = 0;
                        centerType = 1;
                    });
                }
                else if (centerType == 1)
                {
                    MoveCenter(AxisSet.AxisX, -1, () =>
                    {
                        centerXMinus = (firstValue + secondValue + thirdValue) / 2;
                        centerX = (centerXPlus + centerXMinus) / 2;
                        centerAttemps = 0;
                        centerType = 3;
                        listBoxControl1.Items.Insert(0, string.Format(L.R("FormMain.AutoCenter.XCenter", "X中心点:{0:0.000}"), centerX));
                        card.SingleMoveX(new HoleInfo() { X = centerX }, this.axisType);
                    });
                }
                else if (centerType == 3 && flag)
                {
                    MoveCenter(AxisSet.AxisY, 1, () =>
                    {
                        centerYPlus = (firstValue + secondValue + thirdValue) / 2;
                        centerAttemps = 0;
                        centerType = 4;
                    });
                }
                else if (centerType == 4)
                {
                    MoveCenter(AxisSet.AxisY, -1, () =>
                    {
                        centerYMinus = (firstValue + secondValue + thirdValue) / 2;
                        centerY = (centerYPlus + centerYMinus) / 2;
                        centerAttemps = 0;
                        listBoxControl1.Items.Insert(0, string.Format(L.R("FormMain.AutoCenter.YCenter", "Y中心点:{0:0.000}"), centerY));
                        card.SingleMoveY(new HoleInfo() { Y = centerY }, this.axisType);
                        centerType = 5;
                    });
                }
                else if (centerType == 5 && flag)
                {
                    isSkipProtect = false;
                    IOHelper.SetHitProtect(1);
                    Thread.Sleep(50);
                    centerAttemps = 0;
                    centerType = 0;
                    isAutoCenter = false;
                }
                else if (centerType == 10)
                {
                    isSkipProtect = false;
                    IOHelper.SetHitProtect(1);
                    Thread.Sleep(50);
                    centerType = 0;
                    centerAttemps = 0;
                    card.CloseAllMove();
                    isAutoCenter = false;
                }
            }
            #endregion

            #region 雷尼绍检测
            if (!isContinue && isLNSCheck && !IOHelper.IsStopButton())
            {
                if (lnsCheckCurrentLine < pckList.Count)
                {
                    if (lnsCheckCurrentLine == 0 && lnsCheckCount == 0)
                    {
                        PlcHelpr.SendMsg(PortHelper.LNSOn);
                        Thread.Sleep(10);
                    }
                    var current = pckList[lnsCheckCurrentLine];
                    MoveLNSCheck(current, () =>
                    {
                        //1.获取锁存位置
                        var position = card.GetLockPosition();
                        if (lnsCheckType == 2)
                        {
                            current.RealValue = CurrInfo.GetWActPos(((decimal)position) / 1000, current.AxisType);
                            current.CheckValue = OtherSet.LNSAllowValue;
                        }
                        else
                        {
                            current.StandardValue = CurrInfo.GetWActPos(((decimal)position) / 1000, current.AxisType);
                            current.CheckValue = OtherSet.LNSAllowValue;
                        }
                        card.ClearLockPosition();
                        lnsCheckCurrentLine++;
                    });
                }
                else
                {
                    PlcHelpr.SendMsg(PortHelper.LNSOff);
                    isLNSCheck = false;
                }
            }
            #endregion

            #endregion
        }
Example #15
0
 private void StartMove(HoleInfo info)
 {
     SingleMove(info);
     isEndM21 = info.IsJiaGong && !this.cbEmptyRun.Checked;// && (!isSingle || (isSingle && CurrInfo.GetActPosX(info.AxisType) == info.X && CurrInfo.GetActPosY(info.AxisType) == info.Y));
     param = info.Param;
 }
Example #16
0
 private void SingleMove(HoleInfo info)
 {
     card.SingleMove(info, this.tabShow.SelectedTabPage.Text);
 }
Example #17
0
 public void SingleMoveB(HoleInfo moveInfo, string axisType)
 {
     if (moveInfo.B.HasValue)
     {
         decimal actPosB = Contra.GetActPosB(axisType);
         isBPlus = moveInfo.B.Value >= actPosB;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisB,
         GetMovePosition("B", moveInfo.B, actPosB, Contra.LogPosB, isBPlus != isOldBPlus, isOldBPlus, out jianxiB),
         Contra.StartSpeed, (int)AxisSet.SpeedBPerSecond, (double)Contra.AddSpeedTime);
         isOldBPlus = isBPlus;
     }
 }
Example #18
0
 private void miNext_Click(object sender, EventArgs e)
 {
     var selectRow = this.gridViewCnc.FocusedRowHandle;
     if (selectRow < 0)
     {
         throw new Exception(L.R("FormMain.NotChooseAnyHole", "还未选中任何孔位!"));
     }
     if (selectRow + 1 > this.gridViewCnc.RowCount)
     {
         throw new Exception(L.R("FormMain.RunToEnd", "已运行至结尾!"));
     }
     inputHole = null;
     inputInfo = null;
     currPostion = selectRow;
     isContinue = true;
     isRestart = true;
     isSingle = true;
 }
Example #19
0
        public void SingleMoveZ(HoleInfo moveInfo, string axisType, decimal speed = 0)
        {
            if (moveInfo.Z.HasValue)
            {
                Contra.LogPosZ = GetActPos(AxisSet.ZReadAxis) * AxisSet.ZResolution;
                Contra.LogPosA = GetLogPos(AxisSet.AxisZ);
                Contra.TempLogPosA = Contra.LogPosZ + Contra.TempLogPosZ - Contra.LogPosA;
                Contra.TempLogPosA55 = Contra.LogPosZ + Contra.TempLogPosZ55 - Contra.LogPosA;
                Contra.TempLogPosA56 = Contra.LogPosZ + Contra.TempLogPosZ56 - Contra.LogPosA;
                Contra.TempLogPosA57 = Contra.LogPosZ + Contra.TempLogPosZ57 - Contra.LogPosA;
                Contra.TempLogPosA58 = Contra.LogPosZ + Contra.TempLogPosZ58 - Contra.LogPosA;
                Contra.TempLogPosA59 = Contra.LogPosZ + Contra.TempLogPosZ59 - Contra.LogPosA;

                Contra.TempLogPosA60 = Contra.LogPosZ + Contra.TempLogPosZ60 - Contra.LogPosA;
                Contra.TempLogPosA61 = Contra.LogPosZ + Contra.TempLogPosZ61 - Contra.LogPosA;
                Contra.TempLogPosA62 = Contra.LogPosZ + Contra.TempLogPosZ62 - Contra.LogPosA;
                Contra.TempLogPosA63 = Contra.LogPosZ + Contra.TempLogPosZ63 - Contra.LogPosA;
                Contra.TempLogPosA64 = Contra.LogPosZ + Contra.TempLogPosZ64 - Contra.LogPosA;
                Contra.TempLogPosA65 = Contra.LogPosZ + Contra.TempLogPosZ65 - Contra.LogPosA;

                decimal actPosA = Contra.GetActPosZ(axisType);
                var v = GetMovePosition("Z", moveInfo.Z, actPosA, Contra.LogPosA, isAPlus != isOldAPlus, isOldAPlus, out jianxiA);
                isAPlus = moveInfo.Z.Value >= actPosA;
                CtrlCard.Sym_AbsoluteMove(AxisSet.AxisZ,
                v,
                Contra.StartSpeed, (int)(speed == 0 ? AxisSet.SpeedZPerSecond : speed), (double)Contra.AddSpeedTime);
                isOldAPlus = isAPlus;
            }
        }
Example #20
0
        public static HoleCollection LoadCnc(string fileName, string mode)
        {
            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sr = new StreamReader(fs))
                {
                    var collection = new HoleCollection();
                    var axisType = "G54";
                    string line = sr.ReadLine().Replace(" ", "");
                    if (string.IsNullOrEmpty(line) || !line.StartsWith("O1234"))
                    {
                        throw new WarningException(L.R("PNCHelper.FileError1", "文件格式错误:缺少开始符!"));
                    }
                    HoleInfo holeInfo = null;
                    int index = 2;
                    Regex reg = new Regex(@"([X,Y,W,B,C])([-]?\d+(\.\d+)?)");
                    while (true)
                    {
                        line = sr.ReadLine().Replace(" ", "");
                        if (!string.IsNullOrEmpty(line))
                        {
                            if (mode == "2")
                            {
                                if (line.StartsWith("G"))
                                {
                                    holeInfo = new HoleInfo() { IsJiaGong = false, AxisType = axisType };
                                    string[] list = line.Split(new char[] { '	' }, StringSplitOptions.RemoveEmptyEntries);
                                    if (list.Length != 7 && list.Length != 8)
                                    {
                                        throw new WarningException("无效的脚本:" + line);
                                    }
                                    holeInfo.AxisType = list[0];
                                    holeInfo.X = Convert.ToDecimal(list[1]);
                                    holeInfo.Y = Convert.ToDecimal(list[2]);
                                    holeInfo.W = Convert.ToDecimal(list[3]);
                                    holeInfo.B = Convert.ToDecimal(list[4]);
                                    holeInfo.C = Convert.ToDecimal(list[5]);
                                    holeInfo.Param = list[6];
                                    if (list.Length == 8)
                                        holeInfo.IsJiaGong = list[7] == "M21";
                                    collection.Add(holeInfo);
                                }
                                else if ((line.StartsWith("M11") || line.StartsWith("M21")) && holeInfo != null)
                                {
                                    holeInfo.IsJiaGong = true;
                                }
                                else if (line.StartsWith("M30"))
                                {
                                    break;
                                }
                                else
                                {
                                    throw new WarningException(L.R("PNCHelper.FileError3", "文件格式错误:无法解析的行[{0}],行{0}"), line, index);
                                }
                            }
                            else
                            {
                                if (line.StartsWith("G0"))
                                {
                                    holeInfo = new HoleInfo() { IsJiaGong = false, AxisType = axisType };
                                    MatchCollection matchs = reg.Matches(line);
                                    foreach (Match match in matchs)
                                    {
                                        switch (match.Groups[1].Value)
                                        {
                                            case "X": holeInfo.X = Convert.ToDecimal(match.Groups[2].Value); break;
                                            case "Y": holeInfo.Y = Convert.ToDecimal(match.Groups[2].Value); break;
                                            case "W": holeInfo.W = Convert.ToDecimal(match.Groups[2].Value); break;
                                            case "B": holeInfo.B = Convert.ToDecimal(match.Groups[2].Value); break;
                                            case "C": holeInfo.C = Convert.ToDecimal(match.Groups[2].Value); break;
                                        }
                                    }
                                    collection.Add(holeInfo);
                                }
                                else if (line == "G54" || line == "G55" || line == "G56" || line == "G57" || line == "G58" || line == "G59")
                                {
                                    axisType = line;
                                }
                                else if ((line.StartsWith("M11") || line.StartsWith("M21")) && holeInfo != null)
                                {
                                    holeInfo.IsJiaGong = true;
                                }
                                else if (line.StartsWith("M30"))
                                {
                                    break;
                                }
                                else
                                {
                                    throw new WarningException(L.R("PNCHelper.FileError3", "文件格式错误:无法解析的行[{0}],行{0}"), line, index);
                                }
                            }

                            index++;
                        }
                    }
                    return collection;
                }
            }
        }
Example #21
0
 public void SingleMoveW(HoleInfo moveInfo, string axisType)
 {
     if (moveInfo.W.HasValue)
     {
         decimal actPosW = Contra.GetActPosW(axisType);
         isWPlus = moveInfo.W.Value >= actPosW;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisW,
         GetMovePosition("W", moveInfo.W, actPosW, Contra.LogPosW, isWPlus != isOldWPlus, isOldWPlus, out jianxiW),
         Contra.StartSpeed, (int)AxisSet.SpeedWPerSecond, (double)Contra.AddSpeedTime);
         isOldWPlus = isWPlus;
     }
 }
Example #22
0
 public void SingleMoveC(HoleInfo moveInfo, string axisType, int? speed)
 {
     if (moveInfo.C.HasValue)
     {
         decimal actPosC = Contra.GetActPosC(axisType);
         isCPlus = moveInfo.C.Value >= actPosC;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisC,
         GetMovePosition("C", moveInfo.C, actPosC, Contra.LogPosC, isCPlus != isOldCPlus, isOldCPlus, out jianxiC),
         Contra.StartSpeed, speed ?? (int)AxisSet.SpeedCPerSecond, (double)Contra.AddSpeedTime);
         isOldCPlus = isCPlus;
     }
 }
Example #23
0
        public void SingleMove(HoleInfo moveInfo, string axisType)
        {
            decimal actPosW = Contra.GetActPosW(axisType);
            decimal moveToW = moveInfo.W ?? actPosW;

            if (moveState == 0 && actPosW < moveToW)
            {
                isWPlus = moveInfo.W.Value >= actPosW;
                CtrlCard.Sym_AbsoluteMove(AxisSet.AxisW,
                                          GetMovePosition("W", moveInfo.W, actPosW, Contra.LogPosW, isWPlus != isOldWPlus, isOldWPlus, out jianxiW),
                                          Contra.StartSpeed, (int)AxisSet.SpeedWPerSecond, (double)Contra.AddSpeedTime);
                isOldWPlus = isWPlus;
                moveState  = 1;
            }
            else if (moveState == 1 || (!moveInfo.W.HasValue && moveState != 2) || (moveInfo.W.HasValue && actPosW >= moveToW && moveState != 2))
            {
                if (moveInfo.X.HasValue)
                {
                    decimal actPosX = Contra.GetActPosX(axisType);
                    isXPlus = moveInfo.X.Value >= actPosX;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisX,
                                              GetMovePosition("X", moveInfo.X, actPosX, Contra.LogPosX, isXPlus != isOldXPlus, isOldXPlus, out jianxiX),
                                              Contra.StartSpeed, (int)AxisSet.SpeedXPerSecond, (double)Contra.AddSpeedTime);
                    isOldXPlus = isXPlus;
                }
                if (moveInfo.Y.HasValue)
                {
                    decimal actPosY = Contra.GetActPosY(axisType);
                    isYPlus = moveInfo.Y.Value >= actPosY;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisY,
                                              GetMovePosition("Y", moveInfo.Y, actPosY, Contra.LogPosY, isYPlus != isOldYPlus, isOldYPlus, out jianxiY),
                                              Contra.StartSpeed, (int)AxisSet.SpeedYPerSecond, (double)Contra.AddSpeedTime);
                    isOldYPlus = isYPlus;
                }
                if (moveInfo.Z.HasValue)
                {
                    Contra.LogPosZ       = GetActPos(AxisSet.ZReadAxis) * AxisSet.ZResolution;
                    Contra.LogPosA       = GetLogPos(AxisSet.AxisZ);
                    Contra.TempLogPosA   = Contra.LogPosZ + Contra.TempLogPosZ - Contra.LogPosA;
                    Contra.TempLogPosA55 = Contra.LogPosZ + Contra.TempLogPosZ55 - Contra.LogPosA;
                    Contra.TempLogPosA56 = Contra.LogPosZ + Contra.TempLogPosZ56 - Contra.LogPosA;
                    Contra.TempLogPosA57 = Contra.LogPosZ + Contra.TempLogPosZ57 - Contra.LogPosA;
                    Contra.TempLogPosA58 = Contra.LogPosZ + Contra.TempLogPosZ58 - Contra.LogPosA;
                    Contra.TempLogPosA59 = Contra.LogPosZ + Contra.TempLogPosZ59 - Contra.LogPosA;

                    Contra.TempLogPosA60 = Contra.LogPosZ + Contra.TempLogPosZ60 - Contra.LogPosA;
                    Contra.TempLogPosA61 = Contra.LogPosZ + Contra.TempLogPosZ61 - Contra.LogPosA;
                    Contra.TempLogPosA62 = Contra.LogPosZ + Contra.TempLogPosZ62 - Contra.LogPosA;
                    Contra.TempLogPosA63 = Contra.LogPosZ + Contra.TempLogPosZ63 - Contra.LogPosA;
                    Contra.TempLogPosA64 = Contra.LogPosZ + Contra.TempLogPosZ64 - Contra.LogPosA;
                    Contra.TempLogPosA65 = Contra.LogPosZ + Contra.TempLogPosZ65 - Contra.LogPosA;


                    decimal actPosA = Contra.GetActPosZ(axisType);
                    isAPlus = moveInfo.Z.Value >= actPosA;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisZ,
                                              GetMovePosition("Z", moveInfo.Z, actPosA, Contra.LogPosA, isAPlus != isOldAPlus, isOldAPlus, out jianxiA),
                                              Contra.StartSpeed, (int)AxisSet.SpeedZPerSecond, (double)Contra.AddSpeedTime);
                    isOldAPlus = isAPlus;
                }
                if (moveInfo.B.HasValue)
                {
                    decimal actPosB = Contra.GetActPosB(axisType);
                    isBPlus = moveInfo.B.Value >= actPosB;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisB,
                                              GetMovePosition("B", moveInfo.B, actPosB, Contra.LogPosB, isBPlus != isOldBPlus, isOldBPlus, out jianxiB),
                                              Contra.StartSpeed, (int)AxisSet.SpeedBPerSecond, (double)Contra.AddSpeedTime);
                    isOldBPlus = isBPlus;
                }
                if (moveInfo.C.HasValue)
                {
                    decimal actPosC = Contra.GetActPosC(axisType);
                    isCPlus = moveInfo.C.Value >= actPosC;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisC,
                                              GetMovePosition("C", moveInfo.C, actPosC, Contra.LogPosC, isCPlus != isOldCPlus, isOldCPlus, out jianxiC),
                                              Contra.StartSpeed, (int)AxisSet.SpeedCPerSecond, (double)Contra.AddSpeedTime);
                    isOldCPlus = isCPlus;
                }
                moveState = (!moveInfo.W.HasValue || actPosW >= moveToW) ? 2 : 0;
            }
            else if (moveState == 2 && actPosW >= moveToW)
            {
                if (moveInfo.W.HasValue)
                {
                    isWPlus = moveInfo.W.Value >= actPosW;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisW,
                                              GetMovePosition("W", moveInfo.W, actPosW, Contra.LogPosW, isWPlus != isOldWPlus, isOldWPlus, out jianxiW),
                                              Contra.StartSpeed, (int)AxisSet.SpeedWPerSecond, (double)Contra.AddSpeedTime);
                    isOldWPlus = isWPlus;
                }
                moveState = 0;
            }
        }
Example #24
0
 private void miStart_ItemClick(object sender, EventArgs e)
 {
     if (this.gridViewCnc.RowCount == 0)
     {
         throw new Exception(L.R("FormMain.ScriptNotLoad", "还未加载脚本!"));
     }
     inputHole = null;
     inputInfo = null;
     if (currPostion >= this.gridViewCnc.RowCount)
         currPostion = this.gridViewCnc.RowCount - 1;
     isContinue = true;
     isRestart = true;
     card.SetAbsolute();
     timerTotal.Enabled = true;
     this.gridViewCnc.Focus();
 }
Example #25
0
 public void SingleMoveX(HoleInfo moveInfo, string axisType)
 {
     if (moveInfo.X.HasValue)
     {
         decimal actPosX = Contra.GetActPosX(axisType);
         isXPlus = moveInfo.X.Value >= actPosX;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisX,
         GetMovePosition("X", moveInfo.X, actPosX, Contra.LogPosX, isXPlus != isOldXPlus, isOldXPlus, out jianxiX),
         Contra.StartSpeed, (int)AxisSet.SpeedXPerSecond, (double)Contra.AddSpeedTime);
         isOldXPlus = isXPlus;
     }
 }
Example #26
0
        public void SingleMove(HoleInfo moveInfo, string axisType)
        {
            decimal actPosW = Contra.GetActPosW(axisType);
            decimal moveToW = moveInfo.W ?? actPosW;

            if (moveState == 0 && actPosW < moveToW)
            {
                isWPlus = moveInfo.W.Value >= actPosW;
                CtrlCard.Sym_AbsoluteMove(AxisSet.AxisW,
                GetMovePosition("W", moveInfo.W, actPosW, Contra.LogPosW, isWPlus != isOldWPlus, isOldWPlus, out jianxiW),
                Contra.StartSpeed, (int)AxisSet.SpeedWPerSecond, (double)Contra.AddSpeedTime);
                isOldWPlus = isWPlus;
                moveState = 1;
            }
            else if (moveState == 1 || (!moveInfo.W.HasValue && moveState != 2) || (moveInfo.W.HasValue && actPosW >= moveToW && moveState != 2))
            {
                if (moveInfo.X.HasValue)
                {
                    decimal actPosX = Contra.GetActPosX(axisType);
                    isXPlus = moveInfo.X.Value >= actPosX;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisX,
                    GetMovePosition("X", moveInfo.X, actPosX, Contra.LogPosX, isXPlus != isOldXPlus, isOldXPlus, out jianxiX),
                    Contra.StartSpeed, (int)AxisSet.SpeedXPerSecond, (double)Contra.AddSpeedTime);
                    isOldXPlus = isXPlus;
                }
                if (moveInfo.Y.HasValue)
                {
                    decimal actPosY = Contra.GetActPosY(axisType);
                    isYPlus = moveInfo.Y.Value >= actPosY;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisY,
                    GetMovePosition("Y", moveInfo.Y, actPosY, Contra.LogPosY, isYPlus != isOldYPlus, isOldYPlus, out jianxiY),
                    Contra.StartSpeed, (int)AxisSet.SpeedYPerSecond, (double)Contra.AddSpeedTime);
                    isOldYPlus = isYPlus;
                }
                if (moveInfo.Z.HasValue)
                {
                    Contra.LogPosZ = GetActPos(AxisSet.ZReadAxis) * AxisSet.ZResolution;
                    Contra.LogPosA = GetLogPos(AxisSet.AxisZ);
                    Contra.TempLogPosA = Contra.LogPosZ + Contra.TempLogPosZ - Contra.LogPosA;
                    Contra.TempLogPosA55 = Contra.LogPosZ + Contra.TempLogPosZ55 - Contra.LogPosA;
                    Contra.TempLogPosA56 = Contra.LogPosZ + Contra.TempLogPosZ56 - Contra.LogPosA;
                    Contra.TempLogPosA57 = Contra.LogPosZ + Contra.TempLogPosZ57 - Contra.LogPosA;
                    Contra.TempLogPosA58 = Contra.LogPosZ + Contra.TempLogPosZ58 - Contra.LogPosA;
                    Contra.TempLogPosA59 = Contra.LogPosZ + Contra.TempLogPosZ59 - Contra.LogPosA;

                    Contra.TempLogPosA60 = Contra.LogPosZ + Contra.TempLogPosZ60 - Contra.LogPosA;
                    Contra.TempLogPosA61 = Contra.LogPosZ + Contra.TempLogPosZ61 - Contra.LogPosA;
                    Contra.TempLogPosA62 = Contra.LogPosZ + Contra.TempLogPosZ62 - Contra.LogPosA;
                    Contra.TempLogPosA63 = Contra.LogPosZ + Contra.TempLogPosZ63 - Contra.LogPosA;
                    Contra.TempLogPosA64 = Contra.LogPosZ + Contra.TempLogPosZ64 - Contra.LogPosA;
                    Contra.TempLogPosA65 = Contra.LogPosZ + Contra.TempLogPosZ65 - Contra.LogPosA;

                    decimal actPosA = Contra.GetActPosZ(axisType);
                    isAPlus = moveInfo.Z.Value >= actPosA;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisZ,
                    GetMovePosition("Z", moveInfo.Z, actPosA, Contra.LogPosA, isAPlus != isOldAPlus, isOldAPlus, out jianxiA),
                    Contra.StartSpeed, (int)AxisSet.SpeedZPerSecond, (double)Contra.AddSpeedTime);
                    isOldAPlus = isAPlus;
                }
                if (moveInfo.B.HasValue)
                {
                    decimal actPosB = Contra.GetActPosB(axisType);
                    isBPlus = moveInfo.B.Value >= actPosB;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisB,
                    GetMovePosition("B", moveInfo.B, actPosB, Contra.LogPosB, isBPlus != isOldBPlus, isOldBPlus, out jianxiB),
                    Contra.StartSpeed, (int)AxisSet.SpeedBPerSecond, (double)Contra.AddSpeedTime);
                    isOldBPlus = isBPlus;
                }
                if (moveInfo.C.HasValue)
                {
                    decimal actPosC = Contra.GetActPosC(axisType);
                    isCPlus = moveInfo.C.Value >= actPosC;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisC,
                    GetMovePosition("C", moveInfo.C, actPosC, Contra.LogPosC, isCPlus != isOldCPlus, isOldCPlus, out jianxiC),
                    Contra.StartSpeed, (int)AxisSet.SpeedCPerSecond, (double)Contra.AddSpeedTime);
                    isOldCPlus = isCPlus;
                }
                moveState = (!moveInfo.W.HasValue || actPosW >= moveToW) ? 2 : 0;
            }
            else if (moveState == 2 && actPosW >= moveToW)
            {
                if (moveInfo.W.HasValue)
                {
                    isWPlus = moveInfo.W.Value >= actPosW;
                    CtrlCard.Sym_AbsoluteMove(AxisSet.AxisW,
                    GetMovePosition("W", moveInfo.W, actPosW, Contra.LogPosW, isWPlus != isOldWPlus, isOldWPlus, out jianxiW),
                    Contra.StartSpeed, (int)AxisSet.SpeedWPerSecond, (double)Contra.AddSpeedTime);
                    isOldWPlus = isWPlus;
                }
                moveState = 0;
            }
        }
Example #27
0
 public void SingleMoveY(HoleInfo moveInfo, string axisType)
 {
     if (moveInfo.Y.HasValue)
     {
         decimal actPosY = Contra.GetActPosY(axisType);
         isYPlus = moveInfo.Y.Value >= actPosY;
         CtrlCard.Sym_AbsoluteMove(AxisSet.AxisY,
         GetMovePosition("Y", moveInfo.Y, actPosY, Contra.LogPosY, isYPlus != isOldYPlus, isOldYPlus, out jianxiY),
         Contra.StartSpeed, (int)AxisSet.SpeedYPerSecond, (double)Contra.AddSpeedTime);
         isOldYPlus = isYPlus;
     }
 }
Example #28
0
        public static HoleCollection LoadCnc(string fileName, string mode)
        {
            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sr = new StreamReader(fs))
                {
                    var collection = new HoleCollection();
                    var axisType = "G54";
                    string line = sr.ReadLine().Replace(" ", "");
                    if (string.IsNullOrEmpty(line) || !line.StartsWith("O1234"))
                    {
                        throw new WarningException(L.R("PNCHelper.FileError1", "文件格式错误:缺少开始符!"));
                    }
                    HoleInfo holeInfo = null;
                    int index = 2;
                    Regex reg = new Regex(@"([X,Y,W,B,C])([-]?\d+(\.\d+)?)");
                    while (true)
                    {
                        line = sr.ReadLine().Replace(" ", "");
                        if (!string.IsNullOrEmpty(line))
                        {
                            if (mode == "2")
                            {
                                if (line.StartsWith("G"))
                                {
                                    holeInfo = new HoleInfo() { IsJiaGong = false, AxisType = axisType };
                                    string[] list = line.Split(new char[] { '	' }, StringSplitOptions.RemoveEmptyEntries);
                                    if (list.Length != 7 && list.Length != 8)
                                    {
                                        throw new WarningException("无效的脚本:" + line);
                                    }
                                    holeInfo.AxisType = list[0];
                                    holeInfo.X = Convert.ToDecimal(list[1]);
                                    holeInfo.Y = Convert.ToDecimal(list[2]);
                                    holeInfo.W = Convert.ToDecimal(list[3]);
                                    holeInfo.B = Convert.ToDecimal(list[4]);
                                    holeInfo.C = Convert.ToDecimal(list[5]);
                                    holeInfo.Param = list[6];
                                    if (list.Length == 8)
                                        holeInfo.IsJiaGong = list[7] == "M21";
                                    collection.Add(holeInfo);
                                }
                                else if ((line.StartsWith("M11") || line.StartsWith("M21")) && holeInfo != null)
                                {
                                    holeInfo.IsJiaGong = true;
                                }
                                else if (line.StartsWith("M30"))
                                {
                                    break;
                                }
                                else
                                {
                                    throw new WarningException(L.R("PNCHelper.FileError3", "文件格式错误:无法解析的行[{0}],行{0}"), line, index);
                                }
                            }
                            else
                            {
                                if (line.StartsWith("G0"))
                                {
                                    holeInfo = new HoleInfo() { IsJiaGong = false, AxisType = axisType };
                                    MatchCollection matchs = reg.Matches(line);
                                    foreach (Match match in matchs)
                                    {
                                        switch (match.Groups[1].Value)
                                        {
                                            case "X": holeInfo.X = Convert.ToDecimal(match.Groups[2].Value); break;
                                            case "Y": holeInfo.Y = Convert.ToDecimal(match.Groups[2].Value); break;
                                            case "W": holeInfo.W = Convert.ToDecimal(match.Groups[2].Value); break;
                                            case "B": holeInfo.B = Convert.ToDecimal(match.Groups[2].Value); break;
                                            case "C": holeInfo.C = Convert.ToDecimal(match.Groups[2].Value); break;
                                        }
                                    }
                                    collection.Add(holeInfo);
                                }
                                else if (line == "G54" || line == "G55" || line == "G56" || line == "G57" || line == "G58" || line == "G59")
                                {
                                    axisType = line;
                                }
                                else if ((line.StartsWith("M11") || line.StartsWith("M21")) && holeInfo != null)
                                {
                                    holeInfo.IsJiaGong = true;
                                }
                                else if (line.StartsWith("M30"))
                                {
                                    break;
                                }
                                else
                                {
                                    throw new WarningException(L.R("PNCHelper.FileError3", "文件格式错误:无法解析的行[{0}],行{0}"), line, index);
                                }
                            }

                            index++;
                        }
                    }
                    return collection;
                }
            }
        }