1、优化LOG显示与引用

2、添加PMA工具,工具内容待完善
3、修复流程树显示
4、添加开源项目,优化UI空间
5、其他BUG更改
This commit is contained in:
liu.wenjie
2021-11-23 15:51:37 +08:00
parent 47f77f5e64
commit a24dda2525
474 changed files with 91916 additions and 6429 deletions

View File

@@ -110,57 +110,22 @@ namespace CaliperTool
}
set { _resultCol = value; }
}
public HObject inputImage { get; set; } = null;
public ToolRunStatu toolRunStatu { get; set; } = ToolRunStatu.Not_Run;
public SoftwareRunState softwareRunState { get; set; } = SoftwareRunState.Debug;
public string runMessage
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public string runTime
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public void DispImage()
public override void DispImage()
{
if (inputImage != null)
{
FormCaliper.Instance.myHwindow.HobjectToHimage(inputImage);
FormCaliper.Instance.myHwindow.HalconWindow.DispObj(inputImage);
}
}
internal void DrawExpectLine(HWindow_Final myHwindow)
internal void DrawExpectLine(HWindow myHwindow)
{
if (inputImage != null)
{
try
{
myHwindow.DrawModel = true;
myHwindow.Focus();
HOperatorSet.SetColor(myHwindow.hWindowControl.HalconWindow, new HTuple("green"));
HOperatorSet.DrawRectangle2Mod(myHwindow.hWindowControl.HalconWindow, expectRecStartRow, expectRecStartColumn, expectAngle, length1, length2,
HOperatorSet.SetColor(myHwindow, new HTuple("green"));
HOperatorSet.DrawRectangle2Mod(myHwindow, expectRecStartRow, expectRecStartColumn, expectAngle, length1, length2,
out expectRecStartRow, out expectRecStartColumn, out expectAngle, out length1, out length2);
if (inputPose != null)
@@ -177,29 +142,27 @@ namespace CaliperTool
FormCaliper.Instance.tbx_caliperLength1.Text = length1.TupleString("10.3f");
FormCaliper.Instance.tbx_caliperLength2.Text = length2.TupleString("10.3f");
myHwindow.DrawModel = false;
// Run();
}
catch (Exception ex)
{
FormCaliper.Instance.TextBoxMessageDisp(ex.Message, System.Drawing.Color.Red);
FormCaliper.Instance.SetToolStatus(ex.Message, ToolRunStatu.Tool_Run_Error);
}
}
else
{
FormCaliper.Instance.TextBoxMessageDisp("图像为空", System.Drawing.Color.Red);
FormCaliper.Instance.SetToolStatus("图像为空", ToolRunStatu.Not_Asign_Input_Image);
}
}
public void UpdateImage()
{
FormCaliper.Instance.myHwindow.ClearWindow();
FormCaliper.Instance.myHwindow.HalconWindow.ClearWindow();
DispImage();
}
public void Run(SoftwareRunState softwareRunState)
public override void Run(SoftwareRunState softwareRunState)
{
HTuple HMeasureHandle = new HTuple();
HTuple resultRow, resultCol;
@@ -207,7 +170,7 @@ namespace CaliperTool
{
if(softwareRunState == SoftwareRunState.Debug)
{
FormCaliper.Instance.TextBoxMessageDisp("图像为空", System.Drawing.Color.Red);
FormCaliper.Instance.SetToolStatus("图像为空", ToolRunStatu.Not_Asign_Input_Image);
}
toolRunStatu = ToolRunStatu.Not_Input_Image;
return;
@@ -248,10 +211,10 @@ namespace CaliperTool
HOperatorSet.GenCrossContourXld(out crossDisp, ResulttRow, ResultCol, new HTuple(80), new HTuple(0));
if(softwareRunState == SoftwareRunState.Debug)
{
DispMainWindow(FormCaliper.Instance.myHwindow);
DispMainWindow(FormCaliper.Instance.myHwindow.HalconWindow);
FormCaliper.Instance.tbx_resultStartRow.Text = ResulttRow.ToString();
FormCaliper.Instance.tbx_resultStartCol.Text = ResultCol.ToString();
FormCaliper.Instance.TextBoxMessageDisp("运行成功", System.Drawing.Color.Green);
FormCaliper.Instance.SetToolStatus("运行成功", ToolRunStatu.Succeed);
}
// 参数传递
ParamsTrans();
@@ -262,7 +225,7 @@ namespace CaliperTool
toolRunStatu = ToolRunStatu.Not_Succeed;
if (softwareRunState == SoftwareRunState.Debug)
{
FormCaliper.Instance.TextBoxMessageDisp("工具运行异常" + ex.Message, System.Drawing.Color.Red);
FormCaliper.Instance.SetToolStatus("工具运行异常" + ex.Message, ToolRunStatu.Tool_Run_Error);
}
}
finally
@@ -287,20 +250,36 @@ namespace CaliperTool
}
public void DispMainWindow(HWindow_Final window)
public override void DispMainWindow(HWindow window)
{
// 显示矩形
if (dispRec)
if (dispRec && contoursDisp != null)
{
window.DispObj(contoursDisp, "blue");
window.SetColor("blue");
window.DispObj(contoursDisp);
}
// 显示交点
if (dispCross)
if (dispCross && crossDisp != null)
{
window.DispObj(crossDisp, "green");
window.SetColor("green");
window.DispObj(crossDisp);
}
//显示找到的线
// window.DispObj(LineDisp, "green");
}
public void SetToolStatusDisp()
{
FormCaliper.Instance.lb_RunStatus.Text = toolRunStatu == ToolRunStatu.Succeed ? "工具运行成功!" : $"工具运行异常, 异常原因:{runMessage}";
FormCaliper.Instance.lb_RunTime.Text = runTime;
if (toolRunStatu == ToolRunStatu.Succeed)
{
FormCaliper.Instance.statusStrip.BackColor = System.Drawing.Color.LimeGreen;
}
else
{
FormCaliper.Instance.statusStrip.BackColor = System.Drawing.Color.Red;
}
}
}
}

