Ejemplo n.º 1
0
 //加载
 public void LoadXML(string xmlPath)
 {
     /*
      * await Task.Run(() =>
      * {
      *  while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff)
      *  {
      *      Thread.Sleep(500);
      *  }
      * });
      */
     try
     {
         XElement root = XElement.Load(xmlPath);
         XElement epoxyParameterNode = root.Element("EpoxyParameter");
         if (epoxyParameterNode == null)
         {
             return;
         }
         XMLHelper.ReadParameters(epoxyParameterNode, epoxyParameter);
         (addPoxyRegions as AddPoxyRegions).LoadReferenceData();
         XElement epoxyModelVerifyParameterNode = root.Element("EpoxyModelVerifyParameter");
         XMLHelper.ReadParameters(epoxyModelVerifyParameterNode, epoxyModelVerifyParameter);
         XMLHelper.ReadRegion(root, epoxyUserRegions, "EpoxyUserRegions", epoxyParameter.DieImageRowOffset, epoxyParameter.DieImageColumnOffset, true);
         XMLHelper.ReadRegion(root, epoxyReferceUserRegions, "EpoxyReferceUserRegions", epoxyParameter.DieImageRowOffset, epoxyParameter.DieImageColumnOffset, false);
         (addPoxyRegions as AddPoxyRegions).Initial();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 2
0
        public override void LoadXML(string xmlPath)//async
        {
            /*
             * await Task.Run(() =>
             * {
             *  while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff)
             *  {
             *      Thread.Sleep(500);
             *  }
             * });
             */

            try
            {
                XElement root = XElement.Load(xmlPath);
                XElement goldenModelParameterrNode = root.Element("GoldenModelParameter");
                XElement frameLocateParameterNode  = root.Element("FrameLocateParameter");
                if (goldenModelParameterrNode == null)
                {
                    return;
                }
                XMLHelper.ReadParameters(goldenModelParameterrNode, goldenModelParameter);
                (cutOutDieFrame as CutOutDieFrame).LoadReferenceData();
                XMLHelper.ReadParameters(frameLocateParameterNode, frameLocateInspectParameter);

                //XMLHelper.ReadRegion(root, matchUserRegions, "Match_Region", goldenModelParameter.DieImageRowOffset, goldenModelParameter.DieImageColumnOffset);
                //12-05
                XElement matchRegionGroupsNode = root.Element("MatchRegionGroup");
                if (matchRegionGroupsNode == null)
                {
                    return;
                }
                MatchRegionsGroups.Clear();
                foreach (var groupNode in matchRegionGroupsNode.Elements("MatchRegion"))
                {
                    MatchRegionsGroup group = new MatchRegionsGroup();
                    XMLHelper.ReadRegion(groupNode, group.MatchUserRegions, "Region", goldenModelParameter.DieImageRowOffset, goldenModelParameter.DieImageColumnOffset);
                    MatchRegionsGroups.Add(group);
                    group.Index = MatchRegionsGroups.Count;
                }
                (addMatchRegionFrame as AddMatchRegionFrame).GroupsCount = MatchRegionsGroups.Count;

                //框架区域
                XMLHelper.ReadRegion(root, FrameUserRegions, "Frame_Region", goldenModelParameter.DieImageRowOffset, goldenModelParameter.DieImageColumnOffset);

                (cutOutDieFrame as CutOutDieFrame).Initial();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        public override void LoadXML(string xmlPath)
        {
            /*
             * await Task.Run(() =>
             * {
             *  while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff)
             *  {
             *      Thread.Sleep(500);
             *  }
             * });
             */
            try
            {
                XElement root = XElement.Load(xmlPath);
                XElement goldenModelParameterrNode       = root.Element("GoldenModelParameter");
                XElement goldenModelInspectParameterNode = root.Element("GoldenModelInspectParameter");
                if (goldenModelParameterrNode == null)
                {
                    return;
                }
                XMLHelper.ReadParameters(goldenModelInspectParameterNode, goldenModelInspectParameter);
                XMLHelper.ReadParameters(goldenModelParameterrNode, goldenModelParameter);

                (cutOutDie as CutOutDie).LoadReferenceData();

                XMLHelper.ReadRegion(root, matchUserRegions, "Match_Region", goldenModelParameter.DieImageRowOffset, goldenModelParameter.DieImageColumnOffset);
                XMLHelper.ReadRegion(root, inspectUserRegions, "Inspect_Region", goldenModelParameter.DieImageRowOffset, goldenModelParameter.DieImageColumnOffset);
                XMLHelper.ReadRegion(root, rejectUserRegions, "Reject_Region", goldenModelParameter.DieImageRowOffset, goldenModelParameter.DieImageColumnOffset);
                XMLHelper.ReadRegion(root, subUserRegions, "Sub_Regions", goldenModelParameter.DieImageRowOffset, goldenModelParameter.DieImageColumnOffset, true);

                //1211
                foreach (var item in rejectUserRegions)
                {
                    if (item.RegionType == RegionType.Region)
                    {
                        HOperatorSet.ReadRegion(out HObject rejectRegion, $"{ ProductDirctory}\\{ item.RegionPath}");
                        item.CalculateRegion = rejectRegion;
                        HOperatorSet.MoveRegion(rejectRegion, out HObject _rejectRegion, -goldenModelParameter.DieImageRowOffset, -goldenModelParameter.DieImageColumnOffset);
                        item.DisplayRegion = _rejectRegion;
                    }
                }

                (goldenModelInspectVerify as GoldenModelInspectVerify).AddBondOnItem();
                (createGoldenModel as CreateGoldenModel).AddBondOnItem();
                (cutOutDie as CutOutDie).Initial();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "模板保存报错!");
            }
        }
Ejemplo n.º 4
0
        //加载
        public void LoadXML(string xmlPath)
        {
            /*
             * await Task.Run(() =>
             * {
             *  while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff)
             *  {
             *      Thread.Sleep(500);
             *  }
             * });
             */
            try
            {
                XElement root = XElement.Load(xmlPath);
                XElement bond2ModelParameterNode = root.Element("Bond2ModelParameter");
                if (bond2ModelParameterNode == null)
                {
                    return;
                }
                XElement bond2ModelNode = root.Element("Bond2Models");
                if (bond2ModelNode == null)
                {
                    return;
                }
                XMLHelper.ReadParameters(bond2ModelParameterNode, bond2ModelParameter);
                (createBond2Model as CreateBond2Model).LoadReferenceData();

                bond2Models.Clear();
                bondWireRegionGroups.Clear();
                Groups.Clear();
                XElement bondWireParameterNode = root.Element("BondWireParameter");
                XMLHelper.ReadParameters(bondWireParameterNode, bondWireParameter);

                XElement bondAutoRegionsParameterNode = root.Element("BondAutoRegionsParameter"); //自动
                XMLHelper.ReadParameters(bondAutoRegionsParameterNode, bondAutoRegionsParameter); //自动

                //bond2Models.Clear();放前面
                foreach (var modelNode in bond2ModelNode.Elements("Model"))
                {
                    Bond2Model model = new Bond2Model();
                    model.ModelIdPath          = modelNode.Attribute("ModelIDPath")?.Value;
                    model.Index                = (int.Parse)(modelNode.Attribute("Index")?.Value);
                    model.RotatedImagePath     = modelNode.Element("RotatedImagePath")?.Value;
                    model.Bond2UserRegion      = UserRegion.FromXElement(modelNode.Element("Bond2ModelRegion"));
                    model.RotateLineUserRegion = UserRegion.FromXElement(modelNode.Element("RotateLineRegion"));
                    model.Bond2UserRegionDiff  = UserRegion.FromXElement(modelNode.Element("Bond2ModelRegionDiff"));//
                    XMLHelper.ReadRegion(modelNode, model.RefineUserRegions, "RefineRegions");
                    bond2Models.Add(model);
                    model.Index = bond2Models.Count;
                }
                (createBond2Model as CreateBond2Model).ModelsCount = bond2Models.Count;

                // 自动焊点区域部分
                XElement GenGroupsNode = root.Element("GenGroups");
                if (GenGroupsNode != null)
                {
                    foreach (var groupNode in GenGroupsNode.Elements("GenGroup"))
                    {
                        BondMatchAutoRegionGroup group = new BondMatchAutoRegionGroup();
                        group.Bond2UserRegion = UserRegion.FromXElement(groupNode.Element("Bond2Region"), false, bond2ModelParameter.DieImageRowOffset, bond2ModelParameter.DieImageColumnOffset);
                        group.WireUserRegion  = UserRegion.FromXElement(groupNode.Element("WireRegion"), false, bond2ModelParameter.DieImageRowOffset, bond2ModelParameter.DieImageColumnOffset);
                        //XMLHelper.ReadParameters(groupNode, group.Parameter);
                        Groups.Add(group);
                        group.Index          = Groups.Count;
                        group.Bond2_BallNums = int.Parse(groupNode.Attribute("Bond2Numbers")?.Value);
                    }
                }

                XElement bondWireGroupNode = root.Element("BondWireGroups");
                if (bondWireGroupNode == null)
                {
                    return;
                }

                foreach (var groupNode in bondWireGroupNode.Elements("BondWireGroup"))
                {
                    BondWireRegionGroup group = new BondWireRegionGroup();
                    group.Bond2UserRegion = UserRegion.FromXElement(groupNode.Element("Bond2Region"), false, bond2ModelParameter.DieImageRowOffset, bond2ModelParameter.DieImageColumnOffset);
                    group.WireUserRegion  = UserRegion.FromXElement(groupNode.Element("WireRegion"), false, bond2ModelParameter.DieImageRowOffset, bond2ModelParameter.DieImageColumnOffset);                                                                                                                                                                                         //XMLHelper.ReadParameters(groupNode, group.Parameter);
                    bondWireRegionGroups.Add(group);
                    group.Index          = bondWireRegionGroups.Count;
                    group.Bond2_BallNums = int.Parse(groupNode.Attribute("Bond2Numbers")?.Value);
                }

                (bondMatchAutoRegions as BondMatchAutoRegions).GroupsCount = Groups.Count;
                (addBondMatchRegions as AddBondMatchRegions).GroupsCount   = bondWireRegionGroups.Count;

                (createBond2Model as CreateBond2Model).Initial();

                //加载焊点检测区域及其参数
                XMLHelper.ReadRegion(root, BondVerifyUserRegions, "BondVerifyUserRegions", bond2ModelParameter.DieImageRowOffset, bond2ModelParameter.DieImageColumnOffset, false, false, false, false, true);
                //
                XElement BondVerifyModelParaNode = root.Element("BondVerifyModelPara");
                XMLHelper.ReadParameters(BondVerifyModelParaNode, BondVerifyModelPara);
                // 兼容老产品打开参数不保留 2021-0105 by wj
                if (BondVerifyUserRegions.Count() != 0)
                {
                    //更新PadUserRegions
                    for (int i = 0; i < BondVerifyUserRegions.Count; i++)
                    {
                        //检测区域内通道值设置
                        if (BondVerifyUserRegions.ElementAt(i).ChannelNames.Count() == 0)
                        {
                            BondVerifyUserRegions.ElementAt(i).ChannelNames = bond2ModelParameter.ChannelNames;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 5
0
        //加载
        public void LoadXML(string xmlPath)
        {
            // 1216 lw 此处保存产品会出错

            /*await Task.Run(() =>
             * {
             *  while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff)
             *  {
             *      Thread.Sleep(500);
             *  }
             * });*/

            IsLoadXML = true;

            try
            {
                XElement root = XElement.Load(xmlPath);
                XElement wireParameterNode = root.Element("WireParameter");
                if (wireParameterNode == null)
                {
                    return;
                }
                XMLHelper.ReadParameters(wireParameterNode, wireParameter);

                //从金线自动生成区域加载参考信息
                (wireAddAutoRegion as WireAddAutoRegion).LoadReferenceData();

                //-----------------------------------------------------------------------------------------------------------------------------
                XElement wireRegionsGroupNode = root.Element("WireRegionsGroup");
                if (wireRegionsGroupNode == null)
                {
                    return;
                }

                wireRegionsGroup.Clear();
                foreach (var groupNode in wireRegionsGroupNode.Elements("Group"))
                {
                    WireRegionsGroup group = new WireRegionsGroup();
                    group.BondOnICUserRegions    = UserRegion.FromXElement(groupNode.Element("BondOnICUserRegions"), false, wireParameter.DieImageRowOffset, wireParameter.DieImageColumnOffset, false, false, false);
                    group.BondOnFrameUserRegions = UserRegion.FromXElement(groupNode.Element("BondOnFrameUserRegions"), false, wireParameter.DieImageRowOffset, wireParameter.DieImageColumnOffset, false, false, false);
                    //group.RefLineUserRegions = UserRegion.FromXElement(groupNode.Element("RefLineUserRegions"), false, wireParameter.DieImageRowOffset, wireParameter.DieImageColumnOffset);
                    XMLHelper.ReadRegion(groupNode, group.LineUserRegions, "LineUserRegions", wireParameter.DieImageRowOffset, wireParameter.DieImageColumnOffset, false, true, false, false);

                    //1212 金线检测区域的通道值设置-生成线
                    for (int i = 0; i < group.LineUserRegions.Count(); i++)
                    {
                        if (group.LineUserRegions.ElementAt(i).ChannelNames.Count() == 0)
                        {
                            group.LineUserRegions.ElementAt(i).ChannelNames = wireParameter.ChannelNames; // currentChannelName
                            int tmp_ind;
                            tmp_ind = group.LineUserRegions.ElementAt(i).ImageIndex;
                        }
                    }
                    wireRegionsGroup.Add(group);
                    group.Index = wireRegionsGroup.Count;
                }
                (wireAddRegion as WireAddRegion).GroupsCount = wireRegionsGroup.Count;

                //-----加载自动生成金线界面
                //加载起始焊点区域归属
                startBondOnRecipes.Clear();
                XMLHelper.ReadOnRecipes(root, startBondOnRecipes, "StartBondOnRecipes");
                XMLHelper.ReadRegion(root, startBallAutoUserRegion, "StartBallAutoUserRegion", wireParameter.DieImageRowOffset,
                                     wireParameter.DieImageColumnOffset, false, false, false, false);

                // add lw
                HTuple hv__filePath = new HTuple(), hv_FileExists = new HTuple();
                HTuple Startreg_index_after_sort = new HTuple();
                hv__filePath = ModelsDirectory + "Startreg_index_after_sort.tup";
                HOperatorSet.FileExists(hv__filePath, out hv_FileExists);
                if ((int)(hv_FileExists) != 0)
                {
                    HOperatorSet.ReadTuple(hv__filePath, out Startreg_index_after_sort);
                }
                else
                {
                    Startreg_index_after_sort = HTuple.TupleGenSequence(1, startBallAutoUserRegion.Count, 1);
                }

                for (int i = 0; i < Startreg_index_after_sort.Length; i++)
                {
                    startBallAutoUserRegion[i].Index_ini = Startreg_index_after_sort[i];
                }

                if (startBondOnRecipes.Count == 0)
                {
                    IsLoadXML = false;
                    if (wireParameter.IsEnableStartVirtualBond == true)
                    {
                        wireParameter.IsEnableStartVirtualBond = false;
                        wireParameter.IsEnableStartVirtualBond = true;
                    }
                    if (wireParameter.IsEnableStartVirtualBond == false)
                    {
                        wireParameter.IsEnableStartVirtualBond = true;
                        wireParameter.IsEnableStartVirtualBond = false;
                    }
                }

                //加载结束焊点归属
                endBondOnRecipes.Clear();
                XMLHelper.ReadOnRecipes(root, endBondOnRecipes, "EndBondOnRecipes");
                XMLHelper.ReadRegion(root, stopBallAutoUserRegion, "StopBallAutoUserRegion", wireParameter.DieImageRowOffset,
                                     wireParameter.DieImageColumnOffset, false, false, false, false);

                // add lw
                HTuple Stopreg_index_after_sort  = new HTuple();
                hv__filePath = ModelsDirectory + "Stopreg_index_after_sort.tup";
                HOperatorSet.FileExists(hv__filePath, out hv_FileExists);
                if ((int)(hv_FileExists) != 0)
                {
                    HOperatorSet.ReadTuple(hv__filePath, out Stopreg_index_after_sort);
                }
                else
                {
                    Stopreg_index_after_sort = HTuple.TupleGenSequence(1, stopBallAutoUserRegion.Count, 1);
                }

                for (int i = 0; i < Stopreg_index_after_sort.Length; i++)
                {
                    stopBallAutoUserRegion[i].Index_ini = Stopreg_index_after_sort[i];
                }

                if (endBondOnRecipes.Count == 0)
                {
                    IsLoadXML = false;
                    if (wireParameter.IsEnableEndVirtualBond == true)
                    {
                        wireParameter.IsEnableEndVirtualBond = false;
                        wireParameter.IsEnableEndVirtualBond = true;
                    }
                    if (wireParameter.IsEnableEndVirtualBond == false)
                    {
                        wireParameter.IsEnableEndVirtualBond = true;
                        wireParameter.IsEnableEndVirtualBond = false;
                    }
                }

                //---------------生成界面中金线
                (wireAddAutoRegion as WireAddAutoRegion).UpdateStartandStopLineRegions(true);

                //金线模板Model
                XElement wireRegionsModelGroupNode = root.Element("WireRegionsModelGroup");
                if (wireRegionsModelGroupNode == null)
                {
                    return;
                }
                wireRegionsModelGroup.Clear();

                foreach (var modelGroupNode in wireRegionsModelGroupNode.Elements("ModelGroup"))
                {
                    WireAutoRegionGroup modelGroup = new WireAutoRegionGroup();
                    modelGroup.ModelStartUserRegions = UserRegion.FromXElement(modelGroupNode.Element("ModelStartUserRegions"),
                                                                               false, wireParameter.DieImageRowOffset, wireParameter.DieImageColumnOffset, false, false, false);
                    modelGroup.ModelStopUserRegions = UserRegion.FromXElement(modelGroupNode.Element("ModelStopUserRegions"),
                                                                              false, wireParameter.DieImageRowOffset, wireParameter.DieImageColumnOffset, false, false, false);
                    modelGroup.RefLineModelRegions = UserRegion.FromXElement(modelGroupNode.Element("RefLineModelRegions"), false,
                                                                             wireParameter.DieImageRowOffset, wireParameter.DieImageColumnOffset, false, false, false);
                    XMLHelper.ReadRegion(modelGroupNode, modelGroup.LineModelRegions, "LineModelRegions", wireParameter.DieImageRowOffset,
                                         wireParameter.DieImageColumnOffset, false, false, true, false);
                    //1212 金线检测区域的通道值设置-模板线
                    for (int i = 0; i < modelGroup.LineModelRegions.Count(); i++)
                    {
                        if (modelGroup.LineModelRegions.ElementAt(i).ChannelNames.Count() == 0)
                        {
                            modelGroup.LineModelRegions.ElementAt(i).ChannelNames = wireParameter.ChannelNames;
                            int tmp_ind;
                            tmp_ind = modelGroup.LineModelRegions.ElementAt(i).ImageIndex;
                        }
                    }
                    wireRegionsModelGroup.Add(modelGroup);
                    modelGroup.Index = wireRegionsModelGroup.Count;

                    modelGroup.SelectModelNumber = (int)modelGroupNode.FirstAttribute.NextAttribute;
                }
                (wireAddAutoRegion as WireAddAutoRegion).ModelGroupsCount = wireRegionsModelGroup.Count;

                //恢复自动生成金线起始区域金线ModelType  add by wj
                for (int i = 0; i < wireParameter.WireRegModelType.Length; i++)
                {
                    startBallAutoUserRegion[i].ModelGroups       = wireRegionsModelGroup;
                    startBallAutoUserRegion[i].CurrentModelGroup = wireRegionsModelGroup.ElementAt(wireParameter.WireRegModelType[i] - 1);
                }

                //1109 赋值初始排序
                if (wireParameter.WireAutoIndex_sorted_start.Length == startBallAutoUserRegion.Count)
                {
                    for (int i = 0; i < wireParameter.WireAutoIndex_sorted_start.Length; i++)
                    {
                        startBallAutoUserRegion[i].Index_ini = wireParameter.WireAutoIndex_sorted_start[i];
                    }
                }
                if (wireParameter.WireAutoIndex_sorted_stop.Length == stopBallAutoUserRegion.Count)
                {
                    for (int i = 0; i < wireParameter.WireAutoIndex_sorted_stop.Length; i++)
                    {
                        stopBallAutoUserRegion[i].Index_ini = wireParameter.WireAutoIndex_sorted_stop[i];
                    }
                }

                //1029 default model setting
                if (wireRegionsModelGroup.Count > 0)
                {
                    (wireAddAutoRegion as WireAddAutoRegion).CurrentModelGroup = (wireAddAutoRegion as WireAddAutoRegion).ModelGroups.ElementAt(0);
                }

                if ((wireAddAutoRegion as WireAddAutoRegion).StartBallAutoUserRegion.Count > 0)
                {
                    (wireAddAutoRegion as WireAddAutoRegion).WireParameter.IsStartPickUp = true;
                }
                if ((wireAddAutoRegion as WireAddAutoRegion).StopBallAutoUserRegion.Count > 0)
                {
                    (wireAddAutoRegion as WireAddAutoRegion).WireParameter.IsStopPickUp = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 6
0
        //加载
        public void LoadXML(string xmlPath)
        {
            try
            {
                XElement root = XElement.Load(xmlPath);
                XElement AroundBondRegInspectParameterNode = new XElement("AroundBondRegInspectParameter");
                if (AroundBondRegInspectParameterNode == null)
                {
                    return;
                }
                XMLHelper.ReadParameters(AroundBondRegInspectParameterNode, AroundBondRegInspectParameter);

                (createAroundBondRegionModel as CreateAroundBondRegionModel).LoadReferenceData();
                //(createAroundBondRegionModel as CreateAroundBondRegionModel).isLoadXML = isLoadXML;
                //(createAroundBondRegionModel as CreateAroundBondRegionModel).LoadInspectBondRegions();


                //加载区域内检测参数
                XElement AroundBondRegNode = root.Element("AroundBondRegions");
                if (AroundBondRegNode == null)
                {
                    return;
                }
                XMLHelper.ReadRegion(AroundBondRegNode, AroundBondRegUserRegions, "AroundBondReg",
                                     AroundBondRegInspectParameter.DieImageRowOffset, AroundBondRegInspectParameter.DieImageColumnOffset, false, false, false, true);
                //XMLHelper.ReadRegion(AroundBondRegNode, AroundBondRegUserRegions, "AroundBondReg", AroundBondRegInspectParameter.DieImageRowOffset, AroundBondRegInspectParameter.DieImageColumnOffset, false, true);

                //1211
                foreach (var item in AroundBondRegUserRegions)
                {
                    // 兼容老产品打开参数不保留 1223 lw
                    if (item == null)
                    {
                        AroundBondRegUserRegions.Clear();
                        break;
                    }

                    if (item.RegionType == RegionType.Region)
                    {
                        //HOperatorSet.ReadRegion(out HObject freeRegion, $"{ ProductDirctory}\\{ item.RegionPath}");

                        // mod by lht 12-23
                        //HOperatorSet.ReadRegion(out HObject freeRegion, $"{ item.RegionPath}");
                        HOperatorSet.ReadRegion(out HObject freeRegion, $"{ProductDirctory}\\{ item.RegionPath}");

                        item.CalculateRegion = freeRegion;
                        HOperatorSet.MoveRegion(freeRegion, out HObject _freeRegion, -AroundBondRegInspectParameter.DieImageRowOffset, -AroundBondRegInspectParameter.DieImageColumnOffset);
                        item.DisplayRegion = _freeRegion;
                    }
                }
                //if (isLoadXML)
                //{
                //    htWindow.DisplayMultiRegion(AroundBondRegUserRegions2.Where(r => r.IsEnable).Select(r => r.DisplayRegion));
                //}
                //else
                //{
                htWindow.DisplayMultiRegion(AroundBondRegUserRegions.Where(r => r.IsEnable).Select(r => r.DisplayRegion));
                //}
                (createAroundBondRegionModel as CreateAroundBondRegionModel).Initial();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 7
0
        //加载
        public void LoadXML(string xmlPath)
        {
            /*
             * await Task.Run(() =>
             * {
             *  while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff)
             *  {
             *      Thread.Sleep(500);
             *  }
             * });
             */
            try
            {
                XElement root = XElement.Load(xmlPath);
                XElement bondMeasureParameterNode      = root.Element("BondMeasureParameter");
                XElement bond1AutoRegionsParameterNode = root.Element("Bond1AutoRegionsParameter");//自动
                if (bondMeasureParameterNode == null)
                {
                    return;
                }
                XMLHelper.ReadParameters(bondMeasureParameterNode, bondMeasureParameter);
                XMLHelper.ReadParameters(bond1AutoRegionsParameterNode, bond1AutoRegionsParameter);//自动
                (createBondMeasureModel as CreateBondMeasureModel).LoadReferenceData();
                XMLHelper.ReadRegion(root, bondModelUserRegions, "BondModelUserRegions", 0, 0, true);

                //XMLHelper.ReadRegion(root, BondVerifyUserRegions, "BondVerifyUserRegions", bondMeasureParameter.DieImageRowOffset, bondMeasureParameter.DieImageColumnOffset);

                XMLHelper.ReadRegion(root, PadUserRegions, "PadUserRegions", bondMeasureParameter.DieImageRowOffset, bondMeasureParameter.DieImageColumnOffset, false, false, false, false, true);
                //
                XElement BondVerifyModelParaNode = root.Element("BondVerifyModelPara");
                XMLHelper.ReadParameters(BondVerifyModelParaNode, bondVerifyModelPara);
                // 兼容老产品打开参数不保留 2021-0105 by wj
                if (PadUserRegions.Count() != 0)
                {
                    //add by wj 2021-01-05
                    string regionPathName;
                    string regionName = "Pad_Regions";
                    regionPathName = $"\\{regionName}.reg";

                    HOperatorSet.ReadRegion(out HObject freeRegion, $"{ModelsBondDirectory}\\{ regionPathName}");

                    //更新PadUserRegions
                    for (int i = 0; i < PadUserRegions.Count; i++)
                    {
                        //检测区域内通道值设置
                        if (PadUserRegions.ElementAt(i).ChannelNames.Count() == 0)
                        {
                            PadUserRegions.ElementAt(i).ChannelNames = bondMeasureParameter.ChannelNames;
                        }
                        if (PadUserRegions[i].RegionType == RegionType.Region)
                        {
                            HOperatorSet.SelectObj(freeRegion, out HObject padFreeRegion, i + 1);
                            PadUserRegions[i].CalculateRegion = padFreeRegion;
                            HOperatorSet.MoveRegion(padFreeRegion, out HObject _padFreeRegion, -bondMeasureParameter.DieImageRowOffset, -bondMeasureParameter.DieImageColumnOffset);
                            PadUserRegions[i].DisplayRegion = _padFreeRegion;
                        }
                    }
                }

                XMLHelper.ReadRegion(root, Bond2UserRegion, "Bond2UserRegion", 0, 0, true);
                XMLHelper.ReadRegion(root, Bond2UserRegionDiff, "Bond2UserRegionDiff", 0, 0, true);
                XMLHelper.ReadRegion(root, RotateLineUserRegion, "RotateLineUserRegion", 0, 0, true);

                XElement BondMeasureVerifyParameterNode = root.Element("BondMeasureVerifyParameter");
                XMLHelper.ReadParameters(BondMeasureVerifyParameterNode, bondMeasureVerifyParameter);
                (createBondMeasureModel as CreateBondMeasureModel).Initial();

                bondWireRegionGroups.Clear();
                XElement bondWireGroupNode = root.Element("BondWireGroups");
                if (bondWireGroupNode == null)
                {
                    return;
                }
                //自动生成焊点区域部分
                foreach (var groupNode in bondWireGroupNode.Elements("BondWireGroup"))
                {
                    BondWireRegionGroup group = new BondWireRegionGroup();
                    group.Bond2UserRegion = UserRegion.FromXElement(groupNode.Element("Bond2Region"), false);
                    group.WireUserRegion  = UserRegion.FromXElement(groupNode.Element("WireRegion"), false);                                                                                                                                                                                         //XMLHelper.ReadParameters(groupNode, group.Parameter);
                    bondWireRegionGroups.Add(group);
                    group.Index          = bondWireRegionGroups.Count;
                    group.Bond2_BallNums = int.Parse(groupNode.Attribute("Bond2Numbers")?.Value);
                }
                (createAutoBondMeasureModel as CreateAutoBondMeasureModel).GroupsCount = bondWireRegionGroups.Count;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return;
            }
        }
Ejemplo n.º 8
0
        //加载
        public async void LoadXML(string xmlPath) //async
        {
            await Task.Run(() =>
            {
                while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff)
                {
                    Thread.Sleep(500);
                }
            });

            try
            {
                XElement root = XElement.Load(xmlPath);
                XMLHelper.ReadParameters(root, iniParameters);
                DieUserRegions.Clear();
                XMLHelper.ReadRegion(root, DieUserRegions, "Die_Regions", iniParameters.DieImageRowOffset, iniParameters.DieImageColumnOffset);
                if (iniParameters.ImageIndex == 0)
                {
                    iniParameters.ImageIndex = 1;
                }

                if (!File.Exists($"{IniDirectory}ReferenceImage.tiff"))
                {
                    MessageBox.Show("全局数据没有参考图像!");
                    return;
                }
                if (iniParameters.UserRegionForCutOutIndex == -1)
                {
                    MessageBox.Show("全局数据没有参考Die!");
                    return;
                }
                if (!File.Exists(IniDirectory + "TrainningImagesDirectory.tup"))
                {
                    MessageBox.Show("提示:训练图集文件不存在!");
                }

                HOperatorSet.ReadTuple(IniDirectory + "TrainningImagesDirectory.tup", out HTuple TrainningImagesDirectoryTemp);
                //GoldenModelParameter.TrainningImagesDirectory = TrainningImagesDirectoryTemp;
                if (!Directory.Exists(TrainningImagesDirectoryTemp))
                {
                    MessageBox.Show("提示:训练图集不存在!");
                }

                (createReference as CreateReference).LoadImage();
                (createReference as CreateReference).SelectedUserRegion = DieUserRegions.Where(u => u.Index == (int)iniParameters.UserRegionForCutOutIndex).FirstOrDefault();
                (createReference as CreateReference).DieCutOut(false);
                (createReference as CreateReference).Initial();

                //1120
                iniParameters.ChannelNames.Clear();
                for (int i = 0; i < iniParameters.ImageCountChannels; i++)
                {
                    ChannelName tmp_name = new ChannelName();
                    tmp_name.Name = (i + 1).ToString();
                    iniParameters.ChannelNames.Add(tmp_name);
                }
                (createReference as CreateReference).SwitchImageChannelIndex = iniParameters.ImageIndex - 1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 9
0
        //加载
        public void LoadXML(string xmlPath)//async
        {
            //await Task.Run(() =>
            //{
            //    while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff)
            //    {
            //        Thread.Sleep(500);
            //    }
            //});


            try
            {
                XElement root = XElement.Load(xmlPath);
                XElement cutRegionParameterNode = root.Element("CutRegionParameter");
                if (cutRegionParameterNode == null)
                {
                    return;
                }
                XMLHelper.ReadParameters(cutRegionParameterNode, CutRegionParameter);
                (createCutRegionModel as CreateCutRegionModel).LoadReferenceData();
                //(createCutRegionModel as CreateCutRegionModel).LoadInspectCutRegions();

                // add by wj
                //加载区域内检测参数
                XElement AroundBondRegNode = root.Element("CutRegions");
                if (AroundBondRegNode == null)
                {
                    return;
                }
                XMLHelper.ReadRegion(AroundBondRegNode, OriRegionUserRegions, "CutReg",
                                     CutRegionParameter.DieImageRowOffset, CutRegionParameter.DieImageColumnOffset, false, false, false, false);

                foreach (var item in OriRegionUserRegions)
                {
                    // 兼容老产品打开参数不保留 1223 lw
                    if (item == null)
                    {
                        OriRegionUserRegions.Clear();
                        break;
                    }

                    if (item.RegionType == RegionType.Region)
                    {
                        HOperatorSet.ReadRegion(out HObject freeRegion, $"{ProductDirctory}\\{ item.RegionPath}");

                        item.DisplayRegion   = freeRegion;
                        item.CalculateRegion = freeRegion;
                    }
                }

                (createCutRegionModel as CreateCutRegionModel).LoadDilationParameters();

                /*
                 * HOperatorSet.ReadTuple($"{ModelsDirectory}CutRegionParameters.tup",out cutRegionParameters);
                 * HOperatorSet.ReadTuple($"{ModelsDirectory}CutRegionRecipeNames.tup", out CutRegionRecipeNames);
                 * HOperatorSet.ReadRegion(out HObject CutDisplayRegions, $"{ModelsDirectory}CutDisplayRegions.reg");
                 * HOperatorSet.ReadRegion(out HObject CutRegions, $"{ModelsDirectory}CutRegions.reg");
                 * HOperatorSet.MoveRegion(CutDisplayRegions, out HObject DieCutDisplayRegion, -CutRegionParameter.DieImageRowOffset, -CutRegionParameter.DieImageColumnOffset);//
                 * HOperatorSet.MoveRegion(CutRegions, out HObject DieCutRegion, -CutRegionParameter.DieImageRowOffset, -CutRegionParameter.DieImageColumnOffset);//calculation
                 * CutDisplayRegions.CountObj();
                 *
                 * for (int i = 1; i < CutRegionRecipeNames.TupleLength()+1; i++)
                 * {
                 *  UserRegion userRegion = new UserRegion
                 *  {
                 *      DisplayRegion = DieCutDisplayRegion.SelectObj(i),
                 *      CalculateRegion = DieCutRegion.SelectObj(i),
                 *      RegionParameters = new double[1] { cutRegionParameters.TupleSelect(i-1)},
                 *      RecipeNames = CutRegionRecipeNames.TupleSelect(i-1),
                 *      RegionType=RegionType.Dilation,
                 *  };
                 *  if (userRegion == null) return;
                 *  userRegion.Index = CutRegionUserRegions.Count + 1;
                 *  CutRegionUserRegions.Add(userRegion);
                 * }
                 */

                (createCutRegionModel as CreateCutRegionModel).Initial();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }