Example #1
0
        /// <summary>
        /// 保存产品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnSave_Click(object sender, EventArgs e)
        {
            Form_Wait.ShowForm();
            await Task.Run(new Action(() =>
            {
                //需要保存当前产品的相关参数
                if (_operation != null)
                {
                    JFDLAFBoxRecipe jFDLAFBoxRecipe = JFHubCenter.Instance.RecipeManager.GetRecipe("Box", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID")) as JFDLAFBoxRecipe;
                    jFDLAFBoxRecipe.MagezineBox = _operation.MagezineBox;
                    jFDLAFBoxRecipe.MgzIdx = _operation.MgzIdx;
                    jFDLAFBoxRecipe.SaveParamsToCfg();
                    _operation.SaveParamsToCfg();

                    JFHubCenter.Instance.RecipeManager.RemoveRecipe("Product", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"));
                    JFHubCenter.Instance.RecipeManager.RemoveRecipe("Box", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"));

                    JFHubCenter.Instance.RecipeManager.AddRecipe(_operation.Categoty, _operation.ID, _operation as IJFRecipe);
                    JFHubCenter.Instance.RecipeManager.AddRecipe("Box", _operation.ID, jFDLAFBoxRecipe as IJFRecipe);
                }

                JFHubCenter.Instance.RecipeManager.Save();
                if (_operation != null)
                {
                    if (_operation.MgzIdx == -1)
                    {
                        HTLog.Error("注意:当前产品未选择料盒型号,开始流程需要选择料盒型号.");
                        return;
                    }
                }
            }));

            Form_Wait.CloseForm();
        }
Example #2
0
        /// <summary>
        /// 加载产品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnLoadProduct_Click(object sender, EventArgs e)
        {
            string Errstring = "";

            if (lbxProductCategory.SelectedIndex == -1)
            {
                return;
            }
            btnLoadProduct.Enabled = false;

            string pdt = null;

            pdt = lbxProductCategory.SelectedValue.ToString();

            btnLoadProduct.Enabled = true;
            Form_Wait.ShowForm();
            await Task.Run(new Action(() =>
            {
                try
                {
                    //需要加载当前产品相关的参数
                    _operation = JFHubCenter.Instance.RecipeManager.GetRecipe("Product", pdt) as JFDLAFProductRecipe;
                    if (_operation == null)
                    {
                        HTUi.TipError("Recipe Manager中不存在配方:" + pdt);
                        return;
                    }

                    if (Errstring == "")
                    {
                        HTLog.Info("加载产品完成.");
                        HTUi.TipHint("加载产品完成");
                        if (_operation.MgzIdx == -1)
                        {
                            HTLog.Error("注意:当前产品未选择料盒型号,开始流程需要选择料盒型号.");
                        }
                    }
                    else
                    {
                        HTLog.Error("加载产品失败!!!" + Errstring);
                        HTUi.TipError("加载产品失败");
                        HTUi.PopWarn("产品加载失败\n" + Errstring);
                    }
                }
                catch (Exception EXP)
                {
                    HTLog.Error(String.Format("{0}加载新产品失败\n", EXP.ToString()));
                    HTUi.TipError("加载新产品失败");
                }
            }));

            if (_operation != null)
            {
                SetupUI();
            }
            JFHubCenter.Instance.SystemCfg.SetItemValue("CurrentID", pdt);
            JFHubCenter.Instance.SystemCfg.Save();
            Form_Wait.CloseForm();
        }
Example #3
0
 /// <summary>
 /// 指定一半进度条的时间
 /// </summary>
 /// <param name="helfSecond"></param>
 public static void ShowForm(int helfSecond)
 {
     if (Instance == null || Instance.IsDisposed)
     {
         Instance         = new Form_Wait();
         Instance.TopMost = true;
         int SH = Screen.PrimaryScreen.Bounds.Height;
         int SW = Screen.PrimaryScreen.Bounds.Width;
         Instance.HelfSecond        = helfSecond;
         Instance.progressBar1.Step = Instance.progressBar1.Maximum / (Instance.HelfSecond * 1000 / Instance.timer1.Interval);
         //App.mainWin.Enabled = false;
         Instance.Show();
         Instance.Location = new Point((SW - Instance.Size.Width) / 2, (SH - Instance.Size.Height) / 2);
     }
     else
     {
         Instance.Activate();
     }
 }
Example #4
0
        private async void btnSaveCalibModel2D_Click(object sender, EventArgs e)
        {
            if (!this.mTmpFrm.tmpResult.createTmpOK)
            {
                HTUi.PopError("创建标定模板失败!");
                return;
            }
            Form_Wait.ShowForm();
            bool result = await Task.Run(() =>
            {
                try
                {
                    this.aoiModels = new Model();
                    this.aoiModels.Dispose();
                    this.aoiModels.showContour = this.mTmpFrm.tmpResult.showContour.CopyObj(1, -1);
                    this.aoiModels.defRows     = this.mTmpFrm.tmpResult.defRows;
                    this.aoiModels.defCols     = this.mTmpFrm.tmpResult.defCols;
                    this.aoiModels.modelType   = this.mTmpFrm.tmpResult.modelType;
                    this.aoiModels.modelID     = Vision.CopyModel(this.mTmpFrm.tmpResult.modelID, this.mTmpFrm.tmpResult.modelType);
                    this.aoiModels.scoreThresh = this.mTmpFrm.mte_TmpPrmValues.Score;
                    this.aoiModels.angleStart  = this.mTmpFrm.mte_TmpPrmValues.AngleStart;
                    this.aoiModels.angleExtent = this.mTmpFrm.mte_TmpPrmValues.AngleExtent;
                    //保存至硬盘
                    string folderPath             = _station.SystemUV2XYDir + "\\Camera_" + _station.SelectedIndex;
                    _station.CalibrUV2XYModelPath = folderPath;
                    if (!this.aoiModels.WriteModel(folderPath))
                    {
                        HTLog.Error("保存标定模板失败!");
                        HTUi.PopError("保存标定模板失败!");
                        return(false);
                    }

                    string errMsg = "";
                    Pos_Uv2Xy     = new HTuple();
                    double xUV2xy = 0, yUV2xy = 0, zUV2xy = 0;

                    if (!_station.GetAxisPosition(_station.AxisXYZ[0], out xUV2xy, out errMsg))
                    {
                        HTLog.Error(errMsg + ":保存获取X轴反馈坐标失败!");
                        HTUi.PopError(errMsg + ":保存获取X轴反馈坐标失败!");
                        return(false);
                    }

                    if (!_station.GetAxisPosition(_station.AxisXYZ[1], out yUV2xy, out errMsg))
                    {
                        HTLog.Error(errMsg + ":保存获取Y轴反馈坐标失败!");
                        HTUi.PopError(errMsg + ":保存获取Y轴反馈坐标失败!");
                        return(false);
                    }

                    if (!_station.GetAxisPosition(_station.AxisXYZ[2], out zUV2xy, out errMsg))
                    {
                        HTLog.Error(errMsg + ":保存获取Z轴反馈坐标失败!");
                        HTUi.PopError(errMsg + ":保存获取Z轴反馈坐标失败!");
                        return(false);
                    }

                    _station.operation.YUv2xy = yUV2xy;
                    _station.operation.XUv2xy = xUV2xy;
                    _station.operation.ZUv2xy = zUV2xy;

                    Pos_Uv2Xy.Append(_station.operation.XUv2xy);
                    Pos_Uv2Xy.Append(_station.operation.YUv2xy);
                    Pos_Uv2Xy.Append(_station.operation.ZUv2xy);
                    HOperatorSet.WriteTuple(Pos_Uv2Xy, folderPath + "\\Pos_Uv2Xy.tup");
                    HTUi.TipHint("保存标定模板成功!");
                    HTLog.Info("保存标定模板成功!");
                    return(true);
                }
                catch (Exception ex)
                {
                    HTLog.Error(ex.ToString());
                    HTUi.PopError(ex.ToString());

                    return(false);
                }
            });

            Form_Wait.CloseForm();
            if (!result)
            {
                HTLog.Error("保存标定模板失败!");
                HTUi.PopError("保存标定模板失败!");
                return;
            }
            HTUi.TipHint("保存标定模板成功!");
            HTLog.Info("保存标定模板成功!");
        }