示例#1
0
        public MultiTracesCmd(RunnableModule runnableModule, MultiTracesCmdLine multiTracesCmdLine, MeasureHeightCmd mhCmd)
            : base(runnableModule, multiTracesCmdLine)
        {
            this.Valve = multiTracesCmdLine.Valve;
            var structure = runnableModule.CommandsModule.program.ModuleStructure;

            this.multiTracesCmdLine = multiTracesCmdLine;

            foreach (var trace in this.multiTracesCmdLine.Traces)
            {
                TraceBase newTrace = trace.Clone() as TraceBase;
                if (newTrace is TraceLine)
                {
                    TraceLine traceLine = newTrace as TraceLine;
                    traceLine.Start = structure.ToMachine(runnableModule, traceLine.Start);
                    traceLine.End   = structure.ToMachine(runnableModule, traceLine.End);
                }
                else
                {
                    TraceArc traceArc = newTrace as TraceArc;
                    traceArc.Start = structure.ToMachine(runnableModule, traceArc.Start);
                    traceArc.Mid   = structure.ToMachine(runnableModule, traceArc.Mid);
                    traceArc.End   = structure.ToMachine(runnableModule, traceArc.End);
                }
                this.traces.Add(newTrace);
            }

            LineStyle       = multiTracesCmdLine.LineStyle;
            IsWeightControl = multiTracesCmdLine.IsWeightControl;
            wholeWeight     = multiTracesCmdLine.WholeWeight;
            this.OffsetX    = multiTracesCmdLine.OffsetX;
            this.OffsetY    = multiTracesCmdLine.OffsetY;
            this.associatedMeasureHeightCmd = mhCmd;
            //this.CheckRepeat();
        }
示例#2
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (this.listBoxPoints.SelectedIndex < 0)
            {
                return;
            }
            PointTrace pointTrace = pointsCache[this.listBoxPoints.SelectedIndex];

            if (pointTrace.PointType != TracePointType.End)
            {
                return;
            }

            int index = this.listBoxPoints.SelectedIndex;

            PointTrace pointPrev = pointsCache[this.listBoxPoints.SelectedIndex - 1];
            PointD     newPoint  = (Machine.Instance.Robot.PosXY - origin).ToPoint();
            TraceBase  trace     = this.tracesCache[pointTrace.TraceIndex];

            TraceBase tracePrev;

            if (pointTrace.TraceIndex == 0)
            {
                tracePrev = null;
            }
            else
            {
                tracePrev = this.tracesCache[pointTrace.TraceIndex - 1];
            }

            if (this.rbLine.Checked)
            {
                trace.Start = newPoint.Clone() as PointD;
                TraceLine line;
                if (tracePrev == null)
                {
                    line           = new TraceLine(pointPrev.Point.Clone() as PointD, newPoint.Clone() as PointD);
                    line.LineStyle = trace.LineStyle;
                }
                else
                {
                    line           = new TraceLine(tracePrev.End.Clone() as PointD, newPoint.Clone() as PointD);
                    line.LineStyle = trace.LineStyle;
                }
                this.tracesCache.Insert(pointTrace.TraceIndex, line);
            }
            else
            {
                TraceArc arc = new TraceArc(trace.Start, newPoint, trace.End);
                arc.LineStyle = trace.LineStyle;
                this.tracesCache[pointTrace.TraceIndex] = arc;
            }
            this.updatePointsCache();
            this.LoadLines2ListBox();
            this.LoadPoints2ListBox();

            this.listBoxPoints.SelectedIndex = index + 1;
        }
