コード例 #1
0
        public void SaveResult(string pathDir)
        {
            string path = pathDir;

            DirUtils.CreateDir(path);
            //this.FileName = this.FileName.Replace(':', '_');
            path = path + "\\" + DateTime.Now.ToString("yyyyMMdd HHmmss");
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(this.Barcode + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.Depart + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.ComputerInfo + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.MachineInfo + "\r\n");
            stringBuilder.Append(this.GetBarcodePart(this.Barcode) + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.ProductLineInfo + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.OwkInfo + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.UserInfo + "\r\n");
            stringBuilder.Append(this.GetProgramRunTime() + "\r\n");
            stringBuilder.Append(this.GetProgramEndTime() + "\r\n");
            stringBuilder.Append("No  Width  MaxValue  MinValue  Height  MaxValue  MinValue" + "\r\n");
            for (int i = 0; i < this.Results.Count; i++)
            {
                string s = "";
                s += (1 + i).ToString() + "   ";
                s += this.Results[i][0] + "   ";
                s += this.Results[i][1] + "      ";
                s += this.Results[i][2] + "      ";
                s += this.Results[i][3] + "    ";
                s += this.Results[i][4] + "      ";
                s += this.Results[i][5];
                stringBuilder.Append(s + "\r\n");
            }

            CsvUtil.WriteLine(path, stringBuilder.ToString());
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            DrawingMsgCenter.Instance.SendMsg(DrawingMessage.需要更新绘图程序, FluidProgram.CurrentOrDefault());
            DrawProgram.Instance.SetGraphics(this.g, 1);

            //DrawProgram.Instance.Drawing();
        }
コード例 #3
0
        private void Init()
        {
            this.valveControl1.Setup(2);
            for (int i = 0; i < 10; i++)
            {
                this.cbxDotStyle.Items.Add("Type " + (i + 1));
            }
            this.cbxDotStyle.SelectedIndex = 0;
            this.dotStyle = DotStyle.TYPE_1;
            this.dotParam = FluidProgram.CurrentOrDefault().ProgramSettings.GetDotParam(this.dotStyle);

            if (DataSetting.Default.selectDispenseMode)
            {
                this.rdoDispenseMode.Checked = true;
            }
            else
            {
                this.rdoPlasticineMode.Checked = true;
            }
            switch (DataSetting.Default.selectCorrectionAxis)
            {
            case CorrectionAxis.A轴校正:
                this.rdoAxisA.Checked = true;
                break;

            case CorrectionAxis.B轴校正:
                this.rdoAxisB.Checked = true;
                break;

            case CorrectionAxis.A轴和B轴同时校正:
                this.rdoAxisAandB.Checked = true;
                break;
            }
        }
コード例 #4
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();
        }
コード例 #5
0
        public CalculateTheNeedleXYOffset(int valveNo)
        {
            this.valveNo = valveNo;
            InitializeComponent();
            this.valveControl1.Setup(valveNo);
            if (this.valveNo == 1)
            {
                this.picDiagram.Image = Properties.Resources.CalculateTheNeedleXYOffset;
            }
            else
            {
                this.picDiagram.Image = Properties.Resources.CalculateTheNeedle2XYOffset;
            }

            UpdateByFlag();

            for (int i = 0; i < 10; i++)
            {
                cbxDotStyle.Items.Add("Type " + (i + 1));
            }
            cbxDotStyle.SelectedIndex = 9;
            dotParam = FluidProgram.CurrentOrDefault().ProgramSettings.GetDotParam(dotStyle);
            this.ReadLanguageResources();
            this.FormClosed += CalculateTheNeedleXYOffset_FormClosed;
        }
コード例 #6
0
        private void EditCmdLine(int index)
        {
            bool inWorkpiece;
            int  patternNo = 0;

            if (commandsModule is FluidProgram)
            {
                return;
            }
            else if (commandsModule is Workpiece)
            {
                inWorkpiece = true;
            }
            else
            {
                inWorkpiece = false;

                Pattern pattern = commandsModule as Pattern;
                for (int i = 0; i < FluidProgram.CurrentOrDefault().Patterns.Count; i++)
                {
                    if (FluidProgram.CurrentOrDefault().Patterns[i].Name == pattern.Name)
                    {
                        patternNo = i;
                    }
                }
            }

            int[] cmdLiensIndex = new int[1];
            cmdLiensIndex[0] = index;

            DrawingMsgCenter.Instance.SendMsg(DrawingMessage.点击了一个绘图命令, inWorkpiece, patternNo, cmdLiensIndex);
        }
コード例 #7
0
 public void Setup(object[] objs)
 {
     dotParam               = FluidProgram.CurrentOrDefault().ProgramSettings.GetDotParam(dotStyle);
     this.tileType          = (TiltType)objs[0];
     this.valveAngle        = (double)objs[1];
     this.valveCameraOffset = (PointD)objs[2];
     this.standardZ         = (double)objs[3];
 }
コード例 #8
0
        private void btnTeach_Click(object sender, EventArgs e)
        {
            FluidProgram.CurrentOrDefault().ConveyorWidth = double.Parse(this.txtLiveLocation.Text);
            string msg = string.Format("ConveyorWidth:{0}->{1}", ConveyorWidthBackUp, double.Parse(this.txtLiveLocation.Text));

            Logger.DEFAULT.Info(LogCategory.MANUAL | LogCategory.SETTING, this.GetType().Name, msg);
            this.ConveyorWidthBackUp = FluidProgram.CurrentOrDefault().ConveyorWidth;
        }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: SetCode/Fluid
        private void OnLoadProgram(string programPath)
        {
            if (FluidProgram.Current != null && FluidProgram.CurrentFilePath == programPath)
            {
                AlarmServer.Instance.Fire(FluidProgram.Current, AlarmInfoFlu.WarnProgramAlreadyLoaded);
                return;
            }
            this.ProgramCtl.Enabled = false;
            FluidProgram.Load(programPath,
                              program =>
            {
                if (program == null)
                {
                    AlarmServer.Instance.Fire(program, AlarmInfoFlu.WarnProgramNull);
                    return;
                }
                FluidProgram.CurrentFilePath = programPath;
                program.HasChanged           = false;
                //加载程序,切换程序相关硬件参数
                Log.Dprint("Loading program: writing hardware...");
                program.InitHardware();
                Log.Dprint("Loading program: writing hardware done!");
                //语法检查
                if (Executor.Instance.CurrProgramState != Executor.ProgramOuterState.IDLE &&
                    Executor.Instance.CurrProgramState != Executor.ProgramOuterState.ABORTED)
                {
                    return;
                }
                Log.Dprint("Loading program: grammar parsing...");
                FluidProgram.Current.Parse();
                Log.Dprint("Loading program: grammar parse done!");
                //加载飞拍Mark校准值,只能在程序解析后赋值
                if (FluidProgram.Current.RuntimeSettings.FlyOffsetIsValid)
                {
                    bool result = FluidProgram.Current.ModuleStructure.SetAllMarkFlyOffset(FluidProgram.Current.RuntimeSettings.FlyOffsetList);
                    if (!result)
                    {
                        FluidProgram.Current.RuntimeSettings.FlyOffsetIsValid = false;
                    }
                }

                MsgCenter.SendMsg(MsgType.RUNINFO_PROGRAM, this, this.RunInfoCtl, program.Name);
            },
                              (errCode, errMsg) =>
            {
                AlarmServer.Instance.Fire(FluidProgram.Current, AlarmInfoFlu.ErrorLoadingProgram.AppendMsg(errMsg));
            });
            this.ProgramCtl.Enabled = true;

            DrawingMsgCenter.Instance.SendMsg(DrawingMessage.需要更新绘图程序, FluidProgram.CurrentOrDefault());
            DrawingMsgCenter.Instance.SendMsg(DrawingMessage.进入了Workpiece界面);
        }
