示例#1
0
 public EditMultiLinesForm(Pattern pattern, LineCmdLine lineCmdLine, Line line, int indexOfLineCoordinate)
     : this(pattern, lineCmdLine)
 {
     this.line                  = line;
     this.isRunning             = true;
     this.indexOfLineCoordinate = indexOfLineCoordinate;
 }
示例#2
0
        public EditPolyLineForm(Pattern pattern, LineCmdLine lineCmdLine) : base(pattern.GetOriginPos())
        {
            InitializeComponent();
            this.ReadLanguageResources();
            this.pattern = pattern;
            this.origin  = pattern.GetOriginPos();

            if (lineCmdLine == null)
            {
                isCreating       = true;
                this.lineCmdLine = new LineCmdLine()
                {
                    LineMethod = LineMethod.Poly
                };
                this.lineCmdLine.LineStyle       = (LineStyle)Properties.Settings.Default.LineStyle;
                this.lineCmdLine.IsWeightControl = Properties.Settings.Default.LineIsWt;
                this.lineCmdLine.WholeWeight     = Properties.Settings.Default.LineWt;
                //系统坐标->机械坐标
                PointD p = this.pattern.MachineRel(Properties.Settings.Default.LineEndX, Properties.Settings.Default.LineEndY);
                this.tbPointX.Text          = p.X.ToString("0.000");
                this.tbPointY.Text          = p.Y.ToString("0.000");
                this.btnLastCmdLine.Visible = false;
                this.btnNextCmdLine.Visible = false;
            }
            else
            {
                isCreating       = false;
                this.lineCmdLine = lineCmdLine;
                lineCoordinateCache.AddRange(this.lineCmdLine.LineCoordinateList);
                for (int i = 0; i < lineCoordinateCache.Count; i++)
                {
                    if (i == 0)
                    {
                        this.linePointsCache.Add(lineCoordinateCache[i].Start);
                    }
                    this.linePointsCache.Add(lineCoordinateCache[i].End);
                }
            }

            //load points to listboxPoints
            this.LoadPoints2ListBox();
            //load lines to listboxLines
            this.LoadLines2ListBox();
            if (lineCoordinateCache.Count > 0)
            {
                listBoxLines.SelectedIndex = 0;
            }
            cbWeightControl.Checked = this.lineCmdLine.IsWeightControl;
            if (this.lineCmdLine != null)
            {
                this.lineCmdLineBackUp = (LineCmdLine)this.lineCmdLine.Clone();
            }

            this.FormClosed += EditPolyLineForm_FormClosed;
        }
示例#3
0
        /// <summary>
        /// Description	:显示指定指令的编辑窗口到父级编辑窗口
        /// Author      :Xuxixiao
        /// Date		:2019/08/29
        /// </summary>
        /// <param name="cmdLine"></param>
        private void ShowCmdLineEditForm(CmdLine cmdLine)
        {
            if (this.curModule == null)
            {
                return;
            }
            if (EditFormParent.Current == null || EditFormParent.Current.IsDisposed)
            {
                new EditFormParent(cmdLine.CommandsModule as Pattern).Show();
            }

            if (cmdLine is CircleCmdLine)
            {
                EditFormParent.Current.ChangeForm(new EditCircleForm1(this.curModule as Pattern, cmdLine as CircleCmdLine));
            }
            else if (cmdLine is ArcCmdLine)
            {
                EditFormParent.Current.ChangeForm(new EditArcForm1(this.curModule as Pattern, cmdLine as ArcCmdLine));
            }
            else if (cmdLine is DotCmdLine)
            {
                EditFormParent.Current.ChangeForm(new EditDotForm1(this.curModule as Pattern, cmdLine as DotCmdLine));
            }
            else if (cmdLine is FinishShotCmdLine)
            {
                EditFormParent.Current.ChangeForm(new EditFinishShotForm1(this.curModule as Pattern, cmdLine as FinishShotCmdLine));
            }
            else if (cmdLine is SnakeLineCmdLine)
            {
                EditFormParent.Current.ChangeForm(new EditSnakeLineForm1(this.curModule as Pattern, cmdLine as SnakeLineCmdLine));
            }
            else if (cmdLine is LineCmdLine)
            {
                LineCmdLine lineCmdLine = cmdLine as LineCmdLine;
                switch (lineCmdLine.LineMethod)
                {
                case Domain.FluProgram.Common.LineMethod.Multi:
                    EditFormParent.Current.ChangeForm(new EditMultiLinesForm(this.curModule as Pattern, lineCmdLine));
                    break;

                case Domain.FluProgram.Common.LineMethod.Single:
                    EditFormParent.Current.ChangeForm(new EditSingleLineForm(this.curModule as Pattern, lineCmdLine));
                    break;

                case Domain.FluProgram.Common.LineMethod.Poly:
                    EditFormParent.Current.ChangeForm(new EditPolyLineForm(this.curModule as Pattern, lineCmdLine));
                    break;
                }
            }
            else if (cmdLine is NozzleCheckCmdLine)
            {
                EditFormParent.Current.ChangeForm(new EditNozzleCheckForm(this.curModule as Pattern, cmdLine as NozzleCheckCmdLine));
            }
        }
示例#4
0
        ///<summary>
        /// Description	:显示指定指令的编辑窗口
        /// Author      :liyi
        /// Date		:2019/07/23
        ///</summary>
        /// <param name="cmdLine"></param>
        private void ShowCmdLineEditForm(CmdLine cmdLine, Form lastForm)
        {
            if (this.curModule == null)
            {
                return;
            }
            lastForm.Dispose();
            if (cmdLine is CircleCmdLine)
            {
                new EditCircleForm1(this.curModule as Pattern, cmdLine as CircleCmdLine).ShowDialog();
            }
            else if (cmdLine is ArcCmdLine)
            {
                new EditArcForm1(this.curModule as Pattern, cmdLine as ArcCmdLine).ShowDialog();
            }
            else if (cmdLine is DotCmdLine)
            {
                new EditDotForm1(this.curModule as Pattern, cmdLine as DotCmdLine).ShowDialog();
            }
            else if (cmdLine is FinishShotCmdLine)
            {
                new EditFinishShotForm1(this.curModule as Pattern, cmdLine as FinishShotCmdLine).ShowDialog();
            }
            else if (cmdLine is SnakeLineCmdLine)
            {
                new EditSnakeLineForm1(this.curModule as Pattern, cmdLine as SnakeLineCmdLine).ShowDialog();
            }
            else if (cmdLine is LineCmdLine)
            {
                LineCmdLine lineCmdLine = cmdLine as LineCmdLine;
                switch (lineCmdLine.LineMethod)
                {
                case Domain.FluProgram.Common.LineMethod.Multi:
                    new EditMultiLinesForm(this.curModule as Pattern, lineCmdLine).ShowDialog();
                    break;

                case Domain.FluProgram.Common.LineMethod.Single:
                    new EditSingleLineForm(this.curModule as Pattern, lineCmdLine).ShowDialog();
                    break;

                case Domain.FluProgram.Common.LineMethod.Poly:
                    new EditPolyLineForm(this.curModule as Pattern, lineCmdLine).ShowDialog();
                    break;
                }
            }
            else if (cmdLine is NozzleCheckCmdLine)
            {
                new EditNozzleCheckForm(this.curModule as Pattern, cmdLine as NozzleCheckCmdLine).ShowDialog();
            }
        }
