Exemplo n.º 1
0
        private bool getComponentByDesign(string design)
        {
            List <DotCmdLine> dots = new List <DotCmdLine>();

            foreach (var item in this.commandsModule.CmdLineList)
            {
                //如果不是点指令,则终止此次循环
                if (item is DotCmdLine == false)
                {
                    continue;
                }
                DotCmdLine dotCmdLine = item as DotCmdLine;
                if (dotCmdLine.TrackNumber != null && dotCmdLine.TrackNumber.Equals(design))
                {
                    dots.Add(dotCmdLine);
                }
            }
            if (dots == null || dots.Count <= 0)
            {
                return(false);
            }
            string compName = dots[0].Comp;

            foreach (var item in dots)
            {
                if (!item.Comp.Equals(compName))
                {
                    return(false);
                }
            }
            this.comps.Clear();
            this.comps.Add(new Component(dots));
            return(true);
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            FluidProgram.Create("xiaoxu", 0, 0);
            DotCmdLine dot = new DotCmdLine();

            dot.Position.X = 100;
            dot.Position.Y = 100;
            FluidProgram.CurrentOrDefault().Workpiece.AddCmdLine(dot);

            DoCmdLine doPattern = new DoCmdLine("1", 300, 300);

            FluidProgram.CurrentOrDefault().Workpiece.AddCmdLine(doPattern);

            Pattern    pattern = new Pattern(FluidProgram.CurrentOrDefault(), "1", 200, 200);
            DotCmdLine dot1    = new DotCmdLine();

            dot1.Position.X = 200;
            dot1.Position.Y = 200;
            pattern.AddCmdLine(dot1);
            FluidProgram.CurrentOrDefault().AddPattern(pattern);



            DrawingMsgCenter.Instance.SendMsg(DrawingMessage.需要更新绘图程序, FluidProgram.CurrentOrDefault());

            DrawProgram.Instance.SetGraphics(this.g, 1);
            DrawProgram.Instance.Drawing();
        }
