1、增加单独Job的保存、添加和创建

2、每个Job单独绑定一个图像窗体
3、支持通过以job的方式外部调用
This commit is contained in:
liu.wenjie
2022-05-09 16:17:41 +08:00
parent 7ca84a8720
commit 9dcba19b67
36 changed files with 1022 additions and 113 deletions

View File

@@ -24,7 +24,7 @@ namespace PMAlignTool
private HDrawingObject serachRegion_drawing_object = new HDrawingObject();
public List<HDrawingObject> templateModelListAdd = new List<HDrawingObject>() { };
public List<HDrawingObject> templateModelListSub = new List<HDrawingObject>() { };
public List<HDrawingObject> templateModelList = new List<HDrawingObject>() { };
public FormPMAlignTool(ref object pmalign)
{
InitializeComponent();
@@ -191,7 +191,7 @@ namespace PMAlignTool
{
if(myPMAlign.inputImage != null)
{
if(myPMAlign.CreateModelTemplate() == 0)
if(myPMAlign.CreateModelTemplate(false, null) == 0)
{
if (myPMAlign.matchMode == MatchMode.BasedShape)
{

View File

@@ -276,17 +276,25 @@ namespace PMAlignTool
maxScale = FormPMAlignTool.Instance.nud_ScaleRange.Value;
}
public int CreateModelTemplate()
public int CreateModelTemplate(bool setInputModelRegion, HObject inputModelRegion)
{
HObject template;
oldTrainImage = inputImage;
if (FormPMAlignTool.Instance.templateModelListAdd.Count == 0)
// 判断是否从外部输入模板
if(setInputModelRegion)
{
LoggerClass.WriteLog($"{toolName}未划定模板建立区域", MsgLevel.Exception);
isCreateModel = false;
return -1;
templateRegion = inputModelRegion;
}
else
{
if (FormPMAlignTool.Instance.templateModelListAdd.Count == 0)
{
LoggerClass.WriteLog($"{toolName}未划定模板建立区域", MsgLevel.Exception);
isCreateModel = false;
return -1;
}
CreateModelRegion();
}
CreateModelRegion();
HObject createModelImg;
HOperatorSet.GenEmptyObj(out createModelImg);
createModelImg = ProcessImage(inputImage);

View File

@@ -55,6 +55,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WeifenLuo.WinFormsUI.Docking, Version=2.9.0.0, Culture=neutral, PublicKeyToken=null" />
</ItemGroup>
<ItemGroup>
<Compile Include="FormPMAlignTool.cs">

View File

@@ -31,11 +31,10 @@ namespace PMAlignTool
{
public class PMAlignToolRun : IToolRun
{
public void ToolRun(string jobName, int toolIndex, int inputItemNum, TreeNode selectNode, List<IToolInfo> L_toolList)
public void ToolRun(string jobName, int toolIndex, int inputItemNum, TreeNode selectNode, List<IToolInfo> L_toolList, IVisionJob runJob, Form myHalconWindowForm)
{
PMAlign myPMAlign = (PMAlign)L_toolList[toolIndex].tool;
VisionJob myJob = VisionJobParams.pVisionProject.Project[jobName];
VisionJob myJob = (VisionJob)runJob;
for (int j = 0; j < inputItemNum; j++)
{
if (L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value == null)
@@ -64,7 +63,7 @@ namespace PMAlignTool
else
{
myJob.FormLogDisp($"{L_toolList[toolIndex].toolName} 运行成功,{myPMAlign.runTime}", Color.Green, selectNode);
myPMAlign.DispMainWindow(FormImageWindow.Instance.myHWindow);
myPMAlign.DispMainWindow(((FormImageWindow)myHalconWindowForm).myHWindow);
// 将输出值赋值到界面输出中
if (myPMAlign.L_resultList.Count > 0)
{
@@ -75,6 +74,7 @@ namespace PMAlignTool
L_toolList[toolIndex].toolOutput[4] = new ToolIO("GetPose.Score", myPMAlign.L_resultList[0].Socre, DataType.DoubleValue);
}
}
L_toolList[toolIndex].toolRunStatu = myPMAlign.toolRunStatu;
}
}
}