Commit 876e97c3 LN

元器件学习界面

1 个父辈 bc94711e
正在显示 37 个修改的文件 包含 655 行增加211 行删除
......@@ -38,7 +38,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......@@ -92,6 +92,7 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.Management" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Web.Extensions" />
......
using Acc.ImageBox;
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.AutoCountClient
{
public partial class FrmLearning : Form
{
public FrmLearning()
{
InitializeComponent();
}
private ImageBox currShowBox = null;
private int CurrType = -1;
private bool IsCanSel = false;
private string CurrFullFileName = "";
private string CurrPN = "";
private void FrmLearning_Load(object sender, EventArgs e)
{
imageBox0.Image = XRayLearnManager.modelImg_0;
imageBox1.Image = XRayLearnManager.modelImg_1;
imageBox2.Image = XRayLearnManager.modelImg_2;
imageBox3.Image = XRayLearnManager.modelImg_3;
imageBox4.Image = XRayLearnManager.modelImg_4;
imageBox5.Image = XRayLearnManager.modelImg_5;
pictureBox1.Image = XRayLearnManager.smodelImg_1;
pictureBox2.Image = XRayLearnManager.smodelImg_2;
pictureBox3.Image = XRayLearnManager.smodelImg_3;
pictureBox4.Image = XRayLearnManager.smodelImg_4;
pictureBox5.Image = XRayLearnManager.smodelImg_5;
imageBox0.Text = "未找到元器件类型";
imageBox1.Text = "小器件";
imageBox2.Text = "大器件";
imageBox3.Text = "异形三角器件";
imageBox4.Text = "异形三脚大器件";
imageBox5.Text = "异形长条形器件";
ChangeImage(imageBox0);
string testFile = Application.StartupPath + "\\XRAY\\model\\8D.03906.H11-R515232020062200253-20200812181219.png";
UpdateCurrImg(testFile, "8D.03906.H11");
}
public void UpdateCurrImg(string fullFName,string PN)
{
CurrFullFileName = fullFName;
CurrPN = PN;
ChangeSelStatus(true);
imgCurrImg.Image = XRayLearnManager.FormImage(fullFName);
}
private void ChangeSelStatus(bool iscanSel)
{
this.IsCanSel = iscanSel;
ChangeImage(imageBox0, 0, "");
groupBox3.Visible = iscanSel;
}
private bool ChangeImage(ImageBox showImg, int type = 0, string text = "")
{
if (CurrType.Equals(type))
{
return true;
}
CurrType = type;
if (currShowBox == null)
{
imageBox0.Visible = false;
imageBox1.Visible = false;
imageBox2.Visible = false;
imageBox3.Visible = false;
imageBox4.Visible = false;
imageBox5.Visible = false;
}
else
{
currShowBox.Visible = false;
}
showImg.Visible = true;
currShowBox = showImg;
if (text.Equals(""))
{
btnTest.Visible = false;
}
else
{
btnTest.Text = "使用[" + text + "]模板点料测试";
btnTest.Visible = true;
}
return true;
}
private void btnTest_Click(object sender, EventArgs e)
{
int count = 1;
if (imgCurrImg.Image == null || String.IsNullOrEmpty(CurrFullFileName))
{
MessageBox.Show("未加载图片,无法点料");
return;
}
}
private void radioButton0_CheckedChanged(object sender, EventArgs e)
{
ChangeImage(imageBox0, 0);
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
ChangeImage(imageBox1, 1, radioButton1.Text);
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
ChangeImage(imageBox2, 2, radioButton2.Text);
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
ChangeImage(imageBox3, 3, radioButton3.Text);
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
ChangeImage(imageBox4, 4, radioButton4.Text);
}
private void radioButton5_CheckedChanged(object sender, EventArgs e)
{
ChangeImage(imageBox5, 5, radioButton5.Text);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
radioButton1.Checked = true;
}
private void pictureBox2_Click(object sender, EventArgs e)
{
radioButton2.Checked = true;
}
private void pictureBox3_Click(object sender, EventArgs e)
{
radioButton3.Checked = true;
}
private void pictureBox4_Click(object sender, EventArgs e)
{
radioButton4.Checked = true;
}
private void pictureBox5_Click(object sender, EventArgs e)
{
radioButton5.Checked = true;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file
......@@ -10,6 +10,7 @@ using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
......@@ -44,7 +45,7 @@ namespace OnlineStore.AutoCountClient
{
Application.Exit();
}
// AddLearnForm();
//AddLearnForm();
FrmInputEquip frm1 = new FrmInputEquip(robot.inputEquip);
AddForm(" " + robot.inputEquip.Name + " ", frm1);
......@@ -78,18 +79,18 @@ namespace OnlineStore.AutoCountClient
tabPageList.Add(lineTabPage);
tabControl1.Controls.Add(lineTabPage);
}
private void AddLearnForm( )
{
frmLearn = new FrmLearning();
frmLearn.FormBorderStyle = FormBorderStyle.None;
frmLearn.TopLevel = false;
frmLearn.Dock = DockStyle.Fill;
frmLearn.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
panLearn.Controls.Add(frmLearn);
frmLearn.Show();
}
//private void AddLearnForm( )
//{
// frmLearn = new FrmLearning();
// frmLearn.FormBorderStyle = FormBorderStyle.None;
// frmLearn.TopLevel = false;
// frmLearn.Dock = DockStyle.Fill;
// frmLearn.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
// panLearn.Controls.Add(frmLearn);
// frmLearn.Show();
//}
private void FrmMain_Load(object sender, EventArgs e)
{
{
//string fileP = Application.StartupPath + @"\XRAY\tif\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
FrmBase.GetVersion(true);
if (!RobotManager.Init())
......@@ -103,7 +104,7 @@ namespace OnlineStore.AutoCountClient
this.Text = title;
this.notifyIcon1.Text = title;
int autoValue = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
if(autoValue.Equals(1))
if (autoValue.Equals(1))
{
开机自动启动ToolStripMenuItem.Text = gouStr + " 开机自动启动";
}
......@@ -112,10 +113,10 @@ namespace OnlineStore.AutoCountClient
开机自动启动ToolStripMenuItem.Text = "开机自动启动";
}
LoadStoreData();
LoadListView();
LoadListView();
LogUtil.logBox = this.logBox;
LoadOk = true;
tabPage2.Parent = null;
//tabPage2.Parent = null;
// HideForm();
timer1.Start();
}
......@@ -126,7 +127,7 @@ namespace OnlineStore.AutoCountClient
if (this.pictureBox1.Image != null)
{
this.pictureBox1.Image.Dispose();
this.pictureBox1.Image = null;
this.pictureBox1.Image = null;
}
this.pictureBox1.Image = bitmap;
}
......@@ -229,7 +230,7 @@ namespace OnlineStore.AutoCountClient
{
Camera._cam.CloseAll();
}
robot.sQLite.Close();
robot.sQLite.Close();
}
catch (Exception ex)
{
......@@ -370,7 +371,7 @@ namespace OnlineStore.AutoCountClient
private void btnClearLog_Click(object sender, EventArgs e)
{
LogUtil.ClearLog();
}
}
private void btnCopyLog_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject(logBox.Text);
......@@ -524,7 +525,7 @@ namespace OnlineStore.AutoCountClient
}
}
SetItemText(i, item_move_info_index, trayInfo);
SetItemColor(i, s , equip.alarmType);
SetItemColor(i, s, equip.alarmType);
i++;
}
......@@ -582,7 +583,7 @@ namespace OnlineStore.AutoCountClient
}
}
}
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
......@@ -609,7 +610,7 @@ namespace OnlineStore.AutoCountClient
Rectangle recTab = e.Bounds;
recTab = new Rectangle(recTab.X, recTab.Y + 4, recTab.Width, recTab.Height - 4);
e.Graphics.DrawString(tabName, fntTab, bshFore, recTab, sftTab);
}catch(Exception ex)
} catch (Exception ex)
{
LogUtil.error("tabControl1_DrawItem: " + ex.ToString());
}
......@@ -763,7 +764,7 @@ namespace OnlineStore.AutoCountClient
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
ManagerUtil.AutoRun(Application.ExecutablePath, true);
开机自动启动ToolStripMenuItem.Text = gouStr+"开机自动启动";
开机自动启动ToolStripMenuItem.Text = gouStr + "开机自动启动";
}
LogUtil.info(Name + " 点击:" + 开机自动启动ToolStripMenuItem.Text);
}
......@@ -787,8 +788,8 @@ namespace OnlineStore.AutoCountClient
启用蜂鸣器ToolStripMenuItem.Text = gouStr + " 启用蜂鸣器";
}
else
{
启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
{
启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
}
LogUtil.info(Name + " 点击:" + 启用蜂鸣器ToolStripMenuItem.Text);
}
......@@ -798,14 +799,14 @@ namespace OnlineStore.AutoCountClient
if (!LoadOk)
{
return;
}
}
bool result = !启用X射线点料ToolStripMenuItem.Text.Contains(gouStr);
if (result.Equals(robot.XrayBean.OpenXLine))
{
return;
}
robot.XrayBean.OpenXLine = result;
robot.XrayBean.OpenXLine = result;
if (result)
{
启用X射线点料ToolStripMenuItem.Text = gouStr + " 启用X射线点料";
......@@ -822,7 +823,7 @@ namespace OnlineStore.AutoCountClient
if (!LoadOk)
{
return;
}
}
bool result = !aGVCancelStateToolStripMenuItem.Text.Contains(gouStr);
if (result.Equals(AgvClient.CurrCancelState))
......@@ -844,41 +845,59 @@ namespace OnlineStore.AutoCountClient
private void 正常工作模式ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!XRayLearnManager.InLearnMode)
{
正常工作模式ToolStripMenuItem.Text = gouStr + " 正常工作模式";
元器件学习模式ToolStripMenuItem.Text = "元器件学习模式";
return;
}
LogUtil.info(Name + " 点击:" + 正常工作模式ToolStripMenuItem.Text+ ",设置InLearnMode = false");
XRayLearnManager.InLearnMode = false;
//if (!XRayLearnManager.InLearnMode)
//{
// 正常工作模式ToolStripMenuItem.Text = gouStr + " 正常工作模式";
// 元器件学习模式ToolStripMenuItem.Text = "元器件学习模式";
// return;
//}
//LogUtil.info(Name + " 点击:" + 正常工作模式ToolStripMenuItem.Text + ",设置InLearnMode = false");
//XRayLearnManager.InLearnMode = false;
正常工作模式ToolStripMenuItem.Text = gouStr + " 正常工作模式";
元器件学习模式ToolStripMenuItem.Text ="元器件学习模式";
tabPage2.Parent = null;
tabControl1.TabPages.Insert(0,tabPage1);
tabControl1.SelectedIndex = 0;
//正常工作模式ToolStripMenuItem.Text = gouStr + " 正常工作模式";
//元器件学习模式ToolStripMenuItem.Text = "元器件学习模式";
// tabPage2.Parent = null;
//tabControl1.TabPages.Insert(0, tabPage1);
//tabControl1.SelectedIndex = 0;
//tabPage1.Parent = tabControl1;
}
private void 元器件学习模式ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (XRayLearnManager.InLearnMode)
//if (XRayLearnManager.InLearnMode)
//{
// 正常工作模式ToolStripMenuItem.Text = "正常工作模式";
// 元器件学习模式ToolStripMenuItem.Text = gouStr + " 元器件学习模式";
// return;
//}
//LogUtil.info(Name + " 点击:" + 元器件学习模式ToolStripMenuItem.Text + ",设置InLearnMode = true ");
//XRayLearnManager.InLearnMode = true;
//正常工作模式ToolStripMenuItem.Text = "正常工作模式";
//元器件学习模式ToolStripMenuItem.Text = gouStr + " 元器件学习模式";
//tabPage1.Parent = null;
//tabControl1.TabPages.Insert(0, tabPage2);
//tabControl1.SelectedIndex = 0;
}
private void 元器件学习ToolStripMenuItem_Click(object sender, EventArgs e)
{
string backPath = ParamManager.NoConfigPath;
if (!Directory.Exists(backPath))
{
正常工作模式ToolStripMenuItem.Text = "正常工作模式";
元器件学习模式ToolStripMenuItem.Text = gouStr + " 元器件学习模式";
return;
Directory.CreateDirectory(backPath);
}
folderBrowserDialog1.SelectedPath = backPath;
DialogResult result = folderBrowserDialog1.ShowDialog();
if (result.Equals(DialogResult.OK))
{
string folder = folderBrowserDialog1.SelectedPath;
FrmLearning frm = new FrmLearning();
frm.ImagePath = folder;
frm.ShowDialog();
}
LogUtil.info(Name + " 点击:" + 元器件学习模式ToolStripMenuItem.Text + ",设置InLearnMode = true ");
XRayLearnManager.InLearnMode = true;
正常工作模式ToolStripMenuItem.Text = "正常工作模式";
元器件学习模式ToolStripMenuItem.Text = gouStr + " 元器件学习模式";
tabPage1.Parent = null;
tabControl1.TabPages.Insert(0, tabPage2);
tabControl1.SelectedIndex = 0;
//tabPage2.Parent = tabControl1;
}
}
}
......@@ -417,6 +417,9 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>510, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>43</value>
</metadata>
......
......@@ -98,6 +98,7 @@
<Compile Include="bean\BatchMoveBean_Partial.cs" />
<Compile Include="bean\BatchMoveBean.cs" />
<Compile Include="bean\OutputEquip_Shelf.cs" />
<Compile Include="manager\ParamManager.cs" />
<Compile Include="manager\RobotManager.cs" />
<Compile Include="bean\OutputEquip_Partial.cs" />
<Compile Include="bean\InputEquip_InStore.cs" />
......@@ -105,7 +106,6 @@
<Compile Include="bean\InputEquip.cs" />
<Compile Include="manager\RFIDManagercs.cs" />
<Compile Include="manager\SServerManager.cs" />
<Compile Include="manager\XRayLearnManager.cs" />
<Compile Include="model\AxisBean.cs" />
<Compile Include="model\WaitUtil.cs" />
<Compile Include="deviceLibrary\halcon\CodeManager.cs" />
......@@ -146,39 +146,6 @@
<Content Include="XRAY\area.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\0.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\2.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\3.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\4.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\5.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\smallmodel\1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\smallmodel\2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\smallmodel\3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\smallmodel\4.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\model\smallmodel\5.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XRAY\out\out.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
......@@ -215,6 +182,7 @@
<None Include="XRAY\countParam.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="XRAY\pnDetailedList.csv" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
......@@ -9,7 +9,6 @@ type,sign,value,threshold,windowSize
6C1D1,0,0,0,0
6C1H1,0,0,0,0
6CEH1,0,0,0,0
6C1D1,0,0,0,0
6D551,0,0,0,0
7H1F1,0,0,0,0
7H2F1,0,0,0,0
......@@ -30,3 +29,15 @@ type,sign,value,threshold,windowSize
6J121,0,0,0,0
6J161,0,0,0,0
6J181,0,0,0,0
6C.47238.1H1,1,0,30,3
6D.10005.6D1,4,0,30,3
6D.10015.6D1,2,0,30,3
6D.15825.6D1,1,0,30,3
6D.93125.6D1,5,0,30,3
6D.R0005.551,1,0,30,3
6D.R0005.6D1,2,0,30,3
6H.47060.0R2,1,0,30,3
6J.42001.091,1,0,30,3
7H.10222.5F1,2,0,30,3
7H.10521.5F1,1,0,30,3
7H.10613.5B1,1,0,30,3

11.3 KB | 宽: | 高:

9.8 KB | 宽: | 高:

RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/1.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/1.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/1.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/1.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖

11.6 KB | 宽: | 高:

54.5 KB | 宽: | 高:

RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/2.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/2.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/2.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/2.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖

9.6 KB | 宽: | 高:

63.8 KB | 宽: | 高:

RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/3.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/3.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/3.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/3.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖

15.6 KB | 宽: | 高:

64.3 KB | 宽: | 高:

RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/4.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/4.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/4.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/4.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖

11.2 KB | 宽: | 高:

47.5 KB | 宽: | 高:

RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/5.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/5.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/5.png
RC1266-AutoCountMachine/source/DeviceLibrary/XRAY/model/smallmodel/5.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖
......@@ -39,7 +39,6 @@ namespace OnlineStore.DeviceLibrary
private string path2_out = Application.StartupPath + @"\XRAY\out\";
//private string path3_area = Application.StartupPath + @"\XRAY\area.txt";
private Dictionary<string, CountParam> countParamMap = new Dictionary<string, CountParam>();
public X_RAY_Equip(string cid, XRay_Config config)
{
......@@ -93,7 +92,7 @@ namespace OnlineStore.DeviceLibrary
{
System.IO.Directory.CreateDirectory(path2_out);
}
LoadParamMap();
ParamManager.Init();
ResultMinCount = ConfigAppSettings.GetIntValue(Setting_Init.ResultMinCount);
if (ResultMinCount <= 0)
{
......@@ -360,92 +359,9 @@ namespace OnlineStore.DeviceLibrary
return msg;
}
private void LoadParamMap()
{
countParamMap = new Dictionary<string, CountParam>();
string configPath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.CounParamConfig);
if (File.Exists(configPath))
{
try
{
string[] lines = File.ReadAllLines(configPath);
int index = -1;
foreach (string line in lines)
{
index++;
if (index.Equals(0))
{
continue;
}
CountParam param = CountParam.NewParam(line);
if (param != null)
{
if (!countParamMap.ContainsKey(param.PN))
{
countParamMap.Add(param.PN, param);
}
}
}
}
catch (Exception ex)
{
LogUtil.error("解析点料配置文件【" + configPath + "】出错:" + ex.ToString());
}
LogUtil.info("加载点料参数共【" + countParamMap.Count + "】条有效数据" + configPath);
}
else
{
LogUtil.error("未找到点料参数文件:" + configPath);
}
}
}
public class CountParam
{
public CountParam(string pn="", int th=0, int size=0,int sign=0,int value=0)
{
this.PN = pn;
this.Threshold = th;
this.WindowSize = size;
this.Sign = sign;
this.Value = value;
}
public string PN = "";
public int Threshold = 0;
public int WindowSize = 0;
public string AreaValue = "";
public int Sign = 0;
public int Value = 0;
public string ToStr()
{
return "【PN=" + PN + ",sign=" + Sign + ",value=" + Value + ",th=" + Threshold + ",wsize=" + WindowSize+"】";
}
internal static CountParam NewParam(string line)
{
try
{
string[] array = line.Split(',');
if (array.Length >= 5)
{
string pn = array[0].Trim();
int sign = Convert.ToInt32(array[1].Trim());
int value = Convert.ToInt32(array[2].Trim());
int th = Convert.ToInt32(array[3].Trim());
int size = Convert.ToInt32(array[4].Trim());
return new CountParam(pn, th, size,sign,value);
}
}
catch (Exception ex)
{
}
return null;
}
}
}
......@@ -347,7 +347,7 @@ namespace OnlineStore.DeviceLibrary
bool isNg = false;
string NgMsg = "";
int count = 0;
CountParam lastParam = UpdateParamByPN(Work_ReelInfo.WareCode);
CountParam lastParam = ParamManager.GetParamByCode(Work_ReelInfo.WareCode);
if (lastParam != null)
{
string fileP = path1_tif + @"\" + lastFileName;
......@@ -378,8 +378,9 @@ namespace OnlineStore.DeviceLibrary
else
{
isNg = true;
NgMsg = "NG:未找到元器件类型,PN[" + GetCodeStrPN(Work_ReelInfo.WareCode) + "]";
NgMsg = "NG:未找到元器件类型,PN[" +ParamManager. GetCodeStrPN(Work_ReelInfo.WareCode) + "]";
WorkLog("点料:" + NgMsg);
BackNoConfigImg();
}
string outF = path2_out + lastFileName;
......@@ -507,31 +508,6 @@ namespace OnlineStore.DeviceLibrary
}
private CountParam UpdateParamByPN(string codeStr)
{
//bool result = false;
//CountParam lastParam = new CountParam("", ThresholdValue, 3);
string pn = GetCodeStrPN(codeStr);
if (countParamMap.ContainsKey(pn))
{
CountParam lastParam = countParamMap[pn];
LogUtil.debug ("【" + codeStr + "】使用参数 " + lastParam.ToStr() + " ");
return lastParam;
}
return null;
}
private string GetCodeStrPN(string codeStr)
{
string[] codeArray = codeStr.Split(';');
if (codeArray.Length.Equals(2))
{
string pn = codeArray[0];
return pn;
}
return "";
}
private void ClearFilePath()
{
try
......@@ -556,6 +532,28 @@ namespace OnlineStore.DeviceLibrary
}
private void BackNoConfigImg()
{
//将未找到料号配置的图片保存到新的文件夹
string fileP = path1_tif + @"\" + lastFileName;
string backPath = ParamManager.NoConfigPath ;
string backFile = backPath + lastFileName;
try
{
if (!Directory.Exists(backPath))
{
Directory.CreateDirectory(backPath);
}
System.IO.File.Copy(fileP, backFile);
LogUtil.info("BackNoConfigImg 【" + fileP + "】 -> 【" + backFile + "】");
}
catch (Exception ex)
{
LogUtil.error("X图片备份到【" + backFile + "】错误:" + ex.ToString());
}
}
public int GetCountResult(string fileP, CountParam param,out Asa.API.EyemImage tpDstImg)
{
......
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
{
public class ParamManager{
public static string NoConfigPath = @"D:\NoConfigImg\";
private static Dictionary<string, CountParam> countParamMap = new Dictionary<string, CountParam>();
private static string ConfigFilePath = "";
internal static void Init()
{
ConfigFilePath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.CounParamConfig);
countParamMap = LoadParamMap( );
}
public static CountParam GetParamByPN(string pn)
{
if (countParamMap.ContainsKey(pn))
{
CountParam lastParam = countParamMap[pn];
LogUtil.debug("【" + pn + "】使用参数 " + lastParam.ToStr() + " ");
return lastParam;
}
return null;
}
public static CountParam GetParamByCode(string codeStr)
{
//bool result = false;
//CountParam lastParam = new CountParam("", ThresholdValue, 3);
string pn = GetCodeStrPN(codeStr);
if (countParamMap.ContainsKey(pn))
{
CountParam lastParam = countParamMap[pn];
LogUtil.debug("【" + codeStr + "】使用参数 " + lastParam.ToStr() + " ");
return lastParam;
}
return null;
}
internal static string GetCodeStrPN(string codeStr)
{
string[] codeArray = codeStr.Split(';');
if (codeArray.Length.Equals(2))
{
string pn = codeArray[0];
return pn;
}
return "";
}
private static List<CountParam> ErrPnParamList = new List<CountParam>();
public static void AddErrPNParam(CountParam errParam)
{
}
public static void UpdateParam(CountParam param)
{
try
{
if (countParamMap.ContainsKey(param.PN))
{
countParamMap[param.PN] = param;
}
else
{
countParamMap.Add(param.PN, param);
}
LogUtil.info("UpdateParam 【" + param.ToStr() + "】");
}
catch (Exception ex)
{
LogUtil.error("UpdateParam 出错:" + ex.ToString());
}
}
public static void SaveMapToFile()
{
try
{
List<CountParam> pList = new List<CountParam>(countParamMap.Values);
int length = pList.Count + 1;
List<string> lineList = new List<string>();
lineList.Add(CountParam.GetCSVTitle());
foreach (CountParam p in pList)
{
lineList.Add(p.ToCSVStr());
}
File.WriteAllLines(ConfigFilePath, lineList);
LogUtil.info("SaveMapToFile 【" + ConfigFilePath + "】");
}
catch (Exception ex)
{
LogUtil.error("SaveMapToFile 出错:" + ex.ToString());
}
}
internal static Dictionary<string, CountParam> LoadParamMap( )
{
Dictionary<string, CountParam> countParamMap = new Dictionary<string, CountParam>();
if (File.Exists(ConfigFilePath))
{
try
{
string[] lines = File.ReadAllLines(ConfigFilePath);
int index = -1;
foreach (string line in lines)
{
index++;
if (index.Equals(0))
{
continue;
}
CountParam param = CountParam.NewParam(line);
if (param != null)
{
if (!countParamMap.ContainsKey(param.PN))
{
countParamMap.Add(param.PN, param);
}
}
}
}
catch (Exception ex)
{
LogUtil.error("解析文件【" + ConfigFilePath + "】出错:" + ex.ToString());
}
LogUtil.info("加载点料参数共【" + countParamMap.Count + "】条有效数据" + ConfigFilePath);
}
else
{
LogUtil.error("未找到文件:" + ConfigFilePath);
}
return countParamMap;
}
/// <summary>
/// 获取最优算法
/// </summary>
/// <param name="currPN"></param>
/// <returns></returns>
public static CountParam GetOptimalParamByPN(string currPN)
{
CountParam param = GetParamByPN(currPN);
if (param == null)
{
//TODO
}
return param;
}
public static Image FormImage(string fileName)
{
try
{
Image img = Image.FromFile(fileName);
return img;
}
catch (Exception ex)
{
LogUtil.info(ex.ToString());
}
return null;
}
}
public class CountParam
{
public CountParam(string pn, int th = 0, int size = 0, int sign = 0, int value = 0)
{
this.PN = pn;
this.Threshold = th;
this.WindowSize = size;
this.Sign = sign;
this.Value = value;
}
public string PN = "";
public int Threshold = 0;
public int WindowSize = 0;
public string AreaValue = "";
public int Sign = 0;
public int Value = 0;
public string ToStr()
{
return "【PN=" + PN + ",sign=" + Sign + ",value=" + Value + ",th=" + Threshold + ",wsize=" + WindowSize + "】";
}
public string ToCSVStr()
{
//type,sign,value,threshold,windowSize
return PN + spilt + Sign + spilt + Value + spilt + Threshold + spilt + WindowSize;
}
private static char spilt = ',';
internal static CountParam NewParam(string line)
{
try
{
string[] array = line.Split(spilt);
if (array.Length >= 5)
{
string pn = array[0].Trim();
int sign = Convert.ToInt32(array[1].Trim());
int value = Convert.ToInt32(array[2].Trim());
int th = Convert.ToInt32(array[3].Trim());
int size = Convert.ToInt32(array[4].Trim());
return new CountParam(pn, th, size, sign, value);
}
}
catch (Exception ex)
{
}
return null;
}
internal static string GetCSVTitle()
{
return "type,sign,value,threshold,windowSize";
}
}
}
......@@ -47,7 +47,7 @@ namespace OnlineStore.DeviceLibrary
{
try
{
// XRayLearnManager.Init();
//XRayLearnManager.Init();
if (!isInit)
{
DeviceConfig.SubDIList = new Dictionary<int, Dictionary<string, ConfigIO>>();
......
using System;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
......@@ -40,10 +41,10 @@ namespace OnlineStore.DeviceLibrary
IsInit = true;
modelImg_0 = Image.FromFile(path + "\\0.jpg");
modelImg_1 = Image.FromFile(path + "\\1.png");
modelImg_2 = Image.FromFile(path + "\\2.jpg");
modelImg_3 = Image.FromFile(path + "\\3.jpg");
modelImg_4 = Image.FromFile(path + "\\4.jpg");
modelImg_5 = Image.FromFile(path + "\\5.jpg");
modelImg_2 = Image.FromFile(path + "\\2.png");
modelImg_3 = Image.FromFile(path + "\\3.png");
modelImg_4 = Image.FromFile(path + "\\4.png");
modelImg_5 = Image.FromFile(path + "\\5.png");
smodelImg_1 = Image.FromFile(path + "\\smallmodel\\1.png");
......@@ -57,9 +58,10 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
Console.Write(ex.ToString());
LogUtil.info (ex.ToString());
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!