View File

@@ -45,7 +45,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CaliperTool.cs" />
<Compile Include="Caliper.cs" />
<Compile Include="CaliperToolRun.cs" />
<Compile Include="FormCaliper.cs">
<SubType>Form</SubType>
@@ -76,12 +76,8 @@
<Project>{7CD50B44-BF56-4E8E-8FA1-05F6968C1835}</Project>
<Name>ToolBase</Name>
</ProjectReference>
<ProjectReference Include="..\ToolLib.Log\LogForm\LogForm.csproj">
<Project>{6b38d68f-e77b-4761-bde5-a261ea8925dd}</Project>
<Name>LogForm</Name>
</ProjectReference>
<ProjectReference Include="..\ToolLib.Log\Logger\Logger.csproj">
<Project>{d4e052b9-e541-4b67-a1f9-273073ef1d4b}</Project>
<Project>{D4E052B9-E541-4B67-A1F9-273073EF1D4B}</Project>
<Name>Logger</Name>
</ProjectReference>
<ProjectReference Include="..\ToolLib.VisionJob\ToolLib.VisionJob.csproj">

View File

@@ -15,6 +15,7 @@ using CommonMethods;
using CommonMethods.Interface;
using FormLib;
using HalconDotNet;
using Logger;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -38,7 +39,7 @@ namespace CaliperTool
if (L_toolList[toolIndex].toolInput[j].IOName == "InputImage" && L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value == null)
{
selectNode.ForeColor = Color.Red;
Logger.LoggerClass.WriteLog($"{L_toolList[toolIndex].toolName} 无输入图像");
LoggerClass.WriteLog($"{L_toolList[toolIndex].toolName} 无输入图像");
break;
}
else
@@ -46,9 +47,9 @@ namespace CaliperTool
if (L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value != null)
{
string sourceFrom = L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value.ToString();
string sourceToolName = Regex.Split(sourceFrom, " . ")[0];
sourceToolName = sourceToolName.Substring(3, Regex.Split(sourceFrom, " . ")[0].Length - 3);
string toolItem = Regex.Split(sourceFrom, " . ")[1];
string sourceToolName = Regex.Split(sourceFrom, "->")[0];
sourceToolName = sourceToolName.Substring(3, Regex.Split(sourceFrom, "->")[0].Length - 3);
string toolItem = Regex.Split(sourceFrom, "->")[1];
if (L_toolList[toolIndex].toolInput[j].IOName == "InputImage")
{
myCaliper.inputImage = myJob.GetToolInfoByToolName(sourceToolName).GetOutput(toolItem).value as HObject;
@@ -72,7 +73,7 @@ namespace CaliperTool
myCaliper.Run(SoftwareRunState.Release);
if (myCaliper.toolRunStatu == ToolRunStatu.Succeed)
{
myCaliper.DispMainWindow(FormImageWindow.Instance.myHWindow);
myCaliper.DispMainWindow(FormImageWindow.Instance.myHWindow.DispHWindow);
myJob.FormLogDisp(L_toolList[toolIndex].toolName + " 运行成功", Color.Green, selectNode);
}
else

View File

@@ -45,7 +45,6 @@
this.btn_moveCliperRegion = new System.Windows.Forms.Button();
this.cbx_edgeSelect = new System.Windows.Forms.ComboBox();
this.tbx_resultStartCol = new System.Windows.Forms.TextBox();
this.txbLog = new System.Windows.Forms.TextBox();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox4 = new System.Windows.Forms.GroupBox();
@@ -63,6 +62,11 @@
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label7 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.lb_RunStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.lb_Split = new System.Windows.Forms.ToolStripStatusLabel();
this.lb_RunTime = new System.Windows.Forms.ToolStripStatusLabel();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -71,6 +75,7 @@
this.groupBox3.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
//
// tbx_resultStartRow
@@ -242,16 +247,6 @@
this.tbx_resultStartCol.Size = new System.Drawing.Size(71, 21);
this.tbx_resultStartCol.TabIndex = 104;
//
// txbLog
//
this.txbLog.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txbLog.Location = new System.Drawing.Point(1, 487);
this.txbLog.Name = "txbLog";
this.txbLog.ReadOnly = true;
this.txbLog.Size = new System.Drawing.Size(1127, 21);
this.txbLog.TabIndex = 276;
//
// splitContainer1
//
this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@@ -267,6 +262,7 @@
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.BackColor = System.Drawing.Color.White;
this.splitContainer1.Panel2.Controls.Add(this.panel2);
this.splitContainer1.Panel2.Controls.Add(this.groupBox4);
this.splitContainer1.Panel2.Controls.Add(this.groupBox3);
this.splitContainer1.Panel2.Controls.Add(this.groupBox1);
@@ -452,12 +448,49 @@
this.label9.TabIndex = 105;
this.label9.Text = "中心列坐标:";
//
// panel2
//
this.panel2.Location = new System.Drawing.Point(-566, 485);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1127, 25);
this.panel2.TabIndex = 276;
//
// statusStrip
//
this.statusStrip.BackColor = System.Drawing.Color.White;
this.statusStrip.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.lb_RunStatus,
this.lb_Split,
this.lb_RunTime});
this.statusStrip.Location = new System.Drawing.Point(0, 485);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(1132, 24);
this.statusStrip.TabIndex = 276;
this.statusStrip.Text = "statusStrip1";
//
// lb_RunStatus
//
this.lb_RunStatus.Name = "lb_RunStatus";
this.lb_RunStatus.Size = new System.Drawing.Size(0, 19);
//
// lb_Split
//
this.lb_Split.Name = "lb_Split";
this.lb_Split.Size = new System.Drawing.Size(189, 19);
this.lb_Split.Text = " ";
//
// lb_RunTime
//
this.lb_RunTime.Name = "lb_RunTime";
this.lb_RunTime.Size = new System.Drawing.Size(0, 19);
//
// FormCaliper
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1132, 509);
this.Controls.Add(this.txbLog);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.splitContainer1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FormCaliper";
@@ -475,6 +508,8 @@
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -497,7 +532,6 @@
private System.Windows.Forms.Button btn_moveCliperRegion;
public System.Windows.Forms.ComboBox cbx_edgeSelect;
public System.Windows.Forms.TextBox tbx_resultStartCol;
public System.Windows.Forms.TextBox txbLog;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.GroupBox groupBox3;
@@ -515,5 +549,10 @@
private System.Windows.Forms.Label label9;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.CheckBox chBDispCaliperROI;
private System.Windows.Forms.Panel panel2;
public System.Windows.Forms.StatusStrip statusStrip;
public System.Windows.Forms.ToolStripStatusLabel lb_RunStatus;
private System.Windows.Forms.ToolStripStatusLabel lb_Split;
public System.Windows.Forms.ToolStripStatusLabel lb_RunTime;
}
}