Exemplo n.º 3
0
        public DotCmd(RunnableModule runnableModule, DotCmdLine dotCmdLine, MeasureHeightCmd mhCmd)
            : base(runnableModule, dotCmdLine)
        {
            this.Valve = dotCmdLine.Valve;
            var structure = runnableModule.CommandsModule.program.ModuleStructure;

            position        = structure.ToMachine(runnableModule, dotCmdLine.Position);
            DotStyle        = dotCmdLine.DotStyle;
            IsWeightControl = dotCmdLine.IsWeightControl;
            Weight          = dotCmdLine.Weight;
            this.NumShots   = dotCmdLine.NumShots;
            this.IsAssign   = dotCmdLine.IsAssign;
            this.associatedMeasureHeightCmd = mhCmd;
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 将元器件名称相同的点指令按照设计名称进行分类
        /// </summary>
        /// <returns></returns>
        private List <List <DotCmdLine> > GetClassficationDots(string compName)
        {
            List <List <DotCmdLine> > classficationDots = new List <List <DotCmdLine> >();

            foreach (var item in this.commandsModule.CmdLineList)
            {
                //如果不是点指令,则终止此次循环
                if (item is DotCmdLine == false)
                {
                    continue;
                }

                DotCmdLine dotCmdLine = item as DotCmdLine;
                //如果元器件名称相同
                if (dotCmdLine.Comp != null && dotCmdLine.TrackNumber != null && dotCmdLine.Comp.Equals(compName))
                {
                    //是否找到同样的设计名称
                    bool findDesign = false;

                    //遍历已分类的集合
                    foreach (var dotList in classficationDots)
                    {
                        //如果该点的设计名称和某个集合的设计名称一致,则添加到该集合中
                        if (dotCmdLine.TrackNumber.Equals(dotList.First().TrackNumber))
                        {
                            dotList.Add(dotCmdLine);
                            findDesign = true;
                            break;
                        }
                    }

                    //如果没找到,则重新增加一个点集合
                    if (!findDesign)
                    {
                        List <DotCmdLine> dots = new List <DotCmdLine>();
                        dots.Add(dotCmdLine);
                        classficationDots.Add(dots);
                    }
                }
            }

            return(classficationDots);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 编辑点命令
        /// </summary>
        /// <param name="origin">命令所在Pattern的机械坐标</param>
        /// <param name="dotCmdLine">点命令行</param>
        public EditDotMetro(Pattern pattern, DotCmdLine dotCmdLine)
        {
            InitializeComponent();
            this.pattern = pattern;
            this.origin  = pattern.GetOriginPos();
            if (dotCmdLine == null)
            {
                isCreating                      = true;
                this.dotCmdLine                 = new DotCmdLine();
                this.dotCmdLine.Position.X      = Properties.Settings.Default.DotX;
                this.dotCmdLine.Position.Y      = Properties.Settings.Default.DotY;
                this.dotCmdLine.DotStyle        = (DotStyle)Properties.Settings.Default.DotStyle;
                this.dotCmdLine.IsWeightControl = Properties.Settings.Default.DotIsWt;
                this.dotCmdLine.Weight          = Properties.Settings.Default.DotWt;
            }
            else
            {
                isCreating      = false;
                this.dotCmdLine = dotCmdLine;
            }
            //系统坐标->机械坐标
            PointD p = this.pattern.MachineRel(this.dotCmdLine.Position);

            tbLocationX.Text = p.X.ToString("0.000");
            tbLocationY.Text = p.Y.ToString("0.000");
            for (int i = 0; i < 10; i++)
            {
                comboBoxDotType.Items.Add("Type " + (i + 1));
            }
            comboBoxDotType.SelectedIndex = (int)this.dotCmdLine.DotStyle;
            cbWeightControl.Checked       = this.dotCmdLine.IsWeightControl;
            tbWeight.Text            = this.dotCmdLine.Weight.ToString("0.000");
            this.ckbShotNums.Checked = this.dotCmdLine.IsAssign;
            this.tbShots.Text        = this.dotCmdLine.NumShots.ToString("0");
            if (this.dotCmdLine != null)
            {
                this.dotCmdLineBackUp = (DotCmdLine)this.dotCmdLine.Clone();
            }
            //this.ReadLanguageResources();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 编辑点命令
        /// </summary>
        /// <param name="origin">命令所在Pattern的机械坐标</param>
        /// <param name="dotCmdLine">点命令行</param>
        public EditDotForm1(Pattern pattern, DotCmdLine dotCmdLine) : base(pattern.GetOriginPos())
        {
            InitializeComponent();
            this.robotIsXYZU  = Machine.Instance.Robot.AxesStyle == RobotAxesStyle.XYZU;
            this.robotIsXYZUV = Machine.Instance.Robot.AxesStyle == RobotAxesStyle.XYZUV;
            bool showTiltProperty = this.robotIsXYZU || this.robotIsXYZUV;

            this.cbTiltType.Visible  = showTiltProperty;
            this.lblTiltType.Visible = showTiltProperty;
            this.pattern             = pattern;
            this.origin = pattern.GetOriginPos();
            if (dotCmdLine == null)
            {
                isCreating                      = true;
                this.dotCmdLine                 = new DotCmdLine();
                this.dotCmdLine.Position.X      = Properties.Settings.Default.DotX;
                this.dotCmdLine.Position.Y      = Properties.Settings.Default.DotY;
                this.dotCmdLine.DotStyle        = (DotStyle)Properties.Settings.Default.DotStyle;
                this.dotCmdLine.IsWeightControl = Properties.Settings.Default.DotIsWt;
                this.dotCmdLine.Weight          = Properties.Settings.Default.DotWt;
                this.btnLastCmdLine.Visible     = false;
                this.btnNextCmdLine.Visible     = false;
            }
            else
            {
                isCreating      = false;
                this.dotCmdLine = dotCmdLine;
            }
            //系统坐标->机械坐标
            PointD p = this.pattern.MachineRel(this.dotCmdLine.Position);

            tbLocationX.Text = p.X.ToString("0.000");
            tbLocationY.Text = p.Y.ToString("0.000");
            for (int i = 0; i < 10; i++)
            {
                comboBoxDotType.Items.Add("Type " + (i + 1));
            }
            comboBoxDotType.SelectedIndex = (int)this.dotCmdLine.DotStyle;
            cbWeightControl.Checked       = this.dotCmdLine.IsWeightControl;
            tbWeight.Text            = this.dotCmdLine.Weight.ToString("0.000");
            this.ckbShotNums.Checked = this.dotCmdLine.IsAssign;
            this.tbShots.Text        = this.dotCmdLine.NumShots.ToString("0");
            if (this.dotCmdLine != null)
            {
                this.dotCmdLineBackUp = (DotCmdLine)this.dotCmdLine.Clone();
            }

            if (showTiltProperty)
            {
                this.cbTiltType.Items.Add("不倾斜");
                this.cbTiltType.Items.Add("左倾斜");
                this.cbTiltType.Items.Add("右倾斜");
                if (robotIsXYZUV)
                {
                    this.cbTiltType.Items.Add("前倾斜");
                    this.cbTiltType.Items.Add("后倾斜");
                }
                this.cbTiltType.SelectedIndex = (int)this.dotCmdLine.Tilt;
            }
            this.ReadLanguageResources();
        }
Exemplo n.º 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;
                        }
                    }
                }
            }
        }
Exemplo n.º 9
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;
                }
            }
        }
Exemplo n.º 10
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;
                }
            }
        }
Exemplo n.º 11
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);
            }
        }
Exemplo n.º 12
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);
            }
        }
Exemplo n.º 13
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);
            }
        }