コード例 #10
0
        /// <summary>
        /// 计算在手动打线模式下,普通线需要的各种参数
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="lineParam"></param>
        /// <param name="accStartPoint"></param>
        /// <param name="decelEndPoint"></param>
        /// <param name="runSpeed"></param>
        /// <param name="linePoints"></param>
        /// <param name="fluidIntervalSec"></param>
        private void GetManualNormalLineParam(PointD start, PointD end, LineParam lineParam, out PointD accStartPoint, out PointD decelEndPoint, out double runSpeed, out PointD[] linePoints, out double fluidIntervalSec)
        {
            double accDistance = 0, decelDistance = 0;
            // 运动速度不能超过设定的最大速度
            double speed = lineParam.Speed > FluidProgram.CurrentOrDefault().MotionSettings.WorkMaxVel ? FluidProgram.CurrentOrDefault().MotionSettings.WorkMaxVel : lineParam.Speed;

            // 计算加速区间距离
            if (lineParam.AccelDistanceValueType == LineParam.ValueType.COMPUTE)
            {
                accDistance = MathUtils.CalculateDistance(0, speed, Machine.Instance.Robot.AxisX.ConvertAcc2Mm(FluidProgram.CurrentOrDefault().MotionSettings.WeightAcc));
                Log.Dprint("Acc Distance COMPUTE speed=" + speed + ", WeightAcc=" + FluidProgram.CurrentOrDefault().MotionSettings.WeightAcc
                           + ", distance=" + accDistance);
            }
            else
            {
                accDistance = lineParam.AccelDistance;
            }
            // 计算减速区间距离
            if (lineParam.DecelDistanceValueType == LineParam.ValueType.COMPUTE)
            {
                decelDistance = MathUtils.CalculateDistance(speed, 0, -Machine.Instance.Robot.AxisX.ConvertAcc2Mm(FluidProgram.CurrentOrDefault().MotionSettings.WeightAcc));
                Log.Dprint("Decel Distance COMPUTE speed=" + speed + ", WeightAcc=" + FluidProgram.CurrentOrDefault().MotionSettings.WeightAcc
                           + ", distance=" + decelDistance);
            }
            else
            {
                decelDistance = lineParam.DecelDistance;
            }

            // 计算加速区间起始位置和减速区间结束位置
            PointD accStart = calAccStartPosition(start, end, accDistance);
            PointD decelEnd = calDecelEndPosition(start, end, decelDistance);
            // 计算点胶位置
            double intervalSec;

            PointD[] points = calNormalLinePoints(start, end, lineParam, speed, out intervalSec);

            accStartPoint    = accStart;
            decelEndPoint    = decelEnd;
            runSpeed         = speed;
            linePoints       = points;
            fluidIntervalSec = intervalSec;
        }