View File

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using CommonMethods;
using ChoiceTech.Halcon.Control;
using HalconDotNet;
namespace CaliperTool
{
@@ -17,32 +18,43 @@ namespace CaliperTool
public Caliper myCaliper = null;
public IToolInfo myToolInfo = null;
public HWindow_Final myHwindow = new HWindow_Final();
public HSmartWindowControl myHwindow = new HSmartWindowControl();
private static FormCaliper _instance = null;
private static FormCaliper _instance;
public FormCaliper(ref object caliper)
{
InitializeComponent();
myToolInfo = (IToolInfo)caliper;
myCaliper = (Caliper)myToolInfo.tool;
_instance = this;
myCaliper.DispImage();
if (caliper.GetType().FullName != "System.Object")
{
myToolInfo = (IToolInfo)caliper;
myCaliper = (Caliper)myToolInfo.tool;
myCaliper.DispImage();
}
}
public static FormCaliper Instance
{
get
{
if(_instance!= null)
if (_instance != null)
{
return _instance;
lock (_instance)
{
if (_instance == null)
{
object calib = new object();
_instance = new FormCaliper(ref calib);
}
return _instance;
}
}
else
{
object caliper = new object();
_instance = new FormCaliper(ref caliper);
object line = new object();
_instance = new FormCaliper(ref line);
return _instance;
}
}
}
@@ -78,16 +90,7 @@ namespace CaliperTool
private void btn_moveCliperRegion_Click(object sender, EventArgs e)
{
myCaliper.UpdateImage();
myCaliper.DrawExpectLine(myHwindow);
}
public void TextBoxMessageDisp(string mes, Color setColor)
{
txbLog.BackColor = setColor;
txbLog.Text = mes;
txbLog.Font = new Font("微软雅黑", 10, FontStyle.Bold);
//CommonMethods.CommonMethods.Delay(2000);
txbLog.BackColor = Color.White;
myCaliper.DrawExpectLine(myHwindow.HalconWindow);
}
private void btn_runCaliperool_Click(object sender, EventArgs e)
@@ -105,5 +108,29 @@ namespace CaliperTool
myCaliper.sigma = Convert.ToDouble(tbx_Sigma.Text.Trim());
myCaliper.Run(SoftwareRunState.Debug);
}
/// <summary>
/// 设定工具运行状态
/// </summary>
/// <param name="msg">运行中的信息</param>
/// <param name="status">运行状态</param>
public void SetToolStatus(string msg, ToolRunStatu status)
{
if (myCaliper != null)
{
myCaliper.runMessage = msg;
myCaliper.toolRunStatu = status;
lb_RunStatus.Text = myCaliper.toolRunStatu == ToolRunStatu.Succeed ? "工具运行成功!" : $"工具运行异常, 异常原因:{myCaliper.runMessage}";
lb_RunTime.Text = myCaliper.runTime;
if (myCaliper.toolRunStatu == ToolRunStatu.Succeed)
{
statusStrip.BackColor = Color.LimeGreen;
}
else
{
statusStrip.BackColor = Color.Red;
}
}
}
}
}

