Example #1
0
        public MarkCmd(RunnableModule runnableModule, MarkCmdLine markCmdLine) : base(runnableModule, markCmdLine)
        {
            // 转换成机械坐标
            var structure = runnableModule.CommandsModule.program.ModuleStructure;

            position        = structure.ToMachine(runnableModule, markCmdLine.PosInPattern);
            modelFindPrm    = markCmdLine.ModelFindPrm;
            this.IsFromFile = markCmdLine.IsFromFile;
        }
Example #2
0
        public EditAsvMarkForm(Pattern pattern, MarkCmdLine markCmdLine) : base(pattern == null ? new PointD(0, 0) : pattern.GetOriginPos())
        {
            InitializeComponent();
            this.pattern = pattern;
            this.origin  = pattern.GetOriginPos();
            for (int i = 10; i < 20; i++)
            {
                this.comboBox1.Items.Add(i);
            }
            this.cbResultType.Items.Add("1点+角度");
            this.cbResultType.Items.Add("2点");

            this.rbnTaught.Checked = true;
            this.rbnPlace.Checked  = false;
            if (markCmdLine == null)
            {
                this.isCreating  = true;
                this.markCmdLine = new MarkCmdLine();
                this.markCmdLine.ModelFindPrm.ExposureTime = Machine.Instance.Camera.Prm.Exposure;
                this.markCmdLine.ModelFindPrm.Gain         = Machine.Instance.Camera.Prm.Gain;
                //this.markCmdLine.ModelFindPrm.LightType = Machine.Instance.Camera.Prm.LightType;
                this.markCmdLine.ModelFindPrm.ExecutePrm     = (ExecutePrm)Machine.Instance.Light.ExecutePrm.Clone();
                this.cbResultType.SelectedIndex              = 0;
                this.markCmdLine.ModelFindPrm.UnStandardType = 0;
            }
            else
            {
                this.isCreating  = false;
                this.markCmdLine = markCmdLine;
                this.cbResultType.SelectedIndex = markCmdLine.ModelFindPrm.UnStandardType;
            }
            this.markCmdLine.ModelFindPrm.IsUnStandard = true;

            PointD p = this.pattern.MachineRel(this.markCmdLine.PosInPattern);

            tbLocationX.Text   = p.X.ToString("0.000");
            tbLocationY.Text   = p.Y.ToString("0.000");
            txtStandardX1.Text = this.markCmdLine.ModelFindPrm.ReferenceX.ToString();
            txtStandardY1.Text = this.markCmdLine.ModelFindPrm.ReferenceY.ToString();
            txtStandardX2.Text = this.markCmdLine.ModelFindPrm.ReferenceX2.ToString();
            txtStandardY2.Text = this.markCmdLine.ModelFindPrm.ReferenceY2.ToString();
            txtStandardA.Text  = this.markCmdLine.ModelFindPrm.ReferenceA.ToString();

            this.nudSettingTime.Minimum = 0;
            this.nudSettingTime.Maximum = 5000;
            this.nudSettingTime.Value   = this.markCmdLine.ModelFindPrm.SettlingTime;
            this.inspection             = InspectionMgr.Instance.FindBy(this.markCmdLine.ModelFindPrm.InspectionKey);
            this.comboBox1.SelectedItem = this.markCmdLine.ModelFindPrm.InspectionKey;
            this.cameraControl1.SetExposure(this.markCmdLine.ModelFindPrm.ExposureTime);
            this.cameraControl1.SetGain(this.markCmdLine.ModelFindPrm.Gain);
            //this.cameraControl1.SelectLight(this.markCmdLine.ModelFindPrm.LightType);
            this.cameraControl1.SelectLight(this.markCmdLine.ModelFindPrm.ExecutePrm);

            this.SetupLight(this.markCmdLine.ModelFindPrm.ExecutePrm);
            this.ReadLanguageResources();
        }