示例#5
0
        /// <summary>
        /// 螺杆阀Inspect模式下的运行逻辑
        /// </summary>
        /// <returns></returns>
        private Result SvValveInspectLogic(Line line)
        {
            Result ret = Result.OK;

            List <PointD> points = this.CaculateSvValvePoints(line);

            if (line.LineCmd.lineCmdLine == null || points == null)
            {
                return(ret);
            }
            if (line.LineCmd.lineCmdLine.LineMethod != LineMethod.Single)
            {
                return(ret);
            }

            for (int i = 0; i < points.Count; i++)
            {
                //为了去到线段的起点,会跳过list的奇数部分(终点)
                if (i % 2 == 1)
                {
                    continue;
                }
                else
                {
                    ret = Machine.Instance.Robot.MovePosXYAndReply(points[i],
                                                                   FluidProgram.Current.MotionSettings.VelXY,
                                                                   FluidProgram.Current.MotionSettings.AccXY);
                    if (!ret.IsOk)
                    {
                        return(ret);
                    }

                    LineCmdLine    lineCmdline    = line.LineCmd.lineCmdLine;
                    InspectionLine inspectionLine = InspectionMgr.Instance.FindBy((int)lineCmdline.inspectionKey) as InspectionLine;
                    if (inspectionLine != null)
                    {
                        Thread.Sleep(inspectionLine.SettlingTime);
                        double width1, width2;
                        Machine.Instance.CaptureAndInspect(inspectionLine);
                        width1 = inspectionLine.PhyWidth1;
                        width2 = inspectionLine.PhyWidth2;
                        Log.Dprint(inspectionLine.CurrResultStr);
                        string resline = string.Format("{0},{1},{2},{3}", Math.Round(points[i].X, 3), Math.Round(points[i].Y, 3), Math.Round(width1, 3), Math.Round(width2, 3));
                        CsvUtil.WriteLine(line.Program.RuntimeSettings.FilePathInspectRect, resline);
                        Thread.Sleep(inspectionLine.DwellTime);
                    }
                }
            }
            return(ret);
        }
示例#6
0
        public LineCmd(RunnableModule runnableModule, LineCmdLine lineCmdLine, MeasureHeightCmd mhCmd) : base(runnableModule, lineCmdLine)
        {
            this.Valve = lineCmdLine.Valve;
            var    structure = runnableModule.CommandsModule.program.ModuleStructure;
            PointD start, end;

            this.lineCmdLine = lineCmdLine;
            if (!runnableModule.CommandsModule.IsReversePattern)
            {
                foreach (LineCoordinate line in lineCmdLine.LineCoordinateList)
                {
                    start = structure.ToMachine(runnableModule, line.Start);
                    end   = structure.ToMachine(runnableModule, line.End);
                    LineCoordinate newLine = new LineCoordinate(start, end);
                    newLine.Weight     = line.Weight;
                    newLine.LineStyle  = line.LineStyle;
                    newLine.LookOffset = line.LookOffset;//偏移量
                    lineCoordinateList.Add(newLine);
                }
            }
            else
            {
                List <LineCoordinate> lineCoordinateRevs = new List <LineCoordinate>();
                lineCoordinateRevs.AddRange(lineCmdLine.LineCoordinateList);
                lineCoordinateRevs.Reverse();
                foreach (LineCoordinate line in lineCoordinateRevs)
                {
                    start = structure.ToMachine(runnableModule, line.End);
                    end   = structure.ToMachine(runnableModule, line.Start);
                    LineCoordinate newLine = new LineCoordinate(start, end);
                    newLine.Weight         = line.Weight;
                    newLine.LineStyle      = line.LineStyle;
                    newLine.LookOffsetRevs = line.LookOffsetRevs;//偏移量
                    lineCoordinateList.Add(newLine);
                }
            }

            LineStyle       = lineCmdLine.LineStyle;
            IsWeightControl = lineCmdLine.IsWeightControl;
            wholeWeight     = lineCmdLine.WholeWeight;
            this.associatedMeasureHeightCmd = mhCmd;

            this.CheckRepeat();
        }
示例#7
0
        public EditMultiLinesForm(Pattern pattern, LineCmdLine lineCmdLine) : base(pattern.GetOriginPos())
        {
            InitializeComponent();
            this.ReadLanguageResources();
            this.pattern = pattern;
            this.origin  = pattern.GetOriginPos();
            if (lineCmdLine == null)
            {
                isCreating       = true;
                this.lineCmdLine = new LineCmdLine();

                this.tbStartX.Text               = Properties.Settings.Default.LineStartX.ToString("0.000");
                this.tbStartY.Text               = Properties.Settings.Default.LineStartY.ToString("0.000");
                this.tbEndX.Text                 = Properties.Settings.Default.LineEndX.ToString("0.000");
                this.tbEndY.Text                 = Properties.Settings.Default.LineEndY.ToString("0.000");
                this.lineCmdLine.LineStyle       = (LineStyle)Properties.Settings.Default.LineStyle;
                this.lineCmdLine.IsWeightControl = Properties.Settings.Default.LineIsWt;
                this.lineCmdLine.WholeWeight     = Properties.Settings.Default.LineWt;
                this.btnNextCmdLine.Visible      = false;
                this.btnLastCmdLine.Visible      = false;
            }
            else
            {
                isCreating       = false;
                this.lineCmdLine = lineCmdLine;
                lineCoordinateCache.AddRange(this.lineCmdLine.LineCoordinateList);
            }
            //foreach (LineCoordinate coordinate in lineCoordinateCache)
            //{
            //    listBoxPoints.Items.Add(coordinate.ToString());
            //}
            //if (lineCoordinateCache.Count > 0)
            //{
            //    listBoxPoints.SelectedIndex = 0;
            //}
            this.LoadLines2ListBox();
            cbWeightControl.Checked = this.lineCmdLine.IsWeightControl;
            if (this.lineCmdLine != null)
            {
                this.lineCmdLineBackUp = (LineCmdLine)this.lineCmdLine.Clone();
            }
        }
