2024-10-25 13:49:37 +08:00
|
|
|
|
using DocumentFormat.OpenXml.EMMA;
|
2024-12-02 15:02:39 +08:00
|
|
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
2024-10-25 13:49:37 +08:00
|
|
|
|
using LeatherApp.Device;
|
2024-03-07 14:03:22 +08:00
|
|
|
|
using LeatherApp.Interface;
|
|
|
|
|
using Models;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
2024-10-25 13:49:37 +08:00
|
|
|
|
using PG_Detect;
|
2024-03-07 14:03:22 +08:00
|
|
|
|
using Sunny.UI;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2025-02-05 08:40:57 +08:00
|
|
|
|
using System.Windows.Forms.VisualStyles;
|
2024-03-07 14:03:22 +08:00
|
|
|
|
|
|
|
|
|
namespace LeatherApp.Page
|
|
|
|
|
{
|
|
|
|
|
public partial class FProductInfo : UIPage
|
|
|
|
|
{
|
|
|
|
|
private Service.ProductService service=new Service.ProductService();
|
|
|
|
|
private Models.Product model = new Models.Product();
|
|
|
|
|
public FProductInfo()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
#region dataGridView设置
|
|
|
|
|
uiDataGridView1.AllowUserToAddRows = uiDataGridView1.AllowUserToDeleteRows = false;//用户添加删除行
|
|
|
|
|
uiDataGridView2.AllowUserToAddRows = uiDataGridView2.AllowUserToDeleteRows = false;
|
|
|
|
|
uiDataGridView1.AllowUserToResizeRows = uiDataGridView2.AllowUserToResizeRows=false;//用户调整行大小
|
|
|
|
|
//dataGridView1.AllowUserToResizeColumns = false;//用户调整列大小
|
|
|
|
|
//显示行号与列宽度自动调整
|
|
|
|
|
uiDataGridView1.RowHeadersVisible = uiDataGridView2.RowHeadersVisible = true;
|
|
|
|
|
uiDataGridView1.RowHeadersWidth = uiDataGridView2.RowHeadersWidth = 50;
|
|
|
|
|
uiDataGridView1.ColumnHeadersHeightSizeMode = uiDataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
|
|
|
|
|
uiDataGridView1.RowHeadersWidthSizeMode = uiDataGridView2.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;//数据量过百绑定太变
|
|
|
|
|
//dataGridView1.RowPostPaint += (sender, e) =>//序号列头
|
|
|
|
|
//{
|
|
|
|
|
// //Utils.Util.showRowNum_onDataGrid_RowPostPaint(this.dataGridView1, sender, e);
|
|
|
|
|
// Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dataGridView1.RowHeadersWidth - 4, e.RowBounds.Height);
|
|
|
|
|
// TextRenderer.DrawText(e.Graphics, (e.RowIndex * 0.25f).ToString(), dataGridView1.RowHeadersDefaultCellStyle.Font, rectangle, dataGridView1.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
|
|
|
|
|
//};
|
|
|
|
|
//for (int i = 0; i < dataGridView1.Columns.Count; i++)//禁止点击列头排序
|
|
|
|
|
// dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
|
|
|
|
|
////行列交叉处标题
|
|
|
|
|
//if (dataGridView1.RowHeadersVisible) dataGridView1.TopLeftHeaderCell.Value = "SPH/CYL";
|
|
|
|
|
#endregion
|
|
|
|
|
|
2024-08-05 09:39:58 +08:00
|
|
|
|
this.rbMaterial0.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 0).Value<string>("name");
|
|
|
|
|
this.rbMaterial1.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 1).Value<string>("name");
|
|
|
|
|
this.rbMaterial2.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 2).Value<string>("name");
|
|
|
|
|
this.rbMaterial3.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 3).Value<string>("name");
|
|
|
|
|
this.rbMaterial4.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 4).Value<string>("name");
|
|
|
|
|
this.rbMaterial5.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 5).Value<string>("name");
|
|
|
|
|
|
2024-11-08 09:10:43 +08:00
|
|
|
|
if(Config.CustomerName == "MX" || Config.CustomerName == "XCL")
|
|
|
|
|
{
|
|
|
|
|
uiLabel14.Visible = true;
|
|
|
|
|
uiSymbolButton1.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
uiLabel14.Visible = false;
|
|
|
|
|
uiSymbolButton1.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-07 14:03:22 +08:00
|
|
|
|
initData();
|
|
|
|
|
}
|
|
|
|
|
private void initData()
|
|
|
|
|
{
|
|
|
|
|
//var lstMaterial = Config.materialNameList.Select(x => new { code = x.Value<string>("code"), name = x.Value<string>("name") }).ToList();
|
|
|
|
|
//cmbMaterial.ValueMember = "code";
|
|
|
|
|
//cmbMaterial.DisplayMember = "name";
|
|
|
|
|
//cmbMaterial.DataSource = lstMaterial;
|
|
|
|
|
//cmbMaterial.SelectedIndex = -1;
|
|
|
|
|
|
|
|
|
|
var lstColor = Config.colorNameList.Select(x => new { code = x.Value<int>("code"),name = x.Value<string>("name") }).ToList();
|
|
|
|
|
cmbColor.ValueMember = "code";
|
|
|
|
|
cmbColor.DisplayMember = "name";
|
|
|
|
|
cmbColor.DataSource = lstColor;
|
|
|
|
|
cmbColor.SelectedIndex = -1;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
var filePathList = Directory.GetFiles(Application.StartupPath + "\\models\\", "*.trt");//*.onnx,
|
|
|
|
|
string[] onlyNameList=new string[filePathList.Length];
|
|
|
|
|
for (int i = 0; i < filePathList.Length; i++)
|
|
|
|
|
onlyNameList[i]=Path.GetFileName(filePathList[i]);
|
|
|
|
|
this.cmbModelName.Items.AddRange(onlyNameList);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
ABSCamerCardDev devCamer1;
|
|
|
|
|
if (Config.Camer_Name == CamerDevNameEnum.海康)
|
|
|
|
|
devCamer1 = new CamerCardDev();
|
|
|
|
|
else
|
|
|
|
|
devCamer1 = new CamerCardDevIK();
|
|
|
|
|
var value = devCamer1.getFeatureRangeValue("ExposureTime");
|
|
|
|
|
if (value.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
this.tcbarExposureTime.Minimum = (int)value[0];
|
|
|
|
|
this.tcbarExposureTime.Maximum = (int)value[1];
|
|
|
|
|
}
|
|
|
|
|
value = devCamer1.getFeatureRangeValue("Gain");
|
|
|
|
|
if (value.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
this.tcbarGain.Minimum = (int)value[0];
|
|
|
|
|
this.tcbarGain.Maximum = (int)value[1];
|
|
|
|
|
}
|
2025-02-05 08:40:57 +08:00
|
|
|
|
|
|
|
|
|
if(Config.CustomerName == "XCL")
|
|
|
|
|
{
|
|
|
|
|
uiDataGridView2.Columns["col2_1"].HeaderText = "一等品";
|
|
|
|
|
uiDataGridView2.Columns["col2_2"].Visible = false;
|
|
|
|
|
uiDataGridView2.Columns["col2_3"].Visible = false;
|
|
|
|
|
uiDataGridView2.Columns["col2_4"].HeaderText = "二等品";
|
|
|
|
|
uiDataGridView2.Columns["col2_5"].HeaderText = "废品";
|
|
|
|
|
}
|
2024-03-07 14:03:22 +08:00
|
|
|
|
//
|
|
|
|
|
clear(true);
|
|
|
|
|
}
|
|
|
|
|
private void loadProduct(int id,bool resetAll=false)
|
|
|
|
|
{
|
|
|
|
|
model = service.GetModelNav(id);
|
|
|
|
|
if(model == null)
|
|
|
|
|
{
|
|
|
|
|
clear(resetAll);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
loadProduct();
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 对外,生产页面不存在的CODE进行添加
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pcode"> //PX-6</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public void loadProduct(string pcode, bool resetAll = false)
|
|
|
|
|
{
|
|
|
|
|
model = service.GetModelNav(pcode);
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
clear(resetAll);
|
|
|
|
|
string[] codes= pcode.Split('-');
|
2024-08-05 09:39:58 +08:00
|
|
|
|
if (codes[0]=="0" || Config.SuedeList1.Contains(codes[0]))
|
2024-03-07 14:03:22 +08:00
|
|
|
|
this.rbMaterial0.Checked = true;
|
2024-05-21 14:22:10 +08:00
|
|
|
|
else if (codes[0] == "1")
|
2024-03-07 14:03:22 +08:00
|
|
|
|
this.rbMaterial1.Checked = true;
|
2024-05-21 14:22:10 +08:00
|
|
|
|
else if (codes[0] == "2")
|
|
|
|
|
this.rbMaterial2.Checked = true;
|
|
|
|
|
else if (codes[0] == "3")
|
|
|
|
|
this.rbMaterial3.Checked = true;
|
|
|
|
|
else if (codes[0] == "4")
|
|
|
|
|
this.rbMaterial4.Checked = true;
|
|
|
|
|
else if (codes[0] == "5")
|
|
|
|
|
this.rbMaterial5.Checked = true;
|
2024-08-05 09:39:58 +08:00
|
|
|
|
else
|
|
|
|
|
this.rbMaterial1.Checked = true;
|
|
|
|
|
|
2024-03-07 14:03:22 +08:00
|
|
|
|
this.cmbColor.SelectedValue = int.Parse(codes[1]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
loadProduct();
|
|
|
|
|
}
|
2024-05-21 14:22:10 +08:00
|
|
|
|
|
|
|
|
|
private double ContrastLow = 0.8;
|
|
|
|
|
private double ContrastTop = 1.2;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取对比度百分比 0-100 对应0.6-1.4
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="val"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private double ContrastToPercent(double val)
|
|
|
|
|
{
|
|
|
|
|
if (val < ContrastLow)
|
|
|
|
|
return 0;
|
|
|
|
|
else if (val > ContrastTop)
|
|
|
|
|
return 100;
|
|
|
|
|
double temp = 100 /(ContrastTop - ContrastLow) ;
|
|
|
|
|
return Math.Round(temp * (val - ContrastLow),2);
|
|
|
|
|
}
|
|
|
|
|
private double PercentToContrast(double val)
|
|
|
|
|
{
|
|
|
|
|
double tt = 1;
|
|
|
|
|
if (val > 100)
|
|
|
|
|
tt = 100;
|
|
|
|
|
else if (val < 0)
|
|
|
|
|
tt = 0;
|
|
|
|
|
else
|
|
|
|
|
tt = val;
|
|
|
|
|
double temp = tt / 100 * (ContrastTop - ContrastLow);
|
|
|
|
|
return temp + ContrastLow;
|
|
|
|
|
}
|
2024-03-07 14:03:22 +08:00
|
|
|
|
private void loadProduct()
|
|
|
|
|
{
|
|
|
|
|
if (model == null) return;
|
|
|
|
|
if(model.Material=="0")
|
|
|
|
|
this.rbMaterial0.Checked = true;
|
2024-05-21 14:22:10 +08:00
|
|
|
|
else if (model.Material == "1")
|
2024-03-07 14:03:22 +08:00
|
|
|
|
this.rbMaterial1.Checked = true;
|
2024-05-21 14:22:10 +08:00
|
|
|
|
else if (model.Material == "2")
|
|
|
|
|
this.rbMaterial2.Checked = true;
|
|
|
|
|
else if (model.Material == "3")
|
|
|
|
|
this.rbMaterial3.Checked = true;
|
|
|
|
|
else if (model.Material == "4")
|
|
|
|
|
this.rbMaterial4.Checked = true;
|
|
|
|
|
else if (model.Material == "5")
|
|
|
|
|
this.rbMaterial5.Checked = true;
|
|
|
|
|
|
2024-03-07 14:03:22 +08:00
|
|
|
|
this.cmbColor.SelectedValue = model.Color;
|
|
|
|
|
|
|
|
|
|
tcbarLightValue.Value = model.LightValue;
|
|
|
|
|
tcbarExposureTime.Value = (int)model.ExposureTime;
|
|
|
|
|
tcbarGain.Value = (int)model.Gain;
|
|
|
|
|
tcbarTensionValue.Value = (int)model.TensionValue;
|
|
|
|
|
|
|
|
|
|
this.cmbModelName.Text = model.ModelName;
|
|
|
|
|
numDefectAreaLimit.Text = model.DefectAreaLimit.ToString();
|
|
|
|
|
numDefectCountLimit.Text = model.DefectCountLimit.ToString();
|
|
|
|
|
swcDefectPauseForUser.Active = model.DefectPauseForUser;
|
|
|
|
|
|
2024-10-25 13:49:37 +08:00
|
|
|
|
tbClass.Text = model.ClassType;
|
|
|
|
|
tbAera.Text = model.HalconAreaThr.ToString();
|
|
|
|
|
|
2024-08-09 10:34:23 +08:00
|
|
|
|
this.uiSwitch1.Active = model.OpenThicknessDetection;
|
|
|
|
|
uiNumPadTextBox1.Text = model.ThicknessDetectionStopDis.ToString();
|
2024-12-02 15:02:39 +08:00
|
|
|
|
|
|
|
|
|
//按模型加载label
|
|
|
|
|
JArray defectItemList;
|
|
|
|
|
Config.LoadModelDefectItemList(model.ModelName, out defectItemList);
|
|
|
|
|
uiDataGridView1.Rows.Clear();
|
|
|
|
|
uiDataGridView2.Rows.Clear();
|
|
|
|
|
uiDataGridView1.Columns[0].Visible = false;
|
|
|
|
|
string code, name;
|
|
|
|
|
//加行
|
|
|
|
|
foreach (JObject item in defectItemList)
|
|
|
|
|
{
|
|
|
|
|
code = item.Value<string>("code");
|
|
|
|
|
name = item.Value<string>("name");
|
|
|
|
|
//color = item.Value<string>("color");
|
|
|
|
|
uiDataGridView1.Rows.Add();
|
|
|
|
|
uiDataGridView1.Rows[uiDataGridView1.RowCount - 1].HeaderCell.Value = name;
|
|
|
|
|
uiDataGridView1[0, uiDataGridView1.RowCount - 1].Value = code;
|
|
|
|
|
}
|
|
|
|
|
uiDataGridView2.Columns[0].Visible = false;
|
|
|
|
|
//加行
|
|
|
|
|
foreach (JObject item in defectItemList)
|
|
|
|
|
{
|
|
|
|
|
code = item.Value<string>("code");
|
|
|
|
|
name = item.Value<string>("name");
|
|
|
|
|
//color = item.Value<string>("color");
|
|
|
|
|
uiDataGridView2.Rows.Add();
|
|
|
|
|
uiDataGridView2.Rows[uiDataGridView2.RowCount - 1].HeaderCell.Value = name;
|
|
|
|
|
uiDataGridView2[0, uiDataGridView2.RowCount - 1].Value = code;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-07 14:03:22 +08:00
|
|
|
|
//uiDataGridView fill
|
2024-12-02 15:02:39 +08:00
|
|
|
|
//string code;
|
2024-03-07 14:03:22 +08:00
|
|
|
|
QualifiedLimit item1;
|
|
|
|
|
for (int i = 0; i < uiDataGridView1.Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
code = uiDataGridView1.Rows[i].Cells["col_code"].Value.ToString();
|
|
|
|
|
item1 = model.QualifiedLimitList.FirstOrDefault(m=>m.Code == code);
|
|
|
|
|
if (item1 != null)
|
|
|
|
|
{
|
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_zxd"].Value=item1.ZXD;
|
2024-04-12 08:48:03 +08:00
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_area"].Value = item1.Area * 100;
|
2024-05-21 14:22:10 +08:00
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_contrast_top"].Value = ContrastToPercent(item1.ContrastTop);
|
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_contrast_lower"].Value = ContrastToPercent(item1.ContrastLower);
|
2024-03-07 14:03:22 +08:00
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_IsOR"].Value = item1.IsOR;
|
2024-12-09 16:08:24 +08:00
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_Len"].Value = item1.DefectWarnLength;
|
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_Cnt"].Value = item1.DefectWarnCnt;
|
2024-03-07 14:03:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
GradeLimit item2;
|
|
|
|
|
for (int i = 0; i < uiDataGridView2.Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
code = uiDataGridView2.Rows[i].Cells["col2_code"].Value.ToString();
|
|
|
|
|
item2 = model.GradeLimitList.FirstOrDefault(m => m.Code == code);
|
|
|
|
|
if (item2 != null)
|
|
|
|
|
{
|
|
|
|
|
uiDataGridView2.Rows[i].Cells["col2_1"].Value = item2.A;
|
|
|
|
|
uiDataGridView2.Rows[i].Cells["col2_2"].Value = item2.B;
|
|
|
|
|
uiDataGridView2.Rows[i].Cells["col2_3"].Value = item2.C;
|
|
|
|
|
uiDataGridView2.Rows[i].Cells["col2_4"].Value = item2.D;
|
|
|
|
|
uiDataGridView2.Rows[i].Cells["col2_5"].Value = item2.E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
this.btnSave.Visible = this.btnReload.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
private void clear(bool resetAll=false)
|
|
|
|
|
{
|
|
|
|
|
model = new Models.Product();
|
|
|
|
|
if (resetAll)
|
|
|
|
|
{
|
|
|
|
|
rbMaterial0.Checked=rbMaterial1.Checked=false;
|
|
|
|
|
cmbColor.SelectedIndex = -1;
|
|
|
|
|
}
|
|
|
|
|
tcbarLightValue.Value = tcbarExposureTime.Value = tcbarGain.Value = tcbarTensionValue.Value=0;
|
|
|
|
|
//cmbModelName.SelectedIndex = -1;
|
|
|
|
|
numDefectAreaLimit.Text =numDefectCountLimit.Text= "0";
|
|
|
|
|
swcDefectPauseForUser.Active = true;
|
|
|
|
|
|
|
|
|
|
this.btnSave.Visible = true;
|
|
|
|
|
this.btnReload.Visible = false;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
uiDataGridView1.Rows.Clear();
|
|
|
|
|
uiDataGridView2.Rows.Clear();
|
2024-12-02 15:02:39 +08:00
|
|
|
|
|
|
|
|
|
JArray defectItemList;
|
|
|
|
|
Config.LoadModelDefectItemList(model.ModelName, out defectItemList);
|
|
|
|
|
|
2024-03-07 14:03:22 +08:00
|
|
|
|
string code, name;
|
|
|
|
|
//===uiDataGridView1
|
|
|
|
|
//加列
|
|
|
|
|
//uiDataGridView1.Columns.Add("col_code", "code");
|
|
|
|
|
//uiDataGridView1.Columns.Add("col_zxd", "置信度");
|
|
|
|
|
//uiDataGridView1.Columns.Add("col_area", "面积");
|
|
|
|
|
//uiDataGridView1.Columns.Add("col_contrast", "对比度");
|
|
|
|
|
//禁止点击列头排序
|
|
|
|
|
//uiDataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
|
|
|
|
|
uiDataGridView1.Columns[0].Visible = false;
|
|
|
|
|
//加行
|
2024-12-02 15:02:39 +08:00
|
|
|
|
foreach (JObject item in defectItemList)
|
2024-03-07 14:03:22 +08:00
|
|
|
|
{
|
|
|
|
|
code = item.Value<string>("code");
|
|
|
|
|
name = item.Value<string>("name");
|
|
|
|
|
//color = item.Value<string>("color");
|
|
|
|
|
uiDataGridView1.Rows.Add();
|
|
|
|
|
uiDataGridView1.Rows[uiDataGridView1.RowCount - 1].HeaderCell.Value = name;
|
|
|
|
|
uiDataGridView1[0, uiDataGridView1.RowCount - 1].Value = code;
|
|
|
|
|
}
|
|
|
|
|
//===uiDataGridView2
|
|
|
|
|
//加列
|
|
|
|
|
//uiDataGridView2.Columns.Add("col_code", "code");
|
|
|
|
|
//uiDataGridView2.Columns.Add("col_1", "A");
|
|
|
|
|
//uiDataGridView2.Columns.Add("col_2", "B");
|
|
|
|
|
//uiDataGridView2.Columns.Add("col_3", "C");
|
|
|
|
|
//uiDataGridView2.Columns.Add("col_4", "D");
|
|
|
|
|
//uiDataGridView2.Columns.Add("col_5", "E");
|
|
|
|
|
//禁止点击列头排序
|
|
|
|
|
//uiDataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
|
|
|
|
|
uiDataGridView2.Columns[0].Visible = false;
|
|
|
|
|
//加行
|
2024-12-02 15:02:39 +08:00
|
|
|
|
foreach (JObject item in defectItemList)
|
2024-03-07 14:03:22 +08:00
|
|
|
|
{
|
|
|
|
|
code = item.Value<string>("code");
|
|
|
|
|
name = item.Value<string>("name");
|
|
|
|
|
//color = item.Value<string>("color");
|
|
|
|
|
uiDataGridView2.Rows.Add();
|
|
|
|
|
uiDataGridView2.Rows[uiDataGridView2.RowCount - 1].HeaderCell.Value = name;
|
|
|
|
|
uiDataGridView2[0, uiDataGridView2.RowCount - 1].Value = code;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void FProductInfo_Initialize(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void btnNew_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.clear();
|
|
|
|
|
}
|
|
|
|
|
private void btnReload_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.loadProduct(model.Id,true);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
UIMessageTip.ShowError(ex.Message, 2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-05-21 14:22:10 +08:00
|
|
|
|
if (!this.rbMaterial0.Checked && !rbMaterial1.Checked
|
|
|
|
|
&& !rbMaterial2.Checked && !rbMaterial3.Checked
|
|
|
|
|
&& !rbMaterial4.Checked && !rbMaterial5.Checked
|
|
|
|
|
) throw new Exception("请选择材质!");
|
2024-03-07 14:03:22 +08:00
|
|
|
|
if (this.cmbColor.SelectedIndex < 0) throw new Exception("请选择颜色!");
|
|
|
|
|
if (this.cmbModelName.SelectedIndex < 0) throw new Exception("请选择模型!");
|
|
|
|
|
|
2024-05-21 14:22:10 +08:00
|
|
|
|
model.Material = GetMaterialIndex();
|
2024-03-07 14:03:22 +08:00
|
|
|
|
model.Color = (int)cmbColor.SelectedValue;
|
|
|
|
|
model.Code = model.Material+"-"+ model.Color;
|
|
|
|
|
|
|
|
|
|
model.LightValue = tcbarLightValue.Value;
|
|
|
|
|
model.TensionValue = tcbarTensionValue.Value;
|
|
|
|
|
model.ExposureTime = tcbarExposureTime.Value;
|
|
|
|
|
model.Gain = tcbarGain.Value;
|
|
|
|
|
|
|
|
|
|
model.ModelName = this.cmbModelName.Text.Trim();
|
|
|
|
|
model.DefectAreaLimit = double.Parse(numDefectAreaLimit.Text.Trim());
|
|
|
|
|
model.DefectCountLimit = int.Parse(numDefectCountLimit.Text.Trim());
|
|
|
|
|
model.DefectPauseForUser = swcDefectPauseForUser.Active;
|
|
|
|
|
|
2024-10-25 13:49:37 +08:00
|
|
|
|
///halcon参数
|
|
|
|
|
model.ClassType = tbClass.Text;
|
2024-12-18 10:44:17 +08:00
|
|
|
|
model.HalconAreaThr = double.Parse(string.IsNullOrEmpty(tbAera.Text.Trim())? "0": tbAera.Text.Trim());
|
2024-10-25 13:49:37 +08:00
|
|
|
|
|
2024-08-05 09:39:58 +08:00
|
|
|
|
model.OpenThicknessDetection = uiSwitch1.Active;
|
|
|
|
|
int ival;
|
|
|
|
|
if (int.TryParse(uiNumPadTextBox1.Text, out ival))
|
|
|
|
|
model.ThicknessDetectionStopDis = int.Parse(uiNumPadTextBox1.Text.Trim());
|
|
|
|
|
else
|
|
|
|
|
model.ThicknessDetectionStopDis = 0;
|
2024-03-07 14:03:22 +08:00
|
|
|
|
//datagrid
|
|
|
|
|
if (model.QualifiedLimitList == null)
|
|
|
|
|
model.QualifiedLimitList = new List<Models.QualifiedLimit>();
|
|
|
|
|
else
|
|
|
|
|
model.QualifiedLimitList.Clear();
|
|
|
|
|
QualifiedLimit qualifiedLimit = new QualifiedLimit();
|
|
|
|
|
for (int i=0;i< uiDataGridView1.Rows.Count;i++ )
|
|
|
|
|
{
|
|
|
|
|
qualifiedLimit = new Models.QualifiedLimit()
|
|
|
|
|
{
|
|
|
|
|
Code = uiDataGridView1.Rows[i].Cells["col_code"].Value.ToString(),
|
|
|
|
|
ZXD = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_zxd"].Value) ? Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_zxd"].Value) : 0,
|
2024-04-12 08:48:03 +08:00
|
|
|
|
Area = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_area"].Value) ? Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_area"].Value) / 100 : 0,
|
2024-05-21 14:22:10 +08:00
|
|
|
|
ContrastLower = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_contrast_lower"].Value) ? PercentToContrast(Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_contrast_lower"].Value)) : 0,
|
|
|
|
|
ContrastTop = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_contrast_top"].Value) ? PercentToContrast(Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_contrast_top"].Value)) : 0,
|
2024-03-07 14:03:22 +08:00
|
|
|
|
IsOR = Convert.ToBoolean(uiDataGridView1.Rows[i].Cells["col_IsOR"].Value),
|
|
|
|
|
|
2024-08-05 09:39:58 +08:00
|
|
|
|
DefectWarnLength = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_Len"].Value) ? (int)Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_Len"].Value) : 0,
|
|
|
|
|
DefectWarnCnt = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_Cnt"].Value) ? (int)Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_Cnt"].Value) : 0,
|
2024-05-21 14:22:10 +08:00
|
|
|
|
|
2024-12-02 15:02:39 +08:00
|
|
|
|
Name = (string)uiDataGridView1.Rows[i].HeaderCell.Value,
|
2024-03-07 14:03:22 +08:00
|
|
|
|
ModifyUserCode = Config.loginUser.Code,
|
|
|
|
|
CreateUserCode = Config.loginUser.Code
|
|
|
|
|
};
|
|
|
|
|
if (qualifiedLimit.ContrastLower + qualifiedLimit.ContrastTop > 0 && qualifiedLimit.ContrastTop < qualifiedLimit.ContrastLower)
|
2024-05-21 14:22:10 +08:00
|
|
|
|
throw new Exception($"检测标准中第{i+1}行中对比度上限值({ContrastToPercent(qualifiedLimit.ContrastTop)})不可小于下限值({ContrastToPercent(qualifiedLimit.ContrastLower)})!");
|
2024-03-07 14:03:22 +08:00
|
|
|
|
model.QualifiedLimitList.Add(qualifiedLimit);
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
if (model.GradeLimitList == null)
|
|
|
|
|
model.GradeLimitList = new List<Models.GradeLimit>();
|
|
|
|
|
else
|
|
|
|
|
model.GradeLimitList.Clear();
|
|
|
|
|
for (int i = 0; i < uiDataGridView2.Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
model.GradeLimitList.Add(
|
|
|
|
|
new Models.GradeLimit()
|
|
|
|
|
{
|
2024-12-02 15:02:39 +08:00
|
|
|
|
Name = (string)(string)uiDataGridView2.Rows[i].HeaderCell.Value,
|
2024-03-07 14:03:22 +08:00
|
|
|
|
Code = uiDataGridView2.Rows[i].Cells["col2_code"].Value.ToString(),
|
|
|
|
|
A = Utils.Util.IsNumber(uiDataGridView2.Rows[i].Cells["col2_1"].Value)? Convert.ToInt32(uiDataGridView2.Rows[i].Cells["col2_1"].Value) : 0,
|
|
|
|
|
B = Utils.Util.IsNumber(uiDataGridView2.Rows[i].Cells["col2_2"].Value) ? Convert.ToInt32(uiDataGridView2.Rows[i].Cells["col2_2"].Value) : 0,
|
|
|
|
|
C = Utils.Util.IsNumber(uiDataGridView2.Rows[i].Cells["col2_3"].Value) ? Convert.ToInt32(uiDataGridView2.Rows[i].Cells["col2_3"].Value) : 0,
|
|
|
|
|
D = Utils.Util.IsNumber(uiDataGridView2.Rows[i].Cells["col2_4"].Value) ? Convert.ToInt32(uiDataGridView2.Rows[i].Cells["col2_4"].Value) : 0,
|
|
|
|
|
E = Utils.Util.IsNumber(uiDataGridView2.Rows[i].Cells["col2_5"].Value) ? Convert.ToInt32(uiDataGridView2.Rows[i].Cells["col2_5"].Value) : 0,
|
|
|
|
|
ModifyUserCode = Config.loginUser.Code,
|
|
|
|
|
CreateUserCode = Config.loginUser.Code
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
model.ModifyUserCode = Config.loginUser.Code;
|
|
|
|
|
bool result;
|
|
|
|
|
if (model.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
model.CreateUserCode = Config.loginUser.Code;
|
|
|
|
|
result = service.InsertNav(model);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = service.UpdateNav(model);
|
|
|
|
|
}
|
|
|
|
|
if (!result)
|
|
|
|
|
throw new Exception("保存失败!");
|
|
|
|
|
|
2024-10-25 13:49:37 +08:00
|
|
|
|
if (Config.OpenHalconDefect)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PGDetect pg = new PGDetect();
|
|
|
|
|
pg.SaveUserData(Config.HalconParamPath, model.ClassType, model.HalconAreaThr);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"传统算法参数保存失败!{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.btnReload.Visible = true;
|
2024-03-07 14:03:22 +08:00
|
|
|
|
UIMessageTip.ShowOk("保存成功!", 1000);
|
2024-10-25 13:49:37 +08:00
|
|
|
|
|
|
|
|
|
|
2024-03-07 14:03:22 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
UIMessageTip.ShowError(ex.Message, 2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void tcbarLightValue_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lblLightValue.Text = $"{tcbarLightValue.Value}/{tcbarLightValue.Maximum}";
|
|
|
|
|
}
|
|
|
|
|
private void tcbarExposureTime_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lblExposureTime.Text = $"{tcbarExposureTime.Value}/{tcbarExposureTime.Maximum}";
|
|
|
|
|
}
|
|
|
|
|
private void tcbarGainValue_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lblGain.Text = $"{tcbarGain.Value}/{tcbarGain.Maximum}";
|
|
|
|
|
}
|
|
|
|
|
private void tcbarTensionValue_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lblTensionValue.Text = $"{tcbarTensionValue.Value}/{tcbarTensionValue.Maximum}";
|
|
|
|
|
}
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.clear(true);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-21 14:22:10 +08:00
|
|
|
|
string GetMaterialIndex()
|
|
|
|
|
{
|
|
|
|
|
if (this.rbMaterial0.Checked)
|
|
|
|
|
return "0";
|
|
|
|
|
else if (this.rbMaterial1.Checked)
|
|
|
|
|
return "1";
|
|
|
|
|
else if (this.rbMaterial2.Checked)
|
|
|
|
|
return "2";
|
|
|
|
|
else if (this.rbMaterial3.Checked)
|
|
|
|
|
return "3";
|
|
|
|
|
else if (this.rbMaterial4.Checked)
|
|
|
|
|
return "4";
|
|
|
|
|
else
|
|
|
|
|
return "5";
|
|
|
|
|
}
|
2024-03-07 14:03:22 +08:00
|
|
|
|
private void cmbMaterial_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//if (this.cmbMaterial.SelectedIndex < 0 || this.cmbColor.SelectedIndex < 0)
|
|
|
|
|
// return;
|
2024-05-21 14:22:10 +08:00
|
|
|
|
if ((!this.rbMaterial0.Checked && !this.rbMaterial1.Checked && !this.rbMaterial2.Checked
|
|
|
|
|
&& !this.rbMaterial3.Checked && !this.rbMaterial4.Checked && !this.rbMaterial5.Checked)
|
|
|
|
|
|| this.cmbColor.SelectedIndex < 0)
|
2024-03-07 14:03:22 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2024-05-21 14:22:10 +08:00
|
|
|
|
this.loadProduct(GetMaterialIndex() + "-" + this.cmbColor.SelectedValue.ToString());
|
2024-03-07 14:03:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnDefectOption_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.model == null || this.model.Id==0)
|
|
|
|
|
return;
|
|
|
|
|
|
2024-12-02 15:02:39 +08:00
|
|
|
|
FSelDefect frm = new FSelDefect(model.ModelName, model.DefectPauseOption);
|
2024-03-07 14:03:22 +08:00
|
|
|
|
frm.Render();
|
|
|
|
|
frm.Text = "选择瑕疵";
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
if (frm.IsOK)
|
|
|
|
|
{
|
|
|
|
|
model.DefectPauseOption = frm.lstCodes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frm.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void swcDefectPauseForUser_ValueChanged(object sender, bool value)
|
|
|
|
|
{
|
|
|
|
|
btnDefectOption.Enabled = swcDefectPauseForUser.Active;
|
|
|
|
|
}
|
2024-11-08 09:10:43 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MES、ERP信息输入
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void uiSymbolButton1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.model == null || this.model.Id == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
FErpMesEdit frm = new FErpMesEdit(model.Spec);
|
|
|
|
|
frm.Render();
|
|
|
|
|
frm.Text = "MES/ERP信息编辑";
|
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
if (frm.IsOK)
|
|
|
|
|
{
|
|
|
|
|
model.Spec = frm.erpInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frm.Dispose();
|
|
|
|
|
}
|
2024-12-02 15:02:39 +08:00
|
|
|
|
|
|
|
|
|
private void cmbModelName_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//重新加载label
|
|
|
|
|
JArray defectItemList;
|
|
|
|
|
Config.LoadModelDefectItemList(cmbModelName.Text, out defectItemList);
|
|
|
|
|
uiDataGridView1.Rows.Clear();
|
|
|
|
|
uiDataGridView1.Columns[0].Visible = false;
|
|
|
|
|
string code, name;
|
|
|
|
|
//加行
|
|
|
|
|
foreach (JObject item in defectItemList)
|
|
|
|
|
{
|
|
|
|
|
code = item.Value<string>("code");
|
|
|
|
|
name = item.Value<string>("name");
|
|
|
|
|
//color = item.Value<string>("color");
|
|
|
|
|
uiDataGridView1.Rows.Add();
|
|
|
|
|
uiDataGridView1.Rows[uiDataGridView1.RowCount - 1].HeaderCell.Value = name;
|
|
|
|
|
uiDataGridView1[0, uiDataGridView1.RowCount - 1].Value = code;
|
|
|
|
|
}
|
|
|
|
|
if (model != null && model.QualifiedLimitList != null)
|
|
|
|
|
{
|
|
|
|
|
QualifiedLimit item1;
|
|
|
|
|
for (int i = 0; i < uiDataGridView1.Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
code = uiDataGridView1.Rows[i].Cells["col_code"].Value.ToString();
|
|
|
|
|
item1 = model.QualifiedLimitList.FirstOrDefault(m => m.Code == code);
|
|
|
|
|
if (item1 != null)
|
|
|
|
|
{
|
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_zxd"].Value = item1.ZXD;
|
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_area"].Value = item1.Area * 100;
|
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_contrast_top"].Value = ContrastToPercent(item1.ContrastTop);
|
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_contrast_lower"].Value = ContrastToPercent(item1.ContrastLower);
|
|
|
|
|
uiDataGridView1.Rows[i].Cells["col_IsOR"].Value = item1.IsOR;
|
|
|
|
|
//uiDataGridView1.Rows[i].Cells["col_Len"].Value = item1.DefectWarnLength;
|
|
|
|
|
//uiDataGridView1.Rows[i].Cells["col_Cnt"].Value = item1.DefectWarnCnt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-07 14:03:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|