示例#3
0
        public MultiTraces(MultiTracesCmd multiTracesCmd, CoordinateCorrector coordinateCorrector)
        {
            this.RunnableModule = multiTracesCmd.RunnableModule;
            if (this.RunnableModule.Mode == ModuleMode.AssignMode1 || this.RunnableModule.Mode == ModuleMode.MainMode)
            {
                this.Valve = ValveType.Valve1;
            }
            else if (this.RunnableModule.Mode == ModuleMode.DualFallow)
            {
                this.Valve = ValveType.Both;
            }
            else
            {
                this.Valve = ValveType.Valve2;
            }

            foreach (var item in multiTracesCmd.Traces)
            {
                TraceBase newTrace = item.Clone() as TraceBase;
                if (newTrace is TraceLine)
                {
                    TraceLine traceLine = newTrace as TraceLine;
                    traceLine.Start = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceLine.Start, Executor.Instance.Program.ExecutantOriginOffset);
                    traceLine.End   = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceLine.End, Executor.Instance.Program.ExecutantOriginOffset);
                }
                else
                {
                    TraceArc traceArc = newTrace as TraceArc;
                    traceArc.Start = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceArc.Start, Executor.Instance.Program.ExecutantOriginOffset);
                    traceArc.Mid   = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceArc.Mid, Executor.Instance.Program.ExecutantOriginOffset);
                    traceArc.End   = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceArc.End, Executor.Instance.Program.ExecutantOriginOffset);
                }

                //newTrace.Param = multiTracesCmd.RunnableModule.CommandsModule.Program.ProgramSettings.GetLineParam(newLine.LineStyle);
                this.traces.Add(newTrace);
                Log.Dprint(string.Format("{0}: {1}", item.GetType(), item));
            }
            //param = multiTracesCmd.RunnableModule.CommandsModule.Program.ProgramSettings.GetLineParam(multiTracesCmd.LineStyle);
            isWeightControl     = multiTracesCmd.IsWeightControl;
            wholeWeight         = multiTracesCmd.WholeWeight;
            this.OffsetX        = multiTracesCmd.OffsetX;
            this.OffsetY        = multiTracesCmd.OffsetY;
            Program             = multiTracesCmd.RunnableModule.CommandsModule.Program;
            this.multiTracesCmd = multiTracesCmd;
            if (multiTracesCmd.AssociatedMeasureHeightCmd != null)
            {
                curMeasureHeightValue = multiTracesCmd.AssociatedMeasureHeightCmd.RealHtValue;
            }
            else
            {
                curMeasureHeightValue = this.RunnableModule.MeasuredHt;
            }
        }
示例#4
0
        /// <summary>
        /// 获取副阀的AB轴的移动轨迹
        /// </summary>
        /// <param name="multiTraces"></param>
        /// <param name="trace"></param>
        /// <returns></returns>
        private TraceBase getSimulTraces(MultiTraces multiTraces, TraceBase trace)
        {
            TraceBase newTrace = trace.Clone() as TraceBase;

            newTrace.Start = this.getSimulPos(multiTraces, newTrace.Start);
            newTrace.End   = this.getSimulPos(multiTraces, newTrace.End);
            if (newTrace is TraceArc)
            {
                TraceArc traceArc = newTrace as TraceArc;
                traceArc.Mid = this.getSimulPos(multiTraces, traceArc.Mid);
            }
            return(newTrace);
        }
示例#5
0
        /// <summary>
        /// 螺杆阀Wet和Dry模式下的运行逻辑
        /// </summary>
        /// <param name="points"></param>
        /// <returns></returns>
        private Result SvValveWetAndDryLogic(MultiTraces multiTraces)
        {
            Result ret = Result.OK;
            //主阀轨迹
            List <TraceBase> primaryTraces = new List <TraceBase>();
            //副阀轨迹
            List <TraceBase> simulTraces = new List <TraceBase>();

            //将相机坐标位置转换为阀的位置
            foreach (var trace in multiTraces.Traces)
            {
                TraceBase newTrace = trace.Clone() as TraceBase;
                newTrace.Start = newTrace.Start.ToNeedle(multiTraces.Valve);
                newTrace.End   = newTrace.End.ToNeedle(multiTraces.Valve);
                if (newTrace is TraceArc)
                {
                    TraceArc traceArc = newTrace as TraceArc;
                    traceArc.Mid = traceArc.Mid.ToNeedle(multiTraces.Valve);
                }
                primaryTraces.Add(newTrace);
            }

            //为主阀的坐标点进行偏移调整
            foreach (var trace in primaryTraces)
            {
                trace.TranslateBy(multiTraces.OffsetX, multiTraces.OffsetY);
            }

            //生成副阀的坐标点
            for (int i = 0; i < primaryTraces.Count; i++)
            {
                simulTraces.Add(this.getSimulTraces(multiTraces, primaryTraces[i]));
            }

            ret = this.SvValveTracesLogic(multiTraces, primaryTraces, simulTraces);
            if (!ret.IsOk)
            {
                return(ret);
            }

            return(ret);
        }