示例#8
0
        /// <summary>
        /// 执行单条线段命令,连续插补模式,将每条线压入插补队列
        /// </summary>
        /// <param name="line"></param>
        /// <param name="accStart">加速区间距离</param>
        /// <param name="decelEnd">减速区间距离</param>
        /// <param name="speed">线段区间的运动速度</param>
        /// <param name="points">每一滴胶水的点胶位置</param>
        /// <param name="intervalSec">每一滴胶水的打胶时间,单位秒</param>
        /// <returns></returns>
        private Result executeSingleLine(Line directiveLine, LineCoordinate line, PointD accStart, PointD decelEnd, double speed, PointD[] points, double intervalSec)
        {
            double lineOffset = line.Param.Offset;

            // 偏移调整
            if (Machine.Instance.Valve1.RunMode == ValveRunMode.Dry ||
                Machine.Instance.Valve1.RunMode == ValveRunMode.Wet ||
                Machine.Instance.Valve1.RunMode == ValveRunMode.AdjustLine)
            {
                if (directiveLine.LineCmd.RunnableModule.CommandsModule.IsReversePattern)
                {
                    lineOffset += line.LookOffsetRevs;
                }
                else
                {
                    lineOffset += line.LookOffset;
                }
            }
            VectorD v = (line.End - line.Start).Normalize() * lineOffset;
            //相机位置
            PointD cameraLineStart = line.Start + v;
            PointD cameraLineEnd   = line.End + v;
            PointD cameraAccStart  = accStart + v;
            PointD cameraDecEnd    = decelEnd + v;

            PointD[] cameraPoints  = new PointD[points.Length];
            PointD[] cameraPoints2 = new PointD[points.Length];//副阀的点位
            for (int i = 0; i < points.Length; i++)
            {
                cameraPoints[i] = points[i] + v;
            }
            //胶枪点胶起点
            PointD valveAccStart = cameraAccStart.ToNeedle(directiveLine.Valve, directiveLine.Tilt);
            //副阀点胶起点位置(默认值为设定间距)
            PointD simulStart = new PointD(directiveLine.Program.RuntimeSettings.SimulDistence, 0) /*-胶阀原点间距?*/;

            ///生成副阀相关参数(起点、插补点位)
            if (directiveLine.RunnableModule.Mode == ModuleMode.MainMode)
            {
                //副阀插补坐标绝对值(X方向实际坐标取负值) = 主阀机械坐标-副阀机械坐标-双阀原点间距(理论情况-不考虑坐标系不平行)
                VectorD SimulModuleOffset = Machine.Instance.Robot.CalibPrm.NeedleCamera2 - Machine.Instance.Robot.CalibPrm.NeedleCamera1;
                for (int i = 0; i < points.Length; i++)
                {
                    cameraPoints2[i] = cameraPoints[i] - directiveLine.RunnableModule.SimulTransformer.Transform(cameraPoints[i]).ToVector() - SimulModuleOffset;
                    //乘以系数得到AB轴的移动位移
                    cameraPoints2[i].X = -Math.Abs(cameraPoints2[i].X) / Machine.Instance.Robot.CalibPrm.HorizontalRatio;
                    cameraPoints2[i].Y = -cameraPoints2[i].Y / Machine.Instance.Robot.CalibPrm.VerticalRatio;
                }
                //副阀在加速段直接使用实际点胶起始位置
                simulStart = cameraPoints2[0];
            }
            Result ret   = Result.OK;
            double targZ = 0;

            if (Machine.Instance.Laser.Laserable.Vendor == Drive.Sensors.HeightMeasure.Laser.Vendor.Disable)
            {
                targZ = directiveLine.Program.RuntimeSettings.BoardZValue + line.Param.DispenseGap;
            }
            else
            {
                targZ = Converter.NeedleBoard2Z(line.Param.DispenseGap, directiveLine.CurMeasureHeightValue, directiveLine.Tilt);
            }

            if (Machine.Instance.Valve1.RunMode == Drive.ValveSystem.ValveRunMode.Look ||
                Machine.Instance.Valve1.RunMode == Drive.ValveSystem.ValveRunMode.AdjustLine ||
                Machine.Instance.Valve1.RunMode == Drive.ValveSystem.ValveRunMode.InspectRect)
            {
                ret = Machine.Instance.Robot.BufMoveSafeZ();
                if (!ret.IsOk)
                {
                    return(ret);
                }
                if (Machine.Instance.Valve1.RunMode == Drive.ValveSystem.ValveRunMode.Look)
                {
                    ret = Machine.Instance.Robot.BufMoveLnXY(cameraLineStart,
                                                             FluidProgram.Current.MotionSettings.VelXY,
                                                             FluidProgram.Current.MotionSettings.AccXY);
                    if (!ret.IsOk)
                    {
                        return(ret);
                    }

                    ret = Machine.Instance.Robot.BufMoveLnXY(cameraLineEnd,
                                                             line.Param.Speed,
                                                             FluidProgram.Current.MotionSettings.AccXY);
                    if (!ret.IsOk)
                    {
                        return(ret);
                    }

                    Log.Print("current position in LookMode: " + cameraAccStart.ToString() + " || the LookOffset:" + line.LookOffset);
                }
                else if (Machine.Instance.Valve1.RunMode == Drive.ValveSystem.ValveRunMode.AdjustLine)
                {
                    ret = Machine.Instance.Robot.MovePosXYAndReply(cameraLineStart,
                                                                   FluidProgram.Current.MotionSettings.VelXY,
                                                                   FluidProgram.Current.MotionSettings.AccXY);
                    if (!ret.IsOk)
                    {
                        return(ret);
                    }

                    LineCmdLine lineCmdline = directiveLine.LineCmd.lineCmdLine;
                    if (lineCmdline == null || line == null)
                    {
                        return(ret);
                    }

                    Machine.Instance.IsProducting = false;
                    Line.WaitMsg.Reset();
                    switch (lineCmdline.LineMethod)
                    {
                    case LineMethod.Single:
                        MsgCenter.Broadcast(MsgType.MSG_LINEEDITLOOK_SHOW, directiveLine, lineCmdline);
                        break;

                    case LineMethod.Multi:
                    case LineMethod.Poly:
                        MsgCenter.Broadcast(MsgType.MSG_LINEEDITLOOK_SHOW, directiveLine, lineCmdline, directiveLine.LineCoordinates.IndexOf(line));
                        break;

                    default:
                        break;
                    }
                    Line.WaitMsg.WaitOne();
                    Machine.Instance.IsProducting = true;
                }
                else if (Machine.Instance.Valve1.RunMode == Drive.ValveSystem.ValveRunMode.InspectRect)
                {
                    ret = Machine.Instance.Robot.MovePosXYAndReply(cameraLineStart,
                                                                   FluidProgram.Current.MotionSettings.VelXY,
                                                                   FluidProgram.Current.MotionSettings.AccXY);
                    if (!ret.IsOk)
                    {
                        return(ret);
                    }
                    LineCmdLine lineCmdline = directiveLine.LineCmd.lineCmdLine;
                    if (lineCmdline == null || line == null)
                    {
                        return(ret);
                    }
                    if (lineCmdline.LineMethod != LineMethod.Single)
                    {
                        return(ret);
                    }

                    InspectionLine inspectionLine = InspectionMgr.Instance.FindBy((int)lineCmdline.inspectionKey) as InspectionLine;
                    if (inspectionLine != null)
                    {
                        Thread.Sleep(inspectionLine.SettlingTime);
                        double width1, width2;
                        Machine.Instance.CaptureAndInspect(inspectionLine);
                        width1 = inspectionLine.PhyWidth1;
                        width2 = inspectionLine.PhyWidth2;
                        Log.Dprint(inspectionLine.CurrResultStr);
                        string resline = string.Format("{0},{1},{2},{3}", Math.Round(cameraLineStart.X, 3), Math.Round(cameraLineStart.Y, 3), Math.Round(width1, 3), Math.Round(width2, 3));
                        CsvUtil.WriteLine(directiveLine.Program.RuntimeSettings.FilePathInspectRect, resline);
                        Thread.Sleep(inspectionLine.DwellTime);
                    }
                }
                return(ret);
            }

            // 倾斜到位
            Log.Dprint("change tilt status : " + directiveLine.Tilt.ToString());
            ret = Machine.Instance.Valve1.BufChangeValveTiltStatus(directiveLine.Tilt, FluidProgram.Current.MotionSettings.VelU, FluidProgram.Current.MotionSettings.AccU);
            if (!ret.IsOk)
            {
                return(ret);
            }
            double currZ = Machine.Instance.Robot.PosZ;

            //到起点,Z轴到点胶位置
            if (currZ > targZ)
            {
                // 移动到加速区间起始位置
                Log.Dprint("move to position XY : " + valveAccStart);
                if (directiveLine.RunnableModule.Mode == ModuleMode.MainMode)
                {
                    ret = Machine.Instance.Robot.MovePosXYABAndReply(valveAccStart, simulStart,
                                                                     FluidProgram.Current.MotionSettings.VelXYAB,
                                                                     FluidProgram.Current.MotionSettings.AccXYAB,
                                                                     (int)Machine.Instance.Setting.CardSelect);
                }
                else
                {
                    ret = Machine.Instance.Robot.BufMoveLnXY(valveAccStart,
                                                             FluidProgram.Current.MotionSettings.VelXY,
                                                             FluidProgram.Current.MotionSettings.AccXY);
                }
                if (!ret.IsOk)
                {
                    return(ret);
                }
                Log.Dprint("move down to Z : " + targZ.ToString("0.000000") + ", DispenseGap=" + line.Param.DispenseGap.ToString("0.000000"));
                ret = Machine.Instance.Robot.BufMovePosZ(targZ, line.Param.DownSpeed, line.Param.DownAccel);
                if (!ret.IsOk)
                {
                    return(ret);
                }
            }
            else
            {
                Log.Dprint("move up to Z : " + targZ.ToString("0.000000") + ", DispenseGap=" + line.Param.DispenseGap.ToString("0.000000"));
                ret = Machine.Instance.Robot.BufMovePosZ(targZ, line.Param.DownSpeed, line.Param.DownAccel);
                if (!ret.IsOk)
                {
                    return(ret);
                }
                // 移动到加速区间起始位置
                Log.Dprint("move to position XY : " + valveAccStart);
                if (directiveLine.RunnableModule.Mode == ModuleMode.MainMode)
                {
                    ret = Machine.Instance.Robot.MovePosXYABAndReply(valveAccStart, simulStart,
                                                                     FluidProgram.Current.MotionSettings.VelXYAB,
                                                                     FluidProgram.Current.MotionSettings.AccXYAB,
                                                                     (int)Machine.Instance.Setting.CardSelect);
                }
                else
                {
                    ret = Machine.Instance.Robot.BufMoveLnXY(valveAccStart,
                                                             FluidProgram.Current.MotionSettings.VelXY,
                                                             FluidProgram.Current.MotionSettings.AccXY);
                }
                if (!ret.IsOk)
                {
                    return(ret);
                }
            }

            // 移动: 加速区间--线段区间--减速区间
            Log.Dprint("fluid line, accStart=" + cameraAccStart + " start=" + cameraLineStart + ", end=" + cameraLineEnd + ", decelEnd=" + cameraDecEnd + ", spped=" + speed);
            //printPoints(newPoints);
            if (directiveLine.RunnableModule.Mode == ModuleMode.MainMode)
            {
                ret = Machine.Instance.DualValve.FluidLine(cameraAccStart, cameraLineStart, cameraLineEnd, cameraDecEnd, speed, cameraPoints, intervalSec, simulStart, cameraPoints2, FluidProgram.Current.MotionSettings.WeightAcc);
                GlueManagerMgr.Instance.UpdateGlueRemainWeight(0, points.Length * directiveLine.Program.RuntimeSettings.SingleDropWeight);
                GlueManagerMgr.Instance.UpdateGlueRemainWeight(1, points.Length * directiveLine.Program.RuntimeSettings.SingleDropWeight);
            }
            else if (directiveLine.RunnableModule.Mode == ModuleMode.DualFallow)
            {
                ret = Machine.Instance.DualValve.FluidLine(cameraAccStart, cameraLineStart, cameraLineEnd, cameraDecEnd, speed, cameraPoints, intervalSec, FluidProgram.Current.MotionSettings.WeightAcc);
                GlueManagerMgr.Instance.UpdateGlueRemainWeight(0, points.Length * directiveLine.Program.RuntimeSettings.SingleDropWeight);
                GlueManagerMgr.Instance.UpdateGlueRemainWeight(1, points.Length * directiveLine.Program.RuntimeSettings.SingleDropWeight);
            }
            else if (directiveLine.RunnableModule.Mode == ModuleMode.AssignMode2)
            {
                ret = Machine.Instance.Valve2.FluidLine(cameraAccStart, cameraLineStart, cameraLineEnd, cameraDecEnd, speed, cameraPoints, intervalSec, FluidProgram.Current.MotionSettings.WeightAcc);
                GlueManagerMgr.Instance.UpdateGlueRemainWeight(1, points.Length * directiveLine.Program.RuntimeSettings.SingleDropWeight);
            }
            else
            {
                ret = Machine.Instance.Valve1.BufFluidLine(cameraAccStart, cameraLineStart, cameraLineEnd, cameraDecEnd, speed, cameraPoints, intervalSec, FluidProgram.Current.MotionSettings.WeightAcc);
                GlueManagerMgr.Instance.UpdateGlueRemainWeight(0, points.Length * directiveLine.Program.RuntimeSettings.SingleDropWeight);
            }
            if (!ret.IsOk)
            {
                return(ret);
            }

            if (Machine.Instance.Valve1.RunMode == Drive.ValveSystem.ValveRunMode.Wet ||
                Machine.Instance.Valve1.RunMode == Drive.ValveSystem.ValveRunMode.Dry)
            {
                Log.Dprint("RetractDistance : " + line.Param.RetractDistance);
                // 减速区间运动完成后,x y 轴速度为0, 此时需要抬升一段高度
                if (line.Param.RetractDistance > 0)
                {
                    Log.Dprint("move up RetractDistance : " + line.Param.RetractDistance);
                    ret = Machine.Instance.Robot.BufMoveIncZ(line.Param.RetractDistance, line.Param.RetractSpeed, line.Param.RetractAccel);
                    if (!ret.IsOk)
                    {
                        return(ret);
                    }
                }
            }

            return(ret);
        }