コード例 #11
0
 private bool ResultsIsRight()
 {
     if (Results.Count == 0)
     {
         this.SaveResult(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.DataLocalPathDir);
         return(false);
     }
     foreach (var item in this.Results)
     {
         if (Convert.ToDouble(item[0]) > Convert.ToDouble(item[1]) || Convert.ToDouble(item[0]) < Convert.ToDouble(item[2]))
         {
             return(false);
         }
         if (Convert.ToDouble(item[3]) > Convert.ToDouble(item[4]) || Convert.ToDouble(item[3]) < Convert.ToDouble(item[5]))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #12
0
        private void DispensingPot()
        {
            this.btnPrev.Enabled       = false;
            this.btnNext.Enabled       = false;
            this.grpVavelParam.Enabled = false;

            this.lblTitle.Text = this.lblTip[3];

            this.dotStyle = (DotStyle)this.cbxDotStyle.SelectedIndex;
            this.dotParam = FluidProgram.CurrentOrDefault().ProgramSettings.GetDotParam(this.dotStyle);

            Task.Factory.StartNew(new Action(() =>
            {
                Machine.Instance.Robot.MoveSafeZAndReply();

                Result result;

                double dot1Z;//, dot2Z, dot3Z;
                result = this.HeightMeasure(out dot1Z);
                if (!result.IsOk)
                {
                    this.btnPrev.Enabled = true;
                    return;
                }

                result = Machine.Instance.Valve2.DoPurgeAndPrime();
                if (!result.IsOk)
                {
                    this.btnPrev.Enabled = true;
                    return;
                }

                this.ContinueDot(dot1Z);

                this.BeginInvoke(new Action(() =>
                {
                    this.btnPrev.Enabled = true;
                    this.btnNext.Enabled = true;
                }));
            }));
        }
コード例 #13
0
        /// <summary>
        /// 根据当前commandsModule更新绘图程序内容
        /// </summary>
        private void UpdateDrawPanel()
        {
            //绘图相关逻辑
            DrawingMsgCenter.Instance.SendMsg(DrawingMessage.需要更新绘图程序, FluidProgram.CurrentOrDefault());

            if (commandsModule is Workpiece)
            {
                DrawingMsgCenter.Instance.SendMsg(DrawingMessage.进入了Workpiece界面);
            }
            else if (commandsModule is Pattern)
            {
                int     patternNo = 0;
                Pattern pattern   = commandsModule as Pattern;
                for (int i = 0; i < FluidProgram.CurrentOrDefault().Patterns.Count; i++)
                {
                    if (FluidProgram.CurrentOrDefault().Patterns[i].Name == pattern.Name)
                    {
                        patternNo = i;
                    }
                }
                DrawingMsgCenter.Instance.SendMsg(DrawingMessage.进入了Pattern界面, patternNo);
            }
        }
コード例 #14
0
        /// <summary>
        /// 更改命令行背景色
        /// </summary>
        private void ClickCmdLine()
        {
            bool inWorkpiece;
            int  patternNo = 0;

            if (commandsModule is FluidProgram)
            {
                return;
            }
            else if (commandsModule is Workpiece)
            {
                inWorkpiece = true;
            }
            else
            {
                inWorkpiece = false;

                Pattern pattern = commandsModule as Pattern;
                for (int i = 0; i < FluidProgram.CurrentOrDefault().Patterns.Count; i++)
                {
                    if (FluidProgram.CurrentOrDefault().Patterns[i].Name == pattern.Name)
                    {
                        patternNo = i;
                    }
                }
            }
            int[] cmdLiensIndex = new int[this.listView1.SelectedItems.Count];
            for (int i = 0; i < this.listView1.SelectedItems.Count; i++)
            {
                cmdLiensIndex[i] = this.listView1.SelectedItems[i].Index;
            }

            this.highLightSelectedIndices();

            DrawingMsgCenter.Instance.SendMsg(DrawingMessage.点击了一个绘图命令, inWorkpiece, patternNo, cmdLiensIndex);
        }
コード例 #15
0
 private void btnEditDot_Click(object sender, EventArgs e)
 {
     new EditDotParamsForm(FluidProgram.CurrentOrDefault().ProgramSettings.DotParamList).ShowDialog();
 }
コード例 #16
0
        private void UpdateByFlag()
        {
            switch (flag)
            {
            case 0:
                this.pnlDisplay.Controls.Clear();
                this.pnlDisplay.Controls.Add(this.picDiagram);
                this.picDiagram.Show();

                this.btnPrev.Enabled  = false;
                this.btnNext.Enabled  = true;
                this.btnTeach.Enabled = false;
                this.btnDone.Enabled  = false;
                this.lblTitle.Text    = this.lblTip[0];
                break;

            case 1:
                Task.Factory.StartNew(new Action(() =>
                {
                    //抬起到SafeZ
                    Machine.Instance.Robot.MoveSafeZAndReply();
                    //移动到默认平台中心点
                    Machine.Instance.Robot.ManualMovePosXYAndReply(DataSetting.Default.SubstrateCenter);

                    if (Machine.Instance.Laser.Laserable.Vendor == Laser.Vendor.Disable)
                    {
                        Machine.Instance.Robot.MovePosZAndReply(DataSetting.Default.NeedleJetZ);
                        MessageBox.Show("此时的Z轴高度为打胶时的参考高度");
                    }
                }));

                case2IsDone = false;
                //
                this.pnlDisplay.Controls.Clear();
                this.pnlDisplay.Controls.Add(this.cameraControl);
                this.cameraControl.Dock = DockStyle.Fill;
                this.cameraControl.Show();


                this.btnPrev.Enabled  = true;
                this.btnNext.Enabled  = false;
                this.btnTeach.Enabled = true;
                this.btnDone.Enabled  = false;
                this.lblTitle.Text    = this.lblTip[1];
                break;

            case 2:
                if (case2IsDone == false)
                {
                    //重新赋值平台中心点
                    DataSetting.Default.SubstrateCenter = new PointD(Machine.Instance.Robot.PosX, Machine.Instance.Robot.PosY);

                    if (Machine.Instance.Laser.Laserable.Vendor == Laser.Vendor.Disable)
                    {
                        DataSetting.Default.NeedleJetZ = Machine.Instance.Robot.PosZ;
                    }
                }
                else
                {
                }
                this.btnPrev.Enabled     = false;
                this.btnNext.Enabled     = false;
                this.btnTeach.Enabled    = false;
                this.btnDone.Enabled     = false;
                this.btnEditDot.Enabled  = false;
                this.cbxDotStyle.Enabled = false;

                this.dotStyle = (DotStyle)this.cbxDotStyle.SelectedIndex;
                this.dotParam = FluidProgram.CurrentOrDefault().ProgramSettings.GetDotParam(dotStyle);

                Task.Factory.StartNew(() =>
                {
                    double z1 = 0;
                    double z2 = 0;
                    double z3 = 0;
                    double z4 = 0;
                    if (Machine.Instance.Laser.Laserable.Vendor != Laser.Vendor.Disable)
                    {
                        int rst;
                        //关闭光源
                        Machine.Instance.Light.None();

                        Machine.Instance.MeasureHeightBefore();

                        //去点1处测高
                        Machine.Instance.Robot.ManualMovePosXYAndReply(
                            DataSetting.Default.SubstrateCenter.X - 5 + Machine.Instance.Robot.CalibPrm.HeightCamera.X,
                            DataSetting.Default.SubstrateCenter.Y + 5 + Machine.Instance.Robot.CalibPrm.HeightCamera.Y);
                        double height1;
                        rst = Machine.Instance.Laser.Laserable.ReadValue(new TimeSpan(0, 0, 1), out height1);
                        if (rst != 0)
                        {
                            MessageBox.Show(this.lblTip[2]);
                            return;
                        }
                        z1 = Machine.Instance.Robot.CalibPrm.StandardZ + (height1 - Machine.Instance.Robot.CalibPrm.StandardHeight);

                        //去点2处测高
                        Machine.Instance.Robot.ManualMovePosXYAndReply(
                            DataSetting.Default.SubstrateCenter.X + 5 + Machine.Instance.Robot.CalibPrm.HeightCamera.X,
                            DataSetting.Default.SubstrateCenter.Y + 5 + Machine.Instance.Robot.CalibPrm.HeightCamera.Y);
                        double height2;
                        rst = Machine.Instance.Laser.Laserable.ReadValue(new TimeSpan(0, 0, 1), out height2);

                        if (rst != 0)
                        {
                            MessageBox.Show(this.lblTip[2]);
                            return;
                        }
                        z2 = Machine.Instance.Robot.CalibPrm.StandardZ + (height2 - Machine.Instance.Robot.CalibPrm.StandardHeight);

                        //去点3处测高
                        Machine.Instance.Robot.ManualMovePosXYAndReply(
                            DataSetting.Default.SubstrateCenter.X + 5 + Machine.Instance.Robot.CalibPrm.HeightCamera.X,
                            DataSetting.Default.SubstrateCenter.Y - 5 + Machine.Instance.Robot.CalibPrm.HeightCamera.Y);
                        double height3;
                        rst = Machine.Instance.Laser.Laserable.ReadValue(new TimeSpan(0, 0, 1), out height3);
                        if (rst != 0)
                        {
                            MessageBox.Show(this.lblTip[2]);
                            return;
                        }
                        z3 = Machine.Instance.Robot.CalibPrm.StandardZ + (height3 - Machine.Instance.Robot.CalibPrm.StandardHeight);

                        //去点4处测高
                        Machine.Instance.Robot.ManualMovePosXYAndReply(
                            DataSetting.Default.SubstrateCenter.X - 5 + Machine.Instance.Robot.CalibPrm.HeightCamera.X,
                            DataSetting.Default.SubstrateCenter.Y - 5 + Machine.Instance.Robot.CalibPrm.HeightCamera.Y);
                        double height4;
                        rst = Machine.Instance.Laser.Laserable.ReadValue(new TimeSpan(0, 0, 1), out height4);

                        if (rst != 0)
                        {
                            MessageBox.Show(this.lblTip[2]);
                            return;
                        }
                        z4 = Machine.Instance.Robot.CalibPrm.StandardZ + (height4 - Machine.Instance.Robot.CalibPrm.StandardHeight);

                        //打开光源
                        Machine.Instance.Light.ResetToLast();
                        Machine.Instance.MeasureHeightAfter();
                    }
                    else
                    {
                        z1 = DataSetting.Default.NeedleJetZ;
                    }

                    //去清洗位置洗喷嘴
                    Result result;

                    Machine.Instance.Robot.MoveSafeZAndReply();
                    if (this.valveNo == 1)
                    {
                        result = Machine.Instance.Valve1.DoPurgeAndPrime();
                    }
                    else
                    {
                        result = Machine.Instance.Valve2.DoPurgeAndPrime();
                    }
                    if (!result.IsOk)
                    {
                        MessageBox.Show(lblTip[13]);
                        return;
                    }
                    this.BeginInvoke(new Action(() =>
                    {
                        //到点胶位置1点胶
                        this.lblTitle.Text = this.lblTip[3];
                    }));
                    //抬起到SafeZ
                    Machine.Instance.Robot.MoveSafeZAndReply();
                    if (this.valveNo == 1)
                    {
                        //移动到点胶位置1
                        PointD p1 = (DataSetting.Default.SubstrateCenter + new PointD(-5, 5)).ByNeedleCamera(ValveType.Valve1);
                        Machine.Instance.Robot.ManualMovePosXYAndReply(p1);
                        //点胶
                        this.DotByParam(1, z1);
                    }
                    else
                    {
                        //移动到点胶位置1
                        Machine.Instance.Robot.ManualMovePosXYAndReply(
                            DataSetting.Default.SubstrateCenter.X - 5 + Machine.Instance.Robot.CalibPrm.NeedleCamera2.X,
                            DataSetting.Default.SubstrateCenter.Y + 5 + Machine.Instance.Robot.CalibPrm.NeedleCamera2.Y);
                        //点胶
                        this.DotByParam(2, z1);
                    }


                    //到点胶位置2点胶
                    this.BeginInvoke(new Action(() =>
                    {
                        this.lblTitle.Text = this.lblTip[4];
                    }));
                    //抬起到SafeZ
                    Machine.Instance.Robot.MoveSafeZAndReply();
                    if (this.valveNo == 1)
                    {
                        //移动到点胶位置2
                        PointD p2 = (DataSetting.Default.SubstrateCenter + new PointD(5, 5)).ByNeedleCamera(Drive.ValveSystem.ValveType.Valve1);
                        Machine.Instance.Robot.ManualMovePosXYAndReply(p2);
                        //点胶
                        this.DotByParam(1, z1);
                    }
                    else
                    {
                        //移动到点胶位置2
                        Machine.Instance.Robot.ManualMovePosXYAndReply(
                            DataSetting.Default.SubstrateCenter.X + 5 + Machine.Instance.Robot.CalibPrm.NeedleCamera2.X,
                            DataSetting.Default.SubstrateCenter.Y + 5 + Machine.Instance.Robot.CalibPrm.NeedleCamera2.Y);
                        //点胶
                        this.DotByParam(2, z1);
                    }

                    //到点胶位置3点胶
                    this.BeginInvoke(new Action(() =>
                    {
                        this.lblTitle.Text = this.lblTip[5];
                    }));
                    //抬起到SafeZ
                    Machine.Instance.Robot.MoveSafeZAndReply();
                    if (this.valveNo == 1)
                    {
                        //移动到点胶位置3
                        PointD p3 = (DataSetting.Default.SubstrateCenter + new PointD(-5, -5)).ByNeedleCamera(Drive.ValveSystem.ValveType.Valve1);
                        Machine.Instance.Robot.ManualMovePosXYAndReply(p3);
                        //点胶
                        this.DotByParam(1, z1);
                    }
                    else
                    {
                        //移动到点胶位置3
                        Machine.Instance.Robot.ManualMovePosXYAndReply(
                            DataSetting.Default.SubstrateCenter.X - 5 + Machine.Instance.Robot.CalibPrm.NeedleCamera2.X,
                            DataSetting.Default.SubstrateCenter.Y - 5 + Machine.Instance.Robot.CalibPrm.NeedleCamera2.Y);
                        //点胶
                        this.DotByParam(2, z1);
                    }


                    //到点胶位置4点胶
                    this.BeginInvoke(new Action(() =>
                    {
                        this.lblTitle.Text = this.lblTip[6];
                    }));
                    //抬起到SafeZ
                    Machine.Instance.Robot.MoveSafeZAndReply();
                    if (this.valveNo == 1)
                    {
                        //移动到点胶位置4
                        PointD p4 = (DataSetting.Default.SubstrateCenter + new PointD(5, -5)).ByNeedleCamera(Drive.ValveSystem.ValveType.Valve1);
                        Machine.Instance.Robot.ManualMovePosXYAndReply(p4);
                        //点胶
                        this.DotByParam(1, z1);
                    }
                    else
                    {
                        //移动到点胶位置4
                        Machine.Instance.Robot.ManualMovePosXYAndReply(
                            DataSetting.Default.SubstrateCenter.X + 5 + Machine.Instance.Robot.CalibPrm.NeedleCamera2.X,
                            DataSetting.Default.SubstrateCenter.Y - 5 + Machine.Instance.Robot.CalibPrm.NeedleCamera2.Y);
                        //点胶
                        this.DotByParam(2, z1);
                    }


                    //四点点胶完成
                    this.BeginInvoke(new Action(() =>
                    {
                        this.lblTitle.Text       = this.lblTip[7];
                        this.btnPrev.Enabled     = true;
                        this.btnNext.Enabled     = true;
                        this.btnTeach.Enabled    = false;
                        this.btnDone.Enabled     = false;
                        this.btnEditDot.Enabled  = true;
                        this.cbxDotStyle.Enabled = true;
                    }));
                });
                break;

            case 3:
                case2IsDone = true;
                //抬起到SafeZ
                Machine.Instance.Robot.MoveSafeZAndReply();
                //移动到点1附近
                PointD p = (DataSetting.Default.SubstrateCenter + new PointD(-5, 5)).ByNeedleJet(Drive.ValveSystem.ValveType.Valve1);
                Machine.Instance.Robot.ManualMovePosXY(p);

                this.lblTitle.Text           = this.lblTip[8];
                this.btnPrev.Enabled         = true;
                this.btnNext.Enabled         = false;
                this.btnTeach.Enabled        = true;
                this.btnDone.Enabled         = false;
                this.txtDot2Offset.BackColor = Color.White;
                this.txtDot3Offset.BackColor = Color.White;
                this.txtDot4Offset.BackColor = Color.White;

                break;

            case 4:
                //计算点胶阀中心和真实点胶中心的差值
                if (this.valveNo == 1)
                {
                    Machine.Instance.Robot.CalibPrm.NeedleJet1 =
                        (Machine.Instance.Robot.PosXY.ToSystem() - (DataSetting.Default.SubstrateCenter + new PointD(-5, 5)).ToSystem()).ToPoint();
                }
                else
                {
                    Machine.Instance.Robot.CalibPrm.NeedleJet2 = new PointD(
                        Machine.Instance.Robot.PosX - (DataSetting.Default.SubstrateCenter.X - 5),
                        Machine.Instance.Robot.PosY - (DataSetting.Default.SubstrateCenter.Y + 5));
                }

                //抬起到SafeZ
                Machine.Instance.Robot.MoveSafeZAndReply();
                //移动到点2附近
                p = (DataSetting.Default.SubstrateCenter + new PointD(5, 5)).ByNeedleJet(Drive.ValveSystem.ValveType.Valve1);
                Machine.Instance.Robot.ManualMovePosXY(p);

                this.lblTitle.Text    = this.lblTip[9];
                this.btnPrev.Enabled  = true;
                this.btnNext.Enabled  = false;
                this.btnTeach.Enabled = true;
                this.btnDone.Enabled  = false;
                break;

            case 5:
                //计算修正后,在点2时点胶阀中心和实际点胶中心的差值
                PointD dot2Offset = new PointD();
                if (this.valveNo == 1)
                {
                    dot2Offset = (Machine.Instance.Robot.PosXY.ToSystem() - ((DataSetting.Default.SubstrateCenter + new PointD(5, 5)).ToSystem() + Machine.Instance.Robot.CalibPrm.NeedleJet1)).ToPoint();
                }
                else
                {
                    dot2Offset.X = Machine.Instance.Robot.PosX - (DataSetting.Default.SubstrateCenter.X + 5 + Machine.Instance.Robot.CalibPrm.NeedleJet2.X);
                    dot2Offset.Y = Machine.Instance.Robot.PosY - (DataSetting.Default.SubstrateCenter.Y + 5 + Machine.Instance.Robot.CalibPrm.NeedleJet2.Y);
                }
                dot2TotalOffset         = Math.Sqrt(Math.Pow(dot2Offset.X, 2) + Math.Pow(dot2Offset.Y, 2));
                this.txtDot2Offset.Text = dot2TotalOffset.ToString();

                //抬起到SafeZ
                Machine.Instance.Robot.MoveSafeZAndReply();
                //移动到点3附近
                p = (DataSetting.Default.SubstrateCenter + new PointD(-5, -5)).ByNeedleJet(Drive.ValveSystem.ValveType.Valve1);
                Machine.Instance.Robot.ManualMovePosXY(p);

                this.lblTitle.Text    = this.lblTip[10];
                this.btnPrev.Enabled  = true;
                this.btnNext.Enabled  = false;
                this.btnTeach.Enabled = true;
                this.btnDone.Enabled  = false;
                break;

            case 6:
                //计算修正后,在点3时点胶阀中心和实际点胶中心的差值
                PointD dot3Offset = new PointD();
                if (this.valveNo == 1)
                {
                    dot3Offset = (Machine.Instance.Robot.PosXY.ToSystem() - ((DataSetting.Default.SubstrateCenter + new PointD(-5, -5)).ToSystem() + Machine.Instance.Robot.CalibPrm.NeedleJet1)).ToPoint();
                }
                else
                {
                    dot3Offset.X = Machine.Instance.Robot.PosX - (DataSetting.Default.SubstrateCenter.X - 5 + Machine.Instance.Robot.CalibPrm.NeedleJet2.X);
                    dot3Offset.Y = Machine.Instance.Robot.PosY - (DataSetting.Default.SubstrateCenter.Y - 5 + Machine.Instance.Robot.CalibPrm.NeedleJet2.Y);
                }
                dot3TotalOffset         = Math.Pow((Math.Pow(dot3Offset.X, 2) + Math.Pow(dot3Offset.Y, 2)), 0.5);
                this.txtDot3Offset.Text = dot3TotalOffset.ToString();

                //抬起到SafeZ
                Machine.Instance.Robot.MoveSafeZAndReply();
                //移动到点4附近
                p = (DataSetting.Default.SubstrateCenter + new PointD(5, -5)).ByNeedleJet(Drive.ValveSystem.ValveType.Valve1);
                Machine.Instance.Robot.ManualMovePosXY(p);

                this.lblTitle.Text    = this.lblTip[11];
                this.btnPrev.Enabled  = true;
                this.btnNext.Enabled  = false;
                this.btnTeach.Enabled = true;
                this.btnDone.Enabled  = false;
                this.rdoOK.Checked    = false;
                this.rdoFail.Checked  = false;
                this.rdoOK.Enabled    = false;
                this.rdoFail.Enabled  = false;
                break;

            case 7:
                //抬起到SafeZ
                Machine.Instance.Robot.MoveSafeZAndReply();

                //计算修正后,在点4时点胶阀中心和实际点胶中心的差值
                PointD dot4Offset = new PointD();
                if (this.valveNo == 1)
                {
                    dot4Offset = (Machine.Instance.Robot.PosXY.ToSystem() - ((DataSetting.Default.SubstrateCenter + new PointD(5, -5)).ToSystem() + Machine.Instance.Robot.CalibPrm.NeedleJet1)).ToPoint();
                }
                else
                {
                    dot4Offset.X = Machine.Instance.Robot.PosX - (DataSetting.Default.SubstrateCenter.X + 5 + Machine.Instance.Robot.CalibPrm.NeedleJet2.X);
                    dot4Offset.Y = Machine.Instance.Robot.PosY - (DataSetting.Default.SubstrateCenter.Y - 5 + Machine.Instance.Robot.CalibPrm.NeedleJet2.Y);
                }
                dot4TotalOffset         = Math.Pow((Math.Pow(dot4Offset.X, 2) + Math.Pow(dot4Offset.Y, 2)), 0.5);
                this.txtDot4Offset.Text = dot4TotalOffset.ToString();

                if (dot2TotalOffset > Convert.ToDouble(this.txtTolerance.Text))
                {
                    this.rdoFail.Checked         = true;
                    this.rdoFail.Enabled         = true;
                    this.txtDot2Offset.BackColor = Color.DarkRed;
                }
                if (dot3TotalOffset > Convert.ToDouble(this.txtTolerance.Text))
                {
                    this.rdoFail.Checked         = true;
                    this.rdoFail.Enabled         = true;
                    this.txtDot3Offset.BackColor = Color.DarkRed;
                }
                if (dot4TotalOffset > Convert.ToDouble(this.txtTolerance.Text))
                {
                    this.rdoFail.Checked         = true;
                    this.rdoFail.Enabled         = true;
                    this.txtDot4Offset.BackColor = Color.DarkRed;
                }
                if ((dot2TotalOffset <= Convert.ToDouble(this.txtTolerance.Text)) &&
                    (dot3TotalOffset <= Convert.ToDouble(this.txtTolerance.Text)) &&
                    (dot4TotalOffset <= Convert.ToDouble(this.txtTolerance.Text)))
                {
                    this.rdoOK.Checked           = true;
                    this.rdoOK.Enabled           = true;
                    this.txtDot2Offset.BackColor = Color.White;
                    this.txtDot3Offset.BackColor = Color.White;
                    this.txtDot4Offset.BackColor = Color.White;
                }
                this.lblTitle.Text    = this.lblTip[12];
                this.btnPrev.Enabled  = true;
                this.btnNext.Enabled  = false;
                this.btnTeach.Enabled = false;
                this.btnDone.Enabled  = true;
                break;
            }
        }
コード例 #17
0
        private void UpdateByIndex()
        {
            switch (index)
            {
            case 0:
                this.txtMsg.Text     = "用相机寻找到打胶中心,按 [下一步],将会在距离寻找到的中心半径5mm的四个方向打胶";
                this.btnNext.Enabled = true;
                break;

            case 1:
                this.dispensePos = Machine.Instance.Robot.PosXY;
                this.dotStyle    = (DotStyle)this.cbxDotStyle.SelectedIndex;
                this.dotParam    = FluidProgram.CurrentOrDefault().ProgramSettings.GetDotParam(dotStyle);
                this.gap         = this.dotParam.DispenseGap;
                Task.Factory.StartNew(new Action(() =>
                {
                    bool b = this.MeasureHeightAndDot();
                    this.BeginInvoke(new Action(() =>
                    {
                        if (b)
                        {
                            this.txtMsg.Text = "点胶结束,按 [下一步],将会移动到第一个点胶位置";
                        }
                        else
                        {
                            this.txtMsg.Text     = "点胶失败";
                            this.btnNext.Enabled = false;
                        }
                    }));
                }));
                break;

            case 2:
                this.txtMsg.Text = "找到第一个胶点的中心位置,按 [下一步]";
                Machine.Instance.Robot.MoveSafeZAndReply();
                //移动到点1附近
                PointD p1 = new PointD(this.dispensePos.X - 5, this.dispensePos.Y + 5);
                Machine.Instance.Robot.ManualMovePosXY(p1);

                this.txtDot2Offset.BackColor = Color.White;
                this.txtDot3Offset.BackColor = Color.White;
                this.txtDot4Offset.BackColor = Color.White;
                break;

            case 3:
                //计算实际点胶中心和胶阀中心的差值
                this.dotValveOffset = new PointD(Machine.Instance.Robot.PosX - (this.dispensePos.X - 5), Machine.Instance.Robot.PosY - (this.dispensePos.Y + 5));
                this.txtMsg.Text    = "找到第二个胶点的中心位置,按 [下一步]";
                PointD p2 = new PointD(this.dispensePos.X + 5, this.dispensePos.Y + 5);
                Machine.Instance.Robot.ManualMovePosXY(p2);
                break;

            case 4:
                //计算修正后,在点2时实际点胶中心和胶阀中心的差值
                PointD dot2Offset = new PointD();
                dot2Offset.X            = Machine.Instance.Robot.PosX - (this.dispensePos.X + 5 + this.dotValveOffset.X);
                dot2Offset.Y            = Machine.Instance.Robot.PosY - (this.dispensePos.Y + 5 + this.dotValveOffset.Y);
                this.dot2TotalOffset    = Math.Sqrt(Math.Pow(dot2Offset.X, 2) + Math.Pow(dot2Offset.Y, 2));
                this.txtDot2Offset.Text = dot2TotalOffset.ToString();

                this.txtMsg.Text = "找到第三个胶点的中心位置,按 [下一步]";
                Machine.Instance.Robot.MoveSafeZAndReply();
                PointD p3 = new PointD(this.dispensePos.X - 5, this.dispensePos.Y - 5);
                Machine.Instance.Robot.ManualMovePosXY(p3);
                break;

            case 5:
                //计算修正后,在点2时实际点胶中心和胶阀中心的差值
                PointD dot3Offset = new PointD();
                dot3Offset.X            = Machine.Instance.Robot.PosX - (this.dispensePos.X - 5 + this.dotValveOffset.X);
                dot3Offset.Y            = Machine.Instance.Robot.PosY - (this.dispensePos.Y - 5 + this.dotValveOffset.Y);
                this.dot3TotalOffset    = Math.Sqrt(Math.Pow(dot3Offset.X, 2) + Math.Pow(dot3Offset.Y, 2));
                this.txtDot3Offset.Text = dot3TotalOffset.ToString();

                this.txtMsg.Text = "找到第四个胶点的中心位置,按 [下一步]";
                Machine.Instance.Robot.MoveSafeZAndReply();
                PointD p4 = new PointD(this.dispensePos.X + 5, this.dispensePos.Y - 5);
                Machine.Instance.Robot.ManualMovePosXY(p4);
                break;

            case 6:
                //计算修正后,在点2时实际点胶中心和胶阀中心的差值
                PointD dot4Offset = new PointD();
                dot4Offset.X            = Machine.Instance.Robot.PosX - (this.dispensePos.X + 5 + this.dotValveOffset.X);
                dot4Offset.Y            = Machine.Instance.Robot.PosY - (this.dispensePos.Y - 5 + this.dotValveOffset.Y);
                this.dot4TotalOffset    = Math.Sqrt(Math.Pow(dot4Offset.X, 2) + Math.Pow(dot4Offset.Y, 2));
                this.txtDot4Offset.Text = dot4TotalOffset.ToString();

                if (this.dot2TotalOffset > Convert.ToDouble(this.txtTolerance.Text))
                {
                    this.rdoFail.Checked         = true;
                    this.rdoFail.Enabled         = true;
                    this.txtDot2Offset.BackColor = Color.DarkRed;
                }
                if (dot3TotalOffset > Convert.ToDouble(this.txtTolerance.Text))
                {
                    this.rdoFail.Checked         = true;
                    this.rdoFail.Enabled         = true;
                    this.txtDot3Offset.BackColor = Color.DarkRed;
                }
                if (dot4TotalOffset > Convert.ToDouble(this.txtTolerance.Text))
                {
                    this.rdoFail.Checked         = true;
                    this.rdoFail.Enabled         = true;
                    this.txtDot4Offset.BackColor = Color.DarkRed;
                }
                if ((dot2TotalOffset <= Convert.ToDouble(this.txtTolerance.Text)) &&
                    (dot3TotalOffset <= Convert.ToDouble(this.txtTolerance.Text)) &&
                    (dot4TotalOffset <= Convert.ToDouble(this.txtTolerance.Text)))
                {
                    this.rdoOK.Checked           = true;
                    this.rdoOK.Enabled           = true;
                    this.txtDot2Offset.BackColor = Color.White;
                    this.txtDot3Offset.BackColor = Color.White;
                    this.txtDot4Offset.BackColor = Color.White;
                }

                this.txtMsg.Text = "四点校正完成";
                break;
            }
        }
コード例 #18
0
        /// <summary>
        /// 解析指令
        /// 注意: 传递的实际原点坐标值,是引用当前模块的指令(DO, DO MULTIPASS)里面的坐标值;如果当前模块是FluidProgram,则原点值为(0, 0)
        /// </summary>
        /// <param name="origin">当前模块实际原点坐标</param>
        /// <param name="parent">包含当前模块的外层模块, 一个模块解析后对应的是RunnableModule类型,所以parent类型是RunnableModule</param>
        /// <param name="level">当前模块所处的层级,Program为0,Workpiece为1,以此类推</param>
        /// <returns>解析结果. 如果解析成功,携带对应的RunnableModule;如果解析失败,携带出错行CmdLine、出错描述信息</returns>
        private Result parse(CommandsModule commandsModule, PointD origin, RunnableModule parent, int level, int boardNo)
        {
            Pattern        currPattern    = commandsModule as Pattern;
            RunnableModule runnableModule = new RunnableModule(commandsModule, origin);

            runnableModule.BoardNo = boardNo;
            // workpiece下面所有拼版根据因引用的Do指令或DoMultiPass指令的Valve设定拼版
            if (level == 2)
            {
                runnableModule.Valve = (commandsModule as Pattern).Valve;
                if (runnableModule.Valve == Drive.ValveSystem.ValveType.Valve1)
                {
                    runnableModule.Mode     = ModuleMode.AssignMode1;
                    runnableModule.SaveMode = ModuleMode.AssignMode1;
                }
                else if (runnableModule.Valve == Drive.ValveSystem.ValveType.Valve2)
                {
                    runnableModule.Mode     = ModuleMode.AssignMode2;
                    runnableModule.SaveMode = ModuleMode.AssignMode2;
                }
                else if (runnableModule.Valve == Drive.ValveSystem.ValveType.Both)
                {
                    runnableModule.Mode     = ModuleMode.DualFallow;
                    runnableModule.SaveMode = ModuleMode.DualFallow;
                }
            }
            if (level > 2)
            {
                runnableModule.Valve    = parent.Valve;
                runnableModule.Mode     = parent.Mode;
                runnableModule.SaveMode = parent.SaveMode;
            }
            program.ModuleStructure.AddModule(runnableModule, parent, level);
            // 是否已经遇到END:
            bool ended = false;
            // 记录当前处在什么类型的子句中,例如:loop block, pass block
            BlockState blockState = new BlockState();
            // 开始解析:
            List <CmdLine> cmdLineList;

            cmdLineList = new List <CmdLine>(commandsModule.CmdLineList);
            CmdLine          cmdLine             = null;
            bool             hasPassBlock        = false;
            int              lastPassblockIndex  = -1;
            MeasureHeightCmd curMeasureHeightCmd = null;

            //增加螺杆阀的速度、重量键值对
            Dictionary <int, double> svValvespeedDic = new Dictionary <int, double>();

            //TODO 将5换为阀参数设置的默认值,10换为默认值
            svValvespeedDic.Add(5, 10);

            for (int i = 0; i < cmdLineList.Count; i++)
            {
                cmdLine = cmdLineList[i];

                // 忽略被禁用的命令
                if (!cmdLine.Enabled)
                {
                    continue;
                }

                // END: 后面不允许添加任何命令
                if (ended)
                {
                    return(new Result(false, cmdLine, "No commands is allowed to be added after END"));
                }

                if (cmdLine is SetHeightSenseModeCmdLine)
                {
                    runnableModule.AddCommand(new SetHeightSenseModeCmd(runnableModule, cmdLine as SetHeightSenseModeCmdLine));
                }
                else if (cmdLine is MarkCmdLine)
                {
                    // Mark点命令必须处在最前面
                    if (i > 0)
                    {
                        // 寻找Mark点前面的Enable==true且不是注释的命令
                        CmdLine lastestCmdLine = getLastestEnabledCmdLine(cmdLineList, i - 1);
                        if (lastestCmdLine != null && !(lastestCmdLine is MarkCmdLine))
                        {
                            return(new Result(false, cmdLine, "MARK must be added before the other command types."));
                        }
                    }
                    if (findMarkCmdLineIndex(cmdLineList, cmdLine as MarkCmdLine) > 1)
                    {
                        return(new Result(false, cmdLine, "MARK number can not be more than 2."));
                    }
                    MarkCmd markCmd = new MarkCmd(runnableModule, cmdLine as MarkCmdLine);
                    runnableModule.AddCommand(markCmd);
                    program.ModuleStructure.RecordMarkPoint(runnableModule, markCmd);
                }
                else if (cmdLine is BadMarkCmdLine)
                {
                    //// 屏蔽原因 : BadMark模式由每个拼版只有一个 改为 测高指令那种模式
                    //// BadMark点命令必须处在非Mark命令的前面
                    //if (i > 0)
                    //{
                    //    // 寻找Bad Mark点前面的Enable==true且不是注释的命令
                    //    CmdLine lastestCmdLine = getLastestEnabledCmdLine(cmdLineList, i - 1);
                    //    if (lastestCmdLine != null && !(lastestCmdLine is MarkCmdLine))
                    //    {
                    //        // 当前指令前面有非Mark指令,判断是否是BadMark,每个pattern只能添加一个BadMark
                    //        if (lastestCmdLine is BadMarkCmdLine)
                    //        {
                    //            return new Result(false, cmdLine, "Only one BADMARK command can be added per pattern");
                    //        }
                    //        else
                    //        {
                    //            return new Result(false, cmdLine, "BADMARK must be added before the non-mark command types.");
                    //        }
                    //    }
                    //}
                    BadMarkCmd badMarkCmd = new BadMarkCmd(runnableModule, cmdLine as BadMarkCmdLine);
                    runnableModule.AddCommand(badMarkCmd);
                    program.ModuleStructure.RecordBadMarkPoint(runnableModule, badMarkCmd);
                }
                else if (cmdLine is MeasureCmdLine)
                {
                    MeasureCmd measureCmd = new MeasureCmd(runnableModule, cmdLine as MeasureCmdLine);
                    runnableModule.AddCommand(measureCmd);
                    //记录检测指令里的测高
                    program.ModuleStructure.RecordMeasureGlueHTCmds(runnableModule, measureCmd);
                }
                else if (cmdLine is BlobsCmdLine)
                {
                    BlobsCmd blobsCmd = new BlobsCmd(runnableModule, cmdLine as BlobsCmdLine);
                    runnableModule.AddCommand(blobsCmd);
                    program.ModuleStructure.RecordBlobsCmds(runnableModule, blobsCmd);
                }
                else if (cmdLine is BarcodeCmdLine)
                {
                    BarcodeCmd barcodeCmd = new BarcodeCmd(runnableModule, cmdLine as BarcodeCmdLine);
                    runnableModule.AddCommand(barcodeCmd);
                    program.ModuleStructure.RecordBarcodeCmds(runnableModule, barcodeCmd);
                }
                else if (cmdLine is ConveyorBarcodeCmdLine)
                {
                    ConveyorBarcodeCmd conveyorBarcodeCmd = new ConveyorBarcodeCmd(runnableModule, cmdLine as ConveyorBarcodeCmdLine);
                    runnableModule.AddCommand(conveyorBarcodeCmd);
                }
                else if (cmdLine is MeasureHeightCmdLine)
                {
                    MeasureHeightCmdLine measureHeightCmdLine = cmdLine as MeasureHeightCmdLine;
                    curMeasureHeightCmd = new MeasureHeightCmd(runnableModule, measureHeightCmdLine);
                    runnableModule.AddCommand(curMeasureHeightCmd);
                    program.ModuleStructure.RecordMeasureHeightPoint(runnableModule, curMeasureHeightCmd);
                }
                else if (cmdLine is NozzleCheckCmdLine)
                {
                    if (level > 1)
                    {
                        cmdLine.Valve = runnableModule.Valve;
                    }
                    runnableModule.AddCommand(new NozzleCheckCmd(runnableModule, cmdLine as NozzleCheckCmdLine, curMeasureHeightCmd));
                }
                else if (cmdLine is SymbolLinesCmdLine)
                {
                    if (level > 1)
                    {
                        cmdLine.Valve = runnableModule.Valve;
                    }
                    SymbolLinesCmdLine symbolLinesCmdLine = cmdLine as SymbolLinesCmdLine;
                    SymbolLinesCmd     symbolLinesCmd     = new SymbolLinesCmd(runnableModule, symbolLinesCmdLine);
                    runnableModule.AddCommand(symbolLinesCmd);
                    foreach (MeasureHeightCmd item in symbolLinesCmd.GetAllMeasureCmdLineList())
                    {
                        if (item == null)
                        {
                            continue;
                        }
                        program.ModuleStructure.RecordMeasureHeightPoint(runnableModule, item);
                    }
                    program.ModuleStructure.RecordSymbolLinesCmd(runnableModule, symbolLinesCmd);
                }
                else if (cmdLine is MultiTracesCmdLine)
                {
                    if (level > 1)
                    {
                        cmdLine.Valve = runnableModule.Valve;
                    }
                    runnableModule.AddCommand(new MultiTracesCmd(runnableModule, cmdLine as MultiTracesCmdLine, curMeasureHeightCmd));
                }
                else if (cmdLine is DotCmdLine)
                {
                    if (level > 1)
                    {
                        cmdLine.Valve = runnableModule.Valve;
                    }
                    runnableModule.AddCommand(new DotCmd(runnableModule, cmdLine as DotCmdLine, curMeasureHeightCmd));
                }
                else if (cmdLine is FinishShotCmdLine)
                {
                    if (level > 1)
                    {
                        cmdLine.Valve = runnableModule.Valve;
                    }
                    runnableModule.AddCommand(new FinishShotCmd(runnableModule, cmdLine as FinishShotCmdLine, curMeasureHeightCmd));
                }
                else if (cmdLine is LineCmdLine) // 包含了 cmdLine is SnakeLineCmdLine
                {
                    if (level > 1)
                    {
                        cmdLine.Valve = runnableModule.Valve;
                    }
                    runnableModule.AddCommand(new LineCmd(runnableModule, cmdLine as LineCmdLine, curMeasureHeightCmd));
                }
                else if (cmdLine is ArcCmdLine) // 包含了 CircleCmdLine
                {
                    if (level > 1)
                    {
                        cmdLine.Valve = runnableModule.Valve;
                    }
                    runnableModule.AddCommand(new ArcCmd(runnableModule, cmdLine as ArcCmdLine, curMeasureHeightCmd));
                }
                else if (cmdLine is CircleCmdLine)
                {
                    if (level > 1)
                    {
                        cmdLine.Valve = runnableModule.Valve;
                    }
                    runnableModule.AddCommand(new ArcCmd(runnableModule, cmdLine as CircleCmdLine, curMeasureHeightCmd));
                }
                else if (cmdLine is MoveXyCmdLine)
                {
                    runnableModule.AddCommand(new MoveXyCmd(runnableModule, cmdLine as MoveXyCmdLine));
                }
                else if (cmdLine is MoveAbsXyCmdLine)
                {
                    runnableModule.AddCommand(new MoveAbsXyCmd(runnableModule, cmdLine as MoveAbsXyCmdLine));
                }
                else if (cmdLine is MoveAbsZCmdLine)
                {
                    runnableModule.AddCommand(new MoveAbsZCmd(runnableModule, cmdLine as MoveAbsZCmdLine));
                }
                else if (cmdLine is MoveToLocationCmdLine)
                {
                    MoveToLocationCmdLine moveToLocationCmdLine = cmdLine as MoveToLocationCmdLine;
                    // 检测系统预定义坐标名称是否存在
                    if (runnableModule.CommandsModule.program.UserPositions.Find(x => x.Name == moveToLocationCmdLine.PositionName) == null)
                    {
                        return(new Result(false, cmdLine, "\'" + moveToLocationCmdLine.PositionName + "\' is not defined in system."));
                    }
                    runnableModule.AddCommand(new MoveToLocationCmd(runnableModule, moveToLocationCmdLine));
                }
                else if (cmdLine is NormalTimerCmdLine)
                {
                    // TIMER不能放在pass block里面
                    if (blockState.Type == BlockType.PASS_BLOCK)
                    {
                        return(new Result(false, cmdLine, "TIMER must not be added in pass block"));
                    }
                    runnableModule.AddCommand(new NormalTimerCmd(runnableModule, cmdLine as NormalTimerCmdLine));
                }
                else if (cmdLine is TimerCmdLine)
                {
                    // TIMER必须在pass block里面
                    if (blockState.Type != BlockType.PASS_BLOCK)
                    {
                        return(new Result(false, cmdLine, "TIMER must be added in pass block"));
                    }
                    // TIMER必须是END PASS的前一个命令行,也就是说TIMER必须是分组内的最后一个命令行
                    if (i >= cmdLineList.Count - 1 || !(cmdLineList[i + 1] is EndPassCmdLine))
                    {
                        return(new Result(false, cmdLine, "TIMER must be added before END PASS."));
                    }
                    //// TIMER不能放在最后一个分组中,无意义
                    //if (i + 2 <= cmdLineList.Count - 1 && !(cmdLineList[i + 2] is StartPassCmdLine))
                    //{
                    //    return new Result(false, cmdLine, "TIMER is no need to be added in the last pass block.");
                    //}
                    runnableModule.AddCommand(new TimerCmd(runnableModule, cmdLine as TimerCmdLine));
                }
                else if (cmdLine is StepAndRepeatCmdLine)
                {
                    StepAndRepeatCmdLine stepAndRepeatCmdLine = cmdLine as StepAndRepeatCmdLine;
                    Pattern pattern = program.GetPatternByName(stepAndRepeatCmdLine.PatternName);
                    if (pattern == null)
                    {
                        return(new Result(false, cmdLine, "Pattern '" + stepAndRepeatCmdLine.PatternName + "' is not found."));
                    }
                    if (pattern.HasPassBlocks)
                    {
                        return(new Result(false, cmdLine, "Pattern '" + pattern.Name + "' can not contain pass blocks."));
                    }
                    if (pattern.IsContainItself)
                    {
                        return(new Result(false, cmdLine, "Pattern '" + pattern.Name + "' can not contain itself."));
                    }
                    cmdLineList.InsertRange(i + 1, (cmdLine as StepAndRepeatCmdLine).DoCmdLineList);
                }
                else if (cmdLine is DoCmdLine)
                {
                    DoCmdLine doCmdLine = cmdLine as DoCmdLine;
                    Pattern   pattern   = program.GetPatternByName(doCmdLine.PatternName);
                    if (pattern == null)
                    {
                        return(new Result(false, cmdLine, "Pattern '" + doCmdLine.PatternName + "' is not found."));
                    }
                    //设置父级Pattern,建立Pattern的引用关系
                    pattern.ParentPattern = currPattern;
                    currPattern?.AddChild(pattern);
                    Logger.DEFAULT.Debug(this.GetType().Name, string.Format("{0}'s parent pattern is {1}", pattern.Name, currPattern?.Name));

                    if (pattern.HasPassBlocks)
                    {
                        return(new Result(false, cmdLine, "Pattern '" + pattern.Name + "' can not contain pass blocks."));
                    }
                    if (pattern.Name == commandsModule.Name)
                    {
                        return(new Result(false, cmdLine, "Pattern '" + pattern.Name + "' can not contain itself."));
                    }
                    if (checkExitInAncestorNode(pattern, runnableModule))
                    {
                        return(new Result(false, cmdLine, "Pattern '" + pattern.Name + "' can not contain itself."));
                    }
                    pattern.Valve = doCmdLine.Valve;
                    //倒序
                    if (doCmdLine.Reverse)
                    {
                        pattern = pattern.ReversePattern();
                    }
                    if (level > 0)
                    {
                        if (runnableModule.BoardNo != 0)
                        {
                            doCmdLine.BoardNo = runnableModule.BoardNo;
                        }
                        program.ModuleStructure.AddBoardNo(doCmdLine.BoardNo);
                    }
                    Result result = parse(pattern, doCmdLine.Origin, runnableModule, level + 1, doCmdLine.BoardNo);
                    if (!result.IsOk)
                    {
                        return(result);
                    }
                    // 拼版穴位号逻辑
                    (result.Param as RunnableModule).BoardNo = doCmdLine.BoardNo;
                    runnableModule.AddCommand(new DoCmd(runnableModule, result.Param as RunnableModule, curMeasureHeightCmd));
                }
                else if (cmdLine is DoMultiPassCmdLine)
                {
                    if (blockState.Type != BlockType.LOOP_BLOCK)
                    {
                        return(new Result(false, cmdLine, "DO MULTIPASS must be added in loop block."));
                    }
                    DoMultiPassCmdLine doMultiPassCmdLine = cmdLine as DoMultiPassCmdLine;
                    Pattern            pattern            = program.GetPatternByName(doMultiPassCmdLine.PatternName);
                    //设置父级Pattern,建立Pattern的引用关系
                    pattern.ParentPattern = currPattern;
                    if (pattern == null)
                    {
                        return(new Result(false, cmdLine, "Pattern '" + doMultiPassCmdLine.PatternName + "' is not found."));
                    }
                    currPattern?.AddChild(pattern);
                    Logger.DEFAULT.Debug(this.GetType().Name, string.Format("{0}'s parent pattern is {1}", pattern.Name, currPattern?.Name));

                    if (pattern.IsContainItself)
                    {
                        return(new Result(false, cmdLine, "Pattern '" + pattern.Name + "' can not contain itself."));
                    }
                    pattern.Valve = doMultiPassCmdLine.Valve;
                    if (level > 0)
                    {
                        if (runnableModule.BoardNo != 0)
                        {
                            doMultiPassCmdLine.BoardNo = runnableModule.BoardNo;
                        }
                        program.ModuleStructure.AddBoardNo(doMultiPassCmdLine.BoardNo);
                    }
                    Result result = parse(pattern, doMultiPassCmdLine.Origin, runnableModule, level + 1, doMultiPassCmdLine.BoardNo);
                    if (!result.IsOk)
                    {
                        return(result);
                    }
                    if (!pattern.HasPassBlocks)
                    {
                        return(new Result(false, cmdLine, "Pattern '" + doMultiPassCmdLine.PatternName + "' has no pass blocks."));
                    }
                    // 拼版穴位号逻辑
                    (result.Param as RunnableModule).BoardNo = doMultiPassCmdLine.BoardNo;
                    // 此处先暂时添加在cmdList中,在结尾处,对处于子句中的语句,集中处理。
                    runnableModule.AddCommand(new DoMultipassCmd(runnableModule, result.Param as RunnableModule, curMeasureHeightCmd));
                }
                else if (cmdLine is LoopPassCmdLine)
                {
                    if (blockState.Type != BlockType.NONE)
                    {
                        return(new Result(false, cmdLine, blockState.NoEndDescription));
                    }
                    blockState.Type        = BlockType.LOOP_BLOCK;
                    blockState.BlockCmdObj = new LoopBlockCmd(runnableModule, cmdLine as LoopPassCmdLine);
                }
                else if (cmdLine is NextLoopCmdLine)
                {
                    if (blockState.Type != BlockType.LOOP_BLOCK)
                    {
                        return(new Result(false, cmdLine, "LOOP PASS is not found for the loop block."));
                    }
                    //不同拼版的同一个分组只需要一个计时器,不需要每个拼版都记一次时间
                    LoopBlockCmd loopBlockCmd = blockState.BlockCmdObj as LoopBlockCmd;
                    for (int doMultiPassCmdIndex = 1; doMultiPassCmdIndex < loopBlockCmd.DoMultipassCmdList.Count; doMultiPassCmdIndex++)
                    {
                        RunnableModule tempModule = loopBlockCmd.DoMultipassCmdList[doMultiPassCmdIndex].AssociatedRunnableModule;
                        foreach (Command item in tempModule.CmdList)
                        {
                            if (item is PassBlockCmd)
                            {
                                (item as PassBlockCmd).CmdList.RemoveAll(data => data is TimerCmd);
                            }
                        }
                    }
                    runnableModule.AddCommand(blockState.BlockCmdObj as LoopBlockCmd);
                    blockState.Reset();
                }
                else if (cmdLine is StartPassCmdLine)
                {
                    if (blockState.Type != BlockType.NONE)
                    {
                        return(new Result(false, cmdLine, blockState.NoEndDescription));
                    }
                    // 当前pass block序号必须比上一个pass block序号大
                    if ((cmdLine as StartPassCmdLine).Index <= lastPassblockIndex)
                    {
                        return(new Result(false, cmdLine, "Current pass block index must be bigger than the previous."));
                    }
                    // 相邻pass block之间不允许添加指令
                    if (hasPassBlock && !(cmdLineList[i - 1] is EndPassCmdLine))
                    {
                        return(new Result(false, cmdLine, "No commands is allowed to be added between pass blocks."));
                    }
                    blockState.Type        = BlockType.PASS_BLOCK;
                    blockState.BlockCmdObj = new PassBlockCmd(runnableModule, cmdLine as StartPassCmdLine);
                }
                else if (cmdLine is EndPassCmdLine)
                {
                    if (blockState.Type != BlockType.PASS_BLOCK)
                    {
                        return(new Result(false, cmdLine, "START PASS is not found for the pass block"));
                    }
                    PassBlockCmd passBlockCmd = blockState.BlockCmdObj as PassBlockCmd;
                    runnableModule.AddCommand(passBlockCmd);
                    hasPassBlock       = true;
                    lastPassblockIndex = passBlockCmd.Index;
                    blockState.Reset();
                }
                else if (cmdLine is EndCmdLine)
                {
                    ended = true;
                }
                else if (cmdLine is PurgeCmdLine)
                {
                    if (commandsModule is Pattern)
                    {
                        cmdLine.Valve = (commandsModule as Pattern).Valve;
                    }
                    runnableModule.AddCommand(new PurgeCmd(runnableModule, cmdLine as PurgeCmdLine));
                }
                else if (cmdLine is ChangeSpeedCmdLine)
                {
                    ChangeSpeedCmdLine changeSpeedCmdLine = cmdLine as ChangeSpeedCmdLine;

                    if (svValvespeedDic.ContainsKey(changeSpeedCmdLine.Speed))
                    {
                    }
                    else if (this.program.RuntimeSettings.VavelSpeedDic.ContainsKey(changeSpeedCmdLine.Speed))
                    {
                        double value;
                        this.program.RuntimeSettings.VavelSpeedDic.TryGetValue(changeSpeedCmdLine.Speed, out value);
                        svValvespeedDic.Add(changeSpeedCmdLine.Speed, value);
                    }
                    else
                    {
                        //TODO 将10替换为默认参数
                        svValvespeedDic.Add(changeSpeedCmdLine.Speed, 10);
                    }

                    runnableModule.AddCommand(new ChangeSpeedCmd(runnableModule, changeSpeedCmdLine));

                    //传递程序中的速度重量键值对
                    SvOrGearValveSpeedWeightValve.VavelSpeedWeightDic = FluidProgram.CurrentOrDefault().RuntimeSettings.VavelSpeedDic;
                }

                // 处理包含在子句中的语句:
                if (blockState.Type != BlockType.NONE && runnableModule.CmdList.Count > 0)
                {
                    switch (blockState.Type)
                    {
                    case BlockType.LOOP_BLOCK:
                        if (!(cmdLine is LoopPassCmdLine))
                        {
                            if (!(cmdLine is DoMultiPassCmdLine))
                            {
                                return(new Result(false, cmdLine, "Only DO MULTIPASS can be added in loop block."));
                            }
                            (blockState.BlockCmdObj as LoopBlockCmd).DoMultipassCmdList.Add(runnableModule.GetCommandAtTail() as DoMultipassCmd);
                            runnableModule.RemoveCommandAtTail();
                        }
                        break;

                    case BlockType.PASS_BLOCK:
                        if (!(cmdLine is StartPassCmdLine))
                        {
                            (blockState.BlockCmdObj as PassBlockCmd).CmdList.Add(runnableModule.GetCommandAtTail());
                            runnableModule.RemoveCommandAtTail();
                        }
                        break;
                    }
                }
            }

            //替换Program中的SvValveDic
            this.program.RuntimeSettings.VavelSpeedDic = svValvespeedDic;

            var lastCmdLine = getLastestEnabledCmdLine(cmdLineList, cmdLineList.Count - 1);

            // 检查子句命令是否完成
            if (blockState.Type != BlockType.NONE)
            {
                return(new Result(false, lastCmdLine, blockState.NoEndDescription));
            }
            // 必须以END命令结尾
            if (!ended)
            {
                return(new Result(false, lastCmdLine, "END is not found."));
            }

            return(new Result(true, runnableModule));
        }
コード例 #19
0
ファイル: MainForm.cs プロジェクト: SetCode/Fluid
        public MainForm()
        {
            lngResources.Add(strMachine, "Machine:");
            lngResources.Add(strMotion, "Motion:");
            lngResources.Add(strVision, "Vision:");
            lngResources.Add(strLaser, "Laser:");
            lngResources.Add(strScale, "Scale:");
            lngResources.Add(strHeater, "Heater:");
            lngResources.Add(strPropor1, "Propor1:");
            lngResources.Add(strPropor2, "Propor2:");

            //数据库存在
            this.LoadConfig();

            this.MainNav    = new NavigateMain();
            this.ProgramNav = new NavigateProgram();
            this.RunNav     = new NavigateRun();

            this.SetupAlarm();
            //数据库线程启动
            this.SetupDataBase();
            //setup machine
            if (!Machine.Instance.SetupAll())
            {
                return;
            }
            //为了同步气压而增加的事件
            Machine.Instance.Valve1.Proportioner.ChangeProgramAirEvent += FluidProgram.CurrentOrDefault().ChangeAirValue;

            InitializeComponent();
            Ins = this;

            this.WindowState  = FormWindowState.Maximized;
            this.Load        += FormMain_Load;
            this.FormClosing += FormMain_FormClosing;

            this.ProgramCtl      = new ProgramControl();
            this.ProgramCtl.Dock = DockStyle.Fill;
            this.ProgramCtl.SetOwner(this);

            //this.CameraCtl = new CameraControl();
            //this.CameraCtl.Dock = DockStyle.Fill;

            this.ctlCurrPos      = new PositionMainControl();
            this.ctlCurrPos.Dock = DockStyle.Fill;

            this.RunInfoCtl       = new RunInfoControl();
            this.RunInfoCtl.Dock  = DockStyle.Fill;
            this.RunInfoCtl2      = new RunInfoControl2();
            this.RunInfoCtl2.Dock = DockStyle.Fill;

            this.ManualCtl      = new ManualControl();
            this.ManualCtl.Dock = DockStyle.Fill;

            this.canvasControll = new CanvasControll();
            this.canvasControll.SetControlMode(true);
            this.canvasControll.Dock = DockStyle.Fill;

            this.SetupPages();
            this.SetupReceivers();
            this.SetupDrawing();

            ControlUpatingMgr.Add(this);
            Machine.Instance.FSM.StateChanged  += FSM_StateChanged;
            Machine.Instance.LightTower.Opened += LightTower_Opened;

            this.transAlarmForm.SetOwner(this);
            this.createPath();
            this.timer          = new System.Windows.Forms.Timer();
            this.timer.Interval = 100;
            this.timer.Tick    += Timer_Tick;
            this.timer.Start();
            this.ReadLanguageResources();
        }
コード例 #20
0
        /// <summary>
        /// 计算在手动打线模式下,重量线需要的各种参数
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="lineParam"></param>
        /// <param name="weight"></param>
        /// <param name="accStartPoint"></param>
        /// <param name="decelEndPoint"></param>
        /// <param name="runSpeed"></param>
        /// <param name="linePoints"></param>
        /// <param name="fluidIntervalSec"></param>
        private void GetManualWtLineParam(PointD start, PointD end, LineParam lineParam, double weight, out PointD accStartPoint, out PointD decelEndPoint, out double runSpeed, out PointD[] linePoints, out double fluidIntervalSec)
        {
            double accDistance = 0, decelDistance = 0;
            double lineDistance = Math.Sqrt(Math.Pow(end.X - start.X, 2) + Math.Pow(end.Y - start.Y, 2));

            // 计算点胶数量
            int shots = (int)((decimal)weight / (decimal)FluidProgram.CurrentOrDefault().RuntimeSettings.SingleDropWeight);

            // 计算时间 (需要将微秒单位转换成秒)
            double totalTime = Machine.Instance.Valve1.SpraySec * shots;
            // 计算速度
            double wtSpeed = lineDistance / totalTime;

            if (lineParam.WtCtrlSpeedValueType != LineParam.ValueType.COMPUTE)
            {
                wtSpeed = lineParam.WtCtrlSpeed > wtSpeed ? wtSpeed : lineParam.WtCtrlSpeed;
            }

            // 运动速度不能超过设定的最大速度
            wtSpeed = wtSpeed > FluidProgram.CurrentOrDefault().MotionSettings.WeightMaxVel ? FluidProgram.CurrentOrDefault().MotionSettings.WeightMaxVel : wtSpeed;
            Log.Dprint(string.Format("lineDistance={0}, weight={1} totalTime={2}, param.WtCtrlSpeedValueType={3}, param.WtCtrlSpeed={4}, wtSpeed={5}",
                                     lineDistance, weight, totalTime, lineParam.WtCtrlSpeedValueType, lineParam.WtCtrlSpeed, wtSpeed));

            // 计算加速区间距离
            if (lineParam.AccelDistanceValueType == LineParam.ValueType.COMPUTE)
            {
                accDistance = MathUtils.CalculateDistance(0, wtSpeed, Machine.Instance.Robot.AxisX.ConvertAcc2Mm(FluidProgram.CurrentOrDefault().MotionSettings.WeightAcc));
                Log.Dprint("Acc Distance COMPUTE wtSpeed=" + wtSpeed + ", WeightAcc=" + FluidProgram.CurrentOrDefault().MotionSettings.WeightAcc
                           + ", distance=" + accDistance);
            }
            else
            {
                accDistance = lineParam.AccelDistance;
            }

            // 计算减速区间距离
            if (lineParam.DecelDistanceValueType == LineParam.ValueType.COMPUTE)
            {
                decelDistance = MathUtils.CalculateDistance(wtSpeed, 0, -Machine.Instance.Robot.AxisX.ConvertAcc2Mm(FluidProgram.CurrentOrDefault().MotionSettings.WeightAcc));
                Log.Dprint("Decel Distance COMPUTE wtSpeed=" + wtSpeed + ", WeightAcc=" + FluidProgram.CurrentOrDefault().MotionSettings.WeightAcc
                           + ", distance=" + decelDistance);
            }
            else
            {
                decelDistance = lineParam.DecelDistance;
            }
            // 计算加速区间起始位置和减速区间结束位置
            PointD accStart = calAccStartPosition(start, end, accDistance);
            PointD decelEnd = calDecelEndPosition(start, end, decelDistance);

            // 计算点胶位置
            PointD[] points = calFixedTotalOfDots(start, end, shots);

            //基于时间控制
            totalTime = lineDistance / wtSpeed;
            double intervalSec = totalTime / (shots - 1);
            double dispenseSec = Machine.Instance.Valve1.SpraySec;

            if (intervalSec < dispenseSec)
            {
                intervalSec = dispenseSec;
                points      = calFixedTotalOfDots(start, end, (int)(totalTime / intervalSec) + 1);
            }

            accStartPoint    = accStart;
            decelEndPoint    = decelEnd;
            runSpeed         = wtSpeed;
            linePoints       = points;
            fluidIntervalSec = intervalSec;
        }