更改运行方式,添加两种模式Debug和Release模式对在界面点击运行和在工具中运行进行区分

This commit is contained in:
liu.wenjie
2019-08-13 20:45:04 +08:00
parent a4993a95fa
commit e2de1d384f
124 changed files with 137 additions and 95 deletions

View File

@@ -118,6 +118,9 @@ namespace CaliperTool
public ToolRunStatu toolRunStatu { get; set; } = ToolRunStatu.Not_Run;
public SoftwareRunState softwareRunState { get; set; } = SoftwareRunState.Debug;
public void DispImage()
{
if (inputImage != null)
@@ -174,13 +177,16 @@ namespace CaliperTool
DispImage();
}
public void Run()
public void Run(SoftwareRunState softwareRunState)
{
HTuple HMeasureHandle = new HTuple();
HTuple resultRow, resultCol;
if (inputImage == null)
{
FormCaliper.Instance.TextBoxMessageDisp("图像为空", System.Drawing.Color.Red);
if(softwareRunState == SoftwareRunState.Debug)
{
FormCaliper.Instance.TextBoxMessageDisp("图像为空", System.Drawing.Color.Red);
}
toolRunStatu = ToolRunStatu.Not_Input_Image;
return;
}
@@ -217,18 +223,25 @@ namespace CaliperTool
}
//把点显示出来
HOperatorSet.GenCrossContourXld(out crossDisp, ResulttRow, ResultCol, new HTuple(12), new HTuple(0));
DispMainWindow(FormCaliper.Instance.myHwindow);
HOperatorSet.GenCrossContourXld(out crossDisp, ResulttRow, ResultCol, new HTuple(60), new HTuple(0));
if(softwareRunState == SoftwareRunState.Debug)
{
DispMainWindow(FormCaliper.Instance.myHwindow);
FormCaliper.Instance.tbx_resultStartRow.Text = ResulttRow.ToString();
FormCaliper.Instance.tbx_resultStartCol.Text = ResultCol.ToString();
FormCaliper.Instance.TextBoxMessageDisp("运行成功", System.Drawing.Color.Green);
}
// 参数传递
ParamsTrans();
FormCaliper.Instance.tbx_resultStartRow.Text = ResulttRow.ToString();
FormCaliper.Instance.tbx_resultStartCol.Text = ResultCol.ToString();
FormCaliper.Instance.TextBoxMessageDisp("运行成功", System.Drawing.Color.Green);
toolRunStatu = ToolRunStatu.Succeed;
}
catch (Exception ex)
{
FormCaliper.Instance.TextBoxMessageDisp("工具运行异常" + ex.Message, System.Drawing.Color.Red);
toolRunStatu = ToolRunStatu.Not_Succeed;
if (softwareRunState == SoftwareRunState.Debug)
{
FormCaliper.Instance.TextBoxMessageDisp("工具运行异常" + ex.Message, System.Drawing.Color.Red);
}
}
finally
{
@@ -243,9 +256,13 @@ namespace CaliperTool
/// </summary>
private void ParamsTrans()
{
FormCaliper.Instance.myToolInfo.toolOutput.Clear();
FormCaliper.Instance.myToolInfo.toolOutput.Add(new ToolIO("outputCenterRow", ResulttRow, DataType.IntValue));
FormCaliper.Instance.myToolInfo.toolOutput.Add(new ToolIO("outputCenterColumn", ResultCol, DataType.IntValue));
if(FormCaliper.Instance.myToolInfo != null)
{
FormCaliper.Instance.myToolInfo.toolOutput.Clear();
FormCaliper.Instance.myToolInfo.toolOutput.Add(new ToolIO("outputCenterRow", ResulttRow, DataType.IntValue));
FormCaliper.Instance.myToolInfo.toolOutput.Add(new ToolIO("outputCenterColumn", ResultCol, DataType.IntValue));
}
}
public void DispMainWindow(HWindow_Final window)
@@ -258,7 +275,7 @@ namespace CaliperTool
// 显示交点
if (dispCross)
{
window.DispObj(crossDisp, "orange");
window.DispObj(crossDisp, "yellow");
}
//显示找到的线
// window.DispObj(LineDisp, "green");

View File

@@ -19,14 +19,14 @@ namespace CaliperTool
public IToolInfo myToolInfo = null;
public HWindow_Final myHwindow = new HWindow_Final();
private static FormCaliper _instance;
private static FormCaliper _instance = null;
public FormCaliper(ref object caliper)
{
InitializeComponent();
myToolInfo = (IToolInfo)caliper;
myCaliper = (Caliper)myToolInfo.tool;
_instance = this;
myCaliper.DispImage();
}
public static FormCaliper Instance
{
@@ -86,7 +86,7 @@ namespace CaliperTool
txbLog.BackColor = setColor;
txbLog.Text = mes;
txbLog.Font = new Font("微软雅黑", 10, FontStyle.Bold);
CommonMethods.CommonMethods.Delay(2000);
//CommonMethods.CommonMethods.Delay(2000);
txbLog.BackColor = Color.White;
}
@@ -98,12 +98,12 @@ namespace CaliperTool
myCaliper.expectAngle = Convert.ToDouble(tbx_expectPhi.Text.Trim());
// 运行参数
myCaliper.threshold = Convert.ToInt16(tbx_threshold.Text.Trim());
myCaliper.length1 = Convert.ToInt16(tbx_caliperLength1.Text.Trim());
myCaliper.length2 = Convert.ToInt16(tbx_caliperLength2.Text.Trim());
myCaliper.length1 = Convert.ToDouble(tbx_caliperLength1.Text.Trim());
myCaliper.length2 = Convert.ToDouble(tbx_caliperLength2.Text.Trim());
myCaliper.polarity = cbx_polarity.SelectedItem.ToString() == "从明到暗" ? "negative" : "positive";
myCaliper.edgeSelect = cbx_edgeSelect.SelectedItem.ToString();
myCaliper.sigma = Convert.ToDouble(tbx_Sigma.Text.Trim());
myCaliper.Run();
myCaliper.Run(SoftwareRunState.Debug);
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.