示例#9
0
 public EditPolylineMetro(Pattern pattern, LineCmdLine lineCmdLine, Line line, int indexOfLineCoordinate) : this(pattern, lineCmdLine)
 {
     this.line                  = line;
     this.isRunning             = true;
     this.indexOfLineCoordinate = indexOfLineCoordinate;
 }
示例#10
0
        /// <summary>
        /// Author: liyi
        /// Date:   2019/08/27
        /// Description:用于将界面参数更新至传入的轨迹数组
        /// </summary>
        /// <param name="cmdLines"></param>
        private void UpdateCmdLineParam(List <CmdLine> cmdLines)
        {
            if (cmdLines.Count <= 0)
            {
                return;
            }
            if (this.rdoIncrementWeight.Checked)
            {
                isConstantWeight = false;
            }
            else if (this.rdoConstantWeight.Checked)
            {
                isConstantWeight = true;
            }
            if (this.cbxRotate.SelectedIndex == -1)
            {
                this.cbxRotate.SelectedIndex = 0;
            }
            double rotateAngle = this.cbxRotate.SelectedIndex * 90;

            // 机械坐标 -> 系统坐标
            PointD referencePoint = this.pattern.SystemRel(new PointD(this.tbRefX.Value, this.tbRefY.Value));
            PointD offsetPoint    = this.pattern.SystemRel(new PointD(this.tbXOffset.Value, this.tbYOffset.Value));
            double offsetX        = offsetPoint.X; //this.tbXOffset.Value;
            double offsetY        = offsetPoint.Y; //this.tbYOffset.Value;

            foreach (CmdLine cmdLine in cmdLines)
            {
                //判断是否是胶量模式
                //1.胶量模式,全部启用胶量模式
                //2.非胶量模式,全部禁用胶量模式
                //3.都有的状态,只增加胶量值,不更改模式
                if (cmdLine is CircleCmdLine)
                {
                    CircleCmdLine circleCmdLine = cmdLine as CircleCmdLine;
                    circleCmdLine.Weight = GetNewValue(circleCmdLine.Weight, tbWeight.Value, isConstantWeight);
                    PointD temp = GetNewPosition(circleCmdLine.Start, referencePoint, offsetX, offsetY, rotateAngle);
                    circleCmdLine.Start.X = temp.X;
                    circleCmdLine.Start.Y = temp.Y;
                    temp = GetNewPosition(circleCmdLine.Start, referencePoint, offsetX, offsetY, rotateAngle);
                    circleCmdLine.End.X = temp.X;
                    circleCmdLine.End.Y = temp.Y;
                    temp = GetNewPosition(circleCmdLine.Middle, referencePoint, offsetX, offsetY, rotateAngle);
                    circleCmdLine.Middle.X = temp.X;
                    circleCmdLine.Middle.Y = temp.Y;
                    temp = GetNewPosition(circleCmdLine.Middle, referencePoint, offsetX, offsetY, rotateAngle);
                    circleCmdLine.Center.X = temp.X;
                    circleCmdLine.Center.Y = temp.Y;
                    if (this.cbxLineType.SelectedIndex != -1)
                    {
                        circleCmdLine.LineStyle = (LineStyle)this.cmdLineType;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        circleCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                }
                else if (cmdLine is ArcCmdLine)
                {
                    ArcCmdLine arcCmdLine = cmdLine as ArcCmdLine;
                    arcCmdLine.Weight = GetNewValue(arcCmdLine.Weight, tbWeight.Value, isConstantWeight);
                    PointD temp = GetNewPosition(arcCmdLine.Start, referencePoint, offsetX, offsetY, rotateAngle);
                    arcCmdLine.Start.X = temp.X;
                    arcCmdLine.Start.Y = temp.Y;
                    temp                = GetNewPosition(arcCmdLine.End, referencePoint, offsetX, offsetY, rotateAngle);
                    arcCmdLine.End.X    = temp.X;
                    arcCmdLine.End.Y    = temp.Y;
                    temp                = GetNewPosition(arcCmdLine.Middle, referencePoint, offsetX, offsetY, rotateAngle);
                    arcCmdLine.Middle.X = temp.X;
                    arcCmdLine.Middle.Y = temp.Y;
                    temp                = GetNewPosition(arcCmdLine.Center, referencePoint, offsetX, offsetY, rotateAngle);
                    arcCmdLine.Center.X = temp.X;
                    arcCmdLine.Center.Y = temp.Y;
                    if (this.cbxLineType.SelectedIndex != -1)
                    {
                        arcCmdLine.LineStyle = (LineStyle)this.cmdLineType;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        arcCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                }
                else if (cmdLine is DotCmdLine)
                {
                    DotCmdLine dotCmdLine = cmdLine as DotCmdLine;
                    dotCmdLine.Weight = GetNewValue(dotCmdLine.Weight, tbWeight.Value, isConstantWeight);
                    PointD temp = GetNewPosition(dotCmdLine.Position, referencePoint, offsetX, offsetY, rotateAngle);
                    dotCmdLine.Position.X = temp.X;
                    dotCmdLine.Position.Y = temp.Y;
                    if (this.cbxDotType.SelectedIndex != -1)
                    {
                        dotCmdLine.DotStyle = (DotStyle)this.cmdDotType;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        dotCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                }
                else if (cmdLine is SnakeLineCmdLine)
                {
                    SnakeLineCmdLine snakeLineCmdLine = cmdLine as SnakeLineCmdLine;
                    if (this.cbxLineType.SelectedIndex != -1)
                    {
                        snakeLineCmdLine.LineStyle = (LineStyle)this.cmdLineType;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        snakeLineCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                    PointD temp = new PointD();
                    foreach (LineCoordinate item in snakeLineCmdLine.LineCoordinateList)
                    {
                        temp         = GetNewPosition(item.Start, referencePoint, offsetX, offsetY, rotateAngle);
                        item.Start.X = temp.X;
                        item.Start.Y = temp.Y;
                        temp         = GetNewPosition(item.End, referencePoint, offsetX, offsetY, rotateAngle);
                        item.End.X   = temp.X;
                        item.End.Y   = temp.Y;
                    }
                }
                else if (cmdLine is LineCmdLine)
                {
                    LineCmdLine lineCmdLine = cmdLine as LineCmdLine;
                    if (this.cbxLineType.SelectedIndex != -1)
                    {
                        lineCmdLine.LineStyle = (LineStyle)this.cmdLineType;
                    }
                    for (int i = 0; i < lineCmdLine.LineCoordinateList.Count; i++)
                    {
                        lineCmdLine.LineCoordinateList[i].LineStyle = lineCmdLine.LineStyle;
                    }
                    if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate)
                    {
                        lineCmdLine.IsWeightControl = this.cbIsWeightControl.Checked;
                    }
                    if (lineCmdLine.LineMethod == LineMethod.Single)
                    {
                        lineCmdLine.WholeWeight = GetNewValue(lineCmdLine.WholeWeight, tbWeight.Value, isConstantWeight);
                    }
                    else if (lineCmdLine.LineMethod == LineMethod.Multi)
                    {
                        lineCmdLine.WholeWeight = GetNewValue(lineCmdLine.WholeWeight, tbWeight.Value, isConstantWeight);
                    }
                    else if (lineCmdLine.LineMethod == LineMethod.Poly)
                    {
                        lineCmdLine.WholeWeight = GetNewValue(lineCmdLine.WholeWeight, tbWeight.Value, isConstantWeight);
                    }
                    PointD temp = new PointD();
                    foreach (LineCoordinate item in lineCmdLine.LineCoordinateList)
                    {
                        temp         = GetNewPosition(item.Start, referencePoint, offsetX, offsetY, rotateAngle);
                        item.Start.X = temp.X;
                        item.Start.Y = temp.Y;
                        temp         = GetNewPosition(item.End, referencePoint, offsetX, offsetY, rotateAngle);
                        item.End.X   = temp.X;
                        item.End.Y   = temp.Y;
                    }
                }
                else if (cmdLine is MultiTracesCmdLine)
                {
                    MultiTracesCmdLine multiTrace = cmdLine as MultiTracesCmdLine;
                    PointD             temp       = new PointD();
                    foreach (var item in multiTrace.Traces)
                    {
                        if (item is TraceLine)
                        {
                            temp         = GetNewPosition(item.Start, referencePoint, offsetX, offsetY, rotateAngle);
                            item.Start.X = temp.X;
                            item.Start.Y = temp.Y;
                            temp         = GetNewPosition(item.End, referencePoint, offsetX, offsetY, rotateAngle);
                            item.End.X   = temp.X;
                            item.End.Y   = temp.Y;
                        }
                        else if (item is TraceArc)
                        {
                            TraceArc traceArc = item as TraceArc;
                            temp             = GetNewPosition(traceArc.Start, referencePoint, offsetX, offsetY, rotateAngle);
                            traceArc.Start.X = temp.X;
                            traceArc.Start.Y = temp.Y;
                            temp             = GetNewPosition(traceArc.Mid, referencePoint, offsetX, offsetY, rotateAngle);
                            traceArc.Mid.X   = temp.X;
                            traceArc.Mid.Y   = temp.Y;
                            temp             = GetNewPosition(traceArc.End, referencePoint, offsetX, offsetY, rotateAngle);
                            traceArc.End.X   = temp.X;
                            traceArc.End.Y   = temp.Y;
                        }
                    }
                }
                else if (cmdLine is SymbolLinesCmdLine)
                {
                    SymbolLinesCmdLine symbolLinesCmdLine = cmdLine as SymbolLinesCmdLine;
                    PointD             temp = new PointD();
                    double             r    = this.symbolLine1.GetPrm();
                    foreach (var item in symbolLinesCmdLine.Symbols)
                    {
                        item.transitionR = r;
                        if (item.symbolType == SymbolType.Line)
                        {
                            temp = GetNewPosition(item.symbolPoints[0], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[0].X = temp.X;
                            item.symbolPoints[0].Y = temp.Y;
                            temp = GetNewPosition(item.symbolPoints[1], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[1].X = temp.X;
                            item.symbolPoints[1].Y = temp.Y;
                        }
                        else if (item.symbolType == SymbolType.Arc)
                        {
                            temp = GetNewPosition(item.symbolPoints[0], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[0].X = temp.X;
                            item.symbolPoints[0].Y = temp.Y;
                            temp = GetNewPosition(item.symbolPoints[1], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[1].X = temp.X;
                            item.symbolPoints[1].Y = temp.Y;
                            temp = GetNewPosition(item.symbolPoints[2], referencePoint, offsetX, offsetY, rotateAngle);
                            item.symbolPoints[2].X = temp.X;
                            item.symbolPoints[2].Y = temp.Y;
                        }
                    }
                }
            }
        }
示例#11
0
        /// <summary>
        /// 获取第一点轨迹和第一个线轨迹的参数类型
        /// </summary>
        private void GetSymbolParamType()
        {
            //只批量修改和选中的第一条轨迹相同类型的轨迹
            int index = 0;

            foreach (CmdLine cmdLine in this.updateCmdLines)
            {
                if (!lineParamGet)
                {
                    if (cmdLine is CircleCmdLine)
                    {
                        CircleCmdLine temp = cmdLine as CircleCmdLine;
                        this.cmdLineType = (int)temp.LineStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        lineParamGet = true;
                    }
                    else if (cmdLine is ArcCmdLine)
                    {
                        ArcCmdLine temp = cmdLine as ArcCmdLine;
                        this.cmdLineType = (int)temp.LineStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        lineParamGet = true;
                    }
                    else if (cmdLine is SnakeLineCmdLine)
                    {
                        SnakeLineCmdLine temp = cmdLine as SnakeLineCmdLine;
                        this.cmdLineType = (int)temp.LineStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        lineParamGet = true;
                    }
                    else if (cmdLine is LineCmdLine)
                    {
                        LineCmdLine temp = cmdLine as LineCmdLine;
                        this.cmdLineType = (int)temp.LineStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        lineParamGet = true;
                    }
                }

                if (!dotParamGet)
                {
                    if (cmdLine is DotCmdLine)
                    {
                        DotCmdLine temp = cmdLine as DotCmdLine;
                        this.cmdDotType = (int)temp.DotStyle;
                        if (index == 0)
                        {
                            this.weightControlType = temp.IsWeightControl;
                        }
                        dotParamGet = true;
                    }
                }
                index++;
                //第一个点和第一个线的参数都获取后,停止循环
                if (lineParamGet && dotParamGet)
                {
                    break;
                }
            }
        }
示例#12
0
 public EditSingleLineForm(Pattern pattern, LineCmdLine lineCmdLine, Line line)
     : this(pattern, lineCmdLine)
 {
     this.line      = line;
     this.isRunning = true;
 }
示例#13
0
        public EditLineWeightForm(LineCmdLine lineCmdLine, List <LineCoordinate> lineCache)
        {
            InitializeComponent();
            this.ReadLanguageResources();
            this.StartPosition     = FormStartPosition.CenterParent;
            this.panel1.AutoScroll = true;

            this.nudWhole.Increment     = 0.001M;
            this.nudWhole.DecimalPlaces = 3;
            this.nudWhole.Minimum       = 0;
            this.nudWhole.Maximum       = 10000000;
            this.nudEach.Increment      = 0.001M;
            this.nudEach.DecimalPlaces  = 3;
            this.nudEach.Minimum        = 0;
            this.nudEach.Maximum        = 10000000;

            this.rdoWhole.Checked = true;
            this.rdoEach.Checked  = false;

            this.lineCmdLine = lineCmdLine;
            this.lineCache   = lineCache;

            int index = 0;

            foreach (var item in this.lineCache)
            {
                this.sumLength += item.CalculateDistance();
                int y = 25 * index + 5;
                int x = 0;

                Label lblId = new Label();
                lblId.Text     = string.Format("{0}:", index);
                lblId.Width    = 20;
                lblId.Location = new Point(5, y);
                x = 25;
                panel1.Controls.Add(lblId);

                ComboBox cbxLineType = new ComboBox();
                cbxLineType.Location = new Point(x + 5, y);
                cbxLineType.Width    = 90;
                x += 95;
                panel1.Controls.Add(cbxLineType);
                for (int i = 0; i < FluidProgram.Current.ProgramSettings.LineParamList.Count; i++)
                {
                    cbxLineType.Items.Add("Type " + (i + 1));
                }
                this.cbxList.Add(cbxLineType);

                Button btn = new Button();
                btn.Text     = "edit";
                btn.Location = new Point(x + 5, y);
                btn.Width    = 70;
                x           += 80;
                btn.Click   += this.btnEditLineStyle_Click;
                this.panel1.Controls.Add(btn);

                NumericUpDown nud = new NumericUpDown();
                nud.Increment     = 0.001M;
                nud.DecimalPlaces = 3;
                nud.Minimum       = 0;
                nud.Maximum       = 10000000;
                nud.Location      = new Point(x + 5, y);
                nud.Width         = 100;
                x        += 105;
                nud.Value = (decimal)item.Weight;
                this.nudList.Add(nud);
                panel1.Controls.Add(nud);

                Label lbl = new Label();
                lbl.Location = new Point(x, y);
                lbl.Width    = 1000;
                lbl.Text     = string.Format("mg {0}", item);
                panel1.Controls.Add(lbl);
                index++;
            }

            for (int i = 0; i < FluidProgram.Current.ProgramSettings.LineParamList.Count; i++)
            {
                this.cbxAllLineStyle.Items.Add("Type " + (i + 1));
            }

            this.rdoWhole.Checked = this.lineCmdLine.IsWholeWtMode;
            this.rdoEach.Checked  = !this.lineCmdLine.IsWholeWtMode;
            this.nudWhole.Value   = (decimal)this.lineCmdLine.WholeWeight;
            this.nudEach.Value    = (decimal)this.lineCmdLine.EachWeight;
            for (int i = 0; i < this.lineCache.Count; i++)
            {
                this.nudList[i].Value         = (decimal)this.lineCache[i].Weight;
                this.cbxList[i].SelectedIndex = (int)this.lineCache[i].LineStyle;
            }
            this.cbxAllLineStyle.SelectedIndex         = (int)this.lineCmdLine.LineStyle;
            this.cbxAllLineStyle.SelectedIndexChanged += CbxAllLineStyle_SelectedIndexChanged;
        }
示例#14
0
        public EditLineMetro(Pattern pattern, LineCmdLine lineCmdLine)
        {
            InitializeComponent();
            //this.ReadLanguageResources();
            this.pattern = pattern;
            this.origin  = pattern.GetOriginPos();
            if (lineCmdLine == null)
            {
                isCreating       = true;
                this.lineCmdLine = new LineCmdLine()
                {
                    LineMethod = LineMethod.Single
                };
                this.lineCoordinate              = new LineCoordinate(new PointD(), new PointD());
                this.lineCoordinate.Start.X      = Properties.Settings.Default.LineStartX;
                this.lineCoordinate.Start.Y      = Properties.Settings.Default.LineStartY;
                this.lineCoordinate.End.X        = Properties.Settings.Default.LineEndX;
                this.lineCoordinate.End.Y        = Properties.Settings.Default.LineEndY;
                this.lineCmdLine.LineStyle       = (LineStyle)Properties.Settings.Default.LineStyle;
                this.lineCmdLine.IsWeightControl = Properties.Settings.Default.LineIsWt;
                this.lineCmdLine.WholeWeight     = Properties.Settings.Default.LineWt;
            }
            else
            {
                isCreating          = false;
                this.lineCmdLine    = lineCmdLine;
                this.lineCoordinate = this.lineCmdLine.LineCoordinateList[0];
            }
            PointD startMachine = this.pattern.MachineRel(this.lineCoordinate.Start);
            PointD endMachine   = this.pattern.MachineRel(this.lineCoordinate.End);

            this.tbStartX.Text     = startMachine.X.ToString("0.000");
            this.tbStartY.Text     = startMachine.Y.ToString("0.000");
            this.tbEndX.Text       = endMachine.X.ToString("0.000");
            this.tbEndY.Text       = endMachine.Y.ToString("0.000");
            this.offset            = this.lineCoordinate.LookOffset;
            this.nudOffset.Value   = (decimal)this.lineCoordinate.LookOffset;
            this.nudOffset.Enabled = false;
            if (Machine.Instance.Valve1.RunMode == ValveRunMode.AdjustLine)
            {
                this.disableUI();
                this.nudOffset.Enabled = true;
            }

            for (int i = 0; i < FluidProgram.Current.ProgramSettings.LineParamList.Count; i++)
            {
                comboBoxLineType.Items.Add("Type " + (i + 1));
            }
            comboBoxLineType.SelectedIndex = (int)this.lineCmdLine.LineStyle;
            cbWeightControl.Checked        = this.lineCmdLine.IsWeightControl;
            if (this.lineCmdLine.IsWeightControl)
            {
                tbWeight.Text = this.lineCmdLine.WholeWeight.ToString("0.000");
            }

            this.cbInspectionKey.Items.Add(InspectionKey.Line1);
            this.cbInspectionKey.Items.Add(InspectionKey.Line2);
            this.cbInspectionKey.Items.Add(InspectionKey.Line3);
            this.cbInspectionKey.Items.Add(InspectionKey.Line4);
            this.cbInspectionKey.SelectedIndex = 0;
            if (this.pattern.IsReversePattern)
            {
                this.nudOffset.Value = (decimal)this.lineCoordinate.LookOffsetRevs;
            }
            else
            {
                this.nudOffset.Value = (decimal)this.lineCoordinate.LookOffset;
            }
            if (this.lineCmdLine != null)
            {
                this.lineCmdLineBackUp = (LineCmdLine)this.lineCmdLine.Clone();
            }
        }
示例#15
0
 public EditLineMetro(Pattern pattern, LineCmdLine lineCmdLine, Line line)
     : this(pattern, lineCmdLine)
 {
     this.line      = line;
     this.isRunning = true;
 }
示例#16
0
        /// <summary>
        /// Author: liyi
        /// Date: 2019/08/20
        /// Description: 判断是否所有轨迹是否都是胶量模式、是否所有参数类型
        /// </summary>
        private void GetSameProperty()
        {
            foreach (CmdLine cmdLine in this.updateCmdLines)
            {
                if (this.cmdLineTypeIsSame)
                {
                    if (cmdLine is CircleCmdLine)
                    {
                        CircleCmdLine temp = cmdLine as CircleCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdLineType != (int)temp.LineStyle)
                        {
                            this.cmdLineTypeIsSame = false;
                        }
                    }
                    else if (cmdLine is ArcCmdLine)
                    {
                        ArcCmdLine temp = cmdLine as ArcCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdLineType != (int)temp.LineStyle)
                        {
                            this.cmdLineTypeIsSame = false;
                        }
                    }
                    else if (cmdLine is SnakeLineCmdLine)
                    {
                        SnakeLineCmdLine temp = cmdLine as SnakeLineCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdLineType != (int)temp.LineStyle)
                        {
                            this.cmdDotTypeIsSame = false;
                        }
                    }
                    else if (cmdLine is LineCmdLine)
                    {
                        LineCmdLine temp = cmdLine as LineCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdLineType != (int)temp.LineStyle)
                        {
                            this.cmdLineTypeIsSame = false;
                        }
                    }
                }
                if (this.cmdDotTypeIsSame)
                {
                    if (cmdLine is DotCmdLine)
                    {
                        DotCmdLine temp = cmdLine as DotCmdLine;
                        if (temp.IsWeightControl != this.weightControlType)
                        {
                            this.WeightControlTypeIsSame = false;
                        }
                        if (this.cmdDotType != (int)temp.DotStyle)
                        {
                            this.cmdDotTypeIsSame = false;
                        }
                    }
                }

                if ((!this.cmdDotTypeIsSame || !this.dotParamGet) && (!this.cmdLineTypeIsSame || !this.lineParamGet) && !this.WeightControlTypeIsSame)
                {
                    break;
                }
            }
        }
示例#17
0
        /// <summary>
        /// 将程序指令解析为绘图指令,添加到绘图workpiece或者pattern中
        /// </summary>
        /// <param name="cmdLine"></param>
        /// <param name="pattern"></param>
        private void Parse(CmdLine cmdLine, DrawPattern pattern)
        {
            if (cmdLine is ArcCmdLine)
            {
                ArcCmdLine arc            = cmdLine as ArcCmdLine;
                PointF     centerPosition = new PointF((float)arc.Center.X, (float)arc.Center.Y);
                PointF     startPosition  = new PointF((float)arc.Start.X, (float)arc.Start.Y);
                PointF     endPosition    = new PointF((float)arc.End.X, (float)arc.End.Y);
                float      degree         = (float)arc.Degree;
                ArcDrawCmd arcDrawCmd     = new ArcDrawCmd(centerPosition, startPosition, endPosition, degree, arc.Enabled);
                pattern.Add(arcDrawCmd);
            }
            //如果是DoPattern指令
            else if (cmdLine is DoCmdLine)
            {
                if (this._drawPatterns.Count <= 0)
                {
                    pattern.Add(null);
                }
                else if (pattern.GetType().Equals(typeof(DrawWorkPiece)))
                {
                    DoCmdLine doPattern = cmdLine as DoCmdLine;

                    //判断是paternList里的哪一个pattern
                    int index = 0;
                    for (int i = 0; i < fluidProgram.Patterns.Count; i++)
                    {
                        if (fluidProgram.Patterns[i].Name.Equals(doPattern.PatternName))
                        {
                            index = i;
                        }
                    }
                    PointF           origin           = new PointF((float)doPattern.Origin.X, (float)doPattern.Origin.Y);
                    DoPatternDrawCmd doPatternDrawCmd = new DoPatternDrawCmd(this._drawPatterns[index], origin, doPattern.Enabled);

                    pattern.Add(doPatternDrawCmd);
                }
                else
                {
                    pattern.Add(null);
                }
            }
            else if (cmdLine is StepAndRepeatCmdLine)
            {
                if (pattern.GetType().Equals(typeof(DrawWorkPiece)))
                {
                    StepAndRepeatCmdLine array = cmdLine as StepAndRepeatCmdLine;

                    //判断是paternList里的哪一个pattern
                    int index = 0;
                    for (int i = 0; i < fluidProgram.Patterns.Count; i++)
                    {
                        if (fluidProgram.Patterns[i].Name.Equals(array.PatternName))
                        {
                            index = i;
                        }
                    }
                    PointF[] points = new PointF[array.DoCmdLineList.Count];
                    for (int i = 0; i < array.DoCmdLineList.Count; i++)
                    {
                        points[i] = new PointF((float)array.DoCmdLineList[i].Origin.X, (float)array.DoCmdLineList[i].Origin.Y);
                    }

                    ArrayDrawCmd arrayDrawCmd = new ArrayDrawCmd(this._drawPatterns[index], points, array.Enabled);

                    pattern.Add(arrayDrawCmd);
                }
                else
                {
                    pattern.Add(null);
                }
            }
            else if (cmdLine is CircleCmdLine)
            {
                CircleCmdLine circle         = cmdLine as CircleCmdLine;
                PointF        centerPosition = new PointF((float)circle.Center.X, (float)circle.Center.Y);
                float         radius         = (float)Math.Sqrt(Math.Pow(Math.Abs(circle.Start.X - circle.Center.X), 2) + Math.Pow(Math.Abs(circle.Start.Y - circle.Center.Y), 2));
                CircleDrawCmd circleDrawCmd  = new CircleDrawCmd(centerPosition, radius, circle.Enabled);

                pattern.Add(circleDrawCmd);
            }
            else if (cmdLine is DoMultiPassCmdLine)
            {
                if (pattern.GetType().Equals(typeof(DrawWorkPiece)))
                {
                    DoMultiPassCmdLine doMultiPass = cmdLine as DoMultiPassCmdLine;

                    //判断是paternList里的哪一个pattern
                    int index = 0;
                    for (int i = 0; i < fluidProgram.Patterns.Count; i++)
                    {
                        if (fluidProgram.Patterns[i].Name.Equals(doMultiPass.PatternName))
                        {
                            index = i;
                        }
                    }

                    PointF             position       = new PointF((float)doMultiPass.Origin.X, (float)doMultiPass.Origin.Y);
                    DoMultiPassDrawCmd doMultiDrawCmd = new DoMultiPassDrawCmd(this._drawPatterns[index], position, doMultiPass.Enabled);

                    pattern.Add(doMultiDrawCmd);
                }
                else
                {
                    pattern.Add(null);
                }
            }
            else if (cmdLine is DotCmdLine)
            {
                DotCmdLine dot            = cmdLine as DotCmdLine;
                PointF     centerPosition = new PointF((float)dot.Position.X, (float)dot.Position.Y);
                DotDrawCmd dotDrawCmd     = new DotDrawCmd(centerPosition, dot.Enabled);

                pattern.Add(dotDrawCmd);
            }
            else if (cmdLine is MeasureHeightCmdLine)
            {
                MeasureHeightCmdLine height = cmdLine as MeasureHeightCmdLine;
                PointF        position      = new PointF((float)height.Position.X, (float)height.Position.Y);
                HeightDrawCmd heightDrawCmd = new HeightDrawCmd(position, height.Enabled);

                pattern.Add(heightDrawCmd);
            }
            ///包含line、lines和polyline
            else if (cmdLine is LineCmdLine)
            {
                LineCmdLine line       = cmdLine as LineCmdLine;
                int         jointCount = 0;
                if (line.LineCoordinateList.Count == 1)
                {
                    PointF      startPoint  = new PointF((float)line.LineCoordinateList[0].Start.X, (float)line.LineCoordinateList[0].Start.Y);
                    PointF      endPoint    = new PointF((float)line.LineCoordinateList[0].End.X, (float)line.LineCoordinateList[0].End.Y);
                    LineDrawCmd lineDrawCmd = new LineDrawCmd(startPoint, endPoint, true, line.Enabled);

                    pattern.Add(lineDrawCmd);
                }
                else if (line.LineCoordinateList.Count > 1)
                {
                    Line2Points[] lines = new Line2Points[line.LineCoordinateList.Count];

                    for (int i = 0; i < line.LineCoordinateList.Count; i++)
                    {
                        PointF startPoint = new PointF((float)line.LineCoordinateList[i].Start.X, (float)line.LineCoordinateList[i].Start.Y);
                        PointF endPoint   = new PointF((float)line.LineCoordinateList[i].End.X, (float)line.LineCoordinateList[i].End.Y);
                        lines[i] = new Line2Points(startPoint, endPoint);

                        //判断是不是polyline(如果所有相邻线段首尾点一致,则为polyline)
                        if (i > 0 && lines[i].StartPoint == lines[i - 1].EndPoint)
                        {
                            jointCount++;
                        }
                    }

                    //如果是polyline
                    if (jointCount == line.LineCoordinateList.Count - 1)
                    {
                        PointF[] points = new PointF[line.LineCoordinateList.Count + 1];
                        for (int i = 0; i < lines.Length + 1; i++)
                        {
                            if (i == 0)
                            {
                                points[i] = new PointF((float)lines[0].StartPoint.X, (float)lines[0].StartPoint.Y);
                            }
                            else
                            {
                                points[i] = new PointF((float)lines[i - 1].EndPoint.X, (float)lines[i - 1].EndPoint.Y);
                            }
                        }
                        PolyLineDrawCmd polyLineDrawCmd = new PolyLineDrawCmd(points, line.Enabled);
                        pattern.Add(polyLineDrawCmd);
                    }
                    //如果是lines
                    else
                    {
                        LinesDrawCmd linesDrawCmd = new LinesDrawCmd(lines, true, line.Enabled);
                        pattern.Add(linesDrawCmd);
                    }
                }
            }

            else if (cmdLine is MarkCmdLine)
            {
                MarkCmdLine mark        = cmdLine as MarkCmdLine;
                PointF      position    = new PointF((float)mark.PosInPattern.X, (float)mark.PosInPattern.Y);
                MarkDrawCmd markDrawCmd = new MarkDrawCmd(position, mark.Enabled, MarkType.NormalMark);

                pattern.Add(markDrawCmd);
            }

            else if (cmdLine is BadMarkCmdLine)
            {
                BadMarkCmdLine mark        = cmdLine as BadMarkCmdLine;
                PointF         position    = new PointF((float)mark.Position.X, (float)mark.Position.Y);
                MarkDrawCmd    markDrawCmd = new MarkDrawCmd(position, mark.Enabled, MarkType.BadMark);

                pattern.Add(markDrawCmd);
            }

            else if (cmdLine is NozzleCheckCmdLine)
            {
                NozzleCheckCmdLine mark        = cmdLine as NozzleCheckCmdLine;
                PointF             position    = new PointF((float)mark.Position.X, (float)mark.Position.Y);
                MarkDrawCmd        markDrawCmd = new MarkDrawCmd(position, mark.Enabled, MarkType.CheckDotMark);

                pattern.Add(markDrawCmd);
            }

            else if (cmdLine is SnakeLineCmdLine)
            {
                SnakeLineCmdLine snake = cmdLine as SnakeLineCmdLine;

                Line2Points[] lines = new Line2Points[snake.LineCoordinateList.Count];
                for (int i = 0; i < snake.LineCoordinateList.Count; i++)
                {
                    PointF startPoint = new PointF((float)snake.LineCoordinateList[i].Start.X, (float)snake.LineCoordinateList[i].Start.Y);
                    PointF endPoint   = new PointF((float)snake.LineCoordinateList[i].End.X, (float)snake.LineCoordinateList[i].End.Y);
                    lines[i] = new Line2Points(startPoint, endPoint);
                }

                SnakeLineDrawCmd snakeLineDrawCmd = new SnakeLineDrawCmd(lines, true, snake.Enabled);

                pattern.Add(snakeLineDrawCmd);
            }
            else if (cmdLine is SymbolLinesCmdLine)
            {
                SymbolLinesCmdLine symbolLines = cmdLine as SymbolLinesCmdLine;

                SymbolLinesDrawCmd symbolLinesDrawCmd = new SymbolLinesDrawCmd(symbolLines.Symbols, symbolLines.Enabled);

                pattern.Add(symbolLinesDrawCmd);
            }
            else if (cmdLine is MultiTracesCmdLine)
            {
                MultiTracesCmdLine tracesCmdLine = cmdLine as MultiTracesCmdLine;
                MultiTracesDrawCmd tracesDrawCmd = new MultiTracesDrawCmd(tracesCmdLine.Traces, tracesCmdLine.Enabled);
                pattern.Add(tracesDrawCmd);
            }

            //如果是别的逻辑指令,为了保证和程序指令一致性,添加一个null进去
            else
            {
                pattern.Add(null);
            }
        }