示例#6
0
        private void btnTeachEnd_Click(object sender, EventArgs e)
        {
            tbEndX.Text = (Machine.Instance.Robot.PosX - origin.X).ToString("0.000");
            tbEndY.Text = (Machine.Instance.Robot.PosY - origin.Y).ToString("0.000");
            if (!tbEndX.IsValid || !tbEndY.IsValid)
            {
                //MessageBox.Show("Please input valid values.");
                MessageBox.Show("请输入正确的值.");
                return;
            }
            //机械坐标->系统坐标
            this.tempEndPoint = pattern.SystemRel(tbEndX.Value, tbEndY.Value);
            if (hasSamePoints())
            {
                MessageBox.Show("存在相同点,请检查.");
                return;
            }
            TraceBase newTrace = null;

            if (this.rbLine.Checked)
            {
                newTrace = new TraceLine(this.tempStartPoint.Clone() as PointD, this.tempEndPoint.Clone() as PointD);
            }
            else
            {
                newTrace = new TraceArc(this.tempStartPoint.Clone() as PointD, this.tempMidPoint.Clone() as PointD, this.tempEndPoint.Clone() as PointD);
            }
            newTrace.LineStyle = this.comboBoxLineType.SelectedIndex;
            this.tracesCache.Add(newTrace);
            this.updatePointsCache();
            this.LoadLines2ListBox();
            this.LoadPoints2ListBox();
            listBoxLines.SelectedIndex  = listBoxLines.Items.Count - 1;
            listBoxPoints.SelectedIndex = listBoxPoints.Items.Count - 1;
            // 本段终点为下一段轨迹的起点
            this.tempStartPoint.X = this.tempEndPoint.X;
            this.tempStartPoint.Y = this.tempEndPoint.Y;
            this.tbStartX.Text    = this.tempStartPoint.X.ToString("0.000");
            this.tbStartY.Text    = this.tempStartPoint.Y.ToString("0.000");
            this.tbMidX.Text      = this.tempMidPoint.X.ToString("0.000");
            this.tbMidY.Text      = this.tempMidPoint.Y.ToString("0.000");
        }
示例#7
0
        public MultiTracesDrawCmd(List <TraceBase> traces, bool enable)
        {
            for (int i = 0; i < traces.Count; i++)
            {
                if (traces[i] is TraceLine)
                {
                    TraceLine line       = (TraceLine)traces[i];
                    PointF[]  linePoints = new PointF[2];
                    PointF    lineStart  = DrawingUtils.Instance.CoordinateTrans(new PointF((float)line.Start.X, (float)line.Start.Y));
                    PointF    lineEnd    = DrawingUtils.Instance.CoordinateTrans(new PointF((float)line.End.X, (float)line.End.Y));
                    linePoints[0] = lineStart;
                    linePoints[1] = lineEnd;
                    this.linesData.Add(linePoints);
                }
                else if (traces[i] is TraceArc)
                {
                    TraceArc traceArc  = (TraceArc)traces[i];
                    PointF[] arcPoints = new PointF[3];
                    PointF   arcStart  = DrawingUtils.Instance.CoordinateTrans(new PointF((float)traceArc.Start.X, (float)traceArc.Start.Y));
                    PointF   arcCenter = DrawingUtils.Instance.CoordinateTrans(new PointF((float)traceArc.Center.X, (float)traceArc.Center.Y));
                    PointF   arcEnd    = DrawingUtils.Instance.CoordinateTrans(new PointF((float)traceArc.End.X, (float)traceArc.End.Y));
                    arcPoints[0] = arcStart;
                    arcPoints[1] = arcCenter;
                    arcPoints[2] = arcEnd;

                    float degree = (float)traceArc.Degree;
                    this.arcsData.Add(new Tuple <PointF[], float>(arcPoints, degree));
                }

                if (i == traces.Count - 1 && traces[i] is TraceLine)
                {
                    this.lastTrackIsLine = true;
                }
            }

            this.enable = enable;
            this.SetTrack(new PointF(0, 0), Properties.Settings.Default.TrackNormalColor);
        }
示例#8
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;
                        }
                    }
                }
            }
        }