Example #3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.txtPatternName.Text.Trim()))
            {
                if (String.IsNullOrEmpty(this.currPath))
                {
                    return;
                }
                this.patternName = Path.GetFileName(currPath);
            }
            else
            {
                this.patternName = this.txtPatternName.Text.Trim();
            }
            if (FluidProgram.Current != null)
            {
                if (this.currPInfo.Trajectory.PointsOptimized.Count <= 0)
                {
                    return;
                }
                pattern = new Pattern(FluidProgram.Current, this.patternName, FluidProgram.Current.Workpiece.Origin.X, FluidProgram.Current.Workpiece.Origin.Y);

                pattern.CmdLineList.Clear();
                List <CmdLine> cmdLineList = new List <CmdLine>();
                if (this.currPInfo.Mark1 != null)
                {
                    MarkCmdLine mark = new MarkCmdLine(this.currPInfo.Mark1);
                    cmdLineList.Add(mark);
                }
                if (this.currPInfo.Mark2 != null)
                {
                    MarkCmdLine mark = new MarkCmdLine(this.currPInfo.Mark2);
                    cmdLineList.Add(mark);
                }
                foreach (PointD p in this.currPInfo.Trajectory.PointsOptimized)
                {
                    DotCmdLine dotCmdLine = new DotCmdLine();
                    dotCmdLine.Position.X      = p.X;
                    dotCmdLine.Position.Y      = p.Y;
                    dotCmdLine.DotStyle        = DotStyle.TYPE_1;
                    dotCmdLine.IsWeightControl = true;
                    dotCmdLine.Weight          = 0.0;
                    cmdLineList.Add(dotCmdLine);
                }
                cmdLineList.Add(new EndCmdLine());
                pattern.InsertCmdLineRange(0, cmdLineList);
                MsgCenter.Broadcast(Constants.MSG_ADD_PATTERN, this, pattern);
            }
        }
Example #4
0
        /// <summary>
        /// 创建pattern
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.txtPatternName.Text.Trim()))
            {
                if (String.IsNullOrEmpty(this.currPath))
                {
                    return;
                }
                this.patternName = Path.GetFileName(currPath);
            }
            else
            {
                this.patternName = this.txtPatternName.Text.Trim();
            }
            if (!this.isCalculated)
            {
                MessageBox.Show("请先计算pattern原点");
                return;
            }
            if (FluidProgram.Current == null)
            {
                MessageBox.Show("当前程序为空,请先加载或新建程序");
                this.btnOK.Enabled = false;
                return;
            }
            else if (FluidProgram.Current != null)
            {
                if (this.currPInfo == null)
                {
                    return;
                }
                if (this.currPInfo.Trajectory.PointsModified.Count <= 0)
                {
                    return;
                }
                //double x=this.patternNewOrg.X - FluidProgram.Current.Workpiece.GetOriginPos().ToSystem().X;
                //double y= this.patternNewOrg.Y - FluidProgram.Current.Workpiece.GetOriginPos().ToSystem().Y;
                PointD org = (this.patternNewOrg - FluidProgram.Current.Workpiece.GetOriginPos()).ToPoint().ToSystem();
                pattern = new Pattern(FluidProgram.Current, this.patternName, org.X, org.Y);

                pattern.CmdLineList.Clear();
                List <CmdLine> cmdLineList = new List <CmdLine>();
                if (this.currPInfo.Trajectory.MarkPt1 == null || this.currPInfo.Trajectory.MarkPt2 == null)
                {
                    //MessageBox.Show("mark1 and mark2 are null,please set mark1 and mark2");
                    MessageBox.Show("mark1点和mark2点没有设置,请设置mark1点和mark2点");
                    return;
                }
                if (this.currPInfo.Trajectory.MarkPt1 != null)
                {
                    CADImportV1._0.Infrastructure.PointD pd1 = this.currPInfo.Trajectory.MarkPt1.Mid;
                    MarkCmdLine mark = new MarkCmdLine(new PointD(pd1.X, pd1.Y));
                    mark.TrackNumber = this.currPInfo.Trajectory.MarkPt1.Desig;
                    cmdLineList.Add(mark);
                }
                if (this.currPInfo.Trajectory.MarkPt2 != null)
                {
                    CADImportV1._0.Infrastructure.PointD pd2 = this.currPInfo.Trajectory.MarkPt2.Mid;
                    MarkCmdLine mark = new MarkCmdLine(new PointD(pd2.X, pd2.Y));
                    mark.TrackNumber = this.currPInfo.Trajectory.MarkPt2.Desig;
                    cmdLineList.Add(mark);
                }
                foreach (TrajPoint p in this.currPInfo.Trajectory.PointsModified)
                {
                    if (p.Desig.Contains("(Blank)"))
                    {
                        MoveXyCmdLine moveXyCmdLine = new MoveXyCmdLine(p.Mid.X, p.Mid.Y, false);
                        moveXyCmdLine.TrackNumber = p.Desig;
                        cmdLineList.Add(moveXyCmdLine);
                    }
                    else
                    {
                        DotCmdLine dotCmdLine = new DotCmdLine();
                        dotCmdLine.Position.X  = p.Mid.X;
                        dotCmdLine.Position.Y  = p.Mid.Y;
                        dotCmdLine.NumShots    = p.NumShots;
                        dotCmdLine.TrackNumber = p.Desig;
                        dotCmdLine.Rotation    = p.Rotation.ToString("0.00");
                        dotCmdLine.Comp        = p.Comp;

                        if (!p.IsWeight)
                        {
                            dotCmdLine.IsAssign = true;
                        }
                        dotCmdLine.DotStyle = DotStyle.TYPE_1;
                        if (p.Weight <= 0)
                        {
                            dotCmdLine.IsWeightControl = false;
                        }
                        else
                        {
                            dotCmdLine.IsWeightControl = p.IsWeight;
                        }
                        dotCmdLine.Weight = p.Weight;
                        cmdLineList.Add(dotCmdLine);
                    }
                }
                cmdLineList.Add(new EndCmdLine());
                pattern.InsertCmdLineRange(0, cmdLineList);

                //进行校正
                PatternCorrector.Instance.correctPatternRecursive(pattern, this.patternOldOrg, this.patternNewOrg, this.coordinateTransformer);
                MsgCenter.Broadcast(Constants.MSG_ADD_PATTERN, this, pattern);
            }
        }
Example #5
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.txtPatternName.Text.Trim()))
            {
                if (String.IsNullOrEmpty(this.currPath))
                {
                    return;
                }
                this.patternName = Path.GetFileName(currPath);
            }
            else
            {
                this.patternName = this.txtPatternName.Text.Trim();
            }
            if (FluidProgram.Current != null)
            {
                if (this.currPInfo.Trajectory.PointsOptimized.Count <= 0)
                {
                    return;
                }
                pattern = new Pattern(FluidProgram.Current, this.patternName, FluidProgram.Current.Workpiece.Origin.X, FluidProgram.Current.Workpiece.Origin.Y);

                pattern.CmdLineList.Clear();
                List <CmdLine> cmdLineList = new List <CmdLine>();
                if (this.currPInfo.Mark1 == null || this.currPInfo.Mark2 == null)
                {
                    MessageBox.Show("mark1 and mark2 are null,please set mark1 and mark2");
                    return;
                }
                if (this.currPInfo.Mark1 != null)
                {
                    MarkCmdLine mark = new MarkCmdLine(this.currPInfo.Mark1.Mark);
                    cmdLineList.Add(mark);
                }
                if (this.currPInfo.Mark2 != null)
                {
                    MarkCmdLine mark = new MarkCmdLine(this.currPInfo.Mark2.Mark);
                    cmdLineList.Add(mark);
                }
                foreach (TrajPoint p in this.currPInfo.Trajectory.PointsModified)
                {
                    DotCmdLine dotCmdLine = new DotCmdLine();
                    dotCmdLine.Position.X = p.Mid.X;
                    dotCmdLine.Position.Y = p.Mid.Y;
                    FluidProgram.Current.ProgramSettings.DotParamList[0].NumShots = p.NumShots;
                    dotCmdLine.DotStyle = DotStyle.TYPE_1;
                    if (p.Weight <= 0)
                    {
                        dotCmdLine.IsWeightControl = false;
                    }
                    else
                    {
                        dotCmdLine.IsWeightControl = p.IsWeight;
                    }
                    dotCmdLine.Weight = p.Weight;
                    cmdLineList.Add(dotCmdLine);
                }
                cmdLineList.Add(new EndCmdLine());
                pattern.InsertCmdLineRange(0, cmdLineList);
                MsgCenter.Broadcast(Constants.MSG_ADD_PATTERN, this, pattern);
            }
        }
Example #6
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);
            }
        }