View File

@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View File

@@ -32,6 +32,9 @@ G:\VisionEdit\VisionEdit\CaliperTool\obj\Debug\CaliperTool.FormCaliper.resources
G:\VisionEdit\VisionEdit\CaliperTool\obj\Debug\CaliperTool.csproj.GenerateResource.Cache
G:\VisionEdit\VisionEdit\CaliperTool\obj\Debug\CaliperTool.dll
G:\VisionEdit\VisionEdit\CaliperTool\obj\Debug\CaliperTool.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\obj\Debug\CaliperTool.csprojResolveAssemblyReference.cache
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\obj\Debug\CaliperTool.FormCaliper.resources
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\obj\Debug\CaliperTool.csproj.GenerateResource.Cache
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\log4net.config
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\CaliperTool.dll
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\CaliperTool.pdb
@@ -40,7 +43,6 @@ F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\DataStruct.dll
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\FormLib.dll
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\halcondotnet.dll
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\HWindow_Tool.dll
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\LogForm.dll
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\Logger.dll
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\ToolBase.dll
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\ToolLib.VisionJob.dll
@@ -52,15 +54,11 @@ F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\CommonMethods.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\DataStruct.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\FormLib.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\ToolBase.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\LogForm.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\Logger.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\ToolLib.VisionJob.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\HWindow_Tool.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\halcondotnet.xml
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\WeifenLuo.WinFormsUI.Docking.pdb
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\Newtonsoft.Json.xml
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\bin\Debug\DevComponents.DotNetBar2.xml
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\obj\Debug\CaliperTool.csprojResolveAssemblyReference.cache
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\obj\Debug\CaliperTool.FormCaliper.resources
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\obj\Debug\CaliperTool.csproj.GenerateResource.Cache
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\obj\Debug\CaliperTool.dll
F:\GitHubClone\最新克隆\VisionEdit\CaliperTool\obj\Debug\CaliperTool.pdb