Exemplo n.º 1
0
        public bool Init(string modelName)
        {
            MyRun.model = MyRun.ReadModelJS(modelName);
            int Level0 = 0;

            foreach (var step in MyRun.model.ModelSteps.Steps)
            {
                TreeNode node = new TreeNode(step.Type + ":" + step.Name);
                switch (step.Level)
                {
                case 0:
                    tvwSteps.Nodes.Add(node);
                    Level0 = step.Index;
                    break;

                case 1:
                    tvwSteps.Nodes[step.ParentIndex].Nodes.Add(node);
                    break;

                case 2:
                    tvwSteps.Nodes[Level0].Nodes[step.ParentIndex].Nodes.Add(node);
                    break;
                }
            }
            tvwSteps.ExpandAll();
            grp常用检测流程.Enabled = true;
            grp模板检测流程.Enabled = true;
            grp编辑检测流程.Enabled = true;
            btn添加相机.Enabled   = true;
            btn保存模板.Enabled   = true;
            lab模板名称提示.Text    = "";
            return(true);
        }
Exemplo n.º 2
0
        private void btn保存模板_Click(object sender, EventArgs e)
        {
            string     modelName  = txt模板名称.Text;
            ModelSteps modelSteps = new ModelSteps();

            SaveModelSteps(ref modelSteps, -1, tvwSteps.Nodes);

            ProductModelStep.AddModel(modelName, modelSteps, ref MyRun.model);

            //这里判断是否已经有同名模板存在
            MyRun.GetProductModelNameList(out List <string> modelNameList);
            if (modelNameList.Contains(modelName))
            {
                if (MessageBox.Show("模板" + modelName + "已存在\n是否覆盖", "存在同名模板", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    MyRun.WriteModelJS(MyRun.model);
                    MyRun.ModelNumber++;
                    MyRun.CreateModelWindow.Close();
                }
            }
            else
            {
                if (MessageBox.Show("是否保存模板", "保存模板", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    MyRun.WriteModelJS(MyRun.model);
                    MyRun.ModelNumber++;
                    MyRun.CreateModelWindow.Close();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 重连相机
        /// 相机在连接视觉模块时就已经进行连接
        /// </summary>
        /// <returns></returns>
        public static bool ReconnectCam()
        {
            bool ret = MyRun.ReconnectCam();

            ReconnectCamEvent(null, null);
            return(ret);
        }
 private void btn创建模板_Click(object sender, EventArgs e)
 {
     matchingfun = MyRun.GetMatchingFun(cmb定位模板类型.Text);
     if (halconFun.m_hoRegion == null)
     {
         MessageBox.Show("请先新建区域");
         return;
     }
     matchingfun.Create(halconFun.m_hoImage, halconFun.m_hoRegion);
     halconFun.ShowRegion(matchingfun.outContour, Color.Red);
 }
Exemplo n.º 5
0
 private void btn获取图片_Click(object sender, EventArgs e)
 {
     if (MyRun.TriggerCamera(camName, out HalconDotNet.HObject ho_Image))
     {
         halconFun.ShowImage(ho_Image);
         ho_Image.Dispose();
     }
     else
     {
         MessageBox.Show(MyRun.StrErrorMsg);
     }
 }
        public bool Init(string matchName)
        {
            Matching matching = MyRun.model.matchings.Find(x => x.Name == matchName);

            txt定位模板名称.Text = matchName;
            cmb定位模板类型.Text = matching.Type;
            matchingfun    = MyRun.GetMatchingFun(matching.Type);

            matchingfun.Read(MyRun.appPath + "\\model\\" + MyRun.model.modelName, matching);

            MyRun.nowModel.CamName   = matching.CamName;
            MyRun.nowModel.MatchName = matchName;
            RelateCam();
            return(true);
        }
Exemplo n.º 7
0
        private void btn获取相机图片_Click(object sender, EventArgs e)
        {
            MyRun.TriggerCamera(MyRun.nowModel.CamName, out HalconDotNet.HObject ho_Image);

            if (ho_Image is null)
            {
                MessageBox.Show("图片获取失败");
                return;
            }
            if (!matchName.Equals("无模板定位"))
            {
                matchingfun.Find(ho_Image, out halconFun.m_hoImage);
            }
            halconFun.ShowImage(ho_Image);
            ParameterSetControl.SetHalconImage(ho_Image);
            ho_Image.Dispose();
        }
 private void btn获取相机图片_Click(object sender, EventArgs e)
 {
     if (MyRun.TriggerCamera(MyRun.nowModel.CamName, out HalconDotNet.HObject ho_Image))
     {
         halconFun.ShowImage(ho_Image);
         ho_Image.Dispose();
         if (matchingfun.inRegion != null)
         {
             halconFun.SetRegion(matchingfun.inRegion);
         }
         halconFun.SetRegionFillMode(HalconFun.RegionFillMode.Margin);
         halconFun.ShowRegion(Color.Red);
     }
     else
     {
         MessageBox.Show(MyRun.StrErrorMsg);
     }
 }
Exemplo n.º 9
0
        private void RelateMatch()
        {
            if (MyRun.nowModel.MatchName is null)
            {
                return;
            }
            if (MyRun.nowModel.MatchName.Equals("无模板定位"))
            {
                lab当前匹配模板.Text = "当前匹配模板:" + MyRun.nowModel.MatchName;
                matchName      = MyRun.nowModel.MatchName;
            }
            else if (matchName != MyRun.nowModel.MatchName)
            {
                Matching nowMatching = MyRun.model.matchings.Find(x => x.Name == MyRun.nowModel.MatchName);
                matchingfun = MyRun.GetMatchingFun(nowMatching.Type);
                matchingfun.Read(MyRun.appPath + "\\model\\" + MyRun.model.modelName, nowMatching);

                lab当前匹配模板.Text = "当前匹配模板:" + MyRun.nowModel.MatchName;
                matchName      = MyRun.nowModel.MatchName;
            }
        }
Exemplo n.º 10
0
 private void chk实时拍照显示_CheckedChanged(object sender, EventArgs e)
 {
     if (chk实时拍照显示.Checked)
     {
         new Thread(() =>
         {
             while (chk实时拍照显示.Checked)
             {
                 if (MyRun.TriggerCamera(camName, out HalconDotNet.HObject ho_Image))
                 {
                     halconFun.ShowImage(ho_Image);
                     ho_Image.Dispose();
                 }
                 else
                 {
                     MessageBox.Show(MyRun.StrErrorMsg);
                     break;
                 }
             }
         })
         {
             IsBackground = true
         }.Start();
Exemplo n.º 11
0
        private void btn模板名确认_Click(object sender, EventArgs e)
        {
            string modelName = txt模板名称.Text;

            //这里判断是否已经有同名模板存在
            MyRun.GetProductModelNameList(out List <string> modelNameList);
            if (modelNameList.Contains(modelName))
            {
                lab模板名称提示.Text = "模板" + modelName + "已存在";

                Init(modelName);
            }
            else
            {
                Directory.CreateDirectory(MyRun.appPath + "\\model\\" + modelName);
            }
            MyRun.model.modelName = modelName;

            grp常用检测流程.Enabled = true;
            grp模板检测流程.Enabled = true;
            grp编辑检测流程.Enabled = true;
            btn添加相机.Enabled   = true;
            btn保存模板.Enabled   = true;
        }
Exemplo n.º 12
0
 public static bool GetMatchingTypeList(out List <string> matchTypes)
 {
     return(MyRun.GetMatchingTypeList(out matchTypes));
 }
Exemplo n.º 13
0
 /// <summary>
 /// 获取检测功能参数设置的控件
 /// </summary>
 /// <param name="TestItemType"></param>
 /// <param name="ParameterSetControl"></param>
 /// <returns></returns>
 public static bool GetParameterSettingControl(string TestItemType, out I检测参数设置 ParameterSetControl)
 {
     return(MyRun.GetParameterSettingControl(TestItemType, out ParameterSetControl));
 }
Exemplo n.º 14
0
 /// <summary>
 /// 获取检测功能名队列
 /// </summary>
 /// <param name="TestItemTypes"></param>
 /// <returns></returns>
 public static bool GetTestItemTypeList(out List <string> TestItemTypes)
 {
     return(MyRun.GetTestItemTypeList(out TestItemTypes));
 }
Exemplo n.º 15
0
 /// <summary>
 /// 设置相机曝光参数
 /// </summary>
 /// <param name="camName"></param>
 /// <param name="exposureTime"></param>
 /// <returns></returns>
 public static bool SetCameraExposureTime(string camName, float exposureTime)
 {
     return(MyRun.SetCameraExposureTime(camName, exposureTime));
 }
Exemplo n.º 16
0
 /// <summary>
 /// 获取相机曝光参数
 /// </summary>
 /// <param name="camName"></param>
 /// <param name="exposureTime"></param>
 /// <param name="minLimit"></param>
 /// <param name="maxLimit"></param>
 /// <returns></returns>
 public static bool GetCameraExposureTime(string camName, out float exposureTime, out float minLimit, out float maxLimit)
 {
     return(MyRun.GetCameraExposureTime(camName, out exposureTime, out minLimit, out maxLimit));
 }
Exemplo n.º 17
0
 /// <summary>
 /// 获取相机名的队列
 /// </summary>
 /// <param name="CamNames"></param>
 /// <returns></returns>
 public static bool GetCameraNameList(out List <string> CamNames)
 {
     return(MyRun.GetCameraNameList(out CamNames));
 }