Commit b2fb4069 LN

点料算法更新

1 个父辈 6e29a642
...@@ -75,29 +75,18 @@ ...@@ -75,29 +75,18 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Asa.CarerayImage.GetLocalCount(System.String,System.Double,System.Int32,System.Int32@,Asa.API.EyemImage@)"> <member name="M:Asa.CarerayImage.GetLocalCount(System.String,System.Double,System.Int32,System.String@,Asa.API.EyemImage@)">
<summary> <summary>
本地文件器件点料 本地文件普通器件点料
</summary> </summary>
<param name="path"></param> <param name="path"></param>
<param name="dOffset"></param> <param name="dOffset"></param>
<param name="iWinSize"></param> <param name="iWinSize"></param>
<param name="iObjCount"></param> <param name="count"></param>
<param name="tpDstImg"></param> <param name="tpDstImg"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Asa.CarerayImage.GetLocalCountHuge(System.String,System.Double,System.Int32,System.Int32@,Asa.API.EyemImage@)"> <member name="M:Asa.CarerayImage.GetLocalCountIrregular(System.String,System.Double,System.Int32,System.Int32,System.String@,Asa.API.EyemImage@)">
<summary>
本地文件大器件点料
</summary>
<param name="path"></param>
<param name="dOffset"></param>
<param name="iWinSize"></param>
<param name="iObjCount"></param>
<param name="tpDstImg"></param>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.GetLocalCountIrregular(System.String,System.Double,System.Int32,System.Int32,System.Int32@,Asa.API.EyemImage@)">
<summary> <summary>
本地文件异性器件点料 本地文件异性器件点料
</summary> </summary>
...@@ -105,7 +94,7 @@ ...@@ -105,7 +94,7 @@
<param name="dOffset"></param> <param name="dOffset"></param>
<param name="type"></param> <param name="type"></param>
<param name="iWinSize"></param> <param name="iWinSize"></param>
<param name="iObjCount"></param> <param name="count"></param>
<param name="tpDstImg"></param> <param name="tpDstImg"></param>
<returns></returns> <returns></returns>
</member> </member>
...@@ -124,23 +113,9 @@ ...@@ -124,23 +113,9 @@
</summary> </summary>
<param name="ipImage"></param> <param name="ipImage"></param>
</member> </member>
<member name="M:Asa.API.eyemCountObject(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.Int32@,Asa.API.EyemImage@)"> <member name="M:Asa.API.eyemCountObject(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.IntPtr@,Asa.API.EyemImage@)">
<summary>
小盘点料
</summary>
<param name="tpSrcImg"></param>
<param name="fileName"></param>
<param name="dOffset"></param>
<param name="iMinArea"></param>
<param name="iMaxArea"></param>
<param name="iWinSize"></param>
<param name="iObjCount"></param>
<param name="tpDstImg"></param>
<returns></returns>
</member>
<member name="M:Asa.API.eyemCountObject4Huge(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.Int32@,Asa.API.EyemImage@)">
<summary> <summary>
大盘点料 普通器件
</summary> </summary>
<param name="tpSrcImg"></param> <param name="tpSrcImg"></param>
<param name="fileName"></param> <param name="fileName"></param>
...@@ -148,13 +123,13 @@ ...@@ -148,13 +123,13 @@
<param name="iMinArea"></param> <param name="iMinArea"></param>
<param name="iMaxArea"></param> <param name="iMaxArea"></param>
<param name="iWinSize"></param> <param name="iWinSize"></param>
<param name="iObjCount"></param> <param name="pNumObj"></param>
<param name="tpDstImg"></param> <param name="tpDstImg"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Asa.API.eyemCountObjectIrregularParts(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.Int32@,Asa.API.EyemImage@)"> <member name="M:Asa.API.eyemCountObjectIrregularParts(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.IntPtr@,Asa.API.EyemImage@)">
<summary> <summary>
器件 器件
</summary> </summary>
<param name="tpSrcImg"></param> <param name="tpSrcImg"></param>
<param name="fileName"></param> <param name="fileName"></param>
...@@ -162,7 +137,7 @@ ...@@ -162,7 +137,7 @@
<param name="iType"></param> <param name="iType"></param>
<param name="iMaxArea"></param> <param name="iMaxArea"></param>
<param name="iWinSize"></param> <param name="iWinSize"></param>
<param name="iObjCount"></param> <param name="pNumObj"></param>
<param name="tpDstImg"></param> <param name="tpDstImg"></param>
<returns></returns> <returns></returns>
</member> </member>
......
...@@ -142,7 +142,7 @@ namespace OnlineStore.AutoCountClient ...@@ -142,7 +142,7 @@ namespace OnlineStore.AutoCountClient
list.Add(obj.ToCSVStr()); list.Add(obj.ToCSVStr());
} }
File.WriteAllLines(filePath, list.ToArray<string>(), Encoding.GetEncoding("gbk")); File.WriteAllLines(filePath, list.ToArray<string>(), Encoding.UTF8);
MessageBox.Show("成功导出程序到文件:" + "\r\n" + filePath); MessageBox.Show("成功导出程序到文件:" + "\r\n" + filePath);
} }
} }
......
...@@ -282,7 +282,7 @@ namespace OnlineStore.AutoCountClient ...@@ -282,7 +282,7 @@ namespace OnlineStore.AutoCountClient
txtFengzhuang.Text = ""; txtFengzhuang.Text = "";
txtPartNum.Text = ""; txtPartNum.Text = "";
cmbSuanfa.SelectedIndex = 5; cmbSuanfa.SelectedIndex = 5;
lblTuijian.Text = "";
txtPartNum.Enabled = true; txtPartNum.Enabled = true;
groupInfo.Text = "新增元器件"; groupInfo.Text = "新增元器件";
} }
......
using Acc.ImageBox; using Acc.ImageBox;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.DeviceLibrary; using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
...@@ -21,8 +22,7 @@ namespace OnlineStore.AutoCountClient ...@@ -21,8 +22,7 @@ namespace OnlineStore.AutoCountClient
{ {
InitializeComponent(); InitializeComponent();
} }
private ImageBox currShowBox = null; private int CurrType = -2;
private int CurrType = -1;
private string CurrFullFileName = ""; private string CurrFullFileName = "";
private string CurrPN = ""; private string CurrPN = "";
...@@ -85,7 +85,6 @@ namespace OnlineStore.AutoCountClient ...@@ -85,7 +85,6 @@ namespace OnlineStore.AutoCountClient
{ {
btnNext.Enabled = false; btnNext.Enabled = false;
MessageBox.Show("已经是最后一张图片"); MessageBox.Show("已经是最后一张图片");
return; return;
} }
string fullFName = ImageList[currIndex]; string fullFName = ImageList[currIndex];
...@@ -126,6 +125,24 @@ namespace OnlineStore.AutoCountClient ...@@ -126,6 +125,24 @@ namespace OnlineStore.AutoCountClient
{ {
btnNext.Enabled = false; btnNext.Enabled = false;
} }
if (LoadCSVLibrary.CSVBomManager.allComMap.ContainsKey(CurrPN))
{
ComponetInfo com = CSVBomManager.allComMap[CurrPN];
lblDes.Text = "描述:" + com.Describe;
lblFeng.Text = "封装:" + com.Encapsulations;
lblPN.Text = "元器件编号:" + com.PartNum;
lblProName.Text = "产品:" + com.ProductName;
}
else
{
lblPN.Text = "元器件编号:" + CurrPN;
lblDes.Text = "--";
lblFeng.Text = "--";
lblProName.Text = "--";
}
timer1.Start(); timer1.Start();
} }
...@@ -138,10 +155,12 @@ namespace OnlineStore.AutoCountClient ...@@ -138,10 +155,12 @@ namespace OnlineStore.AutoCountClient
CurrType = type; CurrType = type;
int index = 0; int index = 0;
btnTest.Text = "请选择算法"; btnTest.Text = "请选择算法";
bool findsuanfa = false;
foreach (Button btn in SelBtnList) foreach (Button btn in SelBtnList)
{ {
if (index.Equals(type)) if (index.Equals(type))
{ {
findsuanfa = true;
btn.Text = gouStr + btn.Tag; btn.Text = gouStr + btn.Tag;
btnTest.Text = btn.Tag + "-点料测试"; btnTest.Text = btn.Tag + "-点料测试";
btn.BackColor = Color.LightGreen; btn.BackColor = Color.LightGreen;
...@@ -153,12 +172,9 @@ namespace OnlineStore.AutoCountClient ...@@ -153,12 +172,9 @@ namespace OnlineStore.AutoCountClient
} }
index++; index++;
} }
bool isShowBtn = (type >= 0&&type<5);
btnTest.Enabled = isShowBtn;
btnNext.Enabled = isShowBtn;
btnEnd.Enabled = true ;
btnTest.Enabled = findsuanfa;
btnNext.Enabled = findsuanfa;
} }
private void btnTest_Click(object sender, EventArgs e) private void btnTest_Click(object sender, EventArgs e)
...@@ -248,7 +264,7 @@ namespace OnlineStore.AutoCountClient ...@@ -248,7 +264,7 @@ namespace OnlineStore.AutoCountClient
private void btnNext_Click(object sender, EventArgs e) private void btnNext_Click(object sender, EventArgs e)
{ {
btnNext.Enabled = false; //btnNext.Enabled = false;
this.Cursor = System.Windows.Forms.Cursors.WaitCursor; this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
try try
{ {
...@@ -258,7 +274,7 @@ namespace OnlineStore.AutoCountClient ...@@ -258,7 +274,7 @@ namespace OnlineStore.AutoCountClient
{ {
LogUtil.error("下一张 报错:" + ex.ToString()); LogUtil.error("下一张 报错:" + ex.ToString());
} }
btnNext.Enabled = true; //btnNext.Enabled = true;
this.Cursor = System.Windows.Forms.Cursors.Default; this.Cursor = System.Windows.Forms.Cursors.Default;
} }
......
type,sign,value,threshold,windowSize type,sign,value,threshold,windowSize
6H10B,1,5,0,0 6H10B,1,5,0,0
7H5S1,0,0,0,0 7H5S1,0,0,0,0
6H106,1,0,0,0 6H106,1,0,0,0
......
...@@ -559,29 +559,50 @@ namespace OnlineStore.DeviceLibrary ...@@ -559,29 +559,50 @@ namespace OnlineStore.DeviceLibrary
} }
public int GetCountResult(string fileP, CountParam param,out Asa.API.EyemImage tpDstImg) public int GetCountResult(string fileP, CountParam param, out Asa.API.EyemImage tpDstImg)
{ {
// 器件类型
//"小器件" GetLocalCount
//"粘连不严重" GetLocalCountIrregular type = 0
//"大器件" GetLocalCountIrregular type = 1
//"长条型器件" GetLocalCountIrregular type = 2
//"E形状" GetLocalCountIrregular type = 3
//返回的数量是string类型,count = "4000,3000,3500,2000"
int count = 0; int count = 0;
tpDstImg = new API.EyemImage();
try
{
string countStr = "";
int result = 0; int result = 0;
int type = param.Sign; int type = param.Sign;
int threshold = param.Threshold; int threshold = param.Threshold;
int windowsize = param.WindowSize; int windowsize = param.WindowSize;
if (param.Sign.Equals(0)) if (param.Sign.Equals(0))
{ {
result = carerayImage.GetLocalCount(fileP, threshold, windowsize, out count, out tpDstImg); result = carerayImage.GetLocalCount(fileP, threshold, windowsize, out countStr, out tpDstImg);
LogUtil.info("GetCountResult "+ type + " 调用 GetLocalCount 【" + fileP+"】【"+threshold+"】【"+windowsize+"】,返回【"+result+"】,结果【"+count+"】"); LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
} }
else if (param.Sign.Equals(1)) //else if (param.Sign.Equals(1))
//{
// result = carerayImage.GetLocalCountHuge(fileP, threshold, windowsize, out countStr, out tpDstImg);
// LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
//}
else
{ {
result = carerayImage.GetLocalCountHuge(fileP, threshold, windowsize, out count, out tpDstImg); int t = param.Sign - 1;
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + count + "】"); result = carerayImage.GetLocalCountIrregular(fileP, threshold, t, windowsize, out countStr, out tpDstImg);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】[" + t + "]【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
} }
else string[] array = countStr.Split(',');
if (array.Length > 0)
{
count= Convert.ToInt32(array[0]);
}
}
catch (Exception ex)
{ {
int t = param.Sign - 2; LogUtil.error("GetCountResult 出错: " + ex.ToString());
WorkLog("点料:开始调用 carerayImage.GetLocalCountIrregular ");
result = carerayImage.GetLocalCountIrregular(fileP, threshold, t, windowsize, out count, out tpDstImg);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】["+t+"]【" + windowsize + "】,返回【" + result + "】,结果【" + count + "】");
} }
return count; return count;
} }
......
...@@ -121,6 +121,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -121,6 +121,8 @@ namespace OnlineStore.DeviceLibrary
File.WriteAllLines(ConfigFilePath, lineList); File.WriteAllLines(ConfigFilePath, lineList);
LogUtil.info("SaveMapToFile 【" + ConfigFilePath + "】"); LogUtil.info("SaveMapToFile 【" + ConfigFilePath + "】");
CSVBomManager.BackFile(ConfigFilePath, lineList.ToArray());
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -162,7 +162,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -162,7 +162,7 @@ namespace OnlineStore.LoadCSVLibrary
if (!titleIndex.ContainsKey(str)) if (!titleIndex.ContainsKey(str))
{ {
LogUtil.error("未找到必须列:" + str + ",加载数据失败!"); LogUtil.error("未找到必须列:" + str + ",加载数据失败!");
throw new CVSFieldNotMatchingExection("未找到必须列:" + str + ",加载数据失败!"); throw new CVSFieldNotMatchingExection("【"+ lineValue + "】未找到必须列:【" + str + "】,加载数据失败!");
} }
} }
} }
......
...@@ -57,8 +57,14 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -57,8 +57,14 @@ namespace OnlineStore.LoadCSVLibrary
public static string getFilePath() public static string getFilePath()
{ {
string ComPath_Config = ConfigAppSettings.GetValue(Setting_Init.ComPath_Config);
if (String.IsNullOrEmpty(ComPath_Config))
{
ComPath_Config = @"\XRAY\pnDetailedList.csv";
ConfigAppSettings.SaveValue(Setting_Init.ComPath_Config, ComPath_Config);
}
string appPath = Application.StartupPath; string appPath = Application.StartupPath;
string fileName = appPath + ConfigAppSettings.GetValue(Setting_Init.ComPath_Config); string fileName = appPath + ComPath_Config;
return fileName; return fileName;
} }
/// <summary> /// <summary>
...@@ -245,6 +251,8 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -245,6 +251,8 @@ namespace OnlineStore.LoadCSVLibrary
} }
bool result = WriteCSVFile(filePath, lines); bool result = WriteCSVFile(filePath, lines);
LogUtil.info("保存物料库列表到文件 SaveToFile :" + result); LogUtil.info("保存物料库列表到文件 SaveToFile :" + result);
BackFile(filePath, lines);
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
...@@ -264,6 +272,56 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -264,6 +272,56 @@ namespace OnlineStore.LoadCSVLibrary
return false; return false;
} }
public static void BackFile(string filePath, string[] lines)
{
//备份保存
//try
//{
// FileInfo file = new FileInfo(filePath);
// string date = DateTime.Now.ToString("yyyy-MM-dd");
// string targetBackPath = @"C:\configBack\" + date + @"\";
// if (!Directory.Exists(targetBackPath))
// {
// Directory.CreateDirectory(targetBackPath);
// }
// string fileName = file.Name;
// string backFile = targetBackPath + fileName;
// if (File.Exists(backFile))
// {
// File.Delete(backFile);
// }
// File.WriteAllLines(backFile, lines, Encoding.GetEncoding("gbk"));
//}
//catch (Exception e)
//{
// LogUtil.error("备份["+ filePath + "]到C:configBack出错:" + e.ToString());
//}
//备份保存
try
{
FileInfo file = new FileInfo(filePath);
string date = DateTime.Now.ToString("yyyy-MM-dd");
string targetBackPath = @"D:\configBack\" + date + @"\";
if (!Directory.Exists(targetBackPath))
{
Directory.CreateDirectory(targetBackPath);
}
string fileName = file.Name;
string backFile = targetBackPath + fileName;
if (File.Exists(backFile))
{
File.Delete(backFile);
}
File.WriteAllLines(backFile, lines, Encoding.UTF8);
}
catch (Exception e)
{
LogUtil.error("备份[" + filePath + "]到D:configBack出错:" + e.ToString());
}
}
public static ComponetInfo GetCom(string partNum) public static ComponetInfo GetCom(string partNum)
{ {
if (allComMap.ContainsKey(partNum)) if (allComMap.ContainsKey(